wave delay
This commit is contained in:
parent
7d1ca26baa
commit
7864160dcf
6 changed files with 97 additions and 72 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,62 +1,36 @@
|
|||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=18 format=3 uid="uid://bx1wnrgickeyd"]
|
||||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=7 format=3 uid="uid://bx1wnrgickeyd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bximdujbkj2n4" path="res://addons/pvzadventure/AdventureLevelResource.cs" id="1_ed2ji"]
|
||||
[ext_resource type="Script" uid="uid://7rptlb5qr3b6" path="res://addons/pvzadventure/WaveData.cs" id="2_46l53"]
|
||||
[ext_resource type="Script" uid="uid://dl12rj75tk2qi" path="res://addons/pvzadventure/RowSpawn.cs" id="3_xqi0a"]
|
||||
[ext_resource type="Script" uid="uid://cqxj7o8hdm82n" path="res://scripts/resources/ZombieResource.cs" id="4_ak572"]
|
||||
[ext_resource type="Resource" uid="uid://buvacn56kyy2p" path="res://resources/zombies/basic.tres" id="5_ak572"]
|
||||
[ext_resource type="Resource" uid="uid://c38vfdw5b60xw" path="res://resources/zombies/hobo.tres" id="6_pdnxq"]
|
||||
[ext_resource type="Resource" uid="uid://dkhjlu7u0vny6" path="res://resources/zombies/buckethead.tres" id="7_w6xpy"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_w6xpy"]
|
||||
script = ExtResource("3_xqi0a")
|
||||
zombies = Array[ExtResource("4_ak572")]([ExtResource("5_ak572"), ExtResource("5_ak572"), ExtResource("6_pdnxq"), ExtResource("5_ak572"), ExtResource("6_pdnxq")])
|
||||
metadata/_custom_type_script = "uid://dl12rj75tk2qi"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pdnxq"]
|
||||
script = ExtResource("3_xqi0a")
|
||||
zombies = Array[ExtResource("4_ak572")]([ExtResource("5_ak572"), ExtResource("6_pdnxq"), ExtResource("5_ak572"), null, ExtResource("5_ak572")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ypxtr"]
|
||||
script = ExtResource("3_xqi0a")
|
||||
zombies = Array[ExtResource("4_ak572")]([ExtResource("6_pdnxq"), null, null, ExtResource("5_ak572"), null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_46l53"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesOrdered = [SubResource("Resource_w6xpy"), SubResource("Resource_pdnxq"), SubResource("Resource_ypxtr")]
|
||||
spawns = []
|
||||
|
||||
[sub_resource type="Resource" id="Resource_wdkt5"]
|
||||
script = ExtResource("3_xqi0a")
|
||||
zombies = Array[ExtResource("4_ak572")]([null, ExtResource("5_ak572"), null, ExtResource("7_w6xpy"), null])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_asf3k"]
|
||||
script = ExtResource("3_xqi0a")
|
||||
zombies = Array[ExtResource("4_ak572")]([ExtResource("5_ak572"), null, ExtResource("7_w6xpy"), null, null])
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
customWaveDelay = 0.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_yo1i5"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesOrdered = [SubResource("Resource_wdkt5"), SubResource("Resource_asf3k")]
|
||||
spawns = []
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
customWaveDelay = 0.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_xqi0a"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesOrdered = []
|
||||
spawns = []
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
customWaveDelay = 0.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ak572"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesOrdered = []
|
||||
spawns = []
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vfl7c"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesOrdered = []
|
||||
spawns = []
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
customWaveDelay = 0.0
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ed2ji")
|
||||
startSun = 0.0
|
||||
wavePercentage = 0.0
|
||||
waves = [SubResource("Resource_46l53"), SubResource("Resource_yo1i5"), SubResource("Resource_xqi0a"), SubResource("Resource_ak572"), SubResource("Resource_vfl7c")]
|
||||
standardWaveDelay = 0.0
|
||||
waves = [SubResource("Resource_46l53"), SubResource("Resource_yo1i5"), SubResource("Resource_xqi0a"), SubResource("Resource_ak572")]
|
||||
metadata/_custom_type_script = "uid://bximdujbkj2n4"
|
||||
|
|
|
|||
10
resources/levels/testlvl2.tres
Normal file
10
resources/levels/testlvl2.tres
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=2 format=3 uid="uid://cc1jjkslvh8bq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bximdujbkj2n4" path="res://addons/pvzadventure/AdventureLevelResource.cs" id="1_db8ej"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_db8ej")
|
||||
startSun = 0.0
|
||||
wavePercentage = 0.0
|
||||
standardWaveDelay = 0.0
|
||||
waves = []
|
||||
Loading…
Add table
Add a link
Reference in a new issue