From aee610c7a0c66edf8125a66f06aca9da159c3079 Mon Sep 17 00:00:00 2001 From: Yan Wittmann Date: Wed, 8 Jan 2025 18:48:14 +0100 Subject: [PATCH] More PR review --- doc/planning.md | 55 +++++++++++---------- project/main-scenes/island.tscn | 3 +- project/scripts/player/PlayerManager.gd | 20 +++++--- project/scripts/tilemap/TileMapTileTypes.gd | 30 ++++++----- 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/doc/planning.md b/doc/planning.md index d9ff10b..194efcc 100644 --- a/doc/planning.md +++ b/doc/planning.md @@ -1,33 +1,34 @@ ## Todo +- Sprites (Dome) + - camp (multiple textures) + - boat + - see DC +- Design a tilemap for the game (Dome) +- Navigation v3 (Yan) + - Player: function to walk up to a tile, not onto the tile (trees, etc.) + - Visualization: Current navigation path +- Interactive and Non-Interactive Items + - Add all the items needed to build the game (bushes, trees, etc.) + - Add logic regarding the objects, like taking branches, etc. + - Camp, chest (inventory slots, array of items, Interactions) +- Implement Behaviours + - Implement all kinds of Behaviours, see document +- UI, Visualization, make the simulation understandable (Luca, Colin) + - GraphEdit + - GraphEdit toggle (key) + - Inventory + - Player Stats + - Temperature layer toggle (key) + - etc. + +## Done + - Sprites (Dome) - Ground - Berry bush (filled, empty) - Tree (filled, empty) - Ship parts - - camp (multiple textures) -- Design a tilemap for the game (Dome, Colin, Luca) -- Navigation v3 (Yan) - - Player: function to walk up to a tile, not onto the tile (trees, etc.) -- Player v2 (Colin) - - TBD - - Check player pickup function and inventory system (if inventory already full, etc.) - - Check player walking capability - - Interactions with camp, etc. -- Interactive and Non-Interactive Items (Luca) - - Add all the items needed to build the game (bushes, trees, etc.) - - Add logic regarding the objects, like picking up berries or taking branches, etc. - - Camp, chest (inventory slots, array of items) -- Implement Behaviours - - Implement all kinds of Behaviours, see document -- Visualization, make the simulation understandable - - GraphEdit - - Distances - - Current navigation path - - etc. - -## Done - - Initialize Tilemap (Yan) - Script --> World (manages access to tilemap) - Player is on tilemap @@ -53,7 +54,7 @@ - can pick up items from tilemap (Pickup) - can drop items back onto tilemap (Pickup) - Navigation v2 (Yan) - - Support walkable attribute on interactive/non-interactive tilemap items (is_walkable) - - fix pathfinding for unreachable cells - - add search radius (max distance) before canceling - - improve performance (or rather, check performance first) + - Support walkable attribute on interactive/non-interactive tilemap items (is_walkable) + - fix pathfinding for unreachable cells + - add search radius (max distance) before canceling + - improve performance (or rather, check performance first) diff --git a/project/main-scenes/island.tscn b/project/main-scenes/island.tscn index 395f502..bec4894 100644 --- a/project/main-scenes/island.tscn +++ b/project/main-scenes/island.tscn @@ -21,8 +21,9 @@ offset_right = 40.0 offset_bottom = 40.0 [node name="InventoryLabel" type="Label" parent="Camera2D/CanvasLayer/VBoxContainer"] +unique_name_in_owner = true layout_mode = 2 -text = "test" +text = "INV" [node name="Tileset" type="Node2D" parent="."] script = ExtResource("1_k0rw8") diff --git a/project/scripts/player/PlayerManager.gd b/project/scripts/player/PlayerManager.gd index 7d66440..700d841 100644 --- a/project/scripts/player/PlayerManager.gd +++ b/project/scripts/player/PlayerManager.gd @@ -1,7 +1,7 @@ class_name PlayerManager extends Node -@onready var inventory_label = $CanvasLayer/VBoxContainer/InventoryLabel +@onready var inventory_label: Label = %InventoryLabel @export var food_damage: int = 1 @export var temperature_damage: int = 1 @@ -38,8 +38,9 @@ func _process(delta: float) -> void: if Input.is_action_just_pressed("key_5"): pick_up_item(Vector2i(5, 8)) pick_up_item(Vector2i(9, 9)) + update_board() if Input.is_action_just_pressed("key_4"): - var nearest: Vector2i = find_nearest_object(game_manager.world.tilemap_types.OBJECT_COLLECTION_TREE) + var nearest: Vector2i = find_nearest_object([game_manager.world.tilemap_types.OBJECT_I_TREE_1]) # nearest.x = nearest.x - 1 walk_towards(nearest) update_board() @@ -50,6 +51,10 @@ func _process(delta: float) -> void: func update_board() -> void: game_manager.world.tilemap_player.clear_cells() game_manager.world.tilemap_player.set_cell(board_position, tilemap_types.PLAYER) + if inventory_slot and inventory_slot != tilemap_types.EMPTY: + inventory_label.text = str(inventory_slot) + else: + inventory_label.text = "empty" # SECTION: inventory system @@ -64,8 +69,11 @@ func pick_up_item(tilemap_pos: Vector2i) -> void: # check if tile will transform into another tile upon pickup var tile_after_pickup_transform = null - if tilemap_types.OBJECT_COLLECTION_BERRY_FILLED_BUSH.has(pick_up_item_type): - tile_after_pickup_transform = tilemap_types.OBJECT_COLLECTION_BERRY_EMPTY_BUSH[0] + var tile_drop_item: Vector2i = inventory_slot + if tilemap_types.OBJECT_I_FILLED_BUSH == pick_up_item_type: + tile_after_pickup_transform = tilemap_types.OBJECT_I_EMPTY_BUSH + pick_up_item_type = tilemap_types.OBJECT_I_BERRY + tile_drop_item = tilemap_types.OBJECT_I_BERRY # check if the inventory slot is empty if inventory_slot == tilemap_types.EMPTY: @@ -82,11 +90,11 @@ func pick_up_item(tilemap_pos: Vector2i) -> void: game_manager.world.tilemap_interactive.set_cell(tilemap_pos, tile_after_pickup_transform) var drop_location: Vector2i = game_manager.world.find_item_drop_location(tilemap_pos) if drop_location != tilemap_types.EMPTY: - game_manager.world.tilemap_interactive.set_cell(drop_location, inventory_slot) + game_manager.world.tilemap_interactive.set_cell(drop_location, tile_drop_item) else: push_warning("Could not find valid drop position for ", inventory_slot) else: - game_manager.world.tilemap_interactive.set_cell(tilemap_pos, inventory_slot) + game_manager.world.tilemap_interactive.set_cell(tilemap_pos, tile_drop_item) inventory_slot = pick_up_item_type diff --git a/project/scripts/tilemap/TileMapTileTypes.gd b/project/scripts/tilemap/TileMapTileTypes.gd index 5c93b84..1f3b430 100644 --- a/project/scripts/tilemap/TileMapTileTypes.gd +++ b/project/scripts/tilemap/TileMapTileTypes.gd @@ -1,7 +1,7 @@ class_name TileMapTileTypes # global values -const EMPTY: Vector2i = Vector2i(-1, -1) +const EMPTY: Vector2i = Vector2i(-1, -1) const NO_TILE_FOUND: Vector2i = Vector2i(-999999, -999999) # # ground, sid = 0 @@ -16,22 +16,20 @@ const OBJECT_NI_RANDOM_1: Vector2i = Vector2i(0, 0) # testing only, to be remove const OBJECT_NI_RANDOM_2: Vector2i = Vector2i(1, 0) # testing only, to be removed const OBJECT_NI_ROCK_1: Vector2i = Vector2i(2, 0) # I = interactive -const OBJECT_I_BOAT_ENGINE: Vector2i = Vector2i(0, 1) -const OBJECT_I_FUEL: Vector2i = Vector2i(1, 1) -const OBJECT_I_ANCHOR: Vector2i = Vector2i(2, 1) -const OBJECT_I_EMPTY_BUSH: Vector2i = Vector2i(3, 0) -const OBJECT_I_FILLED_BUSH: Vector2i = Vector2i(3, 1) -const OBJECT_I_TREE_1_TOP: Vector2i = Vector2i(4, 0) -const OBJECT_I_TREE_1_BOTTOM: Vector2i = Vector2i(4, 1) -const OBJECT_I_CHEST: Vector2i = Vector2i(0, 2) -const OBJECT_I_GEARS: Vector2i = Vector2i(1, 2) -const OBJECT_I_MEDIKIT: Vector2i = Vector2i(2, 2) -const OBJECT_I_PADDLE: Vector2i = Vector2i(3, 2) -const OBJECT_I_GAS_STOVE: Vector2i = Vector2i(4, 2) +const OBJECT_I_BOAT_ENGINE: Vector2i = Vector2i(0, 1) +const OBJECT_I_FUEL: Vector2i = Vector2i(1, 1) +const OBJECT_I_ANCHOR: Vector2i = Vector2i(2, 1) +const OBJECT_I_EMPTY_BUSH: Vector2i = Vector2i(3, 0) +const OBJECT_I_FILLED_BUSH: Vector2i = Vector2i(3, 1) +const OBJECT_I_BERRY: Vector2i = Vector2i(0, 5) +const OBJECT_I_TREE_1: Vector2i = Vector2i(4, 0) +const OBJECT_I_CHEST: Vector2i = Vector2i(0, 2) +const OBJECT_I_GEARS: Vector2i = Vector2i(1, 2) +const OBJECT_I_MEDIKIT: Vector2i = Vector2i(2, 2) +const OBJECT_I_PADDLE: Vector2i = Vector2i(3, 2) +const OBJECT_I_GAS_STOVE: Vector2i = Vector2i(4, 2) # collections -const OBJECT_COLLECTION_TREE: Array[Vector2i] = [OBJECT_I_TREE_1_TOP, OBJECT_I_TREE_1_BOTTOM] -const OBJECT_COLLECTION_BERRY_FILLED_BUSH: Array[Vector2i] = [OBJECT_I_FILLED_BUSH] -const OBJECT_COLLECTION_BERRY_EMPTY_BUSH: Array[Vector2i] = [OBJECT_I_EMPTY_BUSH] +const OBJECT_COLLECTION_BERRY_SOURCE: Array[Vector2i] = [OBJECT_I_FILLED_BUSH, OBJECT_I_BERRY] # # temperature, sid = 2 const TEMPERATURE_NORMAL: Vector2i = Vector2i(-1, -1)