wave flag
This commit is contained in:
parent
8287cf609a
commit
6d9edc0dc2
7 changed files with 168 additions and 26 deletions
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=18 format=3 uid="uid://br3364jty1j0i"]
|
||||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=32 format=3 uid="uid://br3364jty1j0i"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bximdujbkj2n4" path="res://addons/pvzadventure/AdventureLevelResource.cs" id="1_qb1ge"]
|
||||
[ext_resource type="Script" uid="uid://cw7yc3i2lgcja" path="res://addons/pvzadventure/WaveEvent.cs" id="2_8aewt"]
|
||||
|
|
@ -9,44 +9,115 @@
|
|||
[ext_resource type="Resource" uid="uid://nceohd32fkxk" path="res://resources/zombies/conehead.tres" id="7_yvl2y"]
|
||||
[ext_resource type="Resource" uid="uid://buvacn56kyy2p" path="res://resources/zombies/basic.tres" id="8_ulhin"]
|
||||
[ext_resource type="Resource" uid="uid://c38vfdw5b60xw" path="res://resources/zombies/hobo.tres" id="9_ulhin"]
|
||||
[ext_resource type="Resource" uid="uid://cugwy5bw4wljr" path="res://resources/zombies/door_zombie.tres" id="10_cafd0"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_yvl2y"]
|
||||
[sub_resource type="Resource" id="Resource_n6yt3"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, ExtResource("7_yvl2y"), ExtResource("6_s62qb"), ExtResource("6_s62qb"), null])
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, ExtResource("8_ulhin"), null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_s62qb"]
|
||||
[sub_resource type="Resource" id="Resource_8aewt"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_yvl2y")])
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_n6yt3")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 10.0
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_cafd0"]
|
||||
[sub_resource type="Resource" id="Resource_8h2xm"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, ExtResource("7_yvl2y"), null, ExtResource("7_yvl2y"), null])
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, ExtResource("8_ulhin"), null, ExtResource("8_ulhin"), null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_y8rkm"]
|
||||
[sub_resource type="Resource" id="Resource_3hvjc"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([ExtResource("8_ulhin"), null, ExtResource("8_ulhin"), null, ExtResource("8_ulhin")])
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, null, null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ulhin"]
|
||||
[sub_resource type="Resource" id="Resource_hlq35"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_cafd0"), SubResource("Resource_y8rkm")])
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_8h2xm"), SubResource("Resource_3hvjc")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lxlrs"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, ExtResource("8_ulhin"), null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8miqm"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_lxlrs")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_n6yt3"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, ExtResource("9_ulhin"), ExtResource("9_ulhin"), ExtResource("9_ulhin"), null])
|
||||
[sub_resource type="Resource" id="Resource_s62qb"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8h2xm"]
|
||||
[sub_resource type="Resource" id="Resource_ntuje"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([ExtResource("8_ulhin"), ExtResource("7_yvl2y"), ExtResource("6_s62qb"), ExtResource("7_yvl2y"), ExtResource("8_ulhin")])
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, ExtResource("8_ulhin"), null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_psuap"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, ExtResource("8_ulhin"), null, null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_yvl2y"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_ntuje"), SubResource("Resource_psuap")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_elhtc"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, null, ExtResource("8_ulhin"), null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_cmki6"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, ExtResource("8_ulhin"), null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_f5jkp"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, ExtResource("6_s62qb"), null, null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ulhin"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_elhtc"), SubResource("Resource_cmki6"), SubResource("Resource_f5jkp")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ipg75"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, ExtResource("9_ulhin"), null, null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_cafd0"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_ipg75")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_2tcqp"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([null, null, null, ExtResource("7_yvl2y"), null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_y8rkm"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_2tcqp")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6i5yw"]
|
||||
script = ExtResource("4_8miqm")
|
||||
zombies = Array[ExtResource("5_8miqm")]([ExtResource("10_cafd0"), ExtResource("8_ulhin"), ExtResource("6_s62qb"), ExtResource("7_yvl2y"), ExtResource("9_ulhin")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_dbrq5"]
|
||||
script = ExtResource("3_hlq35")
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_n6yt3"), SubResource("Resource_8h2xm")])
|
||||
zombiesOrdered = Array[ExtResource("4_8miqm")]([SubResource("Resource_6i5yw")])
|
||||
events = Array[ExtResource("2_8aewt")]([])
|
||||
customWaveDelay = 0.0
|
||||
isHugeWave = true
|
||||
|
|
@ -55,7 +126,7 @@ isHugeWave = true
|
|||
script = ExtResource("1_qb1ge")
|
||||
startSun = 50.0
|
||||
wavePercentage = 0.5
|
||||
standardWaveDelay = 8.0
|
||||
standardWaveDelay = 12.0
|
||||
initialWaveDelay = 20.0
|
||||
waves = [SubResource("Resource_s62qb"), SubResource("Resource_ulhin"), SubResource("Resource_dbrq5")]
|
||||
waves = [SubResource("Resource_8aewt"), SubResource("Resource_hlq35"), SubResource("Resource_8miqm"), SubResource("Resource_s62qb"), SubResource("Resource_yvl2y"), SubResource("Resource_ulhin"), SubResource("Resource_cafd0"), SubResource("Resource_y8rkm"), SubResource("Resource_dbrq5")]
|
||||
metadata/_custom_type_script = "uid://bximdujbkj2n4"
|
||||
|
|
|
|||
15
scenes/gui/flag.tscn
Normal file
15
scenes/gui/flag.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://drobbh5x1v7mi"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://6didix2twcty" path="res://assets/sprites/wave-progress/Flag.tres" id="1_ebgak"]
|
||||
[ext_resource type="Script" uid="uid://06ns8r18dalm" path="res://scripts/gui/WaveFlag.cs" id="2_fj7o6"]
|
||||
|
||||
[node name="Flag" type="TextureRect"]
|
||||
show_behind_parent = true
|
||||
anchors_preset = -1
|
||||
offset_left = -7.0
|
||||
offset_top = -22.0
|
||||
offset_right = 13.0
|
||||
texture = ExtResource("1_ebgak")
|
||||
stretch_mode = 5
|
||||
script = ExtResource("2_fj7o6")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
|
@ -271,5 +271,6 @@ fadeAnimation = NodePath("../GameOverScreen/AnimationPlayer")
|
|||
[node name="CollisionShape2D" parent="Checkbox" index="0"]
|
||||
shape = SubResource("WorldBoundaryShape2D_yw4uo")
|
||||
|
||||
[connection signal="HugeWaveInitiated" from="LevelRunner" to="GUI/WaveProgress" method="OnHugeWaveApproached"]
|
||||
[connection signal="ResourceChanged" from="LevelRunner" to="GUI/WaveProgress" method="SetLevelData"]
|
||||
[connection signal="WaveChanged" from="LevelRunner" to="GUI/WaveProgress" method="OnWaveChanged"]
|
||||
|
|
|
|||
17
scripts/gui/WaveFlag.cs
Normal file
17
scripts/gui/WaveFlag.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using Godot;
|
||||
|
||||
|
||||
public partial class WaveFlag : TextureRect
|
||||
{
|
||||
public int waveIndex;
|
||||
public double anim_time;
|
||||
public void HugeWaveApproached(int what)
|
||||
{
|
||||
if (waveIndex == what)
|
||||
{
|
||||
var tween = CreateTween().SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Cubic).SetParallel();
|
||||
tween.TweenProperty(this, "anchor_top", 0.1, anim_time);
|
||||
tween.TweenProperty(this, "anchor_bottom", 0.1, anim_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/gui/WaveFlag.cs.uid
Normal file
1
scripts/gui/WaveFlag.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://06ns8r18dalm
|
||||
|
|
@ -4,8 +4,10 @@ public partial class WaveProgress : TextureProgressBar
|
|||
{
|
||||
private TextureRect head;
|
||||
private Tween tween;
|
||||
|
||||
private PackedScene flagScene = ResourceLoader.Load<PackedScene>("uid://drobbh5x1v7mi");
|
||||
[Export] private double progressTime = 2.0f;
|
||||
[Signal] public delegate void HugeWaveInitiatedEventHandler(int waveNumber);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
head = GetNode<TextureRect>("Head");
|
||||
|
|
@ -15,12 +17,31 @@ public partial class WaveProgress : TextureProgressBar
|
|||
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);
|
||||
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;
|
||||
for (int i = 0; i < resource.waves.Count; i++)
|
||||
{
|
||||
if (resource.waves[i].isHugeWave)
|
||||
{
|
||||
var flag = flagScene.Instantiate<WaveFlag>();
|
||||
AddChild(flag);
|
||||
flag.AnchorTop = 0.5f;
|
||||
flag.AnchorBottom = 0.5f;
|
||||
flag.AnchorLeft = 1.0f - (float)(i + 1) / resource.waves.Count;
|
||||
flag.AnchorRight = 1.0f - (float)(i + 1) / resource.waves.Count;
|
||||
flag.anim_time = progressTime;
|
||||
flag.waveIndex = i;
|
||||
HugeWaveInitiated += flag.HugeWaveApproached;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnHugeWaveApproached(int what)
|
||||
{
|
||||
EmitSignal(SignalName.HugeWaveInitiated, what);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,31 @@ namespace Newlon.Components.Level;
|
|||
public partial class LevelRunner : Node
|
||||
{
|
||||
private AdventureLevelResource resource;
|
||||
private int waveIndex = -1;
|
||||
private bool hugeWaveApproaching = false;
|
||||
[Export] private RowSpawner rowSpawner;
|
||||
[Export] private Timer waveTimer;
|
||||
private int waveIndex = -1;
|
||||
[Export] private float approachNotificationTime;
|
||||
[Signal] public delegate void ResourceChangedEventHandler(AdventureLevelResource resource);
|
||||
[Signal] public delegate void WaveChangedEventHandler(int to);
|
||||
[Signal] public delegate void HugeWaveApproachingCallbackEventHandler();
|
||||
[Signal] public delegate void HugeWaveInitiatedEventHandler(int waveNumber);
|
||||
|
||||
public override void _Ready()
|
||||
public override void _Ready()
|
||||
{
|
||||
waveTimer.Timeout += SummonWave;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (waveTimer.TimeLeft < approachNotificationTime && resource.waves[waveIndex + 1].isHugeWave && hugeWaveApproaching == false)
|
||||
{
|
||||
hugeWaveApproaching = true;
|
||||
EmitSignal(SignalName.HugeWaveApproachingCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetLevelResource(AdventureLevelResource data)
|
||||
{
|
||||
resource = data;
|
||||
|
|
@ -29,7 +43,9 @@ public partial class LevelRunner : Node
|
|||
private void SummonWave()
|
||||
{
|
||||
waveIndex += 1;
|
||||
hugeWaveApproaching = false;
|
||||
EmitSignal(SignalName.WaveChanged, waveIndex);
|
||||
if (resource.waves[waveIndex].isHugeWave) EmitSignal(SignalName.HugeWaveInitiated, waveIndex);
|
||||
rowSpawner.Add(resource.waves[waveIndex].zombiesOrdered);
|
||||
|
||||
if (waveIndex == resource.waves.Count - 1) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue