Add initial game code
This commit is contained in:
parent
f80a60e208
commit
1383997ebf
55 changed files with 1355 additions and 0 deletions
77
scripts/Controller.cs
Normal file
77
scripts/Controller.cs
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
using System;
|
||||
using Godot;
|
||||
|
||||
public partial class Controller : Node
|
||||
{
|
||||
private decimal LastTick = 0;
|
||||
private bool TicksThrottled = false;
|
||||
|
||||
public Ship PlayerShip { get; private set; }
|
||||
|
||||
public Button ExitToMenuButton { get; private set; }
|
||||
|
||||
public Label ShipInfoLabel { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
this.ExitToMenuButton = GetNode<Button>("Container/Top/ExitToMenuButton");
|
||||
|
||||
this.ExitToMenuButton.Pressed += OnExitToMenu;
|
||||
|
||||
this.ShipInfoLabel = GetNode<Label>("Container/TabContainer/Ship/ShipInfo/ShipInfoLabel");
|
||||
|
||||
CallDeferred("ReadyPlayerShip");
|
||||
}
|
||||
|
||||
private void ReadyPlayerShip()
|
||||
{
|
||||
}
|
||||
|
||||
public void UpdatePlayerShip(Ship playerShip)
|
||||
{
|
||||
this.PlayerShip = playerShip;
|
||||
}
|
||||
|
||||
public void OnTick(decimal tick, bool ticksThrottled)
|
||||
{
|
||||
this.LastTick = tick;
|
||||
this.TicksThrottled = ticksThrottled;
|
||||
|
||||
CallDeferred("_OnUpdateGUI");
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
CallDeferred("_OnUpdateGUI");
|
||||
}
|
||||
|
||||
private void _OnUpdateGUI()
|
||||
{
|
||||
this.ShipInfoLabel.Text = $@"Name: {this.PlayerShip.Name}
|
||||
Current Action: {this.PlayerShip.CurrentOrder?.Type.ToString() ?? "IDLE"}
|
||||
|
||||
Location: {this.PlayerShip.Parent.Name}
|
||||
Local X: {Math.Round(Helpers.GetLocalCoordinatesX(this.PlayerShip))}
|
||||
Local Y: {Math.Round(Helpers.GetLocalCoordinatesY(this.PlayerShip))}
|
||||
Global X: {Math.Round(this.PlayerShip.Position.X)}
|
||||
Global Y: {Math.Round(this.PlayerShip.Position.Y)}";
|
||||
}
|
||||
|
||||
public void OnExitToMenu()
|
||||
{
|
||||
GetTree().ChangeSceneToFile("res://scenes/main_menu.tscn");
|
||||
}
|
||||
|
||||
public void OnTest()
|
||||
{
|
||||
CoordinateVector destination = new CoordinateVector(this.PlayerShip.Position.X + Helpers.GetCoordinateFromLY(3), this.PlayerShip.Position.Y);
|
||||
|
||||
Order newOrder = new DestinationOrder(Order.OrderType.MOVE_WARP, destination);
|
||||
|
||||
this.PlayerShip.SetNewPlayerOrder(newOrder);
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue