diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-16 14:22:04 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-16 14:22:04 -0300 |
| commit | c411c496394c7a782854e03f2be8fab4cc1e2a81 (patch) | |
| tree | 6cecaa0f70c9b3fd49a9fce9b383d46c27c41dcd /scripts | |
| parent | 588a80a339a64f15b2e3bada550beb14e16abe3e (diff) | |
Herança e preparativos para o sistema de turnos
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Actor.cs | 18 | ||||
| -rw-r--r-- | scripts/Actor.cs.uid | 1 | ||||
| -rw-r--r-- | scripts/Character.cs | 16 | ||||
| -rw-r--r-- | scripts/Enemy.cs | 6 | ||||
| -rw-r--r-- | scripts/Enemy.cs.uid | 1 |
5 files changed, 27 insertions, 15 deletions
diff --git a/scripts/Actor.cs b/scripts/Actor.cs new file mode 100644 index 0000000..fc69edf --- /dev/null +++ b/scripts/Actor.cs @@ -0,0 +1,18 @@ +using Godot; + +public partial class Actor : Node2D { + [Export] + public TileMapLayer Map { get; set; } + + protected void Walk(Vector2I offset) { + Vector2I toMovePos = Map.LocalToMap(Position); + toMovePos += offset; + + TileData tile = Map.GetCellTileData(toMovePos); + + if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) { + GD.Print(toMovePos); + Position = Map.MapToLocal(toMovePos); + } + } +}
\ No newline at end of file diff --git a/scripts/Actor.cs.uid b/scripts/Actor.cs.uid new file mode 100644 index 0000000..cf29b40 --- /dev/null +++ b/scripts/Actor.cs.uid @@ -0,0 +1 @@ +uid://c0cm4woy8lawl diff --git a/scripts/Character.cs b/scripts/Character.cs index 1e11fcc..e3707f5 100644 --- a/scripts/Character.cs +++ b/scripts/Character.cs @@ -1,9 +1,7 @@ using Godot; using System; -public partial class Character : Sprite2D { - [Export] - public TileMapLayer map; +public partial class Character : Actor { public override void _Input(InputEvent @event) { @@ -30,16 +28,4 @@ public partial class Character : Sprite2D { Walk(offset); } } - - private void Walk(Vector2I offset) { - Vector2I toMovePos = map.LocalToMap(Position); - toMovePos += offset; - - TileData tile = map.GetCellTileData(toMovePos); - - if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) { - GD.Print(toMovePos); - Position = map.MapToLocal(toMovePos); - } - } } diff --git a/scripts/Enemy.cs b/scripts/Enemy.cs new file mode 100644 index 0000000..6f48bd1 --- /dev/null +++ b/scripts/Enemy.cs @@ -0,0 +1,6 @@ +using Godot; +using System; + +public partial class Enemy : Actor { + +} diff --git a/scripts/Enemy.cs.uid b/scripts/Enemy.cs.uid new file mode 100644 index 0000000..93255b7 --- /dev/null +++ b/scripts/Enemy.cs.uid @@ -0,0 +1 @@ +uid://bef1fo3vgvxej |
