52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Godot;
|
|
|
|
public partial class UIHandler : Control
|
|
{
|
|
[Export] CodingWindow codingWindow;
|
|
[Export] PanelContainer robotNaming;
|
|
[Export] Camera3D mainCam;
|
|
public override void _Ready()
|
|
{
|
|
GetNode<ColorPickerButton>("./MainUI/HeaderContainer/Header/LightColor").Color = GameData.lightColor;
|
|
}
|
|
|
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
public override void _Process(double delta)
|
|
{
|
|
codingWindow.OnRobotClicked += (robot) =>
|
|
{
|
|
mainCam.Position = new Vector3(robot.Position.X, mainCam.Position.Y, robot.Position.Z);
|
|
};
|
|
}
|
|
|
|
public void ChangeColor(Color color)
|
|
{
|
|
GameData.lightColor = color;
|
|
LightHandler.RedrawLights(color);
|
|
}
|
|
|
|
public void ShowNamingPopup(Robot robot)
|
|
{
|
|
robotNaming.Visible = true;
|
|
GameData.canMove = false;
|
|
LineEdit name = robotNaming.GetNode<LineEdit>("./VBoxContainer/LineEdit");
|
|
name.Text = robot.Name;
|
|
Button button = robotNaming.GetNode<Button>("./VBoxContainer/Button");
|
|
|
|
Action handler = null;
|
|
handler = () =>
|
|
{
|
|
robot.Name = name.Text;
|
|
name.Text = "";
|
|
robotNaming.Visible = false;
|
|
GameData.canMove = true;
|
|
button.ButtonUp -= handler;
|
|
};
|
|
|
|
button.ButtonUp += handler;
|
|
}
|
|
|
|
}
|