level now should end correctly every time

This commit is contained in:
Rendo 2025-07-22 17:55:18 +05:00
commit 394b07db60
7 changed files with 53 additions and 25 deletions

View file

@ -281,7 +281,7 @@ wavePercentage = 0.5
standardWaveDelay = 30.0 standardWaveDelay = 30.0
initialWaveDelay = 20.0 initialWaveDelay = 20.0
reward = ExtResource("1_eqa0o") reward = ExtResource("1_eqa0o")
forbiddenPlants = Array[String](["wallnut", "aloe", "spikeweed"]) forbiddenPlants = Array[String](["aloe", "spikeweed", "peashooter", "wallnut"])
waves = [SubResource("Resource_c21si"), SubResource("Resource_icaa5"), SubResource("Resource_kc7t2"), SubResource("Resource_66y5q"), SubResource("Resource_tuvrx"), SubResource("Resource_t4nit"), SubResource("Resource_qx8xe"), SubResource("Resource_hyvhe"), SubResource("Resource_8syff"), SubResource("Resource_jfmww"), SubResource("Resource_vrqir"), SubResource("Resource_2seob"), SubResource("Resource_geil0"), SubResource("Resource_lxb1x"), SubResource("Resource_o5y12"), SubResource("Resource_diw66"), SubResource("Resource_pwwqn")] waves = [SubResource("Resource_c21si"), SubResource("Resource_icaa5"), SubResource("Resource_kc7t2"), SubResource("Resource_66y5q"), SubResource("Resource_tuvrx"), SubResource("Resource_t4nit"), SubResource("Resource_qx8xe"), SubResource("Resource_hyvhe"), SubResource("Resource_8syff"), SubResource("Resource_jfmww"), SubResource("Resource_vrqir"), SubResource("Resource_2seob"), SubResource("Resource_geil0"), SubResource("Resource_lxb1x"), SubResource("Resource_o5y12"), SubResource("Resource_diw66"), SubResource("Resource_pwwqn")]
initialScenes = Array[PackedScene]([null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]) initialScenes = Array[PackedScene]([null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null])
metadata/_custom_type_script = "uid://bximdujbkj2n4" metadata/_custom_type_script = "uid://bximdujbkj2n4"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before After
Before After

View file

@ -4,4 +4,4 @@
[resource] [resource]
atlas = ExtResource("1_sbmc0") atlas = ExtResource("1_sbmc0")
region = Rect2(569, 74, 11, 17) region = Rect2(562, 78, 27, 32)

View file

@ -27,7 +27,7 @@ config/windows_native_icon="res://icon.ico"
LevelController="*res://scripts/level/LevelController.cs" LevelController="*res://scripts/level/LevelController.cs"
Cursor="*res://scripts/Cursor.cs" Cursor="*res://scripts/Cursor.cs"
GameRegistry="*res://scripts/systems/GameRegistry.cs" GameRegistry="*res://scripts/systems/GameRegistry.cs"
Cheats="res://scripts/debug/Cheats.cs" Cheats="*res://scripts/debug/Cheats.cs"
AudioSequencer="*res://scenes/audio_sequencer.tscn" AudioSequencer="*res://scenes/audio_sequencer.tscn"
SaveSerializer="*res://scripts/SaveSerializer.cs" SaveSerializer="*res://scripts/SaveSerializer.cs"
PlayerProgress="*res://scripts/PlayerProgress.cs" PlayerProgress="*res://scripts/PlayerProgress.cs"
@ -36,12 +36,17 @@ PlayerProgress="*res://scripts/PlayerProgress.cs"
window/size/viewport_width=600 window/size/viewport_width=600
window/size/viewport_height=400 window/size/viewport_height=400
window/size/mode=4
window/stretch/mode="canvas_items" window/stretch/mode="canvas_items"
[dotnet] [dotnet]
project/assembly_name="NewLON" project/assembly_name="NewLON"
[editor]
movie_writer/movie_file="D:/Projects/GOIDA/newlon/clips/movie.avi"
[editor_plugins] [editor_plugins]
enabled=PackedStringArray("res://addons/floatmodifiers/plugin.cfg", "res://addons/pvzadventure/plugin.cfg") enabled=PackedStringArray("res://addons/floatmodifiers/plugin.cfg", "res://addons/pvzadventure/plugin.cfg")
@ -123,6 +128,7 @@ cheat_unlock_all={
[internationalization] [internationalization]
locale/translations=PackedStringArray("res://translations/plants.en.translation", "res://translations/plants.ru.translation", "res://translations/zombies.en.translation", "res://translations/zombies.ru.translation", "res://translations/gui.en.translation", "res://translations/gui.ru.translation", "res://translations/rewards.en.translation", "res://translations/rewards.ru.translation") locale/translations=PackedStringArray("res://translations/plants.en.translation", "res://translations/plants.ru.translation", "res://translations/zombies.en.translation", "res://translations/zombies.ru.translation", "res://translations/gui.en.translation", "res://translations/gui.ru.translation", "res://translations/rewards.en.translation", "res://translations/rewards.ru.translation")
locale/test="en"
[layer_names] [layer_names]

View file

@ -91,18 +91,18 @@ texture = ExtResource("4_6k60q")
[node name="LockedTexture" type="TextureRect" parent="."] [node name="LockedTexture" type="TextureRect" parent="."]
visible = false visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = -1
anchor_right = 1.0 anchor_left = 0.341463
anchor_bottom = 1.0 anchor_top = 0.339286
offset_left = 28.0 anchor_right = 0.658537
offset_top = 38.0 anchor_bottom = 0.660714
offset_right = -28.0
offset_bottom = -38.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
mouse_filter = 2 mouse_filter = 2
texture = ExtResource("5_tvxj3") texture = ExtResource("5_tvxj3")
expand_mode = 1
stretch_mode = 5 stretch_mode = 5
metadata/_edit_use_anchors_ = true
[node name="CostVeil" type="ColorRect" parent="."] [node name="CostVeil" type="ColorRect" parent="."]
visible = false visible = false

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=55 format=3 uid="uid://dd3yegl1xo44m"] [gd_scene load_steps=57 format=3 uid="uid://dd3yegl1xo44m"]
[ext_resource type="AudioStream" uid="uid://b6xb6mjdecg6a" path="res://assets/audio/sfx/level/readysetplant.mp3" id="1_4gg2g"] [ext_resource type="AudioStream" uid="uid://b6xb6mjdecg6a" path="res://assets/audio/sfx/level/readysetplant.mp3" id="1_4gg2g"]
[ext_resource type="Script" uid="uid://bndu1h5kgcde8" path="res://scripts/level/RuntimeLevelData.cs" id="1_31ltw"] [ext_resource type="Script" uid="uid://bndu1h5kgcde8" path="res://scripts/level/RuntimeLevelData.cs" id="1_31ltw"]
@ -37,7 +37,6 @@
[ext_resource type="AudioStream" uid="uid://cfybn7wn04frs" path="res://assets/audio/music/Grasswalk_Standard.mp3" id="34_tqd4v"] [ext_resource type="AudioStream" uid="uid://cfybn7wn04frs" path="res://assets/audio/music/Grasswalk_Standard.mp3" id="34_tqd4v"]
[ext_resource type="AudioStream" uid="uid://get7nh1goi1c" path="res://assets/audio/music/Grasswalk_cool.mp3" id="35_4gg2g"] [ext_resource type="AudioStream" uid="uid://get7nh1goi1c" path="res://assets/audio/music/Grasswalk_cool.mp3" id="35_4gg2g"]
[ext_resource type="Script" uid="uid://bnj5tlcpmep2o" path="res://scripts/MusicTransitioner.cs" id="36_wwgye"] [ext_resource type="Script" uid="uid://bnj5tlcpmep2o" path="res://scripts/MusicTransitioner.cs" id="36_wwgye"]
[ext_resource type="AudioStream" uid="uid://b0tyhgrhofdes" path="res://assets/audio/music/Grasswalk_filler.mp3" id="37_wwgye"]
[sub_resource type="Animation" id="Animation_vbgdr"] [sub_resource type="Animation" id="Animation_vbgdr"]
resource_name = "CYS_Sequence" resource_name = "CYS_Sequence"
@ -553,26 +552,30 @@ distance = 135.0
normal = Vector2(1, 0) normal = Vector2(1, 0)
distance = 139.0 distance = 139.0
[sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_wwgye"]
stream_count = 1
stream_0 = ExtResource("34_tqd4v")
[sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_4tlhg"]
stream_count = 1
stream_0 = ExtResource("35_4gg2g")
[sub_resource type="AudioStreamInteractive" id="AudioStreamInteractive_4tlhg"] [sub_resource type="AudioStreamInteractive" id="AudioStreamInteractive_4tlhg"]
clip_count = 3 clip_count = 2
clip_0/name = &"Grasswalk Standard" clip_0/name = &"Standard"
clip_0/stream = ExtResource("34_tqd4v") clip_0/stream = SubResource("AudioStreamPlaylist_wwgye")
clip_0/auto_advance = 0 clip_0/auto_advance = 0
clip_1/name = &"Filler" clip_1/name = &"Cool"
clip_1/stream = ExtResource("37_wwgye") clip_1/stream = SubResource("AudioStreamPlaylist_4tlhg")
clip_1/auto_advance = 1 clip_1/auto_advance = 0
clip_1/next_clip = 2
clip_2/name = &"Grasswalk Cool"
clip_2/stream = ExtResource("35_4gg2g")
clip_2/auto_advance = 0
_transitions = { _transitions = {
Vector2i(0, 1): { Vector2i(0, 1): {
"fade_beats": 5.0, "fade_beats": 5.0,
"fade_mode": 3, "fade_mode": 3,
"from_time": 0, "from_time": 0,
"to_time": 1 "to_time": 0
}, },
Vector2i(2, 0): { Vector2i(1, 0): {
"fade_beats": 5.0, "fade_beats": 5.0,
"fade_mode": 4, "fade_mode": 4,
"from_time": 0, "from_time": 0,
@ -580,6 +583,15 @@ Vector2i(2, 0): {
} }
} }
[sub_resource type="GDScript" id="GDScript_4gg2g"]
script/source = "extends Label
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
print(str($\"../LevelRunner\".waveHealth))
"
[node name="StandardLevel" type="Node2D"] [node name="StandardLevel" type="Node2D"]
[node name="MainAnimationPlayer" type="AnimationPlayer" parent="."] [node name="MainAnimationPlayer" type="AnimationPlayer" parent="."]
@ -892,6 +904,13 @@ ignore_time_scale = true
[node name="ReadySetPlantPlayer" type="AudioStreamPlayer" parent="."] [node name="ReadySetPlantPlayer" type="AudioStreamPlayer" parent="."]
[node name="Label" type="Label" parent="."]
offset_left = 308.0
offset_top = 378.0
offset_right = 348.0
offset_bottom = 395.0
script = SubResource("GDScript_4gg2g")
[connection signal="OnLevelStateChanged" from="Data" to="SunSpawner/Timer" method="OnLevelStateChanged"] [connection signal="OnLevelStateChanged" from="Data" to="SunSpawner/Timer" method="OnLevelStateChanged"]
[connection signal="OnLevelStateChanged" from="Data" to="ZombieLevelPrevewer" method="OnLevelStateChanged"] [connection signal="OnLevelStateChanged" from="Data" to="ZombieLevelPrevewer" method="OnLevelStateChanged"]
[connection signal="OnLevelStateChanged" from="Data" to="InitialSpawner" method="OnLevelStateChanged"] [connection signal="OnLevelStateChanged" from="Data" to="InitialSpawner" method="OnLevelStateChanged"]

View file

@ -13,6 +13,7 @@ public partial class LevelRunner : Node
private bool rewardGiven = false; private bool rewardGiven = false;
public float waveHealth = 0; public float waveHealth = 0;
public float waveHealthMax = 0; public float waveHealthMax = 0;
public int aliveZombies = 0;
public List<RuntimeZombieData> zombies = []; public List<RuntimeZombieData> zombies = [];
[Export] private MoneyReward defaultReward; [Export] private MoneyReward defaultReward;
[Export] private RowSpawner rowSpawner; [Export] private RowSpawner rowSpawner;
@ -128,12 +129,14 @@ public partial class LevelRunner : Node
if (waveIndex == resource.waves.Count - 1) if (waveIndex == resource.waves.Count - 1)
{ {
aliveZombies+=1;
zombie.HasBeenKilled += OnLastZombieKilled; zombie.HasBeenKilled += OnLastZombieKilled;
} }
} }
private void OnLastZombieKilled(RuntimeZombieData who) private void OnLastZombieKilled(RuntimeZombieData who)
{ {
if (waveHealth > 0) return; aliveZombies -= 1;
if (aliveZombies > 0) return;
SpawnReward(who.GlobalPosition); SpawnReward(who.GlobalPosition);
} }