diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-17 19:32:36 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-08-17 19:32:36 -0300 |
| commit | ca782d7310f2df854a8727535ac92337c85ed445 (patch) | |
| tree | 7df571c01d48cac56fb8362d4d091bdd2a55c09a /scenes | |
| parent | adb86dd1725276457c13e9a4d37372fda628dea3 (diff) | |
Gigantesco refactor
Diffstat (limited to 'scenes')
| -rw-r--r-- | scenes/DungeonLevel.tscn | 18 | ||||
| -rw-r--r-- | scenes/Game.tscn | 13 | ||||
| -rw-r--r-- | scenes/Player.tscn | 13 | ||||
| -rw-r--r-- | scenes/character.tscn | 12 | ||||
| -rw-r--r-- | scenes/skeleton.tscn | 8 | ||||
| -rw-r--r-- | scenes/test_map.tscn | 29 | ||||
| -rw-r--r-- | scenes/turn_manager.tscn | 60 |
7 files changed, 102 insertions, 51 deletions
diff --git a/scenes/DungeonLevel.tscn b/scenes/DungeonLevel.tscn new file mode 100644 index 0000000..f9d98fd --- /dev/null +++ b/scenes/DungeonLevel.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=4 format=4 uid="uid://dnh8xgk1w76i2"] + +[ext_resource type="TileSet" uid="uid://biilh0ufacguh" path="res://assets/test_tileset.tres" id="1_bxfih"] +[ext_resource type="Script" uid="uid://cy7qumrpks2kx" path="res://scripts/DungeonLevel.cs" id="1_u6mlv"] +[ext_resource type="PackedScene" uid="uid://7sfxgul40ths" path="res://scenes/Player.tscn" id="2_u6mlv"] + +[node name="Map" type="Node2D"] +script = ExtResource("1_u6mlv") + +[node name="Dungeon" type="TileMapLayer" parent="."] +texture_filter = 1 +tile_map_data = PackedByteArray("AAAHAAcAAAAAAAAAAAAIAAcAAAAAAAAAAAAJAAcAAAAAAAAAAAAKAAcAAAAAAAAAAAALAAcAAAAAAAAAAAAMAAcAAAAAAAAAAAANAAcAAAAAAAAAAAAOAAcAAAAAAAAAAAAOAAgAAAAAAAAA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AAMAAAABAAAAAAASAAMAAAABAAAAAAARAAMAAAABAAAAAAAQAAMAAAABAAAAAAAPAAMAAAABAAAAAAAPAAQAAAABAAAAAAAPAAUAAAABAAAAAAAQAAkAAAAAAAAAAAARAAkAAAAAAAAAAAARAAgAAAABAAAAAAASAAgAAAAAAAAAAAATAAgAAAAAAAAAAAAUAAkAAAAAAAAAAAATAAkAAAAAAAAAAAARAAcAAAAAAAAAAAAQAAcAAAAAAAAAAAAQAAYAAAAAAAAAAAAQAAUAAAAAAAAAAAARAAUAAAABAAAAAAARAAQAAAAAAAAAAAASAAQAAAAAAAAAAAATAAQAAAAAAAAAAAAUAAQAAAAAAAAAAAAUAAUAAAAAAAAAAAAVAAUAAAABAAAAAAAVAAYAAAAAAAAAAAAVAAcAAAABAAAAAAAVAAgAAAABAAAAAAAVAAkAAAAAAAAAAAASAAcAAAAAAAAAAAASAAYAAAABAAAAAAASAAUAAAABAAAAAAATAAUAAAAAAAAAAAAUAAYAAAAAAAAAAAAUAAcAAAABAAAAAAAUAAgAAAABAAAAAAATAAcAAAAAAAAAAAATAAYAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAgAAAAAAAAAAAARAAYAAAABAAAAAAASAAkAAAAAAAAAAAAWAAkAAAAAAAAAAAAWAAgAAAAAAAAAAAAWAAcAAAAAAAAAAAAWAAYAAAAAAAAAAAAWAAUAAAAAAAAAAAAWAAQAAAAAAAAAAAAVAAQAAAAAAAAAAAAKAAoAAAAAAAAAAAAJAAsAAAABAAAAAAA=") +tile_set = ExtResource("1_bxfih") + +[node name="Actors" type="Node2D" parent="."] + +[node name="Player" parent="Actors" instance=ExtResource("2_u6mlv")] +position = Vector2(144, 144) diff --git a/scenes/Game.tscn b/scenes/Game.tscn new file mode 100644 index 0000000..6d1a2be --- /dev/null +++ b/scenes/Game.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=4 format=3 uid="uid://u5h6iqyi8wd0"] + +[ext_resource type="Script" uid="uid://dwubb28wt4bhe" path="res://scripts/Game.cs" id="1_cpr0p"] +[ext_resource type="PackedScene" uid="uid://dnh8xgk1w76i2" path="res://scenes/DungeonLevel.tscn" id="2_cpr0p"] +[ext_resource type="Script" uid="uid://ejqmdbc0524i" path="res://scripts/InputHandler.cs" id="3_s0nni"] + +[node name="Game" type="Node"] +script = ExtResource("1_cpr0p") + +[node name="Map" parent="." instance=ExtResource("2_cpr0p")] + +[node name="InputHandler" type="Node" parent="."] +script = ExtResource("3_s0nni") diff --git a/scenes/Player.tscn b/scenes/Player.tscn new file mode 100644 index 0000000..bd40178 --- /dev/null +++ b/scenes/Player.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=3 format=3 uid="uid://7sfxgul40ths"] + +[ext_resource type="Script" uid="uid://c840l08453pu2" path="res://scripts/actors/Player.cs" id="1_p0vlq"] +[ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/character.png" id="1_v6fml"] + +[node name="Player" type="Sprite2D"] +texture = ExtResource("1_v6fml") +centered = false +script = ExtResource("1_p0vlq") + +[node name="Camera2D" type="Camera2D" parent="."] +offset = Vector2(8, 8) +zoom = Vector2(2, 2) diff --git a/scenes/character.tscn b/scenes/character.tscn deleted file mode 100644 index 4b23758..0000000 --- a/scenes/character.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://bl01llfbscv6r"] - -[ext_resource type="Texture2D" uid="uid://dwky8qc2y602k" path="res://assets/sprites/character.png" id="1_agfs1"] -[ext_resource type="Script" uid="uid://c840l08453pu2" path="res://scripts/Character.cs" id="2_rkhd4"] - -[node name="Character" type="Sprite2D" groups=["TimeSlave"]] -texture_filter = 1 -texture = ExtResource("1_agfs1") -script = ExtResource("2_rkhd4") - -[node name="Camera2D" type="Camera2D" parent="."] -zoom = Vector2(4, 4) diff --git a/scenes/skeleton.tscn b/scenes/skeleton.tscn deleted file mode 100644 index 1dc7727..0000000 --- a/scenes/skeleton.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://bsn4a4tfensy8"] - -[ext_resource type="Texture2D" uid="uid://dh5sgjdwkps88" path="res://assets/sprites/skeleton.png" id="1_pbvs3"] -[ext_resource type="Script" uid="uid://bef1fo3vgvxej" path="res://scripts/Enemy.cs" id="2_txkty"] - -[node name="Skeleton" type="Sprite2D" groups=["TimeSlave"]] -texture = ExtResource("1_pbvs3") -script = ExtResource("2_txkty") diff --git a/scenes/test_map.tscn b/scenes/test_map.tscn deleted file mode 100644 index c7be4df..0000000 --- a/scenes/test_map.tscn +++ /dev/null @@ -1,29 +0,0 @@ -[gd_scene load_steps=6 format=4 uid="uid://u5h6iqyi8wd0"] - -[ext_resource type="TileSet" uid="uid://biilh0ufacguh" path="res://assets/test_tileset.tres" id="1_57l66"] -[ext_resource type="Script" uid="uid://dwubb28wt4bhe" path="res://scripts/DungeonLevel.cs" id="1_p21b5"] -[ext_resource type="PackedScene" uid="uid://bl01llfbscv6r" path="res://scenes/character.tscn" id="2_fn2sa"] -[ext_resource type="PackedScene" uid="uid://bsn4a4tfensy8" path="res://scenes/skeleton.tscn" id="3_57l66"] -[ext_resource type="PackedScene" uid="uid://ie3vpgatjvkw" path="res://scenes/turn_manager.tscn" id="4_p21b5"] - -[node name="DungeonLevel" type="Node2D"] -script = ExtResource("1_p21b5") - -[node name="Map" type="TileMapLayer" parent="."] -texture_filter = 1 -tile_map_data = PackedByteArray("AAAHAAcAAAAAAAAAAAAIAAcAAAAAAAAAAAAJAAcAAAAAAAAAAAAKAAcAAAAAAAAAAAALAAcAAAAAAAAAAAAMAAcAAAAAAAAAAAANAAcAAAAAAAAAAAAOAAcAAAAAAAAAAAAOAAgAAAAAAAAAAAANAAgAAAAAAAAAAAAMAAgAAAAAAAAAAAALAAgAAAAAAAAAAAAKAAgAAAAAAAAAAAAJAAgAAAAAAAAAAAAIAAgAAAAAAAAAAAAHAAgAAAAAAAAAAAAHAAkAAAAAAAAAAAAIAAkAAAAAAAAAAAAKA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ARAAgAAAAAAAAAAAASAAgAAAAAAAAAAAATAAgAAAAAAAAAAAAUAAkAAAAAAAAAAAATAAkAAAAAAAAAAAARAAcAAAAAAAAAAAAQAAcAAAAAAAAAAAAQAAYAAAAAAAAAAAAQAAUAAAAAAAAAAAARAAUAAAAAAAAAAAARAAQAAAAAAAAAAAASAAQAAAAAAAAAAAATAAQAAAAAAAAAAAAUAAQAAAAAAAAAAAAUAAUAAAAAAAAAAAAVAAUAAAAAAAAAAAAVAAYAAAAAAAAAAAAVAAcAAAAAAAAAAAAVAAgAAAAAAAAAAAAVAAkAAAAAAAAAAAASAAcAAAAAAAAAAAASAAYAAAAAAAAAAAASAAUAAAAAAAAAAAATAAUAAAAAAAAAAAAUAAYAAAAAAAAAAAAUAAcAAAAAAAAAAAAUAAgAAAAAAAAAAAATAAcAAAAAAAAAAAATAAYAAAAAAAAAAAAQAAQAAAAAAAAAAAAQAAgAAAAAAAAAAAARAAYAAAAAAAAAAAASAAkAAAAAAAAAAAAWAAkAAAAAAAAAAAAWAAgAAAAAAAAAAAAWAAcAAAAAAAAAAAAWAAYAAAAAAAAAAAAWAAUAAAAAAAAAAAAWAAQAAAAAAAAAAAAVAAQAAAAAAAAAAAA=") -tile_set = ExtResource("1_57l66") - -[node name="Character" parent="." node_paths=PackedStringArray("Map") instance=ExtResource("2_fn2sa")] -position = Vector2(135, 135) -Map = NodePath("../Map") - -[node name="Skeleton" parent="." node_paths=PackedStringArray("Map") instance=ExtResource("3_57l66")] -position = Vector2(120, 121) -Map = NodePath("../Map") - -[node name="TurnManager" parent="." instance=ExtResource("4_p21b5")] - -[connection signal="actionPerformed" from="Character" to="TurnManager" method="OnActionEnd"] -[connection signal="actionPerformed" from="Skeleton" to="TurnManager" method="OnActionEnd"] -[connection signal="turnEnd" from="TurnManager" to="." method="OnTurnEnd"] diff --git a/scenes/turn_manager.tscn b/scenes/turn_manager.tscn index 4a1cf5c..9e9a4f7 100644 --- a/scenes/turn_manager.tscn +++ b/scenes/turn_manager.tscn @@ -1,6 +1,62 @@ [gd_scene load_steps=2 format=3 uid="uid://ie3vpgatjvkw"] -[ext_resource type="Script" uid="uid://ynjn2pmluvf6" path="res://scripts/TurnManager.cs" id="1_3c2a3"] +[sub_resource type="CSharpScript" id="CSharpScript_4jeo4"] +script/source = "using Godot; +using System; +using System.Collections.Generic; +using System.Reflection.Metadata.Ecma335; + +public partial class TurnManager : Node { + [Signal] + public delegate void turnBeginEventHandler(); + [Signal] + public delegate void turnEndEventHandler(); + + private Godot.Collections.Array<Node> actors = []; + private int index = 0; + + public int TurnCount { get; private set; } = 1; + + public void Tick() { + EmitSignal(SignalName.turnBegin); + + actors.Clear(); + actors = GetTree().GetNodesInGroup(\"TimeSlave\"); + + index = -1; + NextActor(); + } + + private void NextActor() { + index++; + if (index >= actors.Count) { + EndTurn(); + return; + } + Actor currentActor = (Actor) actors[index]; + currentActor.Energy += currentActor.Speed; + ActorPerformAction(); + } + + private void ActorPerformAction() { + Actor currentActor = (Actor) actors[index]; + if (currentActor.Energy > 0) { + currentActor.PerformAction(); + } else { + NextActor(); + } + } + + public void OnActionEnd() { + ActorPerformAction(); + } + + private void EndTurn() { + TurnCount++; + EmitSignal(SignalName.turnEnd); + } +} +" [node name="TurnManager" type="Node"] -script = ExtResource("1_3c2a3") +script = SubResource("CSharpScript_4jeo4") |
