Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.horizon.game.tiles;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import com.horizon.game.gfx.Render;
- import com.horizon.game.level.Level;
- import com.horizon.game.map.Chunk;
- public abstract class Tile {
- private static HashMap<Integer, Tile> tiles = new HashMap<Integer,Tile>();
- public static final Tile VOID = new BasicTile(0, 0, 0, "Full", true, false, false, "Void", 0xff000000,"Nothing, but is it the end?");
- public static final Tile STONE = new BasicTile(1, 1, 0, "Full",false, false, false, "Stone", 0xffC0C0C0,"It's just stone?");
- 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");
- 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");
- public static final Tile DIRT_1 = new BasicTile(4, 0, 1, "Full", false, false, false, "Dirt", 0xff4CFF00,"Eww, i got it in my shoe!");
- public static final Tile DIRT_2 = new BasicTile(5, 1, 1, "Full", false, false, false, "Dirt", 0xff4CFF00,"Eww, i got it in my shoe!");
- public static final Tile WATER_1 = new BasicTile(6, 2, 2, "Full", false, true, false, "Water", 0xff42A0FF,"Yay time for a little paddle");
- public static final Tile WATER_2 = new BasicTile(7, 3, 2, "Full", false, true, false, "Water", 0xff42A0FF,"Yay time for a little paddle");
- public static final Tile SAND_1 = new BasicTile(8, 8, 1, "Full", true, false, false, "Sand", 0xffF3F781,"Millions of golden pieces of sand");
- public static final Tile SAND_2 = new BasicTile(9, 9, 1, "Full", true, false, false, "Sand", 0xffF3F781,"Millions of golden pieces of sand");
- public static final Tile SNOW_1 = new BasicTile(10, 4, 1, "Full", true, false, false, "Snow", 0xffffffff,"Dont eat the yellow snow!");
- public static final Tile SNOW_2 = new BasicTile(11, 5, 1, "Full", true, false, false, "Snow", 0xffffffff,"Dont eat the yellow snow!");
- 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");
- 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");
- 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");
- 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");
- //tree 1
- public static final Tile PINE_TREE_SMALL_1 = new BasicTile(16, 4, 0, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
- public static final Tile PINE_TREE_SMALL_2 = new BasicTile(17, 5, 0, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
- public static final Tile PINE_TREE_SMALL_3 = new BasicTile(18, 4, 1, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
- public static final Tile PINE_TREE_SMALL_4 = new BasicTile(19, 5, 1, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
- public static final Tile PINE_TREE_SMALL_5 = new BasicTile(20, 4, 2, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
- public static final Tile PINE_TREE_SMALL_6 = new BasicTile(21, 5, 2, "Trees", true, false, false, "Pine Tree", 0xff4CFF00,"");
- public static final Tile FLOWER_1 = new BasicTile(22, 9, 1, "Full", true, false, false, "Flower", 0xffC4A637,"");
- public static final Tile FLOWER_2 = new BasicTile(23, 10, 1, "Full", true, false, false, "Rose", 0xffC4A637,"");
- public static final Tile FLOWER_3 = new BasicTile(24, 11, 1, "Full", true, false, false, "Flower", 0xffC4A637,"");
- //merge tiles
- public static final Tile WATER_SAND = new MergeTile(100, 0, 5, true, false, false, "Sand", 0xffC4A637,"");
- public static final Tile SAND_GRASS = new MergeTile(101, 0, 1, true, false, false, "Grass", 0xffC4A637,"");
- protected byte id;
- protected boolean isSolid;
- // light source
- protected boolean isEmiter;
- private boolean isLiquid;
- private String name;
- protected int baseColour;
- protected String description;
- public Tile(int ID, boolean isSolid, boolean isLiquid, boolean isEmiter,
- String name, int baseColour,String description) {
- this.id = (byte) ID;
- if (tiles.get(ID) != null) {
- throw new RuntimeException("Multiple tiles with same id, ID:" + id);
- }
- this.baseColour = baseColour;
- this.isSolid = isSolid;
- this.isEmiter = isEmiter;
- this.isLiquid = isLiquid;
- this.name = name;
- this.description = description;
- tiles.put(ID, this);
- }
- public byte getID() {
- return id;
- }
- public String getName() {
- return name;
- }
- public boolean isSolid() {
- return isSolid;
- }
- public int getBaseColour() {
- return baseColour;
- }
- public boolean isLightSource() {
- return isEmiter;
- }
- public boolean isLiquid() {
- return isLiquid;
- }
- public String getDescription(){
- return description;
- }
- public abstract void render(int x, int y,Render r,double scale,Level level,int tileX, int tileY,int data,int vue);
- public static Tile getTileByID(int i) {
- for (Tile t : tiles.values()) {
- try{
- if ((byte) i == t.getID()) {
- return t;
- }
- }catch(NullPointerException e){
- System.out.println("Found a null");
- System.exit(0);
- }
- }
- return Tile.VOID;
- }
- public boolean connectsToBlock(int i){
- if(i==id){
- return true;
- }
- return false;
- }
- public boolean connectsToBlock(int i,int b){
- if(i==id||b==id){
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment