From c6bbb834f7758027c0df338f1520f34fad3befea Mon Sep 17 00:00:00 2001 From: Matheus Date: Tue, 9 Sep 2025 19:09:34 -0300 Subject: Organização MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/definitions/Items/small_healing_potion.tres | 2 +- assets/definitions/actor/EntityInspector.tres | 2 +- assets/definitions/actor/Player.tres | 2 +- assets/definitions/actor/Shadow.tres | 2 +- assets/definitions/actor/Skeleton.tres | 2 +- assets/definitions/actor/morcegao.tres | 2 +- assets/definitions/tiles/floor.tres | 2 +- assets/definitions/tiles/wall.tres | 2 +- scenes/Game.tscn | 30 +- scenes/Inspector.tscn | 2 +- scripts/Entities/Actions/Action.cs | 69 +++++ scripts/Entities/Actions/Action.cs.uid | 1 + scripts/Entities/Actions/BumpAction.cs | 38 +++ scripts/Entities/Actions/BumpAction.cs.uid | 1 + scripts/Entities/Actions/DirectionalAction.cs | 37 +++ scripts/Entities/Actions/DirectionalAction.cs.uid | 1 + scripts/Entities/Actions/DropAction.cs | 17 ++ scripts/Entities/Actions/DropAction.cs.uid | 1 + scripts/Entities/Actions/ItemAction.cs | 39 +++ scripts/Entities/Actions/ItemAction.cs.uid | 1 + scripts/Entities/Actions/MeleeAction.cs | 55 ++++ scripts/Entities/Actions/MeleeAction.cs.uid | 1 + scripts/Entities/Actions/MovementAction.cs | 30 ++ scripts/Entities/Actions/MovementAction.cs.uid | 1 + scripts/Entities/Actions/PickUpAction.cs | 51 ++++ scripts/Entities/Actions/PickUpAction.cs.uid | 1 + scripts/Entities/Actions/WaitAction.cs | 104 +++++++ scripts/Entities/Actions/WaitAction.cs.uid | 1 + scripts/Entities/Actors/AI/BaseAI.cs | 54 ++++ scripts/Entities/Actors/AI/BaseAI.cs.uid | 1 + scripts/Entities/Actors/AI/HostileEnemyAI.cs | 84 ++++++ scripts/Entities/Actors/AI/HostileEnemyAI.cs.uid | 1 + scripts/Entities/Actors/Actor.cs | 251 ++++++++++++++++ scripts/Entities/Actors/Actor.cs.uid | 1 + scripts/Entities/Actors/ActorDefinition.cs | 32 +++ scripts/Entities/Actors/ActorDefinition.cs.uid | 1 + scripts/Entities/Actors/Enemy.cs | 54 ++++ scripts/Entities/Actors/Enemy.cs.uid | 1 + scripts/Entities/Actors/EnemyDefinition.cs | 15 + scripts/Entities/Actors/EnemyDefinition.cs.uid | 1 + scripts/Entities/Actors/Inventory.cs | 46 +++ scripts/Entities/Actors/Inventory.cs.uid | 1 + scripts/Entities/Actors/Player.cs | 27 ++ scripts/Entities/Actors/Player.cs.uid | 1 + scripts/Entities/Actors/PlayerDefinition.cs | 11 + scripts/Entities/Actors/PlayerDefinition.cs.uid | 1 + scripts/Entities/Entity.cs | 127 ++++++++ scripts/Entities/Entity.cs.uid | 1 + scripts/Entities/EntityDefinition.cs | 23 ++ scripts/Entities/EntityDefinition.cs.uid | 1 + scripts/Entities/Items/ConsumableItem.cs | 40 +++ scripts/Entities/Items/ConsumableItem.cs.uid | 1 + scripts/Entities/Items/ConsumableItemDefinition.cs | 9 + .../Entities/Items/ConsumableItemDefinition.cs.uid | 1 + scripts/Entities/Items/HealingConsumable.cs | 30 ++ scripts/Entities/Items/HealingConsumable.cs.uid | 1 + .../Entities/Items/HealingConsumableDefinition.cs | 14 + .../Items/HealingConsumableDefinition.cs.uid | 1 + scripts/GUI/Details.cs | 43 +-- scripts/GUI/Hud.cs | 17 +- scripts/GUI/InventoryMenu.cs | 47 +-- scripts/GUI/ItemMenuEntry.cs | 61 ++-- scripts/GUI/Message.cs | 45 ++- scripts/GUI/MessageLog.cs | 12 +- scripts/Game.cs | 59 ++-- scripts/InputHandling/BaseInputHandler.cs | 31 ++ scripts/InputHandling/BaseInputHandler.cs.uid | 1 + scripts/InputHandling/GameOverInputHandler.cs | 16 ++ scripts/InputHandling/GameOverInputHandler.cs.uid | 1 + scripts/InputHandling/InputHandler.cs | 58 ++++ scripts/InputHandling/InputHandler.cs.uid | 1 + scripts/InputHandling/InspectInputHandler.cs | 70 +++++ scripts/InputHandling/InspectInputHandler.cs.uid | 1 + scripts/InputHandling/InventoryInputHandler.cs | 75 +++++ scripts/InputHandling/InventoryInputHandler.cs.uid | 1 + scripts/InputHandling/MainGameInputHandler.cs | 58 ++++ scripts/InputHandling/MainGameInputHandler.cs.uid | 1 + scripts/InputHandling/PickupInputHandler.cs | 50 ++++ scripts/InputHandling/PickupInputHandler.cs.uid | 1 + scripts/Map/DungeonGenerator.cs | 301 +++++++++++++++++++ scripts/Map/DungeonGenerator.cs.uid | 1 + scripts/Map/FieldOfView.cs | 115 ++++++++ scripts/Map/FieldOfView.cs.uid | 1 + scripts/Map/Map.cs | 98 +++++++ scripts/Map/Map.cs.uid | 1 + scripts/Map/MapData.cs | 318 +++++++++++++++++++++ scripts/Map/MapData.cs.uid | 1 + scripts/Map/MapDivision.cs | 113 ++++++++ scripts/Map/MapDivision.cs.uid | 1 + scripts/Map/Tile.cs | 90 ++++++ scripts/Map/Tile.cs.uid | 1 + scripts/Map/TileDefinition.cs | 24 ++ scripts/Map/TileDefinition.cs.uid | 1 + scripts/Time/TurnManager.cs | 102 ++++--- scripts/Utils/Grid.cs | 12 +- scripts/Utils/Inspector.cs | 48 ++++ scripts/Utils/Inspector.cs.uid | 1 + scripts/Utils/MessageLogData.cs | 59 ++-- scripts/Utils/SignalBus.cs | 19 +- scripts/entities/Entity.cs | 108 ------- scripts/entities/Entity.cs.uid | 1 - scripts/entities/EntityDefinition.cs | 20 -- scripts/entities/EntityDefinition.cs.uid | 1 - scripts/entities/actions/Action.cs | 44 --- scripts/entities/actions/Action.cs.uid | 1 - scripts/entities/actions/BumpAction.cs | 32 --- scripts/entities/actions/BumpAction.cs.uid | 1 - scripts/entities/actions/DirectionalAction.cs | 30 -- scripts/entities/actions/DirectionalAction.cs.uid | 1 - scripts/entities/actions/DropAction.cs | 13 - scripts/entities/actions/DropAction.cs.uid | 1 - scripts/entities/actions/ItemAction.cs | 17 -- scripts/entities/actions/ItemAction.cs.uid | 1 - scripts/entities/actions/MeleeAction.cs | 48 ---- scripts/entities/actions/MeleeAction.cs.uid | 1 - scripts/entities/actions/MovementAction.cs | 26 -- scripts/entities/actions/MovementAction.cs.uid | 1 - scripts/entities/actions/PickUpAction.cs | 34 --- scripts/entities/actions/PickUpAction.cs.uid | 1 - scripts/entities/actions/WaitAction.cs | 104 ------- scripts/entities/actions/WaitAction.cs.uid | 1 - scripts/entities/actors/AI/BaseAI.cs | 41 --- scripts/entities/actors/AI/BaseAI.cs.uid | 1 - scripts/entities/actors/AI/HostileEnemyAI.cs | 76 ----- scripts/entities/actors/AI/HostileEnemyAI.cs.uid | 1 - scripts/entities/actors/Actor.cs | 215 -------------- scripts/entities/actors/Actor.cs.uid | 1 - scripts/entities/actors/ActorDefinition.cs | 30 -- scripts/entities/actors/ActorDefinition.cs.uid | 1 - scripts/entities/actors/Enemy.cs | 57 ---- scripts/entities/actors/Enemy.cs.uid | 1 - scripts/entities/actors/EnemyDefinition.cs | 11 - scripts/entities/actors/EnemyDefinition.cs.uid | 1 - scripts/entities/actors/Inspector.cs | 40 --- scripts/entities/actors/Inspector.cs.uid | 1 - scripts/entities/actors/Inventory.cs | 39 --- scripts/entities/actors/Inventory.cs.uid | 1 - scripts/entities/actors/Player.cs | 24 -- scripts/entities/actors/Player.cs.uid | 1 - scripts/entities/actors/PlayerDefinition.cs | 8 - scripts/entities/actors/PlayerDefinition.cs.uid | 1 - scripts/entities/items/ConsumableItem.cs | 37 --- scripts/entities/items/ConsumableItem.cs.uid | 1 - scripts/entities/items/ConsumableItemDefinition.cs | 7 - .../entities/items/ConsumableItemDefinition.cs.uid | 1 - scripts/entities/items/HealingConsumable.cs | 28 -- scripts/entities/items/HealingConsumable.cs.uid | 1 - .../entities/items/HealingConsumableDefinition.cs | 11 - .../items/HealingConsumableDefinition.cs.uid | 1 - scripts/input/BaseInputHandler.cs | 26 -- scripts/input/BaseInputHandler.cs.uid | 1 - scripts/input/GameOverInputHandler.cs | 13 - scripts/input/GameOverInputHandler.cs.uid | 1 - scripts/input/InputHandler.cs | 52 ---- scripts/input/InputHandler.cs.uid | 1 - scripts/input/InspectInputHandler.cs | 58 ---- scripts/input/InspectInputHandler.cs.uid | 1 - scripts/input/InventoryInputHandler.cs | 65 ----- scripts/input/InventoryInputHandler.cs.uid | 1 - scripts/input/MainGameInputHandler.cs | 47 --- scripts/input/MainGameInputHandler.cs.uid | 1 - scripts/input/PickupInputHandler.cs | 41 --- scripts/input/PickupInputHandler.cs.uid | 1 - scripts/map/DungeonGenerator.cs | 272 ------------------ scripts/map/DungeonGenerator.cs.uid | 1 - scripts/map/FieldOfView.cs | 96 ------- scripts/map/FieldOfView.cs.uid | 1 - scripts/map/Map.cs | 86 ------ scripts/map/Map.cs.uid | 1 - scripts/map/MapData.cs | 272 ------------------ scripts/map/MapData.cs.uid | 1 - scripts/map/MapDivision.cs | 98 ------- scripts/map/MapDivision.cs.uid | 1 - scripts/map/Tile.cs | 81 ------ scripts/map/Tile.cs.uid | 1 - scripts/map/TileDefinition.cs | 22 -- scripts/map/TileDefinition.cs.uid | 1 - 177 files changed, 3068 insertions(+), 2585 deletions(-) create mode 100644 scripts/Entities/Actions/Action.cs create mode 100644 scripts/Entities/Actions/Action.cs.uid create mode 100644 scripts/Entities/Actions/BumpAction.cs create mode 100644 scripts/Entities/Actions/BumpAction.cs.uid create mode 100644 scripts/Entities/Actions/DirectionalAction.cs create mode 100644 scripts/Entities/Actions/DirectionalAction.cs.uid create mode 100644 scripts/Entities/Actions/DropAction.cs create mode 100644 scripts/Entities/Actions/DropAction.cs.uid create mode 100644 scripts/Entities/Actions/ItemAction.cs create mode 100644 scripts/Entities/Actions/ItemAction.cs.uid create mode 100644 scripts/Entities/Actions/MeleeAction.cs create mode 100644 scripts/Entities/Actions/MeleeAction.cs.uid create mode 100644 scripts/Entities/Actions/MovementAction.cs create mode 100644 scripts/Entities/Actions/MovementAction.cs.uid create mode 100644 scripts/Entities/Actions/PickUpAction.cs create mode 100644 scripts/Entities/Actions/PickUpAction.cs.uid create mode 100644 scripts/Entities/Actions/WaitAction.cs create mode 100644 scripts/Entities/Actions/WaitAction.cs.uid create mode 100644 scripts/Entities/Actors/AI/BaseAI.cs create mode 100644 scripts/Entities/Actors/AI/BaseAI.cs.uid create mode 100644 scripts/Entities/Actors/AI/HostileEnemyAI.cs create mode 100644 scripts/Entities/Actors/AI/HostileEnemyAI.cs.uid create mode 100644 scripts/Entities/Actors/Actor.cs create mode 100644 scripts/Entities/Actors/Actor.cs.uid create mode 100644 scripts/Entities/Actors/ActorDefinition.cs create mode 100644 scripts/Entities/Actors/ActorDefinition.cs.uid create mode 100644 scripts/Entities/Actors/Enemy.cs create mode 100644 scripts/Entities/Actors/Enemy.cs.uid create mode 100644 scripts/Entities/Actors/EnemyDefinition.cs create mode 100644 scripts/Entities/Actors/EnemyDefinition.cs.uid create mode 100644 scripts/Entities/Actors/Inventory.cs create mode 100644 scripts/Entities/Actors/Inventory.cs.uid create mode 100644 scripts/Entities/Actors/Player.cs create mode 100644 scripts/Entities/Actors/Player.cs.uid create mode 100644 scripts/Entities/Actors/PlayerDefinition.cs create mode 100644 scripts/Entities/Actors/PlayerDefinition.cs.uid create mode 100644 scripts/Entities/Entity.cs create mode 100644 scripts/Entities/Entity.cs.uid create mode 100644 scripts/Entities/EntityDefinition.cs create mode 100644 scripts/Entities/EntityDefinition.cs.uid create mode 100644 scripts/Entities/Items/ConsumableItem.cs create mode 100644 scripts/Entities/Items/ConsumableItem.cs.uid create mode 100644 scripts/Entities/Items/ConsumableItemDefinition.cs create mode 100644 scripts/Entities/Items/ConsumableItemDefinition.cs.uid create mode 100644 scripts/Entities/Items/HealingConsumable.cs create mode 100644 scripts/Entities/Items/HealingConsumable.cs.uid create mode 100644 scripts/Entities/Items/HealingConsumableDefinition.cs create mode 100644 scripts/Entities/Items/HealingConsumableDefinition.cs.uid create mode 100644 scripts/InputHandling/BaseInputHandler.cs create mode 100644 scripts/InputHandling/BaseInputHandler.cs.uid create mode 100644 scripts/InputHandling/GameOverInputHandler.cs create mode 100644 scripts/InputHandling/GameOverInputHandler.cs.uid create mode 100644 scripts/InputHandling/InputHandler.cs create mode 100644 scripts/InputHandling/InputHandler.cs.uid create mode 100644 scripts/InputHandling/InspectInputHandler.cs create mode 100644 scripts/InputHandling/InspectInputHandler.cs.uid create mode 100644 scripts/InputHandling/InventoryInputHandler.cs create mode 100644 scripts/InputHandling/InventoryInputHandler.cs.uid create mode 100644 scripts/InputHandling/MainGameInputHandler.cs create mode 100644 scripts/InputHandling/MainGameInputHandler.cs.uid create mode 100644 scripts/InputHandling/PickupInputHandler.cs create mode 100644 scripts/InputHandling/PickupInputHandler.cs.uid create mode 100644 scripts/Map/DungeonGenerator.cs create mode 100644 scripts/Map/DungeonGenerator.cs.uid create mode 100644 scripts/Map/FieldOfView.cs create mode 100644 scripts/Map/FieldOfView.cs.uid create mode 100644 scripts/Map/Map.cs create mode 100644 scripts/Map/Map.cs.uid create mode 100644 scripts/Map/MapData.cs create mode 100644 scripts/Map/MapData.cs.uid create mode 100644 scripts/Map/MapDivision.cs create mode 100644 scripts/Map/MapDivision.cs.uid create mode 100644 scripts/Map/Tile.cs create mode 100644 scripts/Map/Tile.cs.uid create mode 100644 scripts/Map/TileDefinition.cs create mode 100644 scripts/Map/TileDefinition.cs.uid create mode 100644 scripts/Utils/Inspector.cs create mode 100644 scripts/Utils/Inspector.cs.uid delete mode 100644 scripts/entities/Entity.cs delete mode 100644 scripts/entities/Entity.cs.uid delete mode 100644 scripts/entities/EntityDefinition.cs delete mode 100644 scripts/entities/EntityDefinition.cs.uid delete mode 100644 scripts/entities/actions/Action.cs delete mode 100644 scripts/entities/actions/Action.cs.uid delete mode 100644 scripts/entities/actions/BumpAction.cs delete mode 100644 scripts/entities/actions/BumpAction.cs.uid delete mode 100644 scripts/entities/actions/DirectionalAction.cs delete mode 100644 scripts/entities/actions/DirectionalAction.cs.uid delete mode 100644 scripts/entities/actions/DropAction.cs delete mode 100644 scripts/entities/actions/DropAction.cs.uid delete mode 100644 scripts/entities/actions/ItemAction.cs delete mode 100644 scripts/entities/actions/ItemAction.cs.uid delete mode 100644 scripts/entities/actions/MeleeAction.cs delete mode 100644 scripts/entities/actions/MeleeAction.cs.uid delete mode 100644 scripts/entities/actions/MovementAction.cs delete mode 100644 scripts/entities/actions/MovementAction.cs.uid delete mode 100644 scripts/entities/actions/PickUpAction.cs delete mode 100644 scripts/entities/actions/PickUpAction.cs.uid delete mode 100644 scripts/entities/actions/WaitAction.cs delete mode 100644 scripts/entities/actions/WaitAction.cs.uid delete mode 100644 scripts/entities/actors/AI/BaseAI.cs delete mode 100644 scripts/entities/actors/AI/BaseAI.cs.uid delete mode 100644 scripts/entities/actors/AI/HostileEnemyAI.cs delete mode 100644 scripts/entities/actors/AI/HostileEnemyAI.cs.uid delete mode 100644 scripts/entities/actors/Actor.cs delete mode 100644 scripts/entities/actors/Actor.cs.uid delete mode 100644 scripts/entities/actors/ActorDefinition.cs delete mode 100644 scripts/entities/actors/ActorDefinition.cs.uid delete mode 100644 scripts/entities/actors/Enemy.cs delete mode 100644 scripts/entities/actors/Enemy.cs.uid delete mode 100644 scripts/entities/actors/EnemyDefinition.cs delete mode 100644 scripts/entities/actors/EnemyDefinition.cs.uid delete mode 100644 scripts/entities/actors/Inspector.cs delete mode 100644 scripts/entities/actors/Inspector.cs.uid delete mode 100644 scripts/entities/actors/Inventory.cs delete mode 100644 scripts/entities/actors/Inventory.cs.uid delete mode 100644 scripts/entities/actors/Player.cs delete mode 100644 scripts/entities/actors/Player.cs.uid delete mode 100644 scripts/entities/actors/PlayerDefinition.cs delete mode 100644 scripts/entities/actors/PlayerDefinition.cs.uid delete mode 100644 scripts/entities/items/ConsumableItem.cs delete mode 100644 scripts/entities/items/ConsumableItem.cs.uid delete mode 100644 scripts/entities/items/ConsumableItemDefinition.cs delete mode 100644 scripts/entities/items/ConsumableItemDefinition.cs.uid delete mode 100644 scripts/entities/items/HealingConsumable.cs delete mode 100644 scripts/entities/items/HealingConsumable.cs.uid delete mode 100644 scripts/entities/items/HealingConsumableDefinition.cs delete mode 100644 scripts/entities/items/HealingConsumableDefinition.cs.uid delete mode 100644 scripts/input/BaseInputHandler.cs delete mode 100644 scripts/input/BaseInputHandler.cs.uid delete mode 100644 scripts/input/GameOverInputHandler.cs delete mode 100644 scripts/input/GameOverInputHandler.cs.uid delete mode 100644 scripts/input/InputHandler.cs delete mode 100644 scripts/input/InputHandler.cs.uid delete mode 100644 scripts/input/InspectInputHandler.cs delete mode 100644 scripts/input/InspectInputHandler.cs.uid delete mode 100644 scripts/input/InventoryInputHandler.cs delete mode 100644 scripts/input/InventoryInputHandler.cs.uid delete mode 100644 scripts/input/MainGameInputHandler.cs delete mode 100644 scripts/input/MainGameInputHandler.cs.uid delete mode 100644 scripts/input/PickupInputHandler.cs delete mode 100644 scripts/input/PickupInputHandler.cs.uid delete mode 100644 scripts/map/DungeonGenerator.cs delete mode 100644 scripts/map/DungeonGenerator.cs.uid delete mode 100644 scripts/map/FieldOfView.cs delete mode 100644 scripts/map/FieldOfView.cs.uid delete mode 100644 scripts/map/Map.cs delete mode 100644 scripts/map/Map.cs.uid delete mode 100644 scripts/map/MapData.cs delete mode 100644 scripts/map/MapData.cs.uid delete mode 100644 scripts/map/MapDivision.cs delete mode 100644 scripts/map/MapDivision.cs.uid delete mode 100644 scripts/map/Tile.cs delete mode 100644 scripts/map/Tile.cs.uid delete mode 100644 scripts/map/TileDefinition.cs delete mode 100644 scripts/map/TileDefinition.cs.uid diff --git a/assets/definitions/Items/small_healing_potion.tres b/assets/definitions/Items/small_healing_potion.tres index 56d1294..4a75d72 100644 --- a/assets/definitions/Items/small_healing_potion.tres +++ b/assets/definitions/Items/small_healing_potion.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="HealingConsumableDefinition" load_steps=3 format=3 uid="uid://bm6yx6rwh8bds"] -[ext_resource type="Script" uid="uid://b3qy4gtjfci14" path="res://scripts/entities/items/HealingConsumableDefinition.cs" id="1_4dl2g"] +[ext_resource type="Script" uid="uid://b3qy4gtjfci14" path="res://scripts/Entities/Items/HealingConsumableDefinition.cs" id="1_4dl2g"] [ext_resource type="Texture2D" uid="uid://b7drpdbk4lggb" path="res://assets/sprites/items/small_health_potion.png" id="2_esrbk"] [resource] diff --git a/assets/definitions/actor/EntityInspector.tres b/assets/definitions/actor/EntityInspector.tres index d085b79..8b9b79e 100644 --- a/assets/definitions/actor/EntityInspector.tres +++ b/assets/definitions/actor/EntityInspector.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="ActorDefinition" load_steps=2 format=3 uid="uid://bq3mbgtvjgrg3"] -[ext_resource type="Script" uid="uid://crxw1e37xlrrt" path="res://scripts/entities/actors/ActorDefinition.cs" id="1_na4h7"] +[ext_resource type="Script" uid="uid://crxw1e37xlrrt" path="res://scripts/Entities/Actors/ActorDefinition.cs" id="1_na4h7"] [resource] script = ExtResource("1_na4h7") diff --git a/assets/definitions/actor/Player.tres b/assets/definitions/actor/Player.tres index 56aa604..36c24c5 100644 --- a/assets/definitions/actor/Player.tres +++ b/assets/definitions/actor/Player.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="PlayerDefinition" load_steps=4 format=3 uid="uid://7pwmjcgbcyoo"] -[ext_resource type="Script" uid="uid://bd78nfh1tsjq6" path="res://scripts/entities/actors/PlayerDefinition.cs" id="1_2k33r"] +[ext_resource type="Script" uid="uid://bd78nfh1tsjq6" path="res://scripts/Entities/Actors/PlayerDefinition.cs" id="1_2k33r"] [ext_resource type="Texture2D" uid="uid://w0808ug4al66" path="res://assets/sprites/actors/generic_grave.png" id="1_m72ac"] [ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/actors/player.png" id="3_frwfa"] diff --git a/assets/definitions/actor/Shadow.tres b/assets/definitions/actor/Shadow.tres index cfa0995..8493618 100644 --- a/assets/definitions/actor/Shadow.tres +++ b/assets/definitions/actor/Shadow.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" script_class="EnemyDefinition" load_steps=4 format=3 uid="uid://dqd714474t4ic"] [ext_resource type="Texture2D" uid="uid://w0808ug4al66" path="res://assets/sprites/actors/generic_grave.png" id="1_3bs08"] -[ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/entities/actors/EnemyDefinition.cs" id="1_4jpld"] +[ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/Entities/Actors/EnemyDefinition.cs" id="1_4jpld"] [ext_resource type="Texture2D" uid="uid://br8cqtbd6xcej" path="res://assets/sprites/actors/shadow.png" id="3_kvxyn"] [resource] diff --git a/assets/definitions/actor/Skeleton.tres b/assets/definitions/actor/Skeleton.tres index f67bf56..44a2893 100644 --- a/assets/definitions/actor/Skeleton.tres +++ b/assets/definitions/actor/Skeleton.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" script_class="EnemyDefinition" load_steps=4 format=3 uid="uid://gt6xqa737dyt"] [ext_resource type="Texture2D" uid="uid://w0808ug4al66" path="res://assets/sprites/actors/generic_grave.png" id="1_7fof3"] -[ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/entities/actors/EnemyDefinition.cs" id="1_m5x88"] +[ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/Entities/Actors/EnemyDefinition.cs" id="1_m5x88"] [ext_resource type="Texture2D" uid="uid://dh5sgjdwkps88" path="res://assets/sprites/actors/skeleton.png" id="2_hhidw"] [resource] diff --git a/assets/definitions/actor/morcegao.tres b/assets/definitions/actor/morcegao.tres index 937679f..65c9a6e 100644 --- a/assets/definitions/actor/morcegao.tres +++ b/assets/definitions/actor/morcegao.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" script_class="EnemyDefinition" load_steps=4 format=3 uid="uid://cj0kq4sfft8gh"] [ext_resource type="Texture2D" uid="uid://w0808ug4al66" path="res://assets/sprites/actors/generic_grave.png" id="1_hdleo"] -[ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/entities/actors/EnemyDefinition.cs" id="1_m2lyk"] +[ext_resource type="Script" uid="uid://dkfdm2m2scyks" path="res://scripts/Entities/Actors/EnemyDefinition.cs" id="1_m2lyk"] [ext_resource type="Texture2D" uid="uid://cddn56s7w2lc2" path="res://assets/sprites/actors/morcegao.png" id="3_601km"] [resource] diff --git a/assets/definitions/tiles/floor.tres b/assets/definitions/tiles/floor.tres index 92a8da7..44b0097 100644 --- a/assets/definitions/tiles/floor.tres +++ b/assets/definitions/tiles/floor.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="TileDefinition" load_steps=3 format=3 uid="uid://dfrremrf4rn15"] -[ext_resource type="Script" uid="uid://ba82a33ov6uuo" path="res://scripts/map/TileDefinition.cs" id="1_snxyj"] +[ext_resource type="Script" uid="uid://ba82a33ov6uuo" path="res://scripts/Map/TileDefinition.cs" id="1_snxyj"] [ext_resource type="Texture2D" uid="uid://ds13x1dpu0v4s" path="res://assets/sprites/tiles/floor.png" id="1_vvyfi"] [resource] diff --git a/assets/definitions/tiles/wall.tres b/assets/definitions/tiles/wall.tres index a8ba785..a4fa75d 100644 --- a/assets/definitions/tiles/wall.tres +++ b/assets/definitions/tiles/wall.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" script_class="TileDefinition" load_steps=3 format=3 uid="uid://cdluqrbfcu5ng"] [ext_resource type="Texture2D" uid="uid://s5klxirh5r1w" path="res://assets/sprites/tiles/wall.png" id="1_jkwov"] -[ext_resource type="Script" uid="uid://ba82a33ov6uuo" path="res://scripts/map/TileDefinition.cs" id="1_ugwtv"] +[ext_resource type="Script" uid="uid://ba82a33ov6uuo" path="res://scripts/Map/TileDefinition.cs" id="1_ugwtv"] [resource] script = ExtResource("1_ugwtv") diff --git a/scenes/Game.tscn b/scenes/Game.tscn index 4cb5231..09e9825 100644 --- a/scenes/Game.tscn +++ b/scenes/Game.tscn @@ -1,17 +1,17 @@ [gd_scene load_steps=13 format=3 uid="uid://u5h6iqyi8wd0"] [ext_resource type="Script" uid="uid://dwubb28wt4bhe" path="res://scripts/Game.cs" id="1_cpr0p"] -[ext_resource type="Script" uid="uid://ejqmdbc0524i" path="res://scripts/input/MainGameInputHandler.cs" id="3_400sg"] -[ext_resource type="Script" uid="uid://fe2h4is11tnw" path="res://scripts/map/Map.cs" id="3_cpr0p"] -[ext_resource type="Script" uid="uid://bxt6g7t1uvvia" path="res://scripts/input/InputHandler.cs" id="3_s0nni"] -[ext_resource type="Script" uid="uid://dwyr067lwqcsj" path="res://scripts/map/DungeonGenerator.cs" id="4_78awf"] -[ext_resource type="Script" uid="uid://ogqlb3purl6n" path="res://scripts/input/GameOverInputHandler.cs" id="4_g4kob"] -[ext_resource type="Script" uid="uid://bamlnrj5bm1rd" path="res://scripts/input/InspectInputHandler.cs" id="5_g4kob"] +[ext_resource type="Script" uid="uid://ejqmdbc0524i" path="res://scripts/InputHandling/MainGameInputHandler.cs" id="3_400sg"] +[ext_resource type="Script" uid="uid://fe2h4is11tnw" path="res://scripts/Map/Map.cs" id="3_cpr0p"] +[ext_resource type="Script" uid="uid://bxt6g7t1uvvia" path="res://scripts/InputHandling/InputHandler.cs" id="3_s0nni"] +[ext_resource type="Script" uid="uid://dwyr067lwqcsj" path="res://scripts/Map/DungeonGenerator.cs" id="4_78awf"] +[ext_resource type="Script" uid="uid://ogqlb3purl6n" path="res://scripts/InputHandling/GameOverInputHandler.cs" id="4_g4kob"] +[ext_resource type="Script" uid="uid://bamlnrj5bm1rd" path="res://scripts/InputHandling/InspectInputHandler.cs" id="5_g4kob"] [ext_resource type="PackedScene" uid="uid://bryqrafavmwj4" path="res://scenes/Details.tscn" id="5_qy1jj"] -[ext_resource type="Script" uid="uid://bereyrj1s46y5" path="res://scripts/map/FieldOfView.cs" id="5_s0nni"] +[ext_resource type="Script" uid="uid://bereyrj1s46y5" path="res://scripts/Map/FieldOfView.cs" id="5_s0nni"] [ext_resource type="PackedScene" uid="uid://b4h4xyr1g8o50" path="res://scenes/GUI/hud.tscn" id="6_aug50"] -[ext_resource type="Script" uid="uid://dspqgdxg5jji0" path="res://scripts/input/PickupInputHandler.cs" id="10_3xj3m"] -[ext_resource type="Script" uid="uid://bjcjktvyrdh10" path="res://scripts/input/InventoryInputHandler.cs" id="11_mcffj"] +[ext_resource type="Script" uid="uid://dspqgdxg5jji0" path="res://scripts/InputHandling/PickupInputHandler.cs" id="10_3xj3m"] +[ext_resource type="Script" uid="uid://bjcjktvyrdh10" path="res://scripts/InputHandling/InventoryInputHandler.cs" id="11_mcffj"] [node name="Game" type="Node"] script = ExtResource("1_cpr0p") @@ -21,9 +21,7 @@ script = ExtResource("3_cpr0p") [node name="Generator" type="Node" parent="Map"] script = ExtResource("4_78awf") -seed = 989 -useSeed = false -iterations = 8 +UseSeed = false [node name="FieldOfView" type="Node" parent="Map"] script = ExtResource("5_s0nni") @@ -44,16 +42,16 @@ script = ExtResource("3_400sg") [node name="GameOverInputHandler" type="Node" parent="InputHandler"] script = ExtResource("4_g4kob") -[node name="InspectInputHandler" type="Node" parent="InputHandler" node_paths=PackedStringArray("map")] +[node name="InspectInputHandler" type="Node" parent="InputHandler" node_paths=PackedStringArray("Map")] script = ExtResource("5_g4kob") -map = NodePath("../../Map") +Map = NodePath("../../Map") [node name="PickupInputHandler" type="Node" parent="InputHandler"] script = ExtResource("10_3xj3m") -[node name="InventoryInputHandler" type="Node" parent="InputHandler" node_paths=PackedStringArray("map")] +[node name="InventoryInputHandler" type="Node" parent="InputHandler" node_paths=PackedStringArray("Map")] script = ExtResource("11_mcffj") -map = NodePath("../../Map") +Map = NodePath("../../Map") [node name="Camera2D" type="Camera2D" parent="."] offset = Vector2(8, 8) diff --git a/scenes/Inspector.tscn b/scenes/Inspector.tscn index ad2a062..8b3dcdb 100644 --- a/scenes/Inspector.tscn +++ b/scenes/Inspector.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://dyythuxaio6j4"] [ext_resource type="Texture2D" uid="uid://cjjxf4rbj8gku" path="res://assets/sprites/inspector.png" id="1_psyxb"] -[ext_resource type="Script" uid="uid://dxsrtu4b3pi08" path="res://scripts/entities/actors/Inspector.cs" id="2_g62u7"] +[ext_resource type="Script" uid="uid://dxsrtu4b3pi08" path="res://scripts/Utils/Inspector.cs" id="2_g62u7"] [node name="Sprite2D" type="Sprite2D"] texture = ExtResource("1_psyxb") diff --git a/scripts/Entities/Actions/Action.cs b/scripts/Entities/Actions/Action.cs new file mode 100644 index 0000000..b2d6a4b --- /dev/null +++ b/scripts/Entities/Actions/Action.cs @@ -0,0 +1,69 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actions; + +/// +/// Action representa uma ação no jogo efetuada por um ator. +/// Ações são geradas pelo jogador e pela IA, elas regem os atores do jogo. +/// +public abstract partial class Action : RefCounted +{ + private Actor actor; + + private int cost; + + public Action(Actor actor) + { + Actor = actor; + // Custo base, subclasses podem sobreescrever isto se quiserem. + Cost = 10; + } + + /// + /// O ator que realiza a ação. + /// + public Actor Actor + { + get => actor; + private set + { + actor = value; + } + } + + /// + /// O custo da ação. + /// + protected int Cost + { + get => cost; + set + { + cost = value; + } + } + + /// + /// É conveniente ter acesso ao mapa dentro de uma ação. + /// + protected MapData MapData + { + get => actor.MapData; + } + + /// + /// Método que executa a ação. Subclasses da ação devem implementar este método. + /// + /// Exemplo: + /// + /// Action action = new Action(actor); + /// /* . . . */ + /// action.Perform(); + /// + /// + /// + /// Se a ação foi executada ou não. + public abstract bool Perform(); +} diff --git a/scripts/Entities/Actions/Action.cs.uid b/scripts/Entities/Actions/Action.cs.uid new file mode 100644 index 0000000..9523b0a --- /dev/null +++ b/scripts/Entities/Actions/Action.cs.uid @@ -0,0 +1 @@ +uid://dlejckfyro2ch diff --git a/scripts/Entities/Actions/BumpAction.cs b/scripts/Entities/Actions/BumpAction.cs new file mode 100644 index 0000000..f0a0047 --- /dev/null +++ b/scripts/Entities/Actions/BumpAction.cs @@ -0,0 +1,38 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; + +namespace TheLegendOfGustav.Entities.Actions; + +/// +/// Ação de "Esbarramento", utilizada principalmente pelo jogador. +/// Esta ação direcionada tentará andar para o destino, se houver um +/// ator no caminho, uma ação de ataque é gerada no lugar. +/// +public partial class BumpAction : DirectionalAction +{ + public BumpAction(Actor actor, Vector2I offset) : base(actor, offset) + { + } + + // Como esta ação inevitavelmente gera outras ações, + // não faz sentido descontar a energia do ator. + public override bool Perform() + { + // Declaramos uma ação genérica. + Action action; + + // Se houver um ator no destino, crie uma ação de ataque. + if (GetTarget() != null) + { + action = new MeleeAction(Actor, Offset); + } + else + { + // Mas se não houver, crie uma ação de movimento. + action = new MovementAction(Actor, Offset); + } + + // Executa a ação. + return action.Perform(); + } +} diff --git a/scripts/Entities/Actions/BumpAction.cs.uid b/scripts/Entities/Actions/BumpAction.cs.uid new file mode 100644 index 0000000..f5ce3f8 --- /dev/null +++ b/scripts/Entities/Actions/BumpAction.cs.uid @@ -0,0 +1 @@ +uid://p6ij0dsuvv7y diff --git a/scripts/Entities/Actions/DirectionalAction.cs b/scripts/Entities/Actions/DirectionalAction.cs new file mode 100644 index 0000000..e32e9f2 --- /dev/null +++ b/scripts/Entities/Actions/DirectionalAction.cs @@ -0,0 +1,37 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actions; + +/// +/// Ação direcionada. Esta ação é acompanhada com um vetor que representa uma +/// distância tendo como ponto de partida o ator. +/// +public abstract partial class DirectionalAction : Action +{ + public DirectionalAction(Actor actor, Vector2I offset) : base(actor) + { + Offset = offset; + } + + /// + /// Direção/distância do ator da ação. + /// Seu significado depende da ação que implementará esta classe. + /// + public Vector2I Offset { get; private set; } + + /// + /// Coordenada do alvo da ação. + /// + public Vector2I Destination { get => Actor.GridPosition + Offset; } + + /// + /// Função que obtém o alvo da ação, se houver. + /// + /// O ator alvo da ação, nulo se não houver. + protected Entity GetTarget() + { + return MapData.GetBlockingEntityAtPosition(Destination); + } +} diff --git a/scripts/Entities/Actions/DirectionalAction.cs.uid b/scripts/Entities/Actions/DirectionalAction.cs.uid new file mode 100644 index 0000000..901756a --- /dev/null +++ b/scripts/Entities/Actions/DirectionalAction.cs.uid @@ -0,0 +1 @@ +uid://cxotc2adk05j8 diff --git a/scripts/Entities/Actions/DropAction.cs b/scripts/Entities/Actions/DropAction.cs new file mode 100644 index 0000000..00ddd7e --- /dev/null +++ b/scripts/Entities/Actions/DropAction.cs @@ -0,0 +1,17 @@ +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Entities.Items; + +namespace TheLegendOfGustav.Entities.Actions; + +public partial class DropAction : ItemAction +{ + public DropAction(Player player, ConsumableItem item) : base(player, item) + { + } + + public override bool Perform() + { + Player.Inventory.Drop(Item); + return true; + } +} \ No newline at end of file diff --git a/scripts/Entities/Actions/DropAction.cs.uid b/scripts/Entities/Actions/DropAction.cs.uid new file mode 100644 index 0000000..98ed82f --- /dev/null +++ b/scripts/Entities/Actions/DropAction.cs.uid @@ -0,0 +1 @@ +uid://by48a3a3gbvfa diff --git a/scripts/Entities/Actions/ItemAction.cs b/scripts/Entities/Actions/ItemAction.cs new file mode 100644 index 0000000..14c5d93 --- /dev/null +++ b/scripts/Entities/Actions/ItemAction.cs @@ -0,0 +1,39 @@ +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Entities.Items; + +namespace TheLegendOfGustav.Entities.Actions; + +public partial class ItemAction : Action +{ + private ConsumableItem item; + private Player player; + + public ItemAction(Player player, ConsumableItem item) : base(player) + { + Item = item; + Player = player; + } + + public Player Player + { + get => player; + private set + { + player = value; + } + } + + protected ConsumableItem Item + { + get => item; + set + { + item = value; + } + } + + public override bool Perform() + { + return item.Activate(this); + } +} \ No newline at end of file diff --git a/scripts/Entities/Actions/ItemAction.cs.uid b/scripts/Entities/Actions/ItemAction.cs.uid new file mode 100644 index 0000000..c8c8e23 --- /dev/null +++ b/scripts/Entities/Actions/ItemAction.cs.uid @@ -0,0 +1 @@ +uid://f7ep4u4fwsyl diff --git a/scripts/Entities/Actions/MeleeAction.cs b/scripts/Entities/Actions/MeleeAction.cs new file mode 100644 index 0000000..fcd8368 --- /dev/null +++ b/scripts/Entities/Actions/MeleeAction.cs @@ -0,0 +1,55 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.Entities.Actions; + +/// +/// Ação de ataque físico. Uma ação direcionada que ataca um alvo. +/// +public partial class MeleeAction : DirectionalAction +{ + public MeleeAction(Actor actor, Vector2I offset) : base(actor, offset) + { + } + + /// + /// Ataca o ator na direção da ação. + /// + public override bool Perform() + { + // Eu te disse que este método seria útil. + Entity potentialTarget = GetTarget(); + + // Só podemos atacar atores. + if (potentialTarget is not TheLegendOfGustav.Entities.Actors.Actor) + { + return false; + } + + Actor target = (Actor)potentialTarget; + + // Se não houver um ator na direção, não podemos continuar. + // Isto é uma ação gratuita. + if (target == null) return false; + + // não podemos ter dano negativo. + int damage = Actor.Atk - target.Def; + + string attackDesc = $"{Actor.DisplayName} ataca {target.DisplayName}"; + + if (damage > 0) + { + attackDesc += $" e remove {damage} de HP."; + target.Hp -= damage; + } + else + { + attackDesc += $" mas {target.DisplayName} tem músculos de aço."; + } + + MessageLogData.Instance.AddMessage(attackDesc); + Actor.Energy -= Cost; + return true; + } +} diff --git a/scripts/Entities/Actions/MeleeAction.cs.uid b/scripts/Entities/Actions/MeleeAction.cs.uid new file mode 100644 index 0000000..bc97619 --- /dev/null +++ b/scripts/Entities/Actions/MeleeAction.cs.uid @@ -0,0 +1 @@ +uid://vbptt0gl1ud0 diff --git a/scripts/Entities/Actions/MovementAction.cs b/scripts/Entities/Actions/MovementAction.cs new file mode 100644 index 0000000..0ac842c --- /dev/null +++ b/scripts/Entities/Actions/MovementAction.cs @@ -0,0 +1,30 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actions; + +/// +/// Ação de movimento. Movimenta o ator para a direção de seu Offset. +/// +public partial class MovementAction : DirectionalAction +{ + public MovementAction(Actor actor, Vector2I offset) : base(actor, offset) + { + } + + public override bool Perform() + { + // Não anda se o destino for um tile sólido. + if (!MapData.GetTile(Destination).IsWalkable) return true; + + // Não anda se o destino for oculpado por um ator. + // Na maioria dos casos, essa condição nunca é verdadeira. + if (GetTarget() != null) return true; + + Actor.Walk(Offset); + Actor.Energy -= Cost; + + return true; + } +} diff --git a/scripts/Entities/Actions/MovementAction.cs.uid b/scripts/Entities/Actions/MovementAction.cs.uid new file mode 100644 index 0000000..07569ef --- /dev/null +++ b/scripts/Entities/Actions/MovementAction.cs.uid @@ -0,0 +1 @@ +uid://cdtpdaeg7hh6p diff --git a/scripts/Entities/Actions/PickUpAction.cs b/scripts/Entities/Actions/PickUpAction.cs new file mode 100644 index 0000000..0dbd672 --- /dev/null +++ b/scripts/Entities/Actions/PickUpAction.cs @@ -0,0 +1,51 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Utils; +using TheLegendOfGustav.Entities.Items; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actions; + +public partial class PickupAction : DirectionalAction +{ + private Player player; + + public PickupAction(Player player, Vector2I offset) : base(player, offset) + { + Player = player; + // Pegar itens requer um tempo menor. + Cost = 2; + } + + protected Player Player + { + get => player; + private set + { + player = value; + } + } + + public override bool Perform() + { + ConsumableItem item = MapData.GetFirstItemAtPosition(Destination); + + if (item == null) + { + MessageLogData.Instance.AddMessage("Não tem item aqui."); + return false; + } + + if (player.Inventory.Items.Count >= player.Inventory.Capacity) + { + MessageLogData.Instance.AddMessage("Seu inventário está cheio"); + return false; + } + + MapData.RemoveEntity(item); + player.Inventory.Add(item); + + player.Energy -= Cost; + return true; + } +} \ No newline at end of file diff --git a/scripts/Entities/Actions/PickUpAction.cs.uid b/scripts/Entities/Actions/PickUpAction.cs.uid new file mode 100644 index 0000000..7ca9c72 --- /dev/null +++ b/scripts/Entities/Actions/PickUpAction.cs.uid @@ -0,0 +1 @@ +uid://dydpoqnwxwbq6 diff --git a/scripts/Entities/Actions/WaitAction.cs b/scripts/Entities/Actions/WaitAction.cs new file mode 100644 index 0000000..011703b --- /dev/null +++ b/scripts/Entities/Actions/WaitAction.cs @@ -0,0 +1,104 @@ +using TheLegendOfGustav.Entities.Actors; + +namespace TheLegendOfGustav.Entities.Actions; + +/// +/// Ação da inação. Ação que realiza nada. +/// +public partial class WaitAction : Action +{ + public WaitAction(Actor actor) : base(actor) + { + } + + public override bool Perform() + { +//-=-==============================================-======++++*@@%*+#%%+*%%#*#%%@%**%%#=:+%@%=--.....::::@@@:................... #@----::@@@@@@@@@@@@@ +//--============--===========================================+@. :@ =% @ :* @#= @@*........@@@:................ .::::::@@@@@@@@@@@@ +//===========================================================+@+ * :+ @ :*%* @%+ @=.......:@@@:.......... ...... ..::.:@@@@@@@@@@@ +//===-===========---========--=========----==========--=======%% . . @ =%@* @%+ @@:......@@@:.......... ....... .....:*@@@@@@@@@@ +//=========-==========================--==============-=======#@ #@ #* @%+ @@:.. .@@@:. ........ ..... ..:*@@@@*@@@@@@@@@ +//============================--====---=======================*@ * @@ %@@* @%+ @=. @@@... . =@@@: #@@@@@@@@ +//===--==-========----==---=----==----===========-===-==#@@@@@@@- @ @@ :#%* #*+ *#*: .@@@: . .. .@@@@@@@@ +//-------==--==-==---::---======----===-----==--===---===*%@@@@@* @: @@ * = %= %@@. .. =@@@@@@@ +//--==---==-=--=====----======-=----==-===---=======--========@@@@@%*=+#%#*-=*%%%%**#%%%#*#%%%*=.%@@: @@@@@@@ +//===-=-----=--=--====--======--====-===-=--==----========--==@@@@@: #@@: . . :=*@@@@@@@ +//==--==-===-==-==@@+====--=----==-==-==---=------===========@@@@@@@@@- #@@: . .. :@@@@@@@+@@@@@@ +//==---=--=======@%@*@%-==-==-==-========--==----========-===@ .*@@@@+ #@@: . @@@@@@ +//========-====--==@@%@@+@%===-=--======--:-====-===========%+ .=@@@@%. #@@: . . =@@@@@ +//---=-=-==-----=====*@==@@*@@+==-----=-----====--===@@@*==*@ -@@@@@- :*##=*@@- . . .@@@@@ +//------------===---===%@*=@%=*@*==------------==-=--%@@@@@@: .. ..:#@@@@*:@@@@@@@@@% .@@@@@ +//---==-----===-====-==-==@#=#@@+@@===----==--=====--====%@* ..............+@@@@@@@@@@@@@@. ....:::::. --:+:%: @=:@@@. .::-====@@@@@ +//==-=----==----===--==-----=@-=@@+@#@%=-==-======---====#@ ....:::.::......@@@@@@@@@@@@@% . ..-@#.@:%@*@%.@+ %*:@@*@.@@#@*@=%@# %@@@@@@*@@@@@ +//===----=======-====--=--====-+*%@+@@@=@=--=====--=====+@ .. .+@@@@@@@@@@:...@@@@@@@@@@@@@% -@#@@-@- =@ @% *@.#@.@.@ *@*=@@@% @@@@: +//====--==-===-========---=========@%*@@%%@@#====--====*@: .=@@@@@@%=+: @*::.@@@@@@@@@@@@@@: :@::@=:%@#:.-- :: .: : @@@. +//===---===-==-------:-----=-=====---=@+@@***=========+@: =@@@ : @*=.:@@@@@@@@@@@@@@@ . =@:@@% +//==----===-===-=------==----==--=--====*@@@*==*@@#==+@: . =@ - . #@@*.. +@@@@@@@= . ## -@ +//===---=-==-----=----===----============-======@@@@@@. ..:@= : =@@++== .@@+ . .. -@@@%#@= +//=-=--==-===--------==-=---=---=----------=======*@@. *@@@-@@*@ #= * . . ..:@@@@: +//=====-===-=======-==----====-----=======--==-===%@ .. .=@ = #. .. .. .@: %@@- +//==-==-==-=--===-=====-------=----==--=====-=--=@* .. .* =. :* + .. . %: +//==-==----=-------=------=----==-----==========@: ......+ #%*** @@%%+: . %@= +//===--=-----------=--=--==---===---:=@@@*==-=@@. ....::@ .. %@*:%*-#%#*=: . :=:=%#@@@+ +//==---=-:-====---========-----====-:-=@@@@++@= ....@@%* @-@@+=%%. -@%: -@@@. : +//==----========---------------==========@@@* %@@@:=%@@*@@@@==+@==- .@= .*@- #* +//==-===--===-=---:-----------===========@% :%@=*@@@@@@@@@@@@===%=======+@#+=@#%@ .@@%= +//------=====-------=-:----=#*=========@% :%-.@==@@@@@@@@@@@@++@*=======*@ *= *@@@=. =*=*@@: +//===--=---===------------=*@@@======@% .%- .#%==#@@@@@@@@@@@%+#@@%=====*@ *+*-#@@@- .. . :. %: +//--=======--=-=-----:---=--+@@@=-=@% :%.:==+@*==@@@@@@@@@@@@=---##====*@. *:=@ *@. . . :@@@%@ +//===---=---==---------------=@@@@= =@=======#%-@@@@@@@@@@@@=--*@====*@: @:+@@%.@- . . .@@@@@+ =@*=%=#-. +//=====-----===@@*-----------=@@ *@* =@@=====@+--%@@@@@@@@@@@*-==@====+@= % :@@%@= =#. :. : -*%+#:# +//-=--=--------@@@==---=--+@@@@@@ +@@@= =#%*===-@=--=@@@@@@@@@@@@+-=@=====@+: :@ :. :@@: %* +//*@#==--------=@@@----*@@@@@@@@@@@+ -+=@*===%*--=@@@@@@@@@@@@@=-@*-===%*- : =+ =@%@:.: *%. %* +//%@@+----------+@@@%@@@@@@@@@@@@@@: =*==@+-==@=--@@@@@@@@@@@@@--@*-===%*=:% #: -@@#-: .@@@= +@@@@@% +//+@@#-------==+@@@@@@@@@@@@@@@@@@@@# :: =====@=--=@-=+@@@@@@@@@@@@@-%*====*#=+% @: .:%@@:. *@@%@@@% +//=@@@=---=@@@@@@@@@@@@@@@@@@@@@@@@@@@. =@@= ======@=-=%+==@@@@@@@@@@@@@*=#=====@=%* % ..#@@@. -@@@@@ +//=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*=@@* ==-===#*---@*-%@@@@@@@@@@@@@=%=--==@#@=%%. :@ ::*@-%: -#. %@@@@@@. +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@* :+-====@=---%%=@@@@@@@@@@@@@%*=-====@*@= @: -@@+=- :@@* +@@@@@@@@@@@@= +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@: =@- ==.==--=@----*%%@@@@@@@@@@@@@*=-====#@==. @: %@=:@= =@@= =@@@@@@@@@@@ +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. .@@% =:.---==%=---=%#@@@@@@@@@@@@@%==-====@+=. *: #%%@.: #@@@@@@@@@@@@@@: +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::@@- =- --=--*%-----@@@@@@@@@@@@@@@==---===@=. -: :. .@# =@@@@@@@@@@@@@@@@. *@% +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%. @@:= :==---@=----=@@@@@@@@@@@@@@@=--====#* @: . *@@ #@@@@@@@@@@@@@@@@@@@@@- +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@: @@= % ------@=----#@@@@@@@@@@@@@@*-======%+ @ +@. -@@.:@@@@@@@@@@@@@@@@@@@@@@: +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%: @@= .% .-----=@+=---@@@@@@@@@@@@@@@=--==== *: *: :@@ +@@@@@@@@@@@@@@@@@@@@@@@@@@ := +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@= %.:------@=---*@@@@@@@@@@@@@@@==-==: *= * *@* =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:@@@* +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%: =*:-----@----+@@@@@@@@@@@@@@@#-====. -@= @@=-@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@. +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=.@*----%----+@@@@@@@@@@@@@@@@======. +* .+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -% +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=-:@----=@@@@@@@@@@@@@@@@@====== -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :@@# +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%----@@@@@@@@@@@@@@@@@%====== :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@% +//#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%----%@@@@@@@@@@@@@@@@@*=====- -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//++=+*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%----*@@@@@@@@@@@@@@@@@@+=-==== :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@= +//=====++@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%-----@@@@@@@@@@@@@@@@@@@=-=-==- -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//+===++@@%==*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%-----@@@@@@@@@@@@@@@@@@@@=---=-- :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//++=++%@@+++=++%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%-----#@@@@@@@@@@@@@@@@@@@*======: :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//===++@@==+++====*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@-----*@@@@@@@@@@@@@@@@@@@@*--=---. .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=+++=+++++++++++*@@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=-==-=@@@@@@@@@@@@@@@@@@@@@===----: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//===++==+++++++=%@@+==*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+=====@%@@@@@@@@@@@@@@@@@@@@=-----=: %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//++=====++++===*@%====+==@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*=====@*@@@@@@@@@@@@@@@@@@@@@-------: :@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//++===+++++====++++========@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*=====@+=@@@@@@@@@@@@@@@@@@@@@=------=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=========+==++++=========+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=====#@=*@@@@@@@@@@@@@@@@@@@@%%----=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=+++++========+========+@@@*=+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%=====+@@@@@@@@@@@@@@@@@@@@@@@@=@+-=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//++++++====++=====*@@%==%@*=====#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%@@ %=====+% @@@@@@@@@@@@@@@@@@@@@@*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//==+==+===+++++==*@@=*@@#+=======+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@***%@@*=*@@%**%@@%**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=++==+==++++++++%@@=@*@@%=========*@@@@@@@ %* %+ @= :@+ * @ =@@ @@@@. *# @ %@ # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=======++++++#@@+%@@@@@#=========%@@@@@@@@: :: #: :% @ @+ * @ =@@ -: @@@@ @= * @ % @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//===++==+++%@%*+%@@*+**+==+====+@@@%==%@@@@+ = %* @ %= * @ =@@ -= @@@@: .@: * @ % @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=+=+====++@@@@@@@@@%=====+==+==#*====+*@@@@ @* @ %= * @ =@@ -= @@@@@ @@: * @ % @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=======%@@*+@@%+++++++========+======+=+@@@ - @* @ %= * @ =@@ -= @.%@@: :@@: * @ % @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//==+=+@@**@@@+*@@==++==+===+=========+++++@@ @ @* % @+ + @ :%@ -. @ @@: :@@- + @ + -@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//======%@@+*@@@++=++==++===++========+++++#@- @ :@@= -@@ %@ * +* @: :@@@ @@% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//=+@@#@@@@@@=============++=+++=+==+=+%@@@@%@@@@@%=***+=%%@@@%*: -*%%%+:.=@@@*++*#***=. .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//@%+%@@%==*+============+*%@@%*+*%@@@@@@*%@@@@@@@@%#*=+#**#+%*%##*+=*#####+:@@######***#*=*#**@@@@@@@@@@@@@@@#*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//@%==+@@@===============*@ @%% @@+ @* @ *= =% % #+@ % @ -+ @@@= . @ -@ %+ @@@@@@@@@@@@@@@@@@@@@@@@ +//%@@*=================+=*@. @@ :. @ % =# * @. ** @#- =+*:**= =*% @ -* *#@@@@*. *%: @ @ %* *#@@@@@@@@@@@@@@@@@@@@@@@@ +//==@@#===+++======++=+==*@. @@ =: @ @ :# %= %. %@* %= =@ @@% @ =* @@@@@@@= @@: @ . %+ @@@@@@@@@@@@@@@@@@@@@@@@@@ +//%========+====+%@@%+=+=*@. @@ =: @ @ :% @: :@ - =@* %- -@ @@% -* @@@@@= @@: @ %+ @@@@@@@@@@@@@@@@@@@@@@@@ +//**@@@@@%*%@@@@@@*===++=*@. @@ =: @ @ :% =% -% : @* %: -@ @@@ @ =* @%- +@@= @@: @ + . %+ @@@@@@@@@@@@@@@@@@@@@@@@@@ +//@@@@@@@@@@@@@@*======+=*@. *# :. @ % -# * @-+* @# %: -@ @@@ @ =* +**-@@@= @@: @ @ :. %+ *#@@@@@@@@@@@@@@@@@@@@@@@@ +//@@@@@@@@@@@@*====+==++=*@. @ @@* .@* @ .*#. @ @* #: -@ @@% @ -+ =*%@@= @@: @ @ +. #+ *@@@@@@@@@@@@@@@@@@@@@@@ +//@@@@@@@@@@@======++====+*%@@@@%%%@@@@%*+#@@@@@%#%@@#=+**=. =**+=***==*#*: :%@@@@@@@@@**=+#*==*###*=. -=**+::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +//@@@@@@@@@@+==+==++=====++=====++=+++++++++===+++++#% +@@@* :#%= =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + Actor.Energy -= Cost; + return true; + } +} \ No newline at end of file diff --git a/scripts/Entities/Actions/WaitAction.cs.uid b/scripts/Entities/Actions/WaitAction.cs.uid new file mode 100644 index 0000000..120c8c1 --- /dev/null +++ b/scripts/Entities/Actions/WaitAction.cs.uid @@ -0,0 +1 @@ +uid://c24ebgrcsn6yi diff --git a/scripts/Entities/Actors/AI/BaseAI.cs b/scripts/Entities/Actors/AI/BaseAI.cs new file mode 100644 index 0000000..bdd1e61 --- /dev/null +++ b/scripts/Entities/Actors/AI/BaseAI.cs @@ -0,0 +1,54 @@ +using Godot; + +namespace TheLegendOfGustav.Entities.Actors.AI; + +/// +/// Enum das diferentes IAs disponíveis. +/// +public enum AIType +{ + None, + DefaultHostile +}; + +/// +/// base para as IAs do jogo. +/// +public abstract partial class BaseAI : Node +{ + /// + /// Corpo controlado pela IA. + /// O corpo é a marionete da alma. + /// + protected Actor Body { get; set; } + + public override void _Ready() + { + base._Ready(); + // Por padrão, a IA é filha do nó de seu corpo. + Body = GetParent(); + } + + /// + /// Computa um único turno para o ator controlado. + /// Aviso: NPCs não possuem ações gratuitas. + /// A IA SEMPRE precisa executar uma ação que custe energia. + /// + public abstract void Perform(); + + /// + /// Utiliza o pathfinder do mapa para obter um caminho + /// da posição atual do ator para um destino qualquer. + /// + /// Destino + /// Vetor com vetores, passo a passo para chegar no destino. + public Godot.Collections.Array GetPathTo(Vector2I destination) + { + // Arrays do Godot são muito mais confortáveis de manipular, então + // eu converto o Array do C# em um array do Godot antes de retornar o caminho. + Godot.Collections.Array list = []; + Vector2[] path = Body.MapData.Pathfinder.GetPointPath(Body.GridPosition, destination); + list.AddRange(path); + return list; + } +} \ No newline at end of file diff --git a/scripts/Entities/Actors/AI/BaseAI.cs.uid b/scripts/Entities/Actors/AI/BaseAI.cs.uid new file mode 100644 index 0000000..b23724c --- /dev/null +++ b/scripts/Entities/Actors/AI/BaseAI.cs.uid @@ -0,0 +1 @@ +uid://jgm5qk02hism diff --git a/scripts/Entities/Actors/AI/HostileEnemyAI.cs b/scripts/Entities/Actors/AI/HostileEnemyAI.cs new file mode 100644 index 0000000..dbcf98d --- /dev/null +++ b/scripts/Entities/Actors/AI/HostileEnemyAI.cs @@ -0,0 +1,84 @@ +using Godot; +using TheLegendOfGustav.Entities.Actions; + +namespace TheLegendOfGustav.Entities.Actors.AI; + +/// +/// Uma IA simples. Sempre tentará atacar o jogador com ataques corpo a corpo. +/// +public partial class HostileEnemyAI : BaseAI +{ + /// + /// Caminho até a última posição conhecida do jogador. + /// + private Godot.Collections.Array Path { get; set; } = []; + + public override void Perform() + { + // O alvo da IA sempre é o jogador. + Player target = Body.MapData.Player; + // Vetor que parte do inimigo até o jogador. + Vector2I offset = target.GridPosition - Body.GridPosition; + // Distância entre o inimigo e o jogador. Leva em consideração somente + // um dos eixos. + int distance = int.Max(int.Abs(offset.X), int.Abs(offset.Y)); + + // A ação executada no turno pode ser de ataque ou de movimento. + Action action; + + // Só faz sentido atacar o jogador se o inimigo estiver visível. + if (Body.MapData.GetTile(Body.GridPosition).IsInView) + { + // Se o inimigo consegue ver que o jogador está morto, + // IT'S OVER. + if (!target.IsAlive) + { + action = new WaitAction(Body); + action.Perform(); + return; + } + + // Se estiver do lado do jogador, ataque. + if (distance <= 1) + { + action = new MeleeAction(Body, offset); + action.Perform(); + // Executada a ação, acabamos nosso turno aqui. + return; + } + + // Se o inimigo estiver visível para o jogador, + // consideramos que ele também consiga ver o jogador. + // Logo, atualizamos o caminho para a posição atual do jogador. + Path = GetPathTo(target.GridPosition); + // O primeiro passo é a posição atual do inimigo, podemos remover. + Path.RemoveAt(0); + } + + // Se existir um caminho conhecido para o jogador. + if (Path.Count > 0) + { + // Pegamos o próximo passo para o destino. + Vector2I destination = (Vector2I)Path[0]; + // Se tiver o caminho estiver bloqueado, paramos o nosso turno aqui. + if (Body.MapData.GetBlockingEntityAtPosition(destination) != null) + { + action = new WaitAction(Body); + action.Perform(); + return; + } + + // Caso o contrário, criamos uma nova ação de movimentação e a executamos. + action = new MovementAction(Body, destination - Body.GridPosition); + action.Perform(); + // Podemos remover o passo do caminho. + Path.RemoveAt(0); + return; + } + + // Senão, espere. + action = new WaitAction(Body); + action.Perform(); + return; + } +} \ No newline at end of file diff --git a/scripts/Entities/Actors/AI/HostileEnemyAI.cs.uid b/scripts/Entities/Actors/AI/HostileEnemyAI.cs.uid new file mode 100644 index 0000000..0fa2c32 --- /dev/null +++ b/scripts/Entities/Actors/AI/HostileEnemyAI.cs.uid @@ -0,0 +1 @@ +uid://db28cxff4pl3t diff --git a/scripts/Entities/Actors/Actor.cs b/scripts/Entities/Actors/Actor.cs new file mode 100644 index 0000000..7e6685f --- /dev/null +++ b/scripts/Entities/Actors/Actor.cs @@ -0,0 +1,251 @@ +using Godot; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.Entities.Actors; + +/// +/// A classe de ator define um personagem no jogo. +/// +[GlobalClass] +public partial class Actor : Entity +{ + #region Fields + private int mp; + private int hp; + + private int energy; + #endregion + + #region Constructors + public Actor(Vector2I initialPosition, MapData map, ActorDefinition definition) : base(initialPosition, map, definition) + { + SetDefinition(definition); + } + #endregion + + #region Signals + /// + /// Sinal emitido toda vez que o HP mudar. + /// + /// Novo HP + /// Quantidade máxima de HP. + [Signal] + public delegate void HealthChangedEventHandler(int hp, int maxHp); + + /// + /// Sinal emitido se o ator morrer. + /// + [Signal] + public delegate void DiedEventHandler(); + #endregion + + #region Properties + /// + /// Se o ator está vivo. + /// + public bool IsAlive { get => Hp > 0; } + + /// + /// Utilizado no sistema de turnos. + /// Enquanto o ator tiver energia, ele poderá realizar turnos. + /// + public int Energy + { + get => energy; + set + { + if (value > Speed) + { + energy = Speed; + } + else + { + energy = value; + } + } + } + /// + /// Taxa de recarga de energia. + /// + public int Speed { get => Definition.Speed; } + + /// + /// HP máximo do ator. + /// + public int MaxHp { get; private set; } + /// + /// HP atual do ator. + /// + public int Hp + { + get => hp; + set + { + // Esta propriedade impede que o HP seja maior que o máximo. + hp = int.Clamp(value, 0, MaxHp); + EmitSignal(SignalName.HealthChanged, Hp, MaxHp); + if (hp <= 0) + { + Die(); + } + } + } + + /// + /// Máximo de mana do ator. + /// + public int MaxMp { get; private set; } + /// + /// Mana atual do ator. + /// + public int Mp + { + get => mp; + set + { + mp = int.Clamp(value, 0, MaxMp); + } + } + + /// + /// Estatística de ataque + /// + public int Atk { get; private set; } + + /// + /// Estatística de defesa. + /// + public int Def { get; private set; } + + /// + /// Estatística mental. + /// + public int Men { get; private set; } + + /// + /// A definição do ator possui caracterísitcas padrões que definem + /// o ator em questão. + /// + private ActorDefinition Definition + { + get; + set; + } + #endregion + + #region Methods + /// + /// Executado uma vez por turno, + /// + public void RechargeEnergy() + { + Energy += Speed; + } + + /// + /// Move o ator para uma localização. Veja MovementAction. + /// + /// Vetor que parte da posição do ator até o seu destino. + public void Walk(Vector2I offset) + { + // Cada ator tem um peso no sistema de pathfinding. + // Sempre que ele se mover, removemos seu peso da posição antiga + MapData.UnregisterBlockingEntity(this); + GridPosition += offset; + // E colocamos na próxima. + MapData.RegisterBlockingEntity(this); + // Este peso influencia o algoritmo de pathfinding. + // Atores evitam caminhos bloqueados. por outros atores. + } + + + /// + /// Recupera uma quantidade de HP do ator. + /// + /// HP para recuperar + /// Quanto HP foi realmente recuperado. + public int Heal(int amount) + { + int neoHp = Hp + amount; + + if (neoHp > MaxHp) neoHp = MaxHp; + + int recovered = neoHp - Hp; + Hp = neoHp; + return recovered; + } + + /// + /// Aplica uma definição de NPC para o ator. + /// Se o ator for um boneco de barro, este método é como um + /// sopro de vida. + /// + /// A definição do ator. + public virtual void SetDefinition(ActorDefinition definition) + { + base.SetDefinition(definition); + Definition = definition; + + Type = definition.Type; + + MaxHp = definition.Hp; + Hp = definition.Hp; + MaxMp = definition.Mp; + Mp = definition.Mp; + + Atk = definition.Atk; + Def = definition.Def; + Men = definition.Men; + } + + public virtual void Die() + { + //⠀⠀⠀⠀⢠⣤⣤⣤⢠⣤⣤⣤⣤⣄⢀⣠⣤⣤⣄⠀⠀⠀⢀⣠⣤⣤⣄⠀⣤⣤⠀⠀⣠⣤⣤⣤⣤⣤⡄⢠⣤⣤⣤⣄⠀⠀ + //⠀⠀⠀⠀⠈⢹⣿⠉⠈⠉⣿⣿⠉⠉⢾⣿⣉⣉⠙⠀⠀⢀⣾⡟⠉⠉⣿⣧⢸⣿⡄⢠⣿⠏⣿⣿⣉⣉⡁⢸⣿⡏⢉⣿⡷⠀ + //⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⣿⠀⠀⠈⠿⠿⣿⣿⡀⠀⠸⣿⡇⠀⠀⣾⣿⠀⢿⣿⣸⡿⠀⣿⣿⠿⠿⠇⢸⣿⣿⣿⣿⠀⠀ + //⠀⠀⠀⠀⢠⣼⣿⣤⠀⠀⣿⣿⠀⠀⢷⣦⣤⣼⡿⠁⠀⠀⠹⣿⣤⣴⡿⠋⠀⠘⣿⣿⠃⠀⣿⣿⣤⣤⡄⢸⣿⡇⠙⢿⣦⡀ + //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⢀⣰⣶⣶⣶⣿⣿⣿⣿⣷⣶⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⠿⠛⠛⠻⢿⣿⣿⣿⣿⣿⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⢀⢾⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠈⠉⠉⠉⠻⢿⢿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⢠⠏⢸⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⢻⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⢀⠇⠀⠈⠿⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⢀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⡸⠀⠀⠀⠀⠀⠀⠀⠀⡼⠛⠳⣄⡀⠀⠐⢿⣦⡀⠀⠀⠀⢠⠃⠀⣸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⢠⠇⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠉⣳⠟⠒⠻⣿⣦⡀⠀⡘⠀⢰⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⢀⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠃⢠⣄⡀⠈⠙⢿⡌⠁⠀⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠳⣄⣈⢻⡿⠃⢰⠟⠲⣼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⡰⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⡶⢴⠋⠀⠀⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⡴⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠞⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡴⢟⠒⠀⠀⠀⠀⢰⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠏⠀⠀⠈⠉⣿⠇⠀⢀⡎⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠠⣤⣤⣀⢰⠏⠉⠙⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣠⠴⠢⠦⠽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⣿⣿⣿⣷⡄⣀⡀⠈⠉⠋⢹⠋⠁⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + //⠿⠿⠿⠿⠿⠦⠈⠀⠀⠀⠸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + + string deathMessage; + + if (MapData.Player == this) + { + deathMessage = "Você morreu!"; + } + else + { + deathMessage = $"{DisplayName} morreu!"; + } + + MessageLogData.Instance.AddMessage(deathMessage); + + Texture = Definition.deathTexture; + BlocksMovement = false; + Type = EntityType.CORPSE; + DisplayName = $"Restos mortais de {DisplayName}"; + MapData.UnregisterBlockingEntity(this); + EmitSignal(SignalName.Died); + } + #endregion +} \ No newline at end of file diff --git a/scripts/Entities/Actors/Actor.cs.uid b/scripts/Entities/Actors/Actor.cs.uid new file mode 100644 index 0000000..cf29b40 --- /dev/null +++ b/scripts/Entities/Actors/Actor.cs.uid @@ -0,0 +1 @@ +uid://c0cm4woy8lawl diff --git a/scripts/Entities/Actors/ActorDefinition.cs b/scripts/Entities/Actors/ActorDefinition.cs new file mode 100644 index 0000000..5bd8073 --- /dev/null +++ b/scripts/Entities/Actors/ActorDefinition.cs @@ -0,0 +1,32 @@ +using Godot; + +namespace TheLegendOfGustav.Entities.Actors; + +/// +/// Define de forma genérica as características de um ator. +/// +[GlobalClass] +public partial class ActorDefinition : EntityDefinition +{ + [ExportCategory("Visuals")] + // Sprite de morto + [Export] + public Texture2D deathTexture; + + [ExportCategory("Mechanics")] + [Export] + public int Speed { get; set; } = 10; + + // Estatísticas padrão do ator. + [ExportCategory("Stats")] + [Export] + public int Hp; + [Export] + public int Mp; + [Export] + public int Atk; + [Export] + public int Def; + [Export] + public int Men; +} diff --git a/scripts/Entities/Actors/ActorDefinition.cs.uid b/scripts/Entities/Actors/ActorDefinition.cs.uid new file mode 100644 index 0000000..ddcfe02 --- /dev/null +++ b/scripts/Entities/Actors/ActorDefinition.cs.uid @@ -0,0 +1 @@ +uid://crxw1e37xlrrt diff --git a/scripts/Entities/Actors/Enemy.cs b/scripts/Entities/Actors/Enemy.cs new file mode 100644 index 0000000..c152a0b --- /dev/null +++ b/scripts/Entities/Actors/Enemy.cs @@ -0,0 +1,54 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors.AI; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actors; + +/// +/// Um inimigo é uma espécie de ator que é +/// hostil ao jogador. Inimigos são controlados por IA. +/// +public partial class Enemy : Actor +{ + public Enemy(Vector2I initialPosition, MapData map, EnemyDefinition definition) : base(initialPosition, map, definition) + { + Definition = definition; + SetDefinition(definition); + } + + /// + /// A alma do ator. Gera ações que são executadas todo turno. + /// + public BaseAI Soul { get; private set; } + + private EnemyDefinition Definition { get; set; } + + /// + /// Além de definir as características gerais de um ator, + /// também define qual IA utilizar. + /// + /// Definição do inimigo. + public void SetDefinition(EnemyDefinition definition) + { + // Definimos as características do ator. + base.SetDefinition(Definition); + + // Definimos qual IA utilizar. + switch (definition.AI) + { + case AIType.None: + break; + case AIType.DefaultHostile: + Soul = new HostileEnemyAI(); + AddChild(Soul); + break; + } + } + + public override void Die() + { + Soul.QueueFree(); + Soul = null; + base.Die(); + } +} diff --git a/scripts/Entities/Actors/Enemy.cs.uid b/scripts/Entities/Actors/Enemy.cs.uid new file mode 100644 index 0000000..93255b7 --- /dev/null +++ b/scripts/Entities/Actors/Enemy.cs.uid @@ -0,0 +1 @@ +uid://bef1fo3vgvxej diff --git a/scripts/Entities/Actors/EnemyDefinition.cs b/scripts/Entities/Actors/EnemyDefinition.cs new file mode 100644 index 0000000..97f8f13 --- /dev/null +++ b/scripts/Entities/Actors/EnemyDefinition.cs @@ -0,0 +1,15 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors.AI; + +namespace TheLegendOfGustav.Entities.Actors; + +/// +/// Além das configurações do ator, também possui qual IA utilizar. +/// +[GlobalClass] +public partial class EnemyDefinition : ActorDefinition +{ + [ExportCategory("AI")] + [Export] + public AIType AI; +} \ No newline at end of file diff --git a/scripts/Entities/Actors/EnemyDefinition.cs.uid b/scripts/Entities/Actors/EnemyDefinition.cs.uid new file mode 100644 index 0000000..1ba03e1 --- /dev/null +++ b/scripts/Entities/Actors/EnemyDefinition.cs.uid @@ -0,0 +1 @@ +uid://dkfdm2m2scyks diff --git a/scripts/Entities/Actors/Inventory.cs b/scripts/Entities/Actors/Inventory.cs new file mode 100644 index 0000000..f65dc59 --- /dev/null +++ b/scripts/Entities/Actors/Inventory.cs @@ -0,0 +1,46 @@ +using Godot; +using TheLegendOfGustav.Entities.Items; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.Entities.Actors; + +public partial class Inventory(int capacity) : Node +{ + private Player Player { get; set; } + public int Capacity { get; private set; } = capacity; + public Godot.Collections.Array Items { get; private set; } = []; + + public override void _Ready() + { + base._Ready(); + Player = GetParent(); + } + + public void Drop(ConsumableItem item) + { + Items.Remove(item); + + MapData data = Player.MapData; + + data.InsertEntity(item); + data.EmitSignal(MapData.SignalName.EntityPlaced, item); + + item.MapData = data; + item.GridPosition = Player.GridPosition; + + MessageLogData.Instance.AddMessage($"Você descarta {item.DisplayName}."); + } + + public void Add(ConsumableItem item) + { + if (Items.Count >= Capacity) return; + + Items.Add(item); + } + + public void RemoveItem(ConsumableItem item) + { + Items.Remove(item); + } +} \ No newline at end of file diff --git a/scripts/Entities/Actors/Inventory.cs.uid b/scripts/Entities/Actors/Inventory.cs.uid new file mode 100644 index 0000000..05c2beb --- /dev/null +++ b/scripts/Entities/Actors/Inventory.cs.uid @@ -0,0 +1 @@ +uid://isaqxdpou22h diff --git a/scripts/Entities/Actors/Player.cs b/scripts/Entities/Actors/Player.cs new file mode 100644 index 0000000..7fd80d4 --- /dev/null +++ b/scripts/Entities/Actors/Player.cs @@ -0,0 +1,27 @@ +using Godot; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Actors; + +/// +/// Classe do jogador. Por enquanto não é diferente do Ator, mas isso pode mudar. +/// +[GlobalClass] +public partial class Player : Actor +{ + public Player(Vector2I initialPosition, MapData map, PlayerDefinition definition) : base(initialPosition, map, definition) + { + Definition = definition; + SetDefinition(definition); + } + + private PlayerDefinition Definition { get; set; } + public Inventory Inventory { get; private set; } + + public void SetDefinition(PlayerDefinition definition) + { + Inventory = new(definition.InventoryCapacity); + + AddChild(Inventory); + } +} diff --git a/scripts/Entities/Actors/Player.cs.uid b/scripts/Entities/Actors/Player.cs.uid new file mode 100644 index 0000000..8229b7f --- /dev/null +++ b/scripts/Entities/Actors/Player.cs.uid @@ -0,0 +1 @@ +uid://c840l08453pu2 diff --git a/scripts/Entities/Actors/PlayerDefinition.cs b/scripts/Entities/Actors/PlayerDefinition.cs new file mode 100644 index 0000000..58ae6b4 --- /dev/null +++ b/scripts/Entities/Actors/PlayerDefinition.cs @@ -0,0 +1,11 @@ +using Godot; + +namespace TheLegendOfGustav.Entities.Actors; + +[GlobalClass] +public partial class PlayerDefinition : ActorDefinition +{ + [ExportCategory("Player Mechanics")] + [Export] + public int InventoryCapacity = 0; +} \ No newline at end of file diff --git a/scripts/Entities/Actors/PlayerDefinition.cs.uid b/scripts/Entities/Actors/PlayerDefinition.cs.uid new file mode 100644 index 0000000..9d01ab9 --- /dev/null +++ b/scripts/Entities/Actors/PlayerDefinition.cs.uid @@ -0,0 +1 @@ +uid://bd78nfh1tsjq6 diff --git a/scripts/Entities/Entity.cs b/scripts/Entities/Entity.cs new file mode 100644 index 0000000..412bd7a --- /dev/null +++ b/scripts/Entities/Entity.cs @@ -0,0 +1,127 @@ +using Godot; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.Entities; + +/// +/// Defino aqui que o jogo irá desenhar +/// atores em cima de itens e itens acima de corpos. +/// +public enum EntityType +{ + CORPSE, + ITEM, + ACTOR +}; + +/// +/// Classe para elementos móveis que o jogador pode interagir. +/// +public abstract partial class Entity : Sprite2D +{ + private Vector2I gridPosition = Vector2I.Zero; + + private EntityType type; + private bool blocksMovement; + private string displayName; + + public Entity(Vector2I initialPosition, MapData map, EntityDefinition definition) + { + GridPosition = initialPosition; + MapData = map; + Centered = false; + + SetDefinition(definition); + } + + /// + /// Usado para definir a camada da entidade no mapa. + /// + public EntityType Type + { + get => type; + set + { + type = value; + ZIndex = (int)type; + } + } + + /// + /// É conveniente ter acesso ao mapa dentro da entidade. Isto porque ela existe dentro + /// do mapa, então é necessário ter acesso à algumas informações. + /// + public MapData MapData { get; set; } + + /// + /// Posição da entidade no mapa do jogo. Diferentemente de Position, GridPosition tem como formato + /// os tiles do mapa. + /// + public Vector2I GridPosition + { + set + { + gridPosition = value; + // O sistema de coordenadas do Godot é em pixels, mas faz mais sentido para o jogo utilizar coordenadas em tiles. + // Esta propriedade converte um sistema para o outro automaticamente. + Position = Grid.GridToWorld(value); + } + get => gridPosition; + } + + /// + /// Se a entidade bloqueia movimento (não pode oculpar a mesma célula de outra entidade.) + /// + public bool BlocksMovement + { + get => blocksMovement; + protected set + { + blocksMovement = value; + } + } + + /// + /// Nome da entidade. + /// + public string DisplayName + { + get => displayName; + protected set + { + displayName = value; + } + } + + /// + /// A definição da entidade possui caracterísitcas padrões que definem + /// a entidade em questão. + /// + private EntityDefinition Definition; + + public override void _Ready() + { + base._Ready(); + // Quando a entidade for carregada completamente, atualizamos sua posição para refletir + // sua posição real. + GridPosition = Grid.WorldToGrid(Position); + } + + + + /// + /// Aplica uma definição de NPC para o ator. + /// Se o ator for um boneco de barro, este método é como um + /// sopro de vida. + /// + /// A definição do ator. + public virtual void SetDefinition(EntityDefinition definition) + { + Definition = definition; + BlocksMovement = definition.blocksMovement; + DisplayName = definition.name; + Type = definition.Type; + Texture = definition.texture; + } +} \ No newline at end of file diff --git a/scripts/Entities/Entity.cs.uid b/scripts/Entities/Entity.cs.uid new file mode 100644 index 0000000..f178d64 --- /dev/null +++ b/scripts/Entities/Entity.cs.uid @@ -0,0 +1 @@ +uid://w1325qe64c6w diff --git a/scripts/Entities/EntityDefinition.cs b/scripts/Entities/EntityDefinition.cs new file mode 100644 index 0000000..a6080bd --- /dev/null +++ b/scripts/Entities/EntityDefinition.cs @@ -0,0 +1,23 @@ +using Godot; + +namespace TheLegendOfGustav.Entities; + +[GlobalClass] +public partial class EntityDefinition : Resource +{ + [ExportCategory("Entity Visuals")] + // Nome da entidade. + [Export] + public string name = "unnamed"; + // Seu sprite. + [Export] + public Texture2D texture; + // A camada da entidade. + [Export] + public EntityType Type; + + [ExportCategory("Entity Mechanics")] + // Se a entidade bloqueia movimento. + [Export] + public bool blocksMovement = true; +} \ No newline at end of file diff --git a/scripts/Entities/EntityDefinition.cs.uid b/scripts/Entities/EntityDefinition.cs.uid new file mode 100644 index 0000000..0aed6ab --- /dev/null +++ b/scripts/Entities/EntityDefinition.cs.uid @@ -0,0 +1 @@ +uid://bp33ly3hnjwk0 diff --git a/scripts/Entities/Items/ConsumableItem.cs b/scripts/Entities/Items/ConsumableItem.cs new file mode 100644 index 0000000..f70983a --- /dev/null +++ b/scripts/Entities/Items/ConsumableItem.cs @@ -0,0 +1,40 @@ +using Godot; +using TheLegendOfGustav.Entities.Actions; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Items; + +/// +/// Classe para itens consumíveis. +/// Itens consumíveis são itens de uso limitado. +/// +public abstract partial class ConsumableItem(Vector2I initialPosition, MapData map, EntityDefinition definition) : Entity(initialPosition, map, definition) +{ + + /// + /// Gera uma ação onde o ator consome o item. + /// + /// + /// + public Action GetAction(Player consumer) + { + return new ItemAction(consumer, this); + } + + /// + /// Ativa a função deste item. + /// Este método é chamado pela ação gerada por ele mesmo. + /// Este método permite definir condições para a sua ativação. + /// + /// Ação gerada pelo item. + /// Se a ação foi realizada ou não. + public abstract bool Activate(ItemAction action); + + public void ConsumedBy(Player consumer) + { + Inventory inventory = consumer.Inventory; + inventory.RemoveItem(this); + QueueFree(); + } +} \ No newline at end of file diff --git a/scripts/Entities/Items/ConsumableItem.cs.uid b/scripts/Entities/Items/ConsumableItem.cs.uid new file mode 100644 index 0000000..e6c452a --- /dev/null +++ b/scripts/Entities/Items/ConsumableItem.cs.uid @@ -0,0 +1 @@ +uid://hpppt5k743x diff --git a/scripts/Entities/Items/ConsumableItemDefinition.cs b/scripts/Entities/Items/ConsumableItemDefinition.cs new file mode 100644 index 0000000..9cadc0b --- /dev/null +++ b/scripts/Entities/Items/ConsumableItemDefinition.cs @@ -0,0 +1,9 @@ +using Godot; + +namespace TheLegendOfGustav.Entities.Items; + +/// +/// Esta classe só existe para agrupar seus descendentes. +/// +[GlobalClass] +public abstract partial class ConsumableItemDefinition : EntityDefinition; \ No newline at end of file diff --git a/scripts/Entities/Items/ConsumableItemDefinition.cs.uid b/scripts/Entities/Items/ConsumableItemDefinition.cs.uid new file mode 100644 index 0000000..9ddc0f6 --- /dev/null +++ b/scripts/Entities/Items/ConsumableItemDefinition.cs.uid @@ -0,0 +1 @@ +uid://dpdju2ucehsb0 diff --git a/scripts/Entities/Items/HealingConsumable.cs b/scripts/Entities/Items/HealingConsumable.cs new file mode 100644 index 0000000..32f76a6 --- /dev/null +++ b/scripts/Entities/Items/HealingConsumable.cs @@ -0,0 +1,30 @@ +using Godot; +using TheLegendOfGustav.Entities.Actors; +using TheLegendOfGustav.Utils; +using TheLegendOfGustav.Entities.Actions; +using TheLegendOfGustav.Map; + +namespace TheLegendOfGustav.Entities.Items; + +public partial class HealingConsumable(Vector2I initialPosition, MapData map, HealingConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition) +{ + private HealingConsumableDefinition Definition { get; set; } = definition; + public float HealingPercentage { get; private set; } = definition.healingPercentage; + + public override bool Activate(ItemAction action) + { + Player consumer = action.Player; + int intendedAmount = (int)(HealingPercentage / 100 * consumer.MaxHp); + int recovered = consumer.Heal(intendedAmount); + + // Se não tinha o que curar, a ativação falhou. + if (recovered == 0) + { + MessageLogData.Instance.AddMessage("Você já está saudável."); + return false; + } + MessageLogData.Instance.AddMessage($"Você consome {DisplayName} e recupera {recovered} de HP"); + ConsumedBy(consumer); + return true; + } +} \ No newline at end of file diff --git a/scripts/Entities/Items/HealingConsumable.cs.uid b/scripts/Entities/Items/HealingConsumable.cs.uid new file mode 100644 index 0000000..8f8f942 --- /dev/null +++ b/scripts/Entities/Items/HealingConsumable.cs.uid @@ -0,0 +1 @@ +uid://ct20rmjhaukge diff --git a/scripts/Entities/Items/HealingConsumableDefinition.cs b/scripts/Entities/Items/HealingConsumableDefinition.cs new file mode 100644 index 0000000..d0e5850 --- /dev/null +++ b/scripts/Entities/Items/HealingConsumableDefinition.cs @@ -0,0 +1,14 @@ +using Godot; + +namespace TheLegendOfGustav.Entities.Items; + +[GlobalClass] +public partial class HealingConsumableDefinition : ConsumableItemDefinition +{ + /// + /// Porcentagem da vida do ator para restaurar. + /// + [ExportCategory("Item Mechanics")] + [Export] + public float healingPercentage = 10; +} \ No newline at end of file diff --git a/scripts/Entities/Items/HealingConsumableDefinition.cs.uid b/scripts/Entities/Items/HealingConsumableDefinition.cs.uid new file mode 100644 index 0000000..2fd311d --- /dev/null +++ b/scripts/Entities/Items/HealingConsumableDefinition.cs.uid @@ -0,0 +1 @@ +uid://b3qy4gtjfci14 diff --git a/scripts/GUI/Details.cs b/scripts/GUI/Details.cs index 814d2ac..3c64427 100644 --- a/scripts/GUI/Details.cs +++ b/scripts/GUI/Details.cs @@ -1,48 +1,57 @@ using Godot; -using System; +using TheLegendOfGustav.Entities; +using TheLegendOfGustav.Map; +using TheLegendOfGustav.Utils; + +namespace TheLegendOfGustav.GUI; public partial class Details : CanvasLayer { private static readonly LabelSettings lblSettings = GD.Load("res://assets/definitions/message_label_settings.tres"); - private Map map; - private VBoxContainer entityNames; - private Godot.Collections.Array entities = []; + + private Map.Map Map { get; set; } + private VBoxContainer EntityNames { get; set; } + private Godot.Collections.Array Entities { get; set; } = []; - private Godot.Collections.Array