diff --git a/assets/sprites/atlases/atlas1.png b/assets/sprites/atlases/atlas1.png index 5221a35..9bd9d0a 100644 Binary files a/assets/sprites/atlases/atlas1.png and b/assets/sprites/atlases/atlas1.png differ diff --git a/assets/sprites/wave-progress/Fill.tres b/assets/sprites/wave-progress/Fill.tres new file mode 100644 index 0000000..96e394c --- /dev/null +++ b/assets/sprites/wave-progress/Fill.tres @@ -0,0 +1,8 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://dbt3asr2jel6"] + +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_cib5l"] + +[resource] +atlas = ExtResource("1_cib5l") +region = Rect2(504, 0, 137, 12) +filter_clip = true diff --git a/assets/sprites/wave-progress/Flag.tres b/assets/sprites/wave-progress/Flag.tres new file mode 100644 index 0000000..d62ef48 --- /dev/null +++ b/assets/sprites/wave-progress/Flag.tres @@ -0,0 +1,7 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://6didix2twcty"] + +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_jxs08"] + +[resource] +atlas = ExtResource("1_jxs08") +region = Rect2(665, 0, 20, 22) diff --git a/assets/sprites/wave-progress/Head.tres b/assets/sprites/wave-progress/Head.tres new file mode 100644 index 0000000..b3d37ba --- /dev/null +++ b/assets/sprites/wave-progress/Head.tres @@ -0,0 +1,7 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://bjpea7iqweexm"] + +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_ojsbh"] + +[resource] +atlas = ExtResource("1_ojsbh") +region = Rect2(642, 0, 23, 24) diff --git a/assets/sprites/wave-progress/UnderTexture.tres b/assets/sprites/wave-progress/UnderTexture.tres new file mode 100644 index 0000000..ee74038 --- /dev/null +++ b/assets/sprites/wave-progress/UnderTexture.tres @@ -0,0 +1,7 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://oxjkxtyw0xx0"] + +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_k8txh"] + +[resource] +atlas = ExtResource("1_k8txh") +region = Rect2(361, 0, 143, 20) diff --git a/scenes/gui/wave_progress.tscn b/scenes/gui/wave_progress.tscn new file mode 100644 index 0000000..a6ed04e --- /dev/null +++ b/scenes/gui/wave_progress.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=5 format=3 uid="uid://c668qnmmpli5r"] + +[ext_resource type="Texture2D" uid="uid://oxjkxtyw0xx0" path="res://assets/sprites/wave-progress/UnderTexture.tres" id="1_60lfm"] +[ext_resource type="Texture2D" uid="uid://dbt3asr2jel6" path="res://assets/sprites/wave-progress/Fill.tres" id="2_7f727"] +[ext_resource type="Script" uid="uid://bsnt4slsbathn" path="res://scripts/gui/WaveProgress.cs" id="3_u57hj"] +[ext_resource type="Texture2D" uid="uid://bjpea7iqweexm" path="res://assets/sprites/wave-progress/Head.tres" id="4_5xdew"] + +[node name="WaveProgress" type="TextureProgressBar"] +anchors_preset = -1 +anchor_right = 0.238 +anchor_bottom = 0.05 +offset_right = 0.199997 +step = 0.01 +fill_mode = 1 +stretch_margin_left = 20 +texture_under = ExtResource("1_60lfm") +texture_progress = ExtResource("2_7f727") +texture_progress_offset = Vector2(3, 5) +script = ExtResource("3_u57hj") + +[node name="Head" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -11.5 +offset_top = -12.0 +offset_right = 11.5 +offset_bottom = 12.0 +texture = ExtResource("4_5xdew") +expand_mode = 1 +stretch_mode = 5 diff --git a/scenes/templates/standard_players_house.tscn b/scenes/templates/standard_players_house.tscn index 133c8c3..f6b8880 100644 --- a/scenes/templates/standard_players_house.tscn +++ b/scenes/templates/standard_players_house.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=12 format=3 uid="uid://bu0dh5ct387xu"] +[gd_scene load_steps=13 format=3 uid="uid://bu0dh5ct387xu"] [ext_resource type="PackedScene" uid="uid://dd3yegl1xo44m" path="res://scenes/templates/level_template.tscn" id="1_vdv3d"] [ext_resource type="Resource" uid="uid://br3364jty1j0i" path="res://resources/levels/test_level_for_execution.tres" id="2_bpfdr"] [ext_resource type="Texture2D" uid="uid://b0tb2hjum40aw" path="res://assets/sprites/background_summer.png" id="3_lsqv3"] [ext_resource type="Script" uid="uid://84gvlkflxdhk" path="res://scripts/level/zombe_spawners/RowSpawner.cs" id="4_kn7hc"] [ext_resource type="Script" uid="uid://puqxp2xeg1r2" path="res://scripts/level/LevelRunner.cs" id="5_vbgdr"] +[ext_resource type="PackedScene" uid="uid://c668qnmmpli5r" path="res://scenes/gui/wave_progress.tscn" id="6_yw4uo"] [sub_resource type="Animation" id="Animation_vbgdr"] resource_name = "CYS_Sequence" @@ -224,7 +225,14 @@ anchors_preset = -1 size_flags_horizontal = 3 size_flags_vertical = 3 -[node name="ReadySetPlant" type="RichTextLabel" parent="GUI" index="2"] +[node name="WaveProgress" parent="GUI" index="2" instance=ExtResource("6_yw4uo")] +visible = false +offset_left = 443.0 +offset_top = 377.0 +offset_right = 443.2 +offset_bottom = 377.0 + +[node name="ReadySetPlant" type="RichTextLabel" parent="GUI" index="3"] visible = false anchors_preset = 15 anchor_right = 1.0 @@ -262,3 +270,6 @@ fadeAnimation = NodePath("../GameOverScreen/AnimationPlayer") [node name="CollisionShape2D" parent="Checkbox" index="0"] shape = SubResource("WorldBoundaryShape2D_yw4uo") + +[connection signal="ResourceChanged" from="LevelRunner" to="GUI/WaveProgress" method="SetLevelData"] +[connection signal="WaveChanged" from="LevelRunner" to="GUI/WaveProgress" method="OnWaveChanged"] diff --git a/scripts/gui/WaveProgress.cs b/scripts/gui/WaveProgress.cs new file mode 100644 index 0000000..e9217ae --- /dev/null +++ b/scripts/gui/WaveProgress.cs @@ -0,0 +1,26 @@ +using Godot; + +public partial class WaveProgress : TextureProgressBar +{ + private TextureRect head; + private Tween tween; + + [Export] private double progressTime = 2.0f; + public override void _Ready() + { + head = GetNode("Head"); + } + public void OnWaveChanged(int to) + { + if (Visible == false) Visible = true; + if (tween != null) tween.Kill(); + tween = CreateTween().SetParallel(true).SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out); + tween.TweenProperty(this,"value",to+1,progressTime); + tween.TweenProperty(head,"anchor_right",1.0-(float)(to+1.0f)/MaxValue,progressTime); + tween.TweenProperty(head,"anchor_left",1.0-(float)(to+1.0f)/MaxValue,progressTime); + } + public void SetLevelData(AdventureLevelResource resource) + { + MaxValue = resource.waves.Count; + } +} diff --git a/scripts/gui/WaveProgress.cs.uid b/scripts/gui/WaveProgress.cs.uid new file mode 100644 index 0000000..08810bd --- /dev/null +++ b/scripts/gui/WaveProgress.cs.uid @@ -0,0 +1 @@ +uid://bsnt4slsbathn diff --git a/scripts/level/LevelRunner.cs b/scripts/level/LevelRunner.cs index acd654b..0eace07 100644 --- a/scripts/level/LevelRunner.cs +++ b/scripts/level/LevelRunner.cs @@ -9,6 +9,8 @@ public partial class LevelRunner : Node [Export] private RowSpawner rowSpawner; [Export] private Timer waveTimer; private int waveIndex = -1; + [Signal] public delegate void ResourceChangedEventHandler(AdventureLevelResource resource); + [Signal] public delegate void WaveChangedEventHandler(int to); public override void _Ready() { @@ -21,12 +23,13 @@ public partial class LevelRunner : Node waveTimer.Stop(); waveTimer.WaitTime = resource.initialWaveDelay; waveTimer.Start(); - + EmitSignal(SignalName.ResourceChanged, resource); } private void SummonWave() { waveIndex += 1; + EmitSignal(SignalName.WaveChanged, waveIndex); rowSpawner.Add(resource.waves[waveIndex].zombiesOrdered); if (waveIndex == resource.waves.Count - 1) return;