diff --git a/scenes/entities/Zombies/zombie.tscn b/scenes/entities/Zombies/zombie.tscn index b73ed79..93c6e02 100644 --- a/scenes/entities/Zombies/zombie.tscn +++ b/scenes/entities/Zombies/zombie.tscn @@ -833,7 +833,7 @@ metadata/_edit_lock_ = true [node name="RightLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg"] position = Vector2(-2, 12) -scale = Vector2(0.999836, 0.999836) +scale = Vector2(0.999837, 0.999837) rest = Transform2D(1, 0, 0, 1, -2, 12) editor_settings/show_bone_gizmo = false @@ -902,7 +902,7 @@ metadata/_edit_lock_ = true [node name="Body" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"] use_parent_material = true position = Vector2(1, -2) -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999826, 0.999826) rest = Transform2D(1, 0, 0, 1, 1, -2) editor_settings/show_bone_gizmo = false diff --git a/scenes/templates/standard_players_house.tscn b/scenes/templates/standard_players_house.tscn index 64da0c4..5d9fd74 100644 --- a/scenes/templates/standard_players_house.tscn +++ b/scenes/templates/standard_players_house.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://bu0dh5ct387xu"] +[gd_scene load_steps=16 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"] @@ -6,6 +6,7 @@ [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"] +[ext_resource type="Script" uid="uid://bc3s06ejbotma" path="res://scripts/gui/ZombieLevelPreviewer.cs" id="7_8ajos"] [sub_resource type="Animation" id="Animation_vbgdr"] resource_name = "CYS_Sequence" @@ -324,13 +325,18 @@ approachNotificationTime = 5.0 [node name="WaveTimer" type="Timer" parent="LevelRunner" index="0"] one_shot = true -[node name="Checkbox" parent="." index="16" node_paths=PackedStringArray("gameOverLayer", "fadeAnimation")] +[node name="ZombieLevelPrevewer" type="Node2D" parent="." index="16"] +position = Vector2(855, 76) +script = ExtResource("7_8ajos") + +[node name="Checkbox" parent="." index="17" node_paths=PackedStringArray("gameOverLayer", "fadeAnimation")] gameOverLayer = NodePath("../GameOverZombie") fadeAnimation = NodePath("../GameOverScreen/AnimationPlayer") [node name="CollisionShape2D" parent="Checkbox" index="0"] shape = SubResource("WorldBoundaryShape2D_yw4uo") +[connection signal="OnLevelStateChanged" from="Data" to="ZombieLevelPrevewer" method="OnLevelStateChanged"] [connection signal="FinalWaveInitiated" from="LevelRunner" to="MainAnimationPlayer" method="play" binds= ["FW_Sequence"]] [connection signal="HugeWaveApproachingCallback" from="LevelRunner" to="MainAnimationPlayer" method="play" binds= ["HW_Sequence"]] [connection signal="HugeWaveInitiated" from="LevelRunner" to="GUI/WaveProgress" method="OnHugeWaveApproached"] diff --git a/scripts/gui/ZombieLevelPreviewer.cs b/scripts/gui/ZombieLevelPreviewer.cs new file mode 100644 index 0000000..30ccc08 --- /dev/null +++ b/scripts/gui/ZombieLevelPreviewer.cs @@ -0,0 +1,56 @@ +using Godot; +using Newlon.Components.Zombies; +using System.Collections.Generic; + +namespace Newlon.Components.Level; + +public partial class ZombieLevelPreviewer : Node2D +{ + public void OnLevelStateChanged(RuntimeLevelData.LevelStates state) + { + switch (state) + { + case RuntimeLevelData.LevelStates.ChooseYourSeeds: + SetupZombies(); + break; + case RuntimeLevelData.LevelStates.Pregame: + break; + default: + QueueFree(); + break; + } + } + public void SetupZombies() + { + var to_spawn = FindUnique(); + + foreach (var zombie in to_spawn) + { + var rng_x = (float)GD.RandRange(0.0, 2.0); + var rng_y = (float)GD.RandRange(1.0, 5.0); + + var spawned = zombie.Scene.Instantiate(); + spawned.DisableBrain(); + AddChild(spawned); + spawned.Position += new Vector2(rng_x*Utility.TileWidth, rng_y*Utility.TileHeight); + } + } + public List FindUnique() + { + List zombies = new(); + + foreach (var wave in RuntimeLevelData.Instance.levelResource.waves) + { + foreach (var spawn in wave.zombiesOrdered) + { + foreach (var zombie in spawn.zombies) + { + if (zombie == null || zombies.Contains(zombie)) continue; + zombies.Add(zombie); + } + } + } + + return zombies; + } +} diff --git a/scripts/gui/ZombieLevelPreviewer.cs.uid b/scripts/gui/ZombieLevelPreviewer.cs.uid new file mode 100644 index 0000000..1c59440 --- /dev/null +++ b/scripts/gui/ZombieLevelPreviewer.cs.uid @@ -0,0 +1 @@ +uid://bc3s06ejbotma