From e9701f8ca459fa0015d78cacdc61aee904675598 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 17 Aug 2025 21:10:30 -0300 Subject: Sistema de turnos rudimentar --- scenes/DungeonLevel.tscn | 4 ++-- scripts/DungeonLevel.cs | 5 +++-- scripts/Game.cs | 13 ++++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/scenes/DungeonLevel.tscn b/scenes/DungeonLevel.tscn index 6810ba7..83a33bb 100644 --- a/scenes/DungeonLevel.tscn +++ b/scenes/DungeonLevel.tscn @@ -5,9 +5,9 @@ [ext_resource type="PackedScene" uid="uid://c3wbuxeetj24a" path="res://scenes/Player.tscn" id="2_u6mlv"] [ext_resource type="PackedScene" uid="uid://cnkx22hgs0b3p" path="res://scenes/Skeleton.tscn" id="4_8elbs"] -[node name="Map" type="Node2D" node_paths=PackedStringArray("actors")] +[node name="Map" type="Node2D" node_paths=PackedStringArray("Actors")] script = ExtResource("1_u6mlv") -actors = [NodePath("Actors/Player"), NodePath("Actors/Skeleton")] +Actors = [NodePath("Actors/Player"), NodePath("Actors/Skeleton")] [node name="Dungeon" type="TileMapLayer" parent="."] texture_filter = 1 diff --git a/scripts/DungeonLevel.cs b/scripts/DungeonLevel.cs index d3a5aee..cdafdca 100644 --- a/scripts/DungeonLevel.cs +++ b/scripts/DungeonLevel.cs @@ -6,7 +6,8 @@ public partial class DungeonLevel : Node2D public Player player; private TileMapLayer buildingLayer; [Export] - private Godot.Collections.Array actors = []; + public Godot.Collections.Array Actors { get; private set; } = []; + private Node2D actorsNode; @@ -28,7 +29,7 @@ public partial class DungeonLevel : Node2D } public Actor GetBlockingActorAtPosition(Vector2I pos) { - foreach (Actor actor in actors) { + foreach (Actor actor in Actors) { if (actor.GridPosition == pos && actor.BlocksMovement) { return actor; } diff --git a/scripts/Game.cs b/scripts/Game.cs index ddea395..21531fc 100644 --- a/scripts/Game.cs +++ b/scripts/Game.cs @@ -21,6 +21,17 @@ public partial class Game : Node { Action action = inputHandler.GetAction(); - action?.Perform(this, player); + if (action != null) { + action.Perform(this, player); + HandleEnemyTurns(); + } + } + + private void HandleEnemyTurns() { + foreach (Actor actor in Map.Actors) { + if (actor is Player) continue; + + GD.Print($"O {actor.ActorName} foi cuckado e não tem como agir."); + } } } -- cgit v1.2.3