X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGameItems.java;h=61b3af736653e9097b30df8f49ca1d6c0cfd280d;hb=7646ac0833becd8f9424908ee8bc142b7b3999f8;hp=bd0e5bb1dcd90f2788e7b2bd15f47ac9da3fed3e;hpb=b3da6d46426e2c5ba1c02e2883e33c00f9ffe5b6;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java index bd0e5bb..61b3af7 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java @@ -35,6 +35,12 @@ public class GameItems { return getBlock(id).getMeta().equals("slab"); } + public static boolean fluidCanFlowThere(int thisId, int thatId) { + return thatId == 0 || (!getBlock(thatId).hasCollision() && !isFluid(thatId)) || + (isWater(thisId) && isWater(thatId) && thisId < thatId) || + (isLava(thisId) && isLava(thatId) && thisId < thatId); + } + public static Block getBlock(int id) { return blocks.getValueAt(id); } @@ -107,11 +113,26 @@ public class GameItems { boolean fluid = (block.has("fluid") && block.getBoolean("fluid")); String meta = (block.has("meta") ? block.getString("meta") : ""); String texture = (block.has("texture") ? block.getString("texture") : key); + Sprite sprite = key.equals("none") ? null : + new Sprite(new Texture(Gdx.files.internal("textures/blocks/" + texture + ".png"))); + Block newBlock = new Block( + left, + top, + right, + bottom, + hp, + drop, + collision, + background, + transparent, + blockRequired, + fluid, + meta, + sprite + ); + blocksIds.put(key, blocks.size); - blocks.put(key, new Block(left, top, right, bottom, hp, drop, collision, - background, transparent, blockRequired, fluid, meta, - key.equals("none") ? null : - new Sprite(new Texture(Gdx.files.internal("textures/" + texture + ".png"))))); + blocks.put(key, newBlock); block = block.next(); } while (item != null) { @@ -119,9 +140,10 @@ public class GameItems { String name = (item.has("name") ? item.getString("name") : key); String type = (item.has("type") ? item.getString("type") : "item"); String texture = (item.has("texture") ? item.getString("texture") : key); + Sprite sprite = type.equals("block") ? null : + new Sprite(new Texture(Gdx.files.internal("textures/items/" + texture + ".png"))); itemsIds.put(key, items.size); - items.put(key, new Item(name, type, type.equals("block") ? null : - new Sprite(new Texture(Gdx.files.internal("textures/" + texture + ".png"))))); + items.put(key, new Item(name, type, sprite)); item = item.next(); } }