Guest User

Untitled

a guest
Feb 5th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.78 KB | None | 0 0
  1. package com.horizon.game.tiles;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6.  
  7. import com.horizon.game.gfx.Render;
  8. import com.horizon.game.level.Level;
  9. import com.horizon.game.map.Chunk;
  10.  
  11.  
  12. public abstract class Tile {
  13.  
  14. private static HashMap<Integer, Tile> tiles = new HashMap<Integer,Tile>();
  15.  
  16. public static final Tile VOID = new BasicTile(0, 0, 0, "Full", true, false, false, "Void", 0xff000000,"Nothing, but is it the end?");
  17. public static final Tile STONE = new BasicTile(1, 1, 0, "Full",false, false, false, "Stone", 0xffC0C0C0,"It's just stone?");
  18. public static final Tile GRASS_1 = new BasicTile(2, 2, 1, "Full", false, false, false, "Grass", 0xff4CFF00,"In the wind it looks like lots of little waveing green people");
  19. public static final Tile GRASS_2 = new BasicTile(3, 3, 1, "Full", false, false, false, "Grass", 0xff4CFF00,"In the wind it looks like lots of little waveing green people");
  20. public static final Tile DIRT_1 = new BasicTile(4, 0, 1, "Full", false, false, false, "Dirt", 0xff4CFF00,"Eww, i got it in my shoe!");
  21. public static final Tile DIRT_2 = new BasicTile(5, 1, 1, "Full", false, false, false, "Dirt", 0xff4CFF00,"Eww, i got it in my shoe!");
  22.  
  23.  
  24. public static final Tile WATER_1 = new BasicTile(6, 2, 2, "Full", false, true, false, "Water", 0xff42A0FF,"Yay time for a little paddle");
  25. public static final Tile WATER_2 = new BasicTile(7, 3, 2, "Full", false, true, false, "Water", 0xff42A0FF,"Yay time for a little paddle");
  26. public static final Tile SAND_1 = new BasicTile(8, 8, 1, "Full", true, false, false, "Sand", 0xffF3F781,"Millions of golden pieces of sand");
  27. public static final Tile SAND_2 = new BasicTile(9, 9, 1, "Full", true, false, false, "Sand", 0xffF3F781,"Millions of golden pieces of sand");
  28. public static final Tile SNOW_1 = new BasicTile(10, 4, 1, "Full", true, false, false, "Snow", 0xffffffff,"Dont eat the yellow snow!");
  29. public static final Tile SNOW_2 = new BasicTile(11, 5, 1, "Full", true, false, false, "Snow", 0xffffffff,"Dont eat the yellow snow!");
  30. public static final Tile JUNGLE_GRASS_1 = new BasicTile(12, 0, 2, "Full", true, false, false, "Jungle grass", 0xff339966,"In the wind it looks like lots of little waveing green people");
  31. public static final Tile JUNGLE_GRASS_2 = new BasicTile(13, 1, 2, "Full", true, false, false, "Jungle grass", 0xff339966,"In the wind it looks like lots of little waveing green people");
  32. public static final Tile SAVANA_GRASS_1 = new BasicTile(14, 6, 1, "Full", false, false, false, "Savana Grass", 0xff00CC00,"In the wind it looks like lots of little waveing green people");
  33. public static final Tile SAVANA_GRASS_2 = new BasicTile(15, 7, 1, "Full", false, false, false, "Savana Grass", 0xff00CC00,"In the wind it looks like lots of little waveing green people");
  34.  
  35.  
  36. //tree 1
  37.  
  38.  
  39.  
  40.  
  41. public static final Tile PINE_TREE_SMALL_1 = new BasicTile(16, 4, 0, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
  42. public static final Tile PINE_TREE_SMALL_2 = new BasicTile(17, 5, 0, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
  43. public static final Tile PINE_TREE_SMALL_3 = new BasicTile(18, 4, 1, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
  44. public static final Tile PINE_TREE_SMALL_4 = new BasicTile(19, 5, 1, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
  45. public static final Tile PINE_TREE_SMALL_5 = new BasicTile(20, 4, 2, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
  46. public static final Tile PINE_TREE_SMALL_6 = new BasicTile(21, 5, 2, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
  47.  
  48.  
  49. public static final Tile FLOWER_1 = new BasicTile(22, 9, 1, "Full", true, false, false, "Flower", 0xffC4A637,"");
  50. public static final Tile FLOWER_2 = new BasicTile(23, 10, 1, "Full", true, false, false, "Rose", 0xffC4A637,"");
  51. public static final Tile FLOWER_3 = new BasicTile(24, 11, 1, "Full", true, false, false, "Flower", 0xffC4A637,"");
  52.  
  53.  
  54.  
  55. //merge tiles
  56.  
  57. public static final Tile WATER_SAND = new MergeTile(100, 0, 5, true, false, false, "Sand", 0xffC4A637,"");
  58. public static final Tile SAND_GRASS = new MergeTile(101, 0, 1, true, false, false, "Grass", 0xffC4A637,"");
  59.  
  60. protected byte id;
  61. protected boolean isSolid;
  62. // light source
  63. protected boolean isEmiter;
  64. private boolean isLiquid;
  65. private String name;
  66. protected int baseColour;
  67. protected String description;
  68.  
  69. public Tile(int ID, boolean isSolid, boolean isLiquid, boolean isEmiter,
  70. String name, int baseColour,String description) {
  71. this.id = (byte) ID;
  72. if (tiles.get(ID) != null) {
  73. throw new RuntimeException("Multiple tiles with same id, ID:" + id);
  74. }
  75. this.baseColour = baseColour;
  76. this.isSolid = isSolid;
  77. this.isEmiter = isEmiter;
  78. this.isLiquid = isLiquid;
  79. this.name = name;
  80. this.description = description;
  81. tiles.put(ID, this);
  82. }
  83.  
  84. public byte getID() {
  85. return id;
  86. }
  87.  
  88. public String getName() {
  89. return name;
  90. }
  91.  
  92. public boolean isSolid() {
  93. return isSolid;
  94. }
  95.  
  96. public int getBaseColour() {
  97. return baseColour;
  98. }
  99.  
  100. public boolean isLightSource() {
  101. return isEmiter;
  102. }
  103.  
  104. public boolean isLiquid() {
  105. return isLiquid;
  106. }
  107. public String getDescription(){
  108. return description;
  109. }
  110.  
  111. public abstract void render(int x, int y,Render r,double scale,Level level,int tileX, int tileY,int data,int vue);
  112.  
  113. public static Tile getTileByID(int i) {
  114.  
  115. for (Tile t : tiles.values()) {
  116. try{
  117. if ((byte) i == t.getID()) {
  118. return t;
  119. }
  120. }catch(NullPointerException e){
  121. System.out.println("Found a null");
  122. System.exit(0);
  123. }
  124. }
  125. return Tile.VOID;
  126. }
  127. public boolean connectsToBlock(int i){
  128. if(i==id){
  129. return true;
  130. }
  131. return false;
  132. }
  133. public boolean connectsToBlock(int i,int b){
  134. if(i==id||b==id){
  135. return true;
  136. }
  137. return false;
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment