From a21a93fd9fa33adebe52d1f4478866dcc3b66d96 Mon Sep 17 00:00:00 2001 From: fredboy Date: Mon, 22 Apr 2024 03:28:17 +0700 Subject: [PATCH] Add tools --- android/assets/json/game_items.json | 479 ++++++++++-------- android/assets/textures/items/diamond_axe.png | Bin 0 -> 358 bytes android/assets/textures/items/diamond_hoe.png | Bin 0 -> 331 bytes .../assets/textures/items/diamond_pickaxe.png | Bin 0 -> 374 bytes android/assets/textures/items/gold_axe.png | Bin 0 -> 364 bytes android/assets/textures/items/gold_hoe.png | Bin 0 -> 371 bytes .../assets/textures/items/gold_pickaxe.png | Bin 0 -> 373 bytes android/assets/textures/items/iron_axe.png | Bin 0 -> 360 bytes android/assets/textures/items/iron_hoe.png | Bin 0 -> 340 bytes .../assets/textures/items/iron_pickaxe.png | Bin 0 -> 359 bytes android/assets/textures/items/shears.png | Bin 0 -> 331 bytes android/assets/textures/items/stone_axe.png | Bin 0 -> 371 bytes android/assets/textures/items/stone_hoe.png | Bin 0 -> 379 bytes .../assets/textures/items/stone_pickaxe.png | Bin 0 -> 372 bytes android/assets/textures/items/wood_axe.png | Bin 0 -> 361 bytes android/assets/textures/items/wood_hoe.png | Bin 0 -> 351 bytes .../assets/textures/items/wood_pickaxe.png | Bin 0 -> 357 bytes .../cavedroid/game/mobs/Player.java | 24 +- .../game/model/block/CommonBlockParams.kt | 5 +- .../cavedroid/game/model/dto/BlockDto.kt | 4 +- .../cavedroid/game/model/dto/ItemDto.kt | 3 +- .../game/model/item/CommonItemParams.kt | 2 +- .../cavedroid/game/model/item/Item.kt | 27 + .../game/model/mapper/BlockMapper.kt | 17 +- .../cavedroid/game/model/mapper/ItemMapper.kt | 7 +- .../cavedroid/game/render/BlocksRenderer.kt | 2 +- 26 files changed, 349 insertions(+), 221 deletions(-) create mode 100644 android/assets/textures/items/diamond_axe.png create mode 100644 android/assets/textures/items/diamond_hoe.png create mode 100644 android/assets/textures/items/diamond_pickaxe.png create mode 100644 android/assets/textures/items/gold_axe.png create mode 100644 android/assets/textures/items/gold_hoe.png create mode 100644 android/assets/textures/items/gold_pickaxe.png create mode 100644 android/assets/textures/items/iron_axe.png create mode 100644 android/assets/textures/items/iron_hoe.png create mode 100644 android/assets/textures/items/iron_pickaxe.png create mode 100644 android/assets/textures/items/shears.png create mode 100644 android/assets/textures/items/stone_axe.png create mode 100644 android/assets/textures/items/stone_hoe.png create mode 100644 android/assets/textures/items/stone_pickaxe.png create mode 100644 android/assets/textures/items/wood_axe.png create mode 100644 android/assets/textures/items/wood_hoe.png create mode 100644 android/assets/textures/items/wood_pickaxe.png diff --git a/android/assets/json/game_items.json b/android/assets/json/game_items.json index 25b8db3..4763629 100644 --- a/android/assets/json/game_items.json +++ b/android/assets/json/game_items.json @@ -1,7 +1,6 @@ { "blocks": { "none": { - "id": 0, "collision": false, "transparent": true, "drop": "none", @@ -9,50 +8,53 @@ "meta": "none" }, "stone": { - "id": 1, "hp": 450, "drop": "cobblestone", - "texture": "stone" + "texture": "stone", + "tool_level": 1, + "tool_type": "pickaxe" }, "grass": { - "id": 2, "hp": 54, "drop": "dirt", - "texture": "grass" + "texture": "grass", + "tool_level": 0, + "tool_type": "shovel" }, "dirt": { - "id": 3, "hp": 45, "drop": "dirt", - "texture": "dirt" + "texture": "dirt", + "tool_level": 0, + "tool_type": "shovel" }, "cobblestone": { - "id": 4, "hp": 600, "drop": "cobblestone", - "texture": "cobblestone" + "texture": "cobblestone", + "tool_level": 1, + "tool_type": "pickaxe" }, "planks_oak": { - "id": 5, "hp": 180, "drop": "planks_oak", - "texture": "planks_oak" + "texture": "planks_oak", + "tool_level": 0, + "tool_type": "axe" }, "sapling_oak": { - "id": 6, "collision": false, "transparent": true, "block_required": true, "drop": "sapling_oak", - "texture": "sapling_oak" + "texture": "sapling_oak", + "hp": 1 }, "bedrock": { - "id": 7, "drop": "bedrock", "texture": "bedrock" }, "water": { - "id": 8, "collision": false, "transparent": true, "drop": "water", @@ -63,7 +65,6 @@ "state": 0 }, "lava": { - "id": 9, "collision": false, "drop": "lava", "meta": "lava", @@ -73,135 +74,151 @@ "state": 0 }, "sand": { - "id": 10, "hp": 45, "drop": "sand", - "texture": "sand" + "texture": "sand", + "tool_level": 0, + "tool_type": "shovel" }, "gravel": { - "id": 11, "hp": 54, "drop": "gravel", - "texture": "gravel" + "texture": "gravel", + "tool_level": 0, + "tool_type": "shovel" }, "gold_ore": { - "id": 12, "hp": 900, "drop": "gold_ore", - "texture": "gold_ore" + "texture": "gold_ore", + "tool_level": 3, + "tool_type": "pickaxe" }, "iron_ore": { - "id": 13, "hp": 900, "drop": "iron_ore", - "texture": "iron_ore" + "texture": "iron_ore", + "tool_level": 2, + "tool_type": "pickaxe" }, "coal_ore": { - "id": 14, "hp": 900, "drop": "coal", - "texture": "coal_ore" + "texture": "coal_ore", + "tool_level": 1, + "tool_type": "pickaxe" }, "log_oak": { - "id": 15, "hp": 180, "drop": "log_oak", - "texture": "log_oak" + "texture": "log_oak", + "tool_level": 0, + "tool_type": "axe" }, "leaves_oak": { - "id": 16, "hp": 21, "transparent": true, "drop": "leaves_oak", - "texture": "leaves_oak" + "texture": "leaves_oak", + "tool_level": 1, + "tool_type": "shears" }, "sponge": { - "id": 17, "hp": 54, "drop": "sponge", - "texture": "sponge" + "texture": "sponge", + "tool_level": 0, + "tool_type": "hoe" }, "glass": { - "id": 18, "hp": 27, "transparent": true, "drop": "none", "texture": "glass" }, "lapis_ore": { - "id": 19, "hp": 900, "drop": "lapis", - "texture": "lapis_ore" + "texture": "lapis_ore", + "tool_level": 2, + "tool_type": "pickaxe" }, "lapis_block": { - "id": 20, "hp": 900, "drop": "lapis_block", - "texture": "lapis_block" + "texture": "lapis_block", + "tool_level": 2, + "tool_type": "pickaxe" }, "sandstone": { - "id": 21, "hp": 240, "drop": "sandstone", - "texture": "sandstone" + "texture": "sandstone", + "tool_level": 1, + "tool_type": "pickaxe" }, "noteblock": { - "id": 22, "hp": 75, "drop": "noteblock", - "texture": "noteblock" + "texture": "noteblock", + "tool_level": 0, + "tool_type": "axe" }, "bed_l": { - "id": 23, "hp": 21, "collision": false, "background": true, "transparent": true, "drop": "none", - "texture": "bed_l" + "texture": "bed_l", + "tool_level": 0, + "tool_type": "axe" }, "bed_r": { - "id": 24, "hp": 21, "collision": false, "background": true, "transparent": true, "drop": "none", - "texture": "bed_r" + "texture": "bed_r", + "tool_level": 0, + "tool_type": "axe" }, "web": { - "id": 25, "hp": 1200, "collision": false, "transparent": true, "drop": "web", - "texture": "web" + "texture": "web", + "tool_level": 1, + "tool_type": "shears" }, "tallgrass": { - "id": 26, "collision": false, "transparent": true, "block_required": true, "drop": "tallgrass", - "texture": "tallgrass" + "texture": "tallgrass", + "tool_level": 1, + "tool_type": "shears" }, "deadbush": { - "id": 27, "collision": false, "transparent": true, "block_required": true, "drop": "deadbush", - "texture": "deadbush" + "texture": "deadbush", + "tool_level": 1, + "tool_type": "shears" }, "bricks": { - "id": 28, "hp": 600, "drop": "bricks", - "texture": "bricks" + "texture": "bricks", + "tool_level": 1, + "tool_type": "pickaxe" }, "dandelion": { - "id": 29, "collision": false, "transparent": true, "block_required": true, @@ -209,7 +226,6 @@ "texture": "dandelion" }, "rose": { - "id": 30, "collision": false, "transparent": true, "block_required": true, @@ -217,7 +233,6 @@ "texture": "rose" }, "mushroom_brown": { - "id": 31, "collision": false, "transparent": true, "block_required": true, @@ -225,7 +240,6 @@ "texture": "mushroom_brown" }, "mushroom_red": { - "id": 32, "collision": false, "transparent": true, "block_required": true, @@ -233,115 +247,132 @@ "texture": "mushroom_red" }, "wool_colored_white": { - "id": 33, "hp": 75, "drop": "wool_colored_white", - "texture": "wool_colored_white" + "texture": "wool_colored_white", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_orange": { - "id": 34, "hp": 75, "drop": "wool_colored_orange", - "texture": "wool_colored_orange" + "texture": "wool_colored_orange", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_magenta": { - "id": 35, "hp": 75, "drop": "wool_colored_magenta", - "texture": "wool_colored_magenta" + "texture": "wool_colored_magenta", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_light_blue": { - "id": 36, "hp": 75, "drop": "wool_colored_light_blue", - "texture": "wool_colored_light_blue" + "texture": "wool_colored_light_blue", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_yellow": { - "id": 37, "hp": 75, "drop": "wool_colored_yellow", - "texture": "wool_colored_yellow" + "texture": "wool_colored_yellow", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_lime": { - "id": 38, "hp": 75, "drop": "wool_colored_lime", - "texture": "wool_colored_lime" + "texture": "wool_colored_lime", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_pink": { - "id": 39, "hp": 75, "drop": "wool_colored_pink", - "texture": "wool_colored_pink" + "texture": "wool_colored_pink", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_gray": { - "id": 40, "hp": 75, "drop": "wool_colored_gray", - "texture": "wool_colored_gray" + "texture": "wool_colored_gray", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_silver": { - "id": 41, "hp": 75, "drop": "wool_colored_silver", - "texture": "wool_colored_silver" + "texture": "wool_colored_silver", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_cyan": { - "id": 42, "hp": 75, "drop": "wool_colored_cyan", - "texture": "wool_colored_cyan" + "texture": "wool_colored_cyan", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_purple": { - "id": 43, "hp": 75, "drop": "wool_colored_purple", - "texture": "wool_colored_purple" + "texture": "wool_colored_purple", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_blue": { - "id": 44, "hp": 75, "drop": "wool_colored_blue", - "texture": "wool_colored_blue" + "texture": "wool_colored_blue", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_brown": { - "id": 45, "hp": 75, "drop": "wool_colored_brown", - "texture": "wool_colored_brown" + "texture": "wool_colored_brown", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_green": { - "id": 46, "hp": 75, "drop": "wool_colored_green", - "texture": "wool_colored_green" + "texture": "wool_colored_green", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_red": { - "id": 47, "hp": 75, "drop": "wool_colored_red", - "texture": "wool_colored_red" + "texture": "wool_colored_red", + "tool_level": 0, + "tool_type": "shears" }, "wool_colored_black": { - "id": 48, "hp": 75, "drop": "wool_colored_black", - "texture": "wool_colored_black" + "texture": "wool_colored_black", + "tool_level": 0, + "tool_type": "shears" }, "gold_block": { - "id": 49, "hp": 900, "drop": "gold_block", - "texture": "gold_block" + "texture": "gold_block", + "tool_level": 3, + "tool_type": "pickaxe" }, "iron_block": { - "id": 50, "hp": 1500, "drop": "iron_block", - "texture": "iron_block" + "texture": "iron_block", + "tool_level": 2, + "tool_type": "pickaxe" }, "stone_slab_bottom": { - "id": 51, "top": 8, "sprite_top": 8, "hp": 600, @@ -350,10 +381,11 @@ "meta": "slab", "texture": "stone_slab", "full_block": "double_stone_slab", - "other_part": "stone_slab_top" + "other_part": "stone_slab_top", + "tool_level": 1, + "tool_type": "pickaxe" }, "stone_slab_top": { - "id": 51, "hp": 600, "bottom": 8, "sprite_bottom": 8, @@ -362,17 +394,19 @@ "meta": "slab", "texture": "stone_slab", "full_block": "double_stone_slab", - "other_part": "stone_slab_bottom" + "other_part": "stone_slab_bottom", + "tool_level": 1, + "tool_type": "pickaxe" }, "double_stone_slab": { - "id": 52, "hp": 600, "drop": "stone_slab", "drop_count": 2, - "texture": "stone_slab" + "texture": "stone_slab", + "tool_level": 1, + "tool_type": "pickaxe" }, "sandstone_slab_bottom": { - "id": 53, "top": 8, "sprite_top": 8, "hp": 600, @@ -381,10 +415,11 @@ "meta": "slab", "texture": "sandstone", "full_block": "sandstone", - "other_part": "sandstone_slab_top" + "other_part": "sandstone_slab_top", + "tool_level": 1, + "tool_type": "pickaxe" }, "sandstone_slab_top": { - "id": 53, "bottom": 8, "sprite_bottom": 8, "hp": 600, @@ -393,10 +428,11 @@ "meta": "slab", "texture": "sandstone", "full_block": "sandstone", - "other_part": "sandstone_slab_bottom" + "other_part": "sandstone_slab_bottom", + "tool_level": 1, + "tool_type": "pickaxe" }, "oak_slab_bottom": { - "id": 54, "top": 8, "sprite_top": 8, "hp": 180, @@ -405,10 +441,11 @@ "meta": "slab", "texture": "planks_oak", "full_block": "planks_oak", - "other_part": "oak_slab_top" + "other_part": "oak_slab_top", + "tool_level": 0, + "tool_type": "axe" }, "oak_slab_top": { - "id": 54, "bottom": 8, "sprite_bottom": 8, "hp": 180, @@ -417,10 +454,11 @@ "meta": "slab", "texture": "planks_oak", "full_block": "planks_oak", - "other_part": "oak_slab_bottom" + "other_part": "oak_slab_bottom", + "tool_level": 0, + "tool_type": "axe" }, "cobblestone_slab_bottom": { - "id": 55, "top": 8, "sprite_top": 8, "hp": 600, @@ -429,10 +467,11 @@ "drop": "cobblestone_slab", "texture": "cobblestone", "full_block": "cobblestone", - "other_part": "cobblestone_slab_top" + "other_part": "cobblestone_slab_top", + "tool_level": 1, + "tool_type": "pickaxe" }, "cobblestone_slab_top": { - "id": 55, "bottom": 8, "sprite_bottom": 8, "hp": 600, @@ -441,10 +480,11 @@ "drop": "cobblestone_slab", "texture": "cobblestone", "full_block": "cobblestone", - "other_part": "cobblestone_slab_bottom" + "other_part": "cobblestone_slab_bottom", + "tool_level": 1, + "tool_type": "pickaxe" }, "brick_slab_bottom": { - "id": 56, "top": 8, "sprite_top": 8, "hp": 600, @@ -453,10 +493,11 @@ "meta": "slab", "texture": "bricks", "full_block": "bricks", - "other_part": "brick_slab_top" + "other_part": "brick_slab_top", + "tool_level": 1, + "tool_type": "pickaxe" }, "brick_slab_top": { - "id": 56, "bottom": 8, "sprite_bottom": 8, "hp": 600, @@ -465,16 +506,18 @@ "meta": "slab", "texture": "bricks", "full_block": "bricks", - "other_part": "brick_slab_bottom" + "other_part": "brick_slab_bottom", + "tool_level": 1, + "tool_type": "pickaxe" }, "stonebrick": { - "id": 57, "hp": 450, "drop": "stonebrick", - "texture": "stonebrick" + "texture": "stonebrick", + "tool_level": 1, + "tool_type": "pickaxe" }, "stonebrick_slab_bottom": { - "id": 58, "top": 8, "sprite_top": 8, "hp": 450, @@ -483,10 +526,11 @@ "meta": "slab", "texture": "stonebrick", "full_block": "stonebrick", - "other_part": "stonebrick_slab_top" + "other_part": "stonebrick_slab_top", + "tool_level": 1, + "tool_type": "pickaxe" }, "stonebrick_slab_top": { - "id": 58, "bottom": 8, "sprite_bottom": 8, "hp": 450, @@ -495,10 +539,11 @@ "meta": "slab", "texture": "stonebrick", "full_block": "stonebrick", - "other_part": "brick_slab_bottom" + "other_part": "brick_slab_bottom", + "tool_level": 1, + "tool_type": "pickaxe" }, "cactus": { - "id": 59, "left": 1, "right": 1, "hp": 39, @@ -508,7 +553,6 @@ "texture": "cactus" }, "water_16": { - "id": 60, "collision": false, "transparent": true, "drop": "water_16", @@ -519,7 +563,6 @@ "state": 1 }, "water_12": { - "id": 61, "top": 4, "sprite_top": 4, "collision": false, @@ -532,7 +575,6 @@ "state": 2 }, "water_8": { - "id": 62, "top": 8, "sprite_top": 8, "collision": false, @@ -545,7 +587,6 @@ "state": 3 }, "water_4": { - "id": 63, "top": 12, "sprite_top": 12, "collision": false, @@ -558,7 +599,6 @@ "state": 4 }, "lava_16": { - "id": 64, "collision": false, "drop": "lava_16", "meta": "lava", @@ -568,7 +608,6 @@ "state": 1 }, "lava_12": { - "id": 65, "top": 4, "sprite_top": 4, "collision": false, @@ -580,7 +619,6 @@ "state": 2 }, "lava_8": { - "id": 66, "top": 8, "sprite_top": 8, "collision": false, @@ -592,7 +630,6 @@ "state": 3 }, "lava_4": { - "id": 67, "top": 12, "sprite_top": 12, "collision": false, @@ -604,303 +641,256 @@ "state": 4 }, "obsidian": { - "id": 68, "hp": 1500, "drop": "obsidian", - "texture": "obsidian" + "texture": "obsidian", + "tool_level": 4, + "tool_type": "pickaxe" } }, "items": { "none": { - "id": 0, "name": "", "type": "none", "texture": "none" }, "stone": { - "id": 1, "name": "Stone", "type": "block", "texture": "stone" }, "grass": { - "id": 2, "name": "Grass", "type": "block", "texture": "grass" }, "dirt": { - "id": 3, "name": "Dirt", "type": "block", "texture": "dirt" }, "cobblestone": { - "id": 4, "name": "Cobblestone", "type": "block", "texture": "cobblestone" }, "planks_oak": { - "id": 5, "name": "Oak Planks", "type": "block", "texture": "planks_oak" }, "sapling_oak": { - "id": 6, "name": "Oak Sapling", "type": "block", "texture": "sapling_oak" }, "bedrock": { - "id": 7, "name": "Bedrock", "type": "block", "texture": "bedrock" }, "water": { - "id": 8, "name": "Water", "type": "block", "texture": "water" }, "lava": { - "id": 9, "name": "Lava", "type": "block", "texture": "lava" }, "sand": { - "id": 10, "name": "Sand", "type": "block", "texture": "sand" }, "gravel": { - "id": 11, "name": "Gravel", "type": "block", "texture": "gravel" }, "gold_ore": { - "id": 12, "name": "Golden Ore", "type": "block", "texture": "gold_ore" }, "iron_ore": { - "id": 13, "name": "Iron Ore", "type": "block", "texture": "iron_ore" }, "coal_ore": { - "id": 14, "name": "Coal Ore", "type": "block", "texture": "coal_ore" }, "log_oak": { - "id": 15, "name": "Wood", "type": "block", "texture": "log_oak" }, "leaves_oak": { - "id": 16, "name": "Leaves", "type": "block", "texture": "leaves_oak" }, "glass": { - "id": 17, "name": "Glass", "type": "block", "texture": "glass" }, "lapis_ore": { - "id": 18, "name": "Lapis Ore", "type": "block", "texture": "lapis_ore" }, "lapis_block": { - "id": 19, "name": "Lapis Block", "type": "block", "texture": "lapis_block" }, "sandstone": { - "id": 20, "name": "Sandstone", "type": "block", "texture": "sandstone" }, "web": { - "id": 21, "name": "Cobweb", "type": "block", "texture": "web" }, "tallgrass": { - "id": 22, "name": "Tall Grass", "type": "block", "texture": "tallgrass", "origin_x": 0.5 }, "deadbush": { - "id": 23, "name": "Dead Bush", "type": "block", "texture": "deadbush", "origin_x": 0.5 }, "bricks": { - "id": 24, "name": "Bricks", "type": "block", "texture": "bricks" }, "dandelion": { - "id": 25, "name": "Dandelion", "type": "block", "texture": "dandelion", "origin_x": 0.5 }, "rose": { - "id": 26, "name": "Rose", "type": "block", "texture": "rose", "origin_x": 0.5 }, "mushroom_brown": { - "id": 27, "name": "Mushroom", "type": "block", "texture": "mushroom_brown", "origin_x": 0.5 }, "mushroom_red": { - "id": 28, "name": "Mushroom", "type": "block", "texture": "mushroom_red", "origin_x": 0.5 }, "wool_colored_white": { - "id": 29, "name": "Wool", "type": "block", "texture": "wool_colored_white" }, "wool_colored_orange": { - "id": 30, "name": "Wool", "type": "block", "texture": "wool_colored_orange" }, "wool_colored_magenta": { - "id": 31, "name": "Wool", "type": "block", "texture": "wool_colored_magenta" }, "wool_colored_light_blue": { - "id": 32, "name": "Wool", "type": "block", "texture": "wool_colored_light_blue" }, "wool_colored_yellow": { - "id": 33, "name": "Wool", "type": "block", "texture": "wool_colored_yellow" }, "wool_colored_lime": { - "id": 34, "name": "Wool", "type": "block", "texture": "wool_colored_lime" }, "wool_colored_pink": { - "id": 35, "name": "Wool", "type": "block", "texture": "wool_colored_pink" }, "wool_colored_gray": { - "id": 36, "name": "Wool", "type": "block", "texture": "wool_colored_gray" }, "wool_colored_silver": { - "id": 37, "name": "Wool", "type": "block", "texture": "wool_colored_silver" }, "wool_colored_cyan": { - "id": 38, "name": "Wool", "type": "block", "texture": "wool_colored_cyan" }, "wool_colored_purple": { - "id": 39, "name": "Wool", "type": "block", "texture": "wool_colored_purple" }, "wool_colored_blue": { - "id": 40, "name": "Wool", "type": "block", "texture": "wool_colored_blue" }, "wool_colored_brown": { - "id": 41, "name": "Wool", "type": "block", "texture": "wool_colored_brown" }, "wool_colored_green": { - "id": 42, "name": "Wool", "type": "block", "texture": "wool_colored_green" }, "wool_colored_red": { - "id": 43, "name": "Wool", "type": "block", "texture": "wool_colored_red" }, "wool_colored_black": { - "id": 44, "name": "Wool", "type": "block", "texture": "wool_colored_black" }, "gold_block": { - "id": 45, "name": "Gold Block", "type": "block", "texture": "gold_block" }, "iron_block": { - "id": 46, "name": "Iron Block", "type": "block", "texture": "iron_block" }, "stone_slab": { - "id": 47, "name": "Stone Slab", "type": "slab", "texture": "stone_slab", @@ -908,7 +898,6 @@ "bottom_slab_block": "stone_slab_bottom" }, "sandstone_slab": { - "id": 48, "name": "Sandstone Slab", "type": "slab", "texture": "sandstone_slab", @@ -916,7 +905,6 @@ "bottom_slab_block": "sandstone_slab_bottom" }, "oak_slab": { - "id": 49, "name": "Oak Slab", "type": "slab", "texture": "oak_slab", @@ -924,7 +912,6 @@ "bottom_slab_block": "oak_slab_bottom" }, "cobblestone_slab": { - "id": 50, "name": "Cobblestone Slab", "type": "slab", "texture": "cobblestone_slab", @@ -932,7 +919,6 @@ "bottom_slab_block": "cobblestone_slab_bottom" }, "brick_slab": { - "id": 51, "name": "Brick Slab", "type": "slab", "texture": "brick_slab", @@ -940,13 +926,11 @@ "bottom_slab_block": "brick_slab_bottom" }, "stonebrick": { - "id": 52, "name": "Stone Brick", "type": "block", "texture": "stonebrick" }, "stonebrick_slab": { - "id": 53, "name": "Stone Brick Slab", "type": "slab", "texture": "stonebrick_slab", @@ -954,89 +938,166 @@ "bottom_slab_block": "stonebrick_slab_bottom" }, "cactus": { - "id": 54, "name": "Cactus", "type": "block", "texture": "cactus" }, "obsidian": { - "id": 55, "name": "Obsidian", "type": "block", "texture": "obsidian" }, "wood_sword": { - "id": 56, "name": "Wooden Sword", "type": "sword", "texture": "wood_sword", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level": 1 }, "stone_sword": { - "id": 57, "name": "Stone Sword", "type": "sword", "texture": "stone_sword", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level": 2 }, "iron_sword": { - "id": 58, "name": "Iron Sword", "type": "sword", "texture": "iron_sword", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level": 3 }, "diamond_sword": { - "id": 59, "name": "Diamond Sword", "type": "sword", "texture": "diamond_sword", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level": 4 }, "gold_sword": { - "id": 60, "name": "Golden Sword", "type": "sword", "texture": "gold_sword", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level": 1 }, "wood_shovel": { - "id": 61, "name": "Wooden Shovel", "type": "shovel", "texture": "wood_shovel", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level" : 1 }, "stone_shovel": { - "id": 62, "name": "Stone Shovel", "type": "shovel", "texture": "stone_shovel", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level" : 2 }, "iron_shovel": { - "id": 63, "name": "Iron Shovel", "type": "shovel", "texture": "iron_shovel", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level" : 3 }, "diamond_shovel": { - "id": 64, "name": "Diamond Shovel", "type": "shovel", "texture": "diamond_shovel", - "origin_x": 0.125 + "origin_x": 0.125, + "tool_level" : 4 }, "gold_shovel": { - "id": 65, "name": "Golden Shovel", "type": "shovel", "texture": "gold_shovel", + "origin_x": 0.125, + "tool_level" : 1, + "block_damage_multiplier": 6 + }, + "wood_pickaxe": { + "name": "Wooden Pickaxe", + "type": "pickaxe", + "texture": "wood_pickaxe", + "origin_x": 0.125, + "tool_level" : 1 + }, + "stone_pickaxe": { + "name": "Stone Pickaxe", + "type": "pickaxe", + "texture": "stone_pickaxe", + "origin_x": 0.125, + "tool_level" : 2 + }, + "iron_pickaxe": { + "name": "Iron Pickaxe", + "type": "pickaxe", + "texture": "iron_pickaxe", + "origin_x": 0.125, + "tool_level" : 3 + }, + "diamond_pickaxe": { + "name": "Diamond Pickaxe", + "type": "pickaxe", + "texture": "diamond_pickaxe", + "origin_x": 0.125, + "tool_level" : 4 + }, + "gold_pickaxe": { + "name": "Golden Pickaxe", + "type": "pickaxe", + "texture": "gold_pickaxe", + "origin_x": 0.125, + "tool_level" : 1, + "block_damage_multiplier": 6 + }, + "wood_axe": { + "name": "Wooden Axe", + "type": "axe", + "texture": "wood_axe", + "origin_x": 0.125, + "tool_level" : 1 + }, + "stone_axe": { + "name": "Stone Axe", + "type": "axe", + "texture": "stone_axe", + "origin_x": 0.125, + "tool_level" : 2 + }, + "iron_axe": { + "name": "Iron Axe", + "type": "axe", + "texture": "iron_axe", + "origin_x": 0.125, + "tool_level" : 3 + }, + "diamond_axe": { + "name": "Diamond Axe", + "type": "axe", + "texture": "diamond_axe", + "origin_x": 0.125, + "tool_level" : 4 + }, + "gold_axe": { + "name": "Golden Axe", + "type": "axe", + "texture": "gold_axe", + "origin_x": 0.125, + "tool_level" : 1, + "block_damage_multiplier": 6 + }, + "shears": { + "name": "Shears", + "type": "shears", + "texture": "shears", + "tool_level" : 1, "origin_x": 0.125 }, "bucket_empty": { - "id": 66, "name": "Empty Bucket", "type": "bucket", "texture": "bucket_empty", @@ -1044,7 +1105,6 @@ "action_key": "use_empty_bucket" }, "bucket_water": { - "id": 67, "name": "Water Bucket", "type": "bucket", "texture": "bucket_water", @@ -1052,7 +1112,6 @@ "action_key": "use_water_bucket" }, "bucket_lava": { - "id": 68, "name": "Lava Bucket", "type": "bucket", "texture": "bucket_lava", diff --git a/android/assets/textures/items/diamond_axe.png b/android/assets/textures/items/diamond_axe.png new file mode 100644 index 0000000000000000000000000000000000000000..ac81a2368ec7524ba4cbdd9ebd85f2f5a4f5f0d7 GIT binary patch literal 358 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&+Jc6@_nG1C!Q{j zAr}63Kv zem?wo>C*etmvr8|Yqz%4e(AHH|4#i>U1WQ{c=1+yF*S}X#=tV2*QXC3R(ho6#Sn2Q zDQA*O;p2>hj|xN==$wvWUsiq4LRNvV&33x8z46@iZI`q!oN-&(9x15ZEyj>PJ$U2& zoipEFTh+8~&8I|GwT7xWbDPfAJW2=)*jL1OB}??hnbH{rJGV47>CN~fU+f(4KXKs} zuA~GZ5r)r~e|^U BkJA7E literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/diamond_hoe.png b/android/assets/textures/items/diamond_hoe.png new file mode 100644 index 0000000000000000000000000000000000000000..f0ad2c60cb8a1f022463d7f41e34208877a7dd71 GIT binary patch literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+L6~vJ#O${~L5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33J+nVO$@hV3PI|gH zhFJI~|M>skK5UNMlP1x{rxP<;5+^))TVDUK`9qic|A!_Xe(vti_b*@mynYYc0h8nF zcYoaf=T5!>-@LjH_CCfPY|;(f2TYuI^4u_aY|8K?Mnjl~N!G^@#F1<;5qI19zue?1 zo3z&?#*OpLG-f$AWH2{y9hl{)*TB`t7|8bE5)Ts#Z-b@u>@!lvI6;>1s;*b z3=Dh+L6~vJ#O${~L5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33J+nVO$@hV3zIeJg zhFJJdon*~*$U($4U3c3u-*gAZiBq!FJC<&pYPRn1xl@Nu+3sM>K6s9G2V-mcIc4F= zCsTUF^Xv}K`F*d(XV$VTK~AeKrS)eO-pzWvE%?V5ft~jEvwqL@oucCT#dqVMv-P$N z!G)FkPCok;bpD&Tslc{G*9Ps|Ws!^TIwmrC&;7w%!=x3;SN?#@Abzu6Yo5eqy?R!k zUxkd%o!bQd-A%o=#iM%Dyna>fpqVG_3Y-o$TrF8)Ap69*)k3jvyWxSbZwDP%Ov(hB z1O>j8F+7RhtnKh^q0j{}w}xw431(|~d$bs1I_eWr64x2`pHj_SoX?(Q_s>z%Y$ez6 RB%uEpJYD@<);T3K0RYt&k`e#_ literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/gold_axe.png b/android/assets/textures/items/gold_axe.png new file mode 100644 index 0000000000000000000000000000000000000000..d939170fa2b0f58e20194644dd4784a35d4f7875 GIT binary patch literal 364 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvRqMx;Tbd_$NmMEo^E0|NlS#@%4OafB%>4{AAzZCf1&~hONQCLulF0 zQ$@iBY#${X6fPY6Qom+7ZvZDF^90lPuP!nr&v5Kpc1wV{fN_F~hoae81v4Msiww&o zUs&x3?=WL{a{r5h_=dEU=>n+?9?6MQe%A*aaBMxmkR~vtTlT>v9_9@j4sdZ~vRTS6 z7he^$=bwL0$MKbtECo^wmt~%3I0P8CF&doR*=S~A+RPBf+;NqMNrJ864;Pn7%{ezV z4Yr0wOiLuEY+Lw=g|Ulq!4U&p*Vc@)3JnGi?3o$VZPfZ@qRvgTe~DWM4f DkTQMn literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/gold_hoe.png b/android/assets/textures/items/gold_hoe.png new file mode 100644 index 0000000000000000000000000000000000000000..da32a5dc5344d10dcac4adaa749b4a837ef90387 GIT binary patch literal 371 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvO&Px;Tbd_$UAP|KC3B&#Qz>|NW86UBfT97b7!AL$u;*7!!MTJ`zL!^@!Iuu$G+Zs%od6+&X7HMpI zcu0Za@}4D5FYP^e@)#~?Rv7vipI}uut6=BJ*1)7=dxCYHBufC#0d@x|?!|WwGO~#> zF)!k2$Yk5ea5t2NcZJu-U-lan<<>|ZQ9sErBW;1w4xNi^2TY!`-CA%$AeBMytb)S@ zhKLYFYiY>`rVLYb9A`BOMVK}-#4$Up%!%sa@;j^0aJ%6@4+C>>u8;K^g)czgGI+ZB KxvX!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXY~8w@?$_XpFLe1 zLoEEKPBP>=yo*LU2S?W8wb; zI+Ih%ukz1V+5I^_&CJl{N|DdnTh9)?y|Vavt?T>a`%>312k`{W>Nk#l$CzQiUbFp3 z!|AAb-*QiiH*9OU$oVc+X7h>33rrmjO^-cZ%G9xOtqZT`Z7Uv${9jJDEY`fuIg5{R~z*cR3cAHTky}IX!=TX>VlzlHCs;EmO(a-=zIRQsJTR#H(ht z3_XpjgEe?E8P@z47E3$2@a49xix~b$aNOq2m*8Sdn734G_dx>@HkD`0pHCG1j#V_Q Q0D7On)78&qol`;+05*z|Gynhq literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/iron_axe.png b/android/assets/textures/items/iron_axe.png new file mode 100644 index 0000000000000000000000000000000000000000..2fd16d0919456edf70812d6563e82bd0cfc8f2a6 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP}LJp z7sn6_|EZGX`8j&UpvD_O!OnOFkoC zW)e9$=Z}HP%rn2OCBp;*jpEL;-^~y2JN+{y_}||047LP^j>n1TS8tN~>NRWDI^B~d z3_Uk;&9}sb&3QdtHu_Lq;lf<;V_kQW?2?T#6=FRmawosP$NE(4!Rw6ZT?gdSJedXC zw$9@D`PPD2=x|tbmQ8|0@cQ8S=blIgwkCM+s5DL5HhY6c<^?wAKxT)AkCU&gT+qa} z)8I=ogM{!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP}K!b z7sn6_|KuP4|J%DttXANdZ&UZ-|7CUl0}@B_R%)}aYHM&{zx;pWJTr&X3Z90{nEh#* z68`UAGe`%`n$7pjdR7+m)PrY_uqd1jP-FH`J|i%pqO3?Jf^R+J3x-%@4uM>TGpsLW zbs8~bP0l+XkK2!3yj literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/iron_pickaxe.png b/android/assets/textures/items/iron_pickaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..0746cc06bf44442a118eaae7057fac1832dc6082 GIT binary patch literal 359 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{^MbQ4*Y=R#Ki=l*$m0n3-3i=jR%tP-d)Ws%L0m@TF)WP}O5k z7sn6_|GAS5xehr9xPG@==9})|I6-%-$d-*Bieh3(>8XjS$`y{6SdM;T z5Yqqj`)ZNm=ge2v-tPD)mT~Cp0h@`w$CR&kMmcnCn7)#gVTpg>73f_CPgg&ebxsLQ0EyLw Ap8x;= literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/shears.png b/android/assets/textures/items/shears.png new file mode 100644 index 0000000000000000000000000000000000000000..bfa815c4cf76a8507529f499d848a9ca556c6520 GIT binary patch literal 331 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&*=BV<;Q?(PI|gH zhFJI~|M>sk-c@3?f+i4K*;W2|@c(P}w5GzcBAEaV#r8!4(#Mubs<16O$Z+I9>&DEw zUr!ik@FzVsWmqQI;>`57(TU?M3onD_j62sGgN;4-RN5{#IIv&-zjWuzg0m;$8Z+4v z*RYAW?fl>Wb<5B98LN1oEUIEvX1l=KklFUpv8^G;rHt3;m;u9+5`ngliFyZ@Nwx&? zH2f4^!uU)m<#0iw1@jU~m*zR$GHfjda~MBqYfLDx6c<0H<)P!o$y{W>3Abxc=hWu& zEv}o;%@U_8p5;(?$LXb6jbz!YL*^5`I}K)>Q)7Gfr|zDq`QKT085o&k&PTuf_jixU z=Qk-6IyO$`oYA)0Qu@Nwz8>H5gmuqT4Bl-OSymhq#2C%n@Vt3jo~@o_B<~O3RD)mH z3C)2k83hcuyS-brObS{9&oRtcy7PcWYJjMlCiAo~R=0_c5B@S}#~QP^9IEyP`j)}d L)z4*}Q$iB}eEf-T literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/stone_hoe.png b/android/assets/textures/items/stone_hoe.png new file mode 100644 index 0000000000000000000000000000000000000000..2118229418342cfe36cc6683b01b1763f81705c4 GIT binary patch literal 379 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvR44x;Tbd_)nc^%XP>>z^z#Rb%_{PQ$*Hsg&Uk*O)eY0E#Dvzt*f$J z;0W`Ls7~<>AH`PZ-{@TDIqk>64YP0lymuy#DY?fy?eYofnQD(}Gr~T%-psqUN$$IM zr2g_76^tTB+vf^9yt}^n&HVn^4Q+e3H3%jCGtDf2`-fMmmtC*HnNMSzru$j1j9+VK z#kij3JD`5-SOl*(Q+TnW!}dTi>3_g0LG1%O)Py52?a*+G|FYSv9 T`hgTe~DWM4fJT;J; literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/stone_pickaxe.png b/android/assets/textures/items/stone_pickaxe.png new file mode 100644 index 0000000000000000000000000000000000000000..13bdd7524ff21bf133f7b96b1126b9e287e7c284 GIT binary patch literal 372 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvO&Rx;Tbd_$UAP|KHwKqV@9i%OC6S&3ReC^Jw~X5$2@fm-;o!c>^S`Fw`)lSZ{K4-+uo0{J8=@?_Ug=ZNZ$7aJnaL!!z;z z^?%qmIwq+|G87q|Fui{6Ez53}C$fup8*XxavOXbdpns4_T;GGgh%uY(CXZ;+iLh%<{-{ui*VxHh8ag58M?$}aEmV{Z2(;QqUFesi?Xt>NUL2W`>fQ@tO z2BtM^0;?ri40sqa*;u6vXE`z)We75DX6RyE;Gpbk%%Q+j01Uh{7XI#gd$~%1-evG~ L^>bP0l+XkK88v>v literal 0 HcmV?d00001 diff --git a/android/assets/textures/items/wood_axe.png b/android/assets/textures/items/wood_axe.png new file mode 100644 index 0000000000000000000000000000000000000000..b0cbde6132f609c7b253d2341f1ce8f4b9fd5b33 GIT binary patch literal 361 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvRqJx;Tbd`1ejWo4(N01AZQt^zC-$yxKVUPPXP&L$iU6B z;vFl)Yw>GgkGj|*5=D3)ToU2?Z&u3Dn#Vlr5xeghkKFh1Z)?l^0ir2Y}{Ps zuPeEXHu1o4%!@@rEJtQ?e`t|>oOxfZ*!02A7e_33l?(r{EZ{x!Wu2yc z!r{xgv)IpHpK^j#p)2>6s<9M{!n~Z?>{ZJh8@3*NeB3Y_iP`lDx4b`b#whtbU-v}ighqqG^c{Dm?%8rcqrv>xp$w4;T#Gdv@-H7s;$kW~ x^mS{A90SMZEg{bp6wG^?7^Y1Vc5`+J-qIjwAH2XZMi=Nm22WQ%mvv4FO#rAQhB*KL literal 0 HcmV?d00001 diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java index 216db6a..34a936d 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java @@ -118,12 +118,30 @@ public class Player extends Mob { final Block foregroundBlock = gameWorld.getForeMap(cursorX, cursorY); final Block backgroundBlock = gameWorld.getBackMap(cursorX, cursorY); + @CheckForNull final Block target; - final boolean canHitBlock = !foregroundBlock.isNone() && foregroundBlock.getParams().getHitPoints() >= 0 - || !backgroundBlock.isNone() && backgroundBlock.getParams().getHitPoints() >= 0; + if (!foregroundBlock.isNone() && foregroundBlock.getParams().getHitPoints() >= 0) { + target = foregroundBlock; + } else if (!backgroundBlock.isNone() && backgroundBlock.getParams().getHitPoints() >= 0) { + target = backgroundBlock; + } else { + target = null; + } + + final boolean canHitBlock = target != null; + + float multiplier = 1f; + final Item currentItem = inventory[slot].getItem(); + if (currentItem instanceof Item.Tool && canHitBlock) { + if (target.getParams().getToolType() == currentItem.getClass() + && ((Item.Tool)currentItem).getLevel() >= target.getParams().getToolLevel()) { + multiplier = 2f * ((Item.Tool)currentItem).getLevel(); + } + multiplier *= ((Item.Tool)currentItem).getBlockDamageMultiplier(); + } if (hitting && canHitBlock) { - blockDamage += 60f * delta; + blockDamage += 60f * delta * multiplier; } else { blockDamage = 0f; } diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/block/CommonBlockParams.kt b/core/src/ru/deadsoftware/cavedroid/game/model/block/CommonBlockParams.kt index 1c9c510..584e737 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/block/CommonBlockParams.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/block/CommonBlockParams.kt @@ -1,9 +1,10 @@ package ru.deadsoftware.cavedroid.game.model.block import com.badlogic.gdx.graphics.Texture +import ru.deadsoftware.cavedroid.game.model.item.Item data class CommonBlockParams( - @Deprecated("numeric id's will be removed") val id: Int, + @Deprecated("numeric id's will be removed") val id: Int?, val key: String, val collisionMargins: BlockMargins, val hitPoints: Int, @@ -15,4 +16,6 @@ data class CommonBlockParams( val animationInfo: BlockAnimationInfo?, val texture: Texture?, val spriteMargins: BlockMargins, + val toolLevel: Int, + val toolType: Class? ) diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/dto/BlockDto.kt b/core/src/ru/deadsoftware/cavedroid/game/model/dto/BlockDto.kt index e30ae52..1a7dc4b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/dto/BlockDto.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/dto/BlockDto.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable @Serializable data class BlockDto( - @Deprecated("numeric ids will be removed") @SerialName("id") val id: Int, + @Deprecated("numeric ids will be removed") @SerialName("id") val id: Int? = null, @SerialName("left") val left: Int = 0, @SerialName("top") val top: Int = 0, @SerialName("right") val right: Int = 0, @@ -28,4 +28,6 @@ data class BlockDto( @SerialName("full_block") val fullBlock: String? = null, @SerialName("state") val state: Int? = null, @SerialName("other_part") val otherPart: String? = null, + @SerialName("tool_level") val toolLevel: Int = 0, + @SerialName("tool_type") val toolType: String? = null, ) diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/dto/ItemDto.kt b/core/src/ru/deadsoftware/cavedroid/game/model/dto/ItemDto.kt index 4d57886..0fa2075 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/dto/ItemDto.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/dto/ItemDto.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable @Serializable data class ItemDto( - @Deprecated("numeric ids will be removed") @SerialName("id") val id: Int, + @Deprecated("numeric ids will be removed") @SerialName("id") val id: Int? = null, @SerialName("name") val name: String, @SerialName("type") val type: String, @SerialName("texture") val texture: String, @@ -16,4 +16,5 @@ data class ItemDto( @SerialName("block_damage_multiplier") val blockDamageMultiplier: Float = 1f, @SerialName("top_slab_block") val topSlabBlock: String? = null, @SerialName("bottom_slab_block") val bottomSlabBlock: String? = null, + @SerialName("tool_level") val toolLevel: Int? = null, ) diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/item/CommonItemParams.kt b/core/src/ru/deadsoftware/cavedroid/game/model/item/CommonItemParams.kt index 57480c8..06da72f 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/item/CommonItemParams.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/item/CommonItemParams.kt @@ -3,7 +3,7 @@ package ru.deadsoftware.cavedroid.game.model.item import ru.deadsoftware.cavedroid.misc.utils.SpriteOrigin data class CommonItemParams( - @Deprecated("numeric id's will be removed") val id: Int, + @Deprecated("numeric id's will be removed") val id: Int?, val key: String, val name: String, val inHandSpriteOrigin: SpriteOrigin, diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/item/Item.kt b/core/src/ru/deadsoftware/cavedroid/game/model/item/Item.kt index b56f068..2b6b5fc 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/item/Item.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/item/Item.kt @@ -54,6 +54,7 @@ sealed class Item { sealed class Tool : Item() { abstract val mobDamageMultiplier: Float abstract val blockDamageMultiplier: Float + abstract val level: Int } sealed class Usable : Item() { @@ -90,6 +91,7 @@ sealed class Item { override val sprite: Sprite, override val mobDamageMultiplier: Float, override val blockDamageMultiplier: Float, + override val level: Int, ) : Tool() data class Shovel( @@ -97,6 +99,31 @@ sealed class Item { override val sprite: Sprite, override val mobDamageMultiplier: Float, override val blockDamageMultiplier: Float, + override val level: Int, + ) : Tool() + + data class Axe( + override val params: CommonItemParams, + override val sprite: Sprite, + override val mobDamageMultiplier: Float, + override val blockDamageMultiplier: Float, + override val level: Int, + ) : Tool() + + data class Pickaxe( + override val params: CommonItemParams, + override val sprite: Sprite, + override val mobDamageMultiplier: Float, + override val blockDamageMultiplier: Float, + override val level: Int, + ) : Tool() + + data class Shears( + override val params: CommonItemParams, + override val sprite: Sprite, + override val mobDamageMultiplier: Float, + override val blockDamageMultiplier: Float, + override val level: Int, ) : Tool() data class Bucket( diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/mapper/BlockMapper.kt b/core/src/ru/deadsoftware/cavedroid/game/model/mapper/BlockMapper.kt index a122754..667d92b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/mapper/BlockMapper.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/mapper/BlockMapper.kt @@ -6,6 +6,7 @@ import ru.deadsoftware.cavedroid.game.GameItemsHolder import ru.deadsoftware.cavedroid.game.model.block.* import ru.deadsoftware.cavedroid.game.model.block.Block.* import ru.deadsoftware.cavedroid.game.model.dto.BlockDto +import ru.deadsoftware.cavedroid.game.model.item.Item import ru.deadsoftware.cavedroid.misc.Assets import javax.inject.Inject @@ -47,10 +48,24 @@ class BlockMapper @Inject constructor() { top = dto.spriteTop, right = dto.spriteRight, bottom = dto.spriteBottom, - ) + ), + toolLevel = dto.toolLevel, + toolType = mapToolType(dto), ) } + private fun mapToolType(dto: BlockDto): Class? { + return when(dto.toolType) { + "shovel" -> Item.Shovel::class.java + "sword" -> Item.Sword::class.java + "pickaxe" -> Item.Pickaxe::class.java + "axe" -> Item.Axe::class.java + "shears" -> Item.Shears::class.java + + else -> null + } + } + private fun mapBlockDropInfo(dto: BlockDto): BlockDropInfo? { val drop = dto.drop val dropCount = dto.dropCount diff --git a/core/src/ru/deadsoftware/cavedroid/game/model/mapper/ItemMapper.kt b/core/src/ru/deadsoftware/cavedroid/game/model/mapper/ItemMapper.kt index 7646e22..6bcad04 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/model/mapper/ItemMapper.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/model/mapper/ItemMapper.kt @@ -20,8 +20,11 @@ class ItemMapper @Inject constructor() { return when (dto.type) { "bucket" -> Bucket(params, requireNotNull(loadSprite(dto)), requireNotNull(dto.actionKey)) - "shovel" -> Shovel(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier) - "sword" -> Sword(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier) + "shovel" -> Shovel(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier, requireNotNull(dto.toolLevel)) + "sword" -> Sword(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier, requireNotNull(dto.toolLevel)) + "pickaxe" -> Pickaxe(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier, requireNotNull(dto.toolLevel)) + "axe" -> Axe(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier, requireNotNull(dto.toolLevel)) + "shears" -> Shears(params, requireNotNull(loadSprite(dto)), dto.mobDamageMultiplier, dto.blockDamageMultiplier, requireNotNull(dto.toolLevel)) "block" -> Block(params, requireNotNull(block)) "slab" -> Slab(params, requireNotNull(slabTopBlock), requireNotNull(slabBottomBlock)) "none" -> None(params) diff --git a/core/src/ru/deadsoftware/cavedroid/game/render/BlocksRenderer.kt b/core/src/ru/deadsoftware/cavedroid/game/render/BlocksRenderer.kt index 60a9ef8..378ed7b 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/render/BlocksRenderer.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/render/BlocksRenderer.kt @@ -23,7 +23,7 @@ abstract class BlocksRenderer( get() = isNone() || params.isTransparent private fun blockDamageSprite(index: Int): Sprite? { - if (index !in 0..MAX_BLOCK_DAMAGE_INDEX) { + if (index !in 0..< MAX_BLOCK_DAMAGE_INDEX) { return null } return Assets.blockDamageSprites[index] -- 2.29.2