X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGameItems.java;h=da430773336efa771a35be542ad0bae8efcb3883;hb=d58d40ec24363550fad10bd6047cee2618912186;hp=c3e020791570a456bf906f41165d8a76cb654171;hpb=793c88f81ae273b531dcdea267e1720c6878cc95;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java index c3e0207..da43077 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java @@ -37,8 +37,8 @@ public class GameItems { public static boolean fluidCanFlowThere(int thisId, int thatId) { return thatId == 0 || (!getBlock(thatId).hasCollision() && !isFluid(thatId)) || - (isWater(thisId) && isWater(thatId) && thatId >= thisId) || - (isLava(thisId) && isLava(thatId) && thatId >= thisId); + (isWater(thisId) && isWater(thatId) && thisId < thatId) || + (isLava(thisId) && isLava(thatId) && thisId < thatId); } public static Block getBlock(int id) { @@ -100,34 +100,50 @@ public class GameItems { JsonValue item = json.child.next.child; while (block != null) { String key = block.name; - int left = (block.has("left") ? block.getInt("left") : 0); - int right = (block.has("right") ? block.getInt("right") : 0); - int top = (block.has("top") ? block.getInt("top") : 0); - int bottom = (block.has("bottom") ? block.getInt("bottom") : 0); - int hp = (block.has("hp") ? block.getInt("hp") : -1); - String drop = (block.has("drop") ? block.getString("drop") : key); - boolean collision = (!block.has("collision") || block.getBoolean("collision")); - boolean background = (block.has("background") && block.getBoolean("background")); - boolean transparent = !(!block.has("collision") || block.getBoolean("collision")); - boolean blockRequired = (block.has("block_required") && block.getBoolean("block_required")); - 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); + int left = block.has("left") ? block.getInt("left") : 0; + int right = block.has("right") ? block.getInt("right") : 0; + int top = block.has("top") ? block.getInt("top") : 0; + int bottom = block.has("bottom") ? block.getInt("bottom") : 0; + int hp = block.has("hp") ? block.getInt("hp") : -1; + String drop = block.has("drop") ? block.getString("drop") : key; + boolean collision = !block.has("collision") || block.getBoolean("collision"); + boolean background = block.has("background") && block.getBoolean("background"); + boolean transparent = block.has("transparent") && block.getBoolean("transparent"); + boolean blockRequired = block.has("block_required") && block.getBoolean("block_required"); + 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) { String key = item.name; - 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); + 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(); } }