Wave display
This commit is contained in:
parent
0e9e17cfdc
commit
96e6a20e95
10 changed files with 188 additions and 5 deletions
8
addons/pvzadventure/FieldSpawn.cs
Normal file
8
addons/pvzadventure/FieldSpawn.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class FieldSpawn : Resource
|
||||
{
|
||||
[Export] public PackedScene scene;
|
||||
[Export] public Vector2 position;
|
||||
}
|
||||
1
addons/pvzadventure/FieldSpawn.cs.uid
Normal file
1
addons/pvzadventure/FieldSpawn.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://gbeuv0b1mvd7
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class WaveData : Resource
|
||||
{
|
||||
|
||||
[Export] private Array<ZombieResource> zombiesDisordered;
|
||||
[Export] private Array<ZombieRowSpawn> zombiesOrdered;
|
||||
[Export] private Array<FieldSpawn> spawns;
|
||||
}
|
||||
|
|
|
|||
12
addons/pvzadventure/ZombieRowSpawn.cs
Normal file
12
addons/pvzadventure/ZombieRowSpawn.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using Godot;
|
||||
|
||||
[Tool]
|
||||
public partial class ZombieRowSpawn : Resource
|
||||
{
|
||||
[Export] public ZombieResource zombie1;
|
||||
[Export] public ZombieResource zombie2;
|
||||
[Export] public ZombieResource zombie3;
|
||||
[Export] public ZombieResource zombie4;
|
||||
[Export] public ZombieResource zombie5;
|
||||
|
||||
}
|
||||
1
addons/pvzadventure/ZombieRowSpawn.cs.uid
Normal file
1
addons/pvzadventure/ZombieRowSpawn.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ct730nm5jan8i
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dkq82o31vr3i2"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dkq82o31vr3i2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dkgxtig5fwdgi" path="res://addons/pvzadventure/scripts/AdventureEditor.cs" id="1_go5yu"]
|
||||
[ext_resource type="Script" uid="uid://binuuattefn7d" path="res://addons/pvzadventure/scripts/FileButton.cs" id="2_d5hwn"]
|
||||
[ext_resource type="Script" uid="uid://b0hl4ap18wbb2" path="res://addons/pvzadventure/scripts/AdventureResourceInspector.cs" id="3_d5hwn"]
|
||||
|
||||
[node name="AdventureEditor" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
|
|
@ -50,5 +51,31 @@ layout_mode = 2
|
|||
[node name="Inspector" type="VSplitContainer" parent="VBoxContainer/WorkArea"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LevelInspector" type="Tree" parent="VBoxContainer/WorkArea/Inspector"]
|
||||
[node name="Cellinspector" type="MarginContainer" parent="VBoxContainer/WorkArea/Inspector"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ResourceInspector" type="VBoxContainer" parent="VBoxContainer/WorkArea/Inspector"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
script = ExtResource("3_d5hwn")
|
||||
|
||||
[node name="Tree" type="Tree" parent="VBoxContainer/WorkArea/Inspector/ResourceInspector"]
|
||||
custom_minimum_size = Vector2(0, 100)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
hide_folding = true
|
||||
enable_recursive_folding = false
|
||||
hide_root = true
|
||||
|
||||
[node name="ControlButtons" type="HBoxContainer" parent="VBoxContainer/WorkArea/Inspector/ResourceInspector"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
|
||||
[node name="NewButton" type="Button" parent="VBoxContainer/WorkArea/Inspector/ResourceInspector/ControlButtons"]
|
||||
layout_mode = 2
|
||||
text = "New"
|
||||
|
||||
[connection signal="ResourceChanged" from="." to="VBoxContainer/WorkArea/Inspector/ResourceInspector" method="Refresh"]
|
||||
[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"]
|
||||
|
|
|
|||
|
|
@ -6,9 +6,13 @@ public partial class AdventureEditor : MarginContainer
|
|||
public AdventureLevelResource editedResource;
|
||||
public string editedPath;
|
||||
|
||||
[Signal]
|
||||
public delegate void ResourceChangedEventHandler(AdventureLevelResource to);
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
editedResource = ResourceLoader.Load<AdventureLevelResource>(editedPath);
|
||||
EmitSignal(SignalName.ResourceChanged, editedResource);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
|
|
|
|||
74
addons/pvzadventure/scripts/AdventureResourceInspector.cs
Normal file
74
addons/pvzadventure/scripts/AdventureResourceInspector.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
[Tool]
|
||||
public partial class AdventureResourceInspector : Node
|
||||
{
|
||||
const int DISORDERED = 0;
|
||||
const int ORDERED = 1;
|
||||
const int SPAWNS = 2;
|
||||
|
||||
private Tree tree;
|
||||
private AdventureLevelResource heldResource;
|
||||
private TreeItem root;
|
||||
public override void _Ready()
|
||||
{
|
||||
tree = GetNode<Tree>("Tree");
|
||||
}
|
||||
|
||||
public void Refresh(AdventureLevelResource resource)
|
||||
{
|
||||
heldResource = resource;
|
||||
RefreshTree();
|
||||
}
|
||||
|
||||
private void RefreshTree()
|
||||
{
|
||||
tree.Clear();
|
||||
root = tree.CreateItem();
|
||||
root.DisableFolding = true;
|
||||
|
||||
for (int i = 0; i < heldResource.waves.Count; i++)
|
||||
{
|
||||
var item = tree.CreateItem(root);
|
||||
item.DisableFolding = true;
|
||||
item.SetText(0, string.Format("Wave {0}", i));
|
||||
|
||||
var disorder = tree.CreateItem(item);
|
||||
disorder.SetText(0, "Disordered zombies");
|
||||
|
||||
var order = tree.CreateItem(item);
|
||||
order.SetText(0, "Ordered zombies");
|
||||
|
||||
var spawns = tree.CreateItem(item);
|
||||
spawns.SetText(0, "Field spawns");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnNewButtonPressed()
|
||||
{
|
||||
var wave = new WaveData();
|
||||
heldResource.waves.Add(wave);
|
||||
RefreshTree();
|
||||
}
|
||||
|
||||
public void OnItemSelected()
|
||||
{
|
||||
var selected = tree.GetSelected();
|
||||
if (selected.GetParent() == root) return;
|
||||
|
||||
var index = selected.GetIndex();
|
||||
if (index == DISORDERED)
|
||||
{
|
||||
|
||||
}
|
||||
else if (index == ORDERED)
|
||||
{
|
||||
|
||||
}
|
||||
else if (index == SPAWNS)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b0hl4ap18wbb2
|
||||
|
|
@ -1,9 +1,61 @@
|
|||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=2 format=3 uid="uid://bx1wnrgickeyd"]
|
||||
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=11 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"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_yo1i5"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
metadata/_custom_type_script = "uid://7rptlb5qr3b6"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_xqi0a"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
metadata/_custom_type_script = "uid://7rptlb5qr3b6"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ak572"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
metadata/_custom_type_script = "uid://7rptlb5qr3b6"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_46l53"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vfl7c"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pdnxq"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
|
||||
[sub_resource type="Resource" id="Resource_w6xpy"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ypxtr"]
|
||||
script = ExtResource("2_46l53")
|
||||
zombiesDisordered = null
|
||||
zombiesOrdered = null
|
||||
spawns = null
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ed2ji")
|
||||
startSun = 0.0
|
||||
waves = null
|
||||
waves = [SubResource("Resource_yo1i5"), SubResource("Resource_xqi0a"), SubResource("Resource_ak572"), SubResource("Resource_46l53"), SubResource("Resource_vfl7c"), SubResource("Resource_pdnxq"), SubResource("Resource_w6xpy"), SubResource("Resource_ypxtr")]
|
||||
metadata/_custom_type_script = "uid://bximdujbkj2n4"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue