Restructered project folders
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class CodingWindow : PanelContainer
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
GenerateCodingBlocks();
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Input.IsActionJustPressed("codingwindow"))
|
||||
{
|
||||
Visible = !Visible;
|
||||
if (Visible)
|
||||
{
|
||||
ReloadRobots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Move, Harvest, Craft
|
||||
public void GenerateCodingBlocks()
|
||||
{
|
||||
PackedScene nodePrefab = ResourceLoader.LoadProgramNodePrefab();
|
||||
Control node1 = nodePrefab.Instantiate<Control>();
|
||||
node1.GetNode<RichTextLabel>("./Node/NodeContainer/NodeText").Text = "Move";
|
||||
GetNode<VBoxContainer>("./HBoxContainer/CodeBlocks/VBoxContainer").AddChild(node1);
|
||||
|
||||
Control node2 = nodePrefab.Instantiate<Control>();
|
||||
node2.GetNode<RichTextLabel>("./Node/NodeContainer/NodeText").Text = "Harvest";
|
||||
GetNode<VBoxContainer>("./HBoxContainer/CodeBlocks/VBoxContainer").AddChild(node2);
|
||||
|
||||
Control node3 = nodePrefab.Instantiate<Control>();
|
||||
node3.GetNode<RichTextLabel>("./Node/NodeContainer/NodeText").Text = "Craft";
|
||||
GetNode<VBoxContainer>("./HBoxContainer/CodeBlocks/VBoxContainer").AddChild(node3);
|
||||
}
|
||||
|
||||
public void ReloadRobots()
|
||||
{
|
||||
VBoxContainer robotList = GetNode<VBoxContainer>("./HBoxContainer/Robotlist/VBoxContainer");
|
||||
foreach(Node node in robotList.GetChildren())
|
||||
{
|
||||
robotList.RemoveChild(node);
|
||||
node.QueueFree();
|
||||
}
|
||||
PackedScene nodePrefab = ResourceLoader.LoadProgramNodePrefab();
|
||||
Control robot;
|
||||
|
||||
foreach (Robot robotObject in GameData.robots)
|
||||
{
|
||||
robot = nodePrefab.Instantiate<Control>();
|
||||
robot.GetNode<RichTextLabel>("./Node/NodeContainer/NodeText").Text = robotObject.Position.ToString();
|
||||
GetNode<VBoxContainer>("./HBoxContainer/Robotlist/VBoxContainer").AddChild(robot);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user