game registry internal refactor
This commit is contained in:
parent
be2ebf1223
commit
d5573db251
11 changed files with 68 additions and 188 deletions
|
|
@ -1,41 +0,0 @@
|
||||||
[gd_scene load_steps=2 format=3 uid="uid://cubfkr2mkgxjc"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dac0bvlhho7u4" path="res://scripts/DebugZombieSpawner.cs" id="1_m367a"]
|
|
||||||
|
|
||||||
[node name="DebugZombieSpawner" type="PopupPanel" node_paths=PackedStringArray("label", "line", "spin")]
|
|
||||||
initial_position = 1
|
|
||||||
size = Vector2i(200, 100)
|
|
||||||
visible = true
|
|
||||||
script = ExtResource("1_m367a")
|
|
||||||
label = NodePath("Vbox/Similars")
|
|
||||||
line = NodePath("Vbox/Line/LineEdit")
|
|
||||||
spin = NodePath("Vbox/Line/SpinBox")
|
|
||||||
|
|
||||||
[node name="Vbox" type="VBoxContainer" parent="."]
|
|
||||||
offset_left = 4.0
|
|
||||||
offset_top = 4.0
|
|
||||||
offset_right = 196.0
|
|
||||||
offset_bottom = 96.0
|
|
||||||
|
|
||||||
[node name="Line" type="HBoxContainer" parent="Vbox"]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="LineEdit" type="LineEdit" parent="Vbox/Line"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
focus_next = NodePath("../SpinBox")
|
|
||||||
max_length = 16
|
|
||||||
|
|
||||||
[node name="SpinBox" type="SpinBox" parent="Vbox/Line"]
|
|
||||||
layout_mode = 2
|
|
||||||
min_value = 1.0
|
|
||||||
max_value = 50.0
|
|
||||||
value = 1.0
|
|
||||||
|
|
||||||
[node name="Similars" type="Label" parent="Vbox"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_vertical = 3
|
|
||||||
|
|
||||||
[connection signal="popup_hide" from="." to="." method="OnPopupHide"]
|
|
||||||
[connection signal="text_changed" from="Vbox/Line/LineEdit" to="." method="OnTextChanged"]
|
|
||||||
[connection signal="text_submitted" from="Vbox/Line/LineEdit" to="." method="OnTextSubmitted"]
|
|
||||||
|
|
@ -814,7 +814,7 @@ metadata/_edit_lock_ = true
|
||||||
[node name="RightUpperLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"]
|
[node name="RightUpperLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"]
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
position = Vector2(-6, 3)
|
position = Vector2(-6, 3)
|
||||||
scale = Vector2(0.999836, 0.999836)
|
scale = Vector2(0.999837, 0.999837)
|
||||||
rest = Transform2D(1, 0, 0, 1, -6, 3)
|
rest = Transform2D(1, 0, 0, 1, -6, 3)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
|
|
@ -826,13 +826,13 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="RightLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg"]
|
[node name="RightLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg"]
|
||||||
position = Vector2(-2, 12)
|
position = Vector2(-2, 12)
|
||||||
scale = Vector2(0.999837, 0.999837)
|
scale = Vector2(0.99983, 0.99983)
|
||||||
rest = Transform2D(1, 0, 0, 1, -2, 12)
|
rest = Transform2D(1, 0, 0, 1, -2, 12)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
[node name="RightFoot" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg"]
|
[node name="RightFoot" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg"]
|
||||||
position = Vector2(-2, 14)
|
position = Vector2(-2, 14)
|
||||||
scale = Vector2(0.999832, 0.999832)
|
scale = Vector2(0.999834, 0.999834)
|
||||||
rest = Transform2D(1, 0, 0, 1, -2, 14)
|
rest = Transform2D(1, 0, 0, 1, -2, 14)
|
||||||
auto_calculate_length_and_angle = false
|
auto_calculate_length_and_angle = false
|
||||||
length = 12.0
|
length = 12.0
|
||||||
|
|
@ -855,7 +855,7 @@ metadata/_edit_lock_ = true
|
||||||
[node name="LeftUpperLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"]
|
[node name="LeftUpperLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"]
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
position = Vector2(6, 4)
|
position = Vector2(6, 4)
|
||||||
scale = Vector2(0.99983, 0.99983)
|
scale = Vector2(0.999834, 0.999834)
|
||||||
rest = Transform2D(1, 0, 0, 1, 6, 4)
|
rest = Transform2D(1, 0, 0, 1, 6, 4)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
|
|
@ -867,7 +867,7 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="LeftLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg"]
|
[node name="LeftLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg"]
|
||||||
position = Vector2(-1, 13)
|
position = Vector2(-1, 13)
|
||||||
scale = Vector2(0.999835, 0.999835)
|
scale = Vector2(0.99983, 0.99983)
|
||||||
rest = Transform2D(1, 0, 0, 1, -1, 13)
|
rest = Transform2D(1, 0, 0, 1, -1, 13)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
|
|
@ -879,7 +879,7 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="LeftFoot" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg"]
|
[node name="LeftFoot" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg"]
|
||||||
position = Vector2(6, 10)
|
position = Vector2(6, 10)
|
||||||
scale = Vector2(0.999833, 0.999833)
|
scale = Vector2(0.999824, 0.999824)
|
||||||
rest = Transform2D(1, 0, 0, 1, 6, 10)
|
rest = Transform2D(1, 0, 0, 1, 6, 10)
|
||||||
auto_calculate_length_and_angle = false
|
auto_calculate_length_and_angle = false
|
||||||
length = 12.0
|
length = 12.0
|
||||||
|
|
@ -903,7 +903,7 @@ editor_settings/show_bone_gizmo = false
|
||||||
z_index = -1
|
z_index = -1
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
position = Vector2(-14, -23)
|
position = Vector2(-14, -23)
|
||||||
scale = Vector2(0.999827, 0.999827)
|
scale = Vector2(0.999829, 0.999829)
|
||||||
rest = Transform2D(1, 0, 0, 1, -14, -23)
|
rest = Transform2D(1, 0, 0, 1, -14, -23)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
|
|
@ -915,13 +915,13 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="RightLowerArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm"]
|
[node name="RightLowerArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm"]
|
||||||
position = Vector2(-2, 15)
|
position = Vector2(-2, 15)
|
||||||
scale = Vector2(0.999826, 0.999826)
|
scale = Vector2(0.999829, 0.999829)
|
||||||
rest = Transform2D(1, 0, 0, 1, -2, 15)
|
rest = Transform2D(1, 0, 0, 1, -2, 15)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
[node name="RightHand" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm"]
|
[node name="RightHand" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm"]
|
||||||
position = Vector2(-1, 13)
|
position = Vector2(-1, 13)
|
||||||
scale = Vector2(0.999829, 0.999829)
|
scale = Vector2(0.999824, 0.999824)
|
||||||
rest = Transform2D(1, 0, 0, 1, -1, 13)
|
rest = Transform2D(1, 0, 0, 1, -1, 13)
|
||||||
auto_calculate_length_and_angle = false
|
auto_calculate_length_and_angle = false
|
||||||
length = 8.0
|
length = 8.0
|
||||||
|
|
@ -949,8 +949,8 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="Tie" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"]
|
[node name="Tie" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"]
|
||||||
position = Vector2(-9, -21)
|
position = Vector2(-9, -21)
|
||||||
rotation = 0.0566317
|
rotation = 0.12179
|
||||||
skew = -0.0004673
|
skew = -0.000472784
|
||||||
rest = Transform2D(1, 0, 0, 1, -9, -21)
|
rest = Transform2D(1, 0, 0, 1, -9, -21)
|
||||||
auto_calculate_length_and_angle = false
|
auto_calculate_length_and_angle = false
|
||||||
length = 24.0
|
length = 24.0
|
||||||
|
|
@ -965,7 +965,7 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="Head" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"]
|
[node name="Head" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"]
|
||||||
position = Vector2(-10, -25)
|
position = Vector2(-10, -25)
|
||||||
scale = Vector2(0.999832, 0.999832)
|
scale = Vector2(0.999829, 0.999829)
|
||||||
rest = Transform2D(1, 0, 0, 1, -10, -25)
|
rest = Transform2D(1, 0, 0, 1, -10, -25)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
|
|
@ -988,7 +988,6 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="Right_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
|
[node name="Right_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
|
||||||
position = Vector2(-16, -8)
|
position = Vector2(-16, -8)
|
||||||
scale = Vector2(1, 1)
|
|
||||||
texture = SubResource("AtlasTexture_vcc72")
|
texture = SubResource("AtlasTexture_vcc72")
|
||||||
centered = false
|
centered = false
|
||||||
offset = Vector2(-2, -2)
|
offset = Vector2(-2, -2)
|
||||||
|
|
@ -996,15 +995,14 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="Left_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
|
[node name="Left_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
|
||||||
position = Vector2(-4, -9)
|
position = Vector2(-4, -9)
|
||||||
scale = Vector2(1, 1)
|
|
||||||
texture = SubResource("AtlasTexture_kto0i")
|
texture = SubResource("AtlasTexture_kto0i")
|
||||||
centered = false
|
centered = false
|
||||||
offset = Vector2(-2, -2)
|
offset = Vector2(-2, -2)
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="Jaw" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
|
[node name="Jaw" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
|
||||||
position = Vector2(-3.0007, 2.99882)
|
position = Vector2(-3.00149, 2.99746)
|
||||||
rotation = 0.00549593
|
rotation = 0.0118193
|
||||||
scale = Vector2(0.999828, 0.999828)
|
scale = Vector2(0.999828, 0.999828)
|
||||||
texture = SubResource("AtlasTexture_x5uj2")
|
texture = SubResource("AtlasTexture_x5uj2")
|
||||||
centered = false
|
centered = false
|
||||||
|
|
@ -1056,7 +1054,7 @@ remote_path = NodePath("../../HeadParticle/Head/Left_Eye")
|
||||||
|
|
||||||
[node name="LeftUpperArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"]
|
[node name="LeftUpperArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"]
|
||||||
position = Vector2(-1, -20)
|
position = Vector2(-1, -20)
|
||||||
scale = Vector2(0.999826, 0.999826)
|
scale = Vector2(0.999835, 0.999835)
|
||||||
rest = Transform2D(1, 0, 0, 1, -1, -20)
|
rest = Transform2D(1, 0, 0, 1, -1, -20)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
|
|
@ -1078,8 +1076,8 @@ minTorque = -45.0
|
||||||
maxTorque = 45.0
|
maxTorque = 45.0
|
||||||
|
|
||||||
[node name="Left_Lower_Arm" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile"]
|
[node name="Left_Lower_Arm" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile"]
|
||||||
rotation = 0.0532462
|
rotation = 0.114509
|
||||||
scale = Vector2(0.999998, 0.999998)
|
scale = Vector2(1, 1)
|
||||||
texture = SubResource("AtlasTexture_auqeq")
|
texture = SubResource("AtlasTexture_auqeq")
|
||||||
centered = false
|
centered = false
|
||||||
offset = Vector2(-5, 0)
|
offset = Vector2(-5, 0)
|
||||||
|
|
@ -1088,7 +1086,7 @@ metadata/_edit_lock_ = true
|
||||||
[node name="Left_Hand" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm"]
|
[node name="Left_Hand" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm"]
|
||||||
show_behind_parent = true
|
show_behind_parent = true
|
||||||
position = Vector2(-0.99983, 12.9978)
|
position = Vector2(-0.99983, 12.9978)
|
||||||
rotation = -0.0234996
|
rotation = -0.0505374
|
||||||
scale = Vector2(0.99966, 0.99966)
|
scale = Vector2(0.99966, 0.99966)
|
||||||
texture = SubResource("AtlasTexture_vlvtp")
|
texture = SubResource("AtlasTexture_vlvtp")
|
||||||
centered = false
|
centered = false
|
||||||
|
|
@ -1105,13 +1103,13 @@ _observedEntity = NodePath("../../../../../../../..")
|
||||||
|
|
||||||
[node name="LeftLowerArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm"]
|
[node name="LeftLowerArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm"]
|
||||||
position = Vector2(-2, 14)
|
position = Vector2(-2, 14)
|
||||||
scale = Vector2(0.999828, 0.999828)
|
scale = Vector2(0.99983, 0.99983)
|
||||||
rest = Transform2D(1, 0, 0, 1, -2, 14)
|
rest = Transform2D(1, 0, 0, 1, -2, 14)
|
||||||
editor_settings/show_bone_gizmo = false
|
editor_settings/show_bone_gizmo = false
|
||||||
|
|
||||||
[node name="LeftHand" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm"]
|
[node name="LeftHand" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm"]
|
||||||
position = Vector2(-1, 13)
|
position = Vector2(-1, 13)
|
||||||
scale = Vector2(0.99983, 0.99983)
|
scale = Vector2(0.999829, 0.999829)
|
||||||
rest = Transform2D(1, 0, 0, 1, -1, 13)
|
rest = Transform2D(1, 0, 0, 1, -1, 13)
|
||||||
auto_calculate_length_and_angle = false
|
auto_calculate_length_and_angle = false
|
||||||
length = 6.0
|
length = 6.0
|
||||||
|
|
@ -1161,6 +1159,7 @@ entity = NodePath("..")
|
||||||
[node name="Mover" type="Node" parent="."]
|
[node name="Mover" type="Node" parent="."]
|
||||||
script = ExtResource("4_u5syx")
|
script = ExtResource("4_u5syx")
|
||||||
_speed = SubResource("Resource_ckb7n")
|
_speed = SubResource("Resource_ckb7n")
|
||||||
|
_speedControlMult = 0.740519
|
||||||
|
|
||||||
[node name="HitPlayer" type="Node" parent="."]
|
[node name="HitPlayer" type="Node" parent="."]
|
||||||
script = ExtResource("12_he8da")
|
script = ExtResource("12_he8da")
|
||||||
|
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
using Godot;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public partial class DebugZombieSpawner : PopupPanel
|
|
||||||
{
|
|
||||||
private List<string> variants;
|
|
||||||
[Export] private Label label;
|
|
||||||
[Export] private LineEdit line;
|
|
||||||
[Export] private SpinBox spin;
|
|
||||||
|
|
||||||
public void OnTextChanged(string text)
|
|
||||||
{
|
|
||||||
variants = GameRegistry.GetZombieNames();
|
|
||||||
variants.Sort(Comparer);
|
|
||||||
|
|
||||||
if (variants.Count > 3)
|
|
||||||
{
|
|
||||||
label.Text = $"{variants[0]}\n{variants[1]}\n{variants[2]}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
label.Text = "";
|
|
||||||
for (int i = 0; i < variants.Count; i++)
|
|
||||||
{
|
|
||||||
label.Text += variants[i] + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void OnTextSubmitted(string text)
|
|
||||||
{
|
|
||||||
spin.GrabFocus();
|
|
||||||
}
|
|
||||||
public void OnPopupHide()
|
|
||||||
{
|
|
||||||
if (variants == null || variants.Count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ZombieSequencer.Instance.DebugClearQueue();
|
|
||||||
for(int i = 0; i < spin.Value; i++)
|
|
||||||
{
|
|
||||||
ZombieSequencer.Instance.Add(variants[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
QueueFree();
|
|
||||||
}
|
|
||||||
private int Comparer(string x, string y)
|
|
||||||
{
|
|
||||||
return LevensteinDistance(x,line.Text) - LevensteinDistance(y,line.Text);
|
|
||||||
}
|
|
||||||
private static int LevensteinDistance(string a, string b)
|
|
||||||
{
|
|
||||||
if (b.Length == 0)
|
|
||||||
{
|
|
||||||
return a.Length;
|
|
||||||
}
|
|
||||||
else if (a.Length == 0)
|
|
||||||
{
|
|
||||||
return b.Length;
|
|
||||||
}
|
|
||||||
else if (a[0] == b[0])
|
|
||||||
{
|
|
||||||
return LevensteinDistance(a[1..], b[1..]);
|
|
||||||
}
|
|
||||||
List<int> x = [LevensteinDistance(a[1..], b[1..]), LevensteinDistance(a[1..], b), LevensteinDistance(a, b[1..])];
|
|
||||||
return 1 + x.Min();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://dac0bvlhho7u4
|
|
||||||
|
|
@ -72,7 +72,7 @@ public partial class SaveSerializer : Node
|
||||||
|
|
||||||
foreach (var plantId in parsed.PlayerPlants)
|
foreach (var plantId in parsed.PlayerPlants)
|
||||||
{
|
{
|
||||||
playerProgress.PlayerPlants.Add(GameRegistry.GetPlantByName(plantId));
|
playerProgress.PlayerPlants.Add((PlantResource)GameRegistry.GetEntityByName(plantId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ public partial class SaveSerializer : Node
|
||||||
}
|
}
|
||||||
private static void InitiateCleanSave()
|
private static void InitiateCleanSave()
|
||||||
{
|
{
|
||||||
PlayerProgress.Instance.PlayerPlants = new List<PlantResource>([GameRegistry.GetPlantByName("peashooter")]);
|
PlayerProgress.Instance.PlayerPlants = new List<PlantResource>([(PlantResource)GameRegistry.GetEntityByName("peashooter")]);
|
||||||
PlayerProgress.Instance.Money = 0;
|
PlayerProgress.Instance.Money = 0;
|
||||||
|
|
||||||
SaveGame();
|
SaveGame();
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,6 @@ public partial class Cheats : Node
|
||||||
{
|
{
|
||||||
RuntimeLevelData.Instance.AddSun(50);
|
RuntimeLevelData.Instance.AddSun(50);
|
||||||
}
|
}
|
||||||
if (@event.IsActionPressed("cheat_zombie_spawn"))
|
|
||||||
{
|
|
||||||
var spawner = GD.Load<PackedScene>("res://scenes/debug_zombie_spawner.tscn").Instantiate<DebugZombieSpawner>();
|
|
||||||
|
|
||||||
GetTree().CurrentScene.AddChild(spawner);
|
|
||||||
}
|
|
||||||
if (@event.IsActionPressed("cheat_unlock_all"))
|
if (@event.IsActionPressed("cheat_unlock_all"))
|
||||||
{
|
{
|
||||||
PlayerProgress.Instance.PlayerPlants = GameRegistry.GetPlants();
|
PlayerProgress.Instance.PlayerPlants = GameRegistry.GetPlants();
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,11 @@ using Newlon.Components.GUI.Seedpackets;
|
||||||
|
|
||||||
public partial class AlmanachGrid : GridContainer
|
public partial class AlmanachGrid : GridContainer
|
||||||
{
|
{
|
||||||
private PackedScene _plantCard;
|
private PackedScene _plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
||||||
[Export]
|
[Export]
|
||||||
private bool _zombies;
|
private bool _zombies;
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
|
||||||
|
|
||||||
if (_zombies)
|
if (_zombies)
|
||||||
{
|
{
|
||||||
var list = GameRegistry.GetZombies();
|
var list = GameRegistry.GetZombies();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using Newlon;
|
||||||
using Newlon.Components;
|
using Newlon.Components;
|
||||||
using Newlon.Components.Level;
|
using Newlon.Components.Level;
|
||||||
using Newlon.Components.Plants;
|
using Newlon.Components.Plants;
|
||||||
|
|
@ -37,7 +38,7 @@ public partial class InitialPackedSceneSpawner : Node
|
||||||
{
|
{
|
||||||
PoolContainer.Instance.Plants.AddChild(plant);
|
PoolContainer.Instance.Plants.AddChild(plant);
|
||||||
node.GlobalPosition = position;
|
node.GlobalPosition = position;
|
||||||
plant.Resource = GameRegistry.GetPlantByName(plant.internal_id);
|
plant.Resource = GameRegistry.GetEntityByName(plant.internal_id) as PlantResource;
|
||||||
PoolContainer.Instance.EntityField[plant.Resource.Layer].Add(plant.GlobalPosition, plant);
|
PoolContainer.Instance.EntityField[plant.Resource.Layer].Add(plant.GlobalPosition, plant);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ public partial class SurvivalZombieSpawner : Node
|
||||||
List<ZombieResource> list = [];
|
List<ZombieResource> list = [];
|
||||||
foreach (var res in pool)
|
foreach (var res in pool)
|
||||||
{
|
{
|
||||||
list.Add(GameRegistry.GetZombieByName(res));
|
list.Add(GameRegistry.GetEntityByName(res) as ZombieResource);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ public partial class ZombieSequencer : Node2D
|
||||||
|
|
||||||
private void Spawn(string id, int lane)
|
private void Spawn(string id, int lane)
|
||||||
{
|
{
|
||||||
RuntimeZombieData zombie = GameRegistry.GetZombieByName(id).Scene.Instantiate<RuntimeZombieData>();
|
RuntimeZombieData zombie = GameRegistry.GetEntityByName(id).Scene.Instantiate<RuntimeZombieData>();
|
||||||
PoolContainer.Instance.Zombies.AddChild(zombie);
|
PoolContainer.Instance.Zombies.AddChild(zombie);
|
||||||
|
|
||||||
zombie.GlobalPosition = new Vector2(GlobalPosition.X, FieldParams.RightFieldBoundary.Y - (lane - 1) * FieldParams.TileHeight);
|
zombie.GlobalPosition = new Vector2(GlobalPosition.X, FieldParams.RightFieldBoundary.Y - (lane - 1) * FieldParams.TileHeight);
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@ public partial class GameRegistry : Node
|
||||||
private const string PLANT_RESOURCE_PATH = "res://assets/plants/";
|
private const string PLANT_RESOURCE_PATH = "res://assets/plants/";
|
||||||
private const string ZOMBIE_RESOURCE_PATH = "res://assets/zombies/";
|
private const string ZOMBIE_RESOURCE_PATH = "res://assets/zombies/";
|
||||||
public static GameRegistry Instance { get; private set; }
|
public static GameRegistry Instance { get; private set; }
|
||||||
public static readonly Dictionary<string, PlantResource> PlantDictionary = [];
|
public static readonly Dictionary<string, DisplayResource> EntityDictionary = [];
|
||||||
public static readonly Dictionary<string, ZombieResource> ZombieDictionary = [];
|
|
||||||
|
|
||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
|
|
@ -21,10 +20,9 @@ public partial class GameRegistry : Node
|
||||||
{
|
{
|
||||||
var plant = ResourceLoader.Load<PlantResource>(PLANT_RESOURCE_PATH + file);
|
var plant = ResourceLoader.Load<PlantResource>(PLANT_RESOURCE_PATH + file);
|
||||||
plant.internal_id = file.ToLower().Split('.')[0];
|
plant.internal_id = file.ToLower().Split('.')[0];
|
||||||
PlantDictionary.Add(file.ToLower().Split('.')[0], plant);
|
EntityDictionary.Add(file.ToLower().Split('.')[0], plant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zombie init
|
//Zombie init
|
||||||
string[] zombieFiles = ResourceLoader.ListDirectory(ZOMBIE_RESOURCE_PATH);
|
string[] zombieFiles = ResourceLoader.ListDirectory(ZOMBIE_RESOURCE_PATH);
|
||||||
|
|
||||||
|
|
@ -34,66 +32,67 @@ public partial class GameRegistry : Node
|
||||||
{
|
{
|
||||||
var zombie = ResourceLoader.Load<ZombieResource>(ZOMBIE_RESOURCE_PATH + file);
|
var zombie = ResourceLoader.Load<ZombieResource>(ZOMBIE_RESOURCE_PATH + file);
|
||||||
zombie.internal_id = file.ToLower().Split('.')[0];
|
zombie.internal_id = file.ToLower().Split('.')[0];
|
||||||
ZombieDictionary.Add(file.ToLower().Split('.')[0], zombie);
|
EntityDictionary.Add(file.ToLower().Split('.')[0], zombie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlantResource GetPlantByName(string name)
|
public static DisplayResource GetEntityByName(string name)
|
||||||
{
|
{
|
||||||
if (PlantDictionary.ContainsKey(name) == false) return null;
|
if (EntityDictionary.ContainsKey(name) == false) return null;
|
||||||
return PlantDictionary[name];
|
return EntityDictionary[name];
|
||||||
}
|
}
|
||||||
public static List<string> GetPlantNames()
|
public static List<string> GetEntityNames()
|
||||||
{
|
{
|
||||||
List<string> result = [];
|
List<string> result = [];
|
||||||
foreach (var key in PlantDictionary.Keys)
|
foreach (var key in EntityDictionary.Keys)
|
||||||
{
|
{
|
||||||
result.Add(key);
|
result.Add(key);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public static List<DisplayResource> GetEntities()
|
||||||
|
{
|
||||||
|
List<DisplayResource> result = [];
|
||||||
|
foreach (var value in EntityDictionary.Values)
|
||||||
|
{
|
||||||
|
result.Add(value);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public static List<PlantResource> GetPlants()
|
public static List<PlantResource> GetPlants()
|
||||||
{
|
{
|
||||||
List<PlantResource> result = [];
|
var entities = GetEntities();
|
||||||
foreach (var value in PlantDictionary.Values)
|
List<PlantResource> plants = [];
|
||||||
{
|
|
||||||
result.Add(value);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public static int GetPlantCount()
|
|
||||||
{
|
|
||||||
return PlantDictionary.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ZombieResource GetZombieByName(string name)
|
foreach (var entity in entities)
|
||||||
{
|
|
||||||
if (ZombieDictionary.ContainsKey(name) == false) return null;
|
|
||||||
return ZombieDictionary[name];
|
|
||||||
}
|
|
||||||
public static List<string> GetZombieNames()
|
|
||||||
{
|
|
||||||
List<string> result = [];
|
|
||||||
foreach (var key in ZombieDictionary.Keys)
|
|
||||||
{
|
{
|
||||||
result.Add(key);
|
if (entity is PlantResource plant)
|
||||||
|
{
|
||||||
|
plants.Add(plant);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
return plants;
|
||||||
}
|
}
|
||||||
public static List<ZombieResource> GetZombies()
|
public static List<ZombieResource> GetZombies()
|
||||||
{
|
{
|
||||||
List<ZombieResource> result = [];
|
var entities = GetEntities();
|
||||||
foreach (var value in ZombieDictionary.Values)
|
List<ZombieResource> zombies = [];
|
||||||
{
|
|
||||||
result.Add(value);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int GetZombieCount()
|
foreach (var entity in entities)
|
||||||
|
{
|
||||||
|
if (entity is ZombieResource zombie)
|
||||||
|
{
|
||||||
|
zombies.Add(zombie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return zombies;
|
||||||
|
}
|
||||||
|
public static int GetEntityCount()
|
||||||
{
|
{
|
||||||
return ZombieDictionary.Count;
|
return EntityDictionary.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue