wave delay

This commit is contained in:
Rendo 2025-07-16 16:12:50 +05:00
commit 7864160dcf
6 changed files with 97 additions and 72 deletions

View file

@ -8,5 +8,6 @@ public partial class AdventureLevelResource : Resource
[Export] public float startSun;
//[Export] public Array<Conditions> conditions;
[Export(PropertyHint.Range,"0,1,0.01")] public float wavePercentage;
[Export] public float standardWaveDelay;
[Export] public Array<WaveData> waves;
}

View file

@ -5,6 +5,7 @@ using Godot.Collections;
[Tool]
public partial class WaveData : Resource
{
[Export] public Array<RowSpawn> zombiesOrdered;
[Export] public Array<WaveEvent> spawns;
[Export] public Array<RowSpawn> zombiesOrdered = new();
[Export] public Array<WaveEvent> events = new();
[Export] public float customWaveDelay = 0;
}

View file

@ -19,16 +19,16 @@ theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
script = ExtResource("1_go5yu")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
[node name="Editor" type="VBoxContainer" parent="."]
layout_mode = 2
[node name="StatusBar" type="PanelContainer" parent="VBoxContainer"]
[node name="StatusBar" type="PanelContainer" parent="Editor"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/StatusBar"]
[node name="HBoxContainer" type="HBoxContainer" parent="Editor/StatusBar"]
layout_mode = 2
[node name="FileButton" type="MenuButton" parent="VBoxContainer/StatusBar/HBoxContainer"]
[node name="FileButton" type="MenuButton" parent="Editor/StatusBar/HBoxContainer"]
layout_mode = 2
text = "File"
switch_on_hover = true
@ -41,46 +41,49 @@ popup/item_2/text = "Open"
popup/item_2/id = 2
script = ExtResource("2_d5hwn")
[node name="FileDialog" type="FileDialog" parent="VBoxContainer/StatusBar/HBoxContainer/FileButton"]
[node name="FileDialog" type="FileDialog" parent="Editor/StatusBar/HBoxContainer/FileButton"]
[node name="WorkArea" type="HSplitContainer" parent="VBoxContainer"]
[node name="WorkArea" type="HSplitContainer" parent="Editor"]
layout_mode = 2
size_flags_vertical = 3
split_offset = 500
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/WorkArea"]
[node name="PanelContainer" type="PanelContainer" parent="Editor/WorkArea"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 3.0
[node name="ZombieEditor" parent="VBoxContainer/WorkArea/PanelContainer" instance=ExtResource("3_1ojhm")]
[node name="ZombieEditor" parent="Editor/WorkArea/PanelContainer" instance=ExtResource("3_1ojhm")]
visible = false
layout_mode = 2
[node name="Inspector" type="VSplitContainer" parent="VBoxContainer/WorkArea"]
[node name="Inspector" type="VSplitContainer" parent="Editor/WorkArea"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ResourceInspector" type="VBoxContainer" parent="VBoxContainer/WorkArea/Inspector" node_paths=PackedStringArray("editorContainer")]
[node name="ResourceInspector" type="VBoxContainer" parent="Editor/WorkArea/Inspector" node_paths=PackedStringArray("editorContainer")]
layout_mode = 2
size_flags_vertical = 3
script = ExtResource("3_d5hwn")
editorContainer = NodePath("../../PanelContainer")
[node name="Tree" type="Tree" parent="VBoxContainer/WorkArea/Inspector/ResourceInspector"]
[node name="Tree" type="Tree" parent="Editor/WorkArea/Inspector/ResourceInspector"]
custom_minimum_size = Vector2(0, 100)
layout_mode = 2
size_flags_vertical = 3
hide_folding = true
enable_recursive_folding = false
[node name="ControlButtons" type="HBoxContainer" parent="VBoxContainer/WorkArea/Inspector/ResourceInspector"]
[node name="ControlButtons" type="HBoxContainer" parent="Editor/WorkArea/Inspector/ResourceInspector"]
layout_mode = 2
size_flags_vertical = 8
[node name="NewButton" type="Button" parent="VBoxContainer/WorkArea/Inspector/ResourceInspector/ControlButtons"]
[node name="NewButton" type="Button" parent="Editor/WorkArea/Inspector/ResourceInspector/ControlButtons"]
layout_mode = 2
text = "New"
[connection signal="ResourceChanged" from="." to="VBoxContainer/WorkArea/Inspector/ResourceInspector" method="Refresh"]
[connection signal="Refreshed" from="VBoxContainer/WorkArea/Inspector/ResourceInspector" to="." method="Save"]
[connection signal="button_clicked" from="VBoxContainer/WorkArea/Inspector/ResourceInspector/Tree" to="VBoxContainer/WorkArea/Inspector/ResourceInspector" method="OnTreeButtonClicked"]
[connection signal="item_selected" from="VBoxContainer/WorkArea/Inspector/ResourceInspector/Tree" to="VBoxContainer/WorkArea/Inspector/ResourceInspector" method="OnItemSelected"]
[connection signal="pressed" from="VBoxContainer/WorkArea/Inspector/ResourceInspector/ControlButtons/NewButton" to="VBoxContainer/WorkArea/Inspector/ResourceInspector" method="OnNewButtonPressed"]
[connection signal="ResourceChanged" from="." to="Editor/WorkArea/Inspector/ResourceInspector" method="Refresh"]
[connection signal="Refreshed" from="Editor/WorkArea/Inspector/ResourceInspector" to="." method="Save"]
[connection signal="button_clicked" from="Editor/WorkArea/Inspector/ResourceInspector/Tree" to="Editor/WorkArea/Inspector/ResourceInspector" method="OnTreeButtonClicked"]
[connection signal="item_edited" from="Editor/WorkArea/Inspector/ResourceInspector/Tree" to="Editor/WorkArea/Inspector/ResourceInspector" method="OnItemEdited"]
[connection signal="item_selected" from="Editor/WorkArea/Inspector/ResourceInspector/Tree" to="Editor/WorkArea/Inspector/ResourceInspector" method="OnItemSelected"]
[connection signal="pressed" from="Editor/WorkArea/Inspector/ResourceInspector/ControlButtons/NewButton" to="Editor/WorkArea/Inspector/ResourceInspector" method="OnNewButtonPressed"]

View file

@ -1,5 +1,6 @@
using Godot;
using System;
using System.Globalization;
[Tool]
public partial class AdventureResourceInspector : Node
@ -38,6 +39,9 @@ public partial class AdventureResourceInspector : Node
root.SetText(0, "Level");
EmitSignal(SignalName.Refreshed);
var initial = tree.CreateItem(root);
initial.SetText(0, "Initial data");
for (int i = 0; i < heldResource.waves.Count; i++)
{
var item = tree.CreateItem(root);
@ -50,6 +54,13 @@ public partial class AdventureResourceInspector : Node
var spawns = tree.CreateItem(item);
spawns.SetText(0, "Events");
var delay = tree.CreateItem(item);
if (heldResource.waves[i].customWaveDelay > 0)
delay.SetText(0, heldResource.waves[i].customWaveDelay.ToString(new CultureInfo("en-US")));
else
delay.SetText(0, "Delay");
delay.SetEditable(0, true);
}
}
@ -62,39 +73,64 @@ public partial class AdventureResourceInspector : Node
public void OnItemSelected()
{
var selected = tree.GetSelected();
if ((selected.GetParent() == root && selected.GetIndex() != 0) || selected.IsEditable(0)) return;
foreach (var child in editorContainer.GetChildren())
{
child.QueueFree();
}
var selected = tree.GetSelected();
if (selected == root)
{
GD.Print("level pressed");
return;
}
else
var index = selected.GetIndex();
if (index == 0 && selected.GetParent() == root)
{
if (selected.GetParent() == root) return;
var index = selected.GetIndex();
if (index == ORDERED)
GD.Print("Initial data selected");
return;
}
if (index == ORDERED)
{
var editor = zombieEditorScene.Instantiate<ZombieEditor>();
editorContainer.AddChild(editor);
editor.SetEditedWave(heldResource.waves[int.Parse(selected.GetParent().GetText(0).Split(" ")[1])]);
editor.SetEditedWave(heldResource.waves[GetWaveIndex(selected.GetParent())]);
return;
}
else if (index == EVENTS)
{
GD.Print("Events pressed");
return;
}
}
}
public void OnItemEdited()
{
var selected = tree.GetEdited();
if (float.TryParse(selected.GetText(0), new CultureInfo("en-US"), out float result))
{
heldResource.waves[GetWaveIndex(selected.GetParent())].customWaveDelay = result;
}
else
{
selected.SetText(0, "Delay");
heldResource.waves[GetWaveIndex(selected.GetParent())].customWaveDelay = 0;
}
}
public void OnTreeButtonClicked(TreeItem item, int column, int id, int button_index)
{
heldResource.waves.RemoveAt(item.GetIndex());
heldResource.waves.RemoveAt(GetWaveIndex(item));
RefreshTree();
}
private int GetWaveIndex(TreeItem waveTreeItem)
{
return int.Parse(waveTreeItem.GetText(0).Split(" ")[1]);
}
}