wave progress

This commit is contained in:
Rendo 2025-07-16 23:26:21 +05:00
commit 8287cf609a
10 changed files with 107 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before After
Before After

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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="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="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="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://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="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"] [sub_resource type="Animation" id="Animation_vbgdr"]
resource_name = "CYS_Sequence" resource_name = "CYS_Sequence"
@ -224,7 +225,14 @@ anchors_preset = -1
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 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 visible = false
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -262,3 +270,6 @@ fadeAnimation = NodePath("../GameOverScreen/AnimationPlayer")
[node name="CollisionShape2D" parent="Checkbox" index="0"] [node name="CollisionShape2D" parent="Checkbox" index="0"]
shape = SubResource("WorldBoundaryShape2D_yw4uo") shape = SubResource("WorldBoundaryShape2D_yw4uo")
[connection signal="ResourceChanged" from="LevelRunner" to="GUI/WaveProgress" method="SetLevelData"]
[connection signal="WaveChanged" from="LevelRunner" to="GUI/WaveProgress" method="OnWaveChanged"]

View file

@ -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<TextureRect>("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;
}
}

View file

@ -0,0 +1 @@
uid://bsnt4slsbathn

View file

@ -9,6 +9,8 @@ public partial class LevelRunner : Node
[Export] private RowSpawner rowSpawner; [Export] private RowSpawner rowSpawner;
[Export] private Timer waveTimer; [Export] private Timer waveTimer;
private int waveIndex = -1; private int waveIndex = -1;
[Signal] public delegate void ResourceChangedEventHandler(AdventureLevelResource resource);
[Signal] public delegate void WaveChangedEventHandler(int to);
public override void _Ready() public override void _Ready()
{ {
@ -21,12 +23,13 @@ public partial class LevelRunner : Node
waveTimer.Stop(); waveTimer.Stop();
waveTimer.WaitTime = resource.initialWaveDelay; waveTimer.WaitTime = resource.initialWaveDelay;
waveTimer.Start(); waveTimer.Start();
EmitSignal(SignalName.ResourceChanged, resource);
} }
private void SummonWave() private void SummonWave()
{ {
waveIndex += 1; waveIndex += 1;
EmitSignal(SignalName.WaveChanged, waveIndex);
rowSpawner.Add(resource.waves[waveIndex].zombiesOrdered); rowSpawner.Add(resource.waves[waveIndex].zombiesOrdered);
if (waveIndex == resource.waves.Count - 1) return; if (waveIndex == resource.waves.Count - 1) return;