Restructered project folders
This commit is contained in:
@@ -12,7 +12,14 @@ public partial class CodingWindow : PanelContainer
|
||||
// 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 (Input.IsActionJustPressed("codingwindow"))
|
||||
{
|
||||
Visible = !Visible;
|
||||
if (Visible)
|
||||
{
|
||||
ReloadRobots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Move, Harvest, Craft
|
||||
@@ -31,4 +38,23 @@ public partial class CodingWindow : PanelContainer
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public partial class GameData
|
||||
@@ -8,6 +9,9 @@ public partial class GameData
|
||||
public static int visibleLayer = 0;
|
||||
//Determines if the player can move the camera or not (Necessary for input and options menu)
|
||||
public static bool canMove = true;
|
||||
public static int maxRobotCount = 1000;
|
||||
public static List<Robot> robots = new List<Robot>();
|
||||
|
||||
//--- PLAYER ADJUSTABLE VALUES ---
|
||||
//Color used in primary objects (e.g. Robots)
|
||||
public static Color primaryColor = new Color("#276ac2");
|
||||
|
||||
@@ -84,12 +84,12 @@ public partial class World : Node3D
|
||||
visibleLayer = currentLayer;
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("spawn_robot"))
|
||||
if (Input.IsActionJustPressed("spawn_robot") && robots.Count < maxRobotCount)
|
||||
{
|
||||
Robot robot = ResourceLoader.LoadRobotPrefab().Instantiate<Robot>();
|
||||
robot.Position = map[0].tiles[1, 1].Position;
|
||||
robot.Position -= new Vector3(0, 1.5f, 0);
|
||||
robot.Position = map[0].tiles[rand.Next(layerSize), rand.Next(layerSize)].Position;
|
||||
AddChild(robot);
|
||||
robots.Add(robot);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user