Added survival mechanic that consumes inventory items if needed.
This commit is contained in:
@@ -16,6 +16,10 @@ public partial class UIHandler : Control
|
||||
[Export] PanelContainer inventory;
|
||||
[Export] ResearchList researchList;
|
||||
[Export] TextureRect robotAlarm;
|
||||
[Export] RichTextLabel energyLabel;
|
||||
[Export] RichTextLabel waterLabel;
|
||||
[Export] RichTextLabel hungerLabel;
|
||||
[Export] RichTextLabel survivalStatus;
|
||||
|
||||
private bool receivedRobotJumpSignal = false;
|
||||
public override void _Ready()
|
||||
@@ -89,6 +93,7 @@ public partial class UIHandler : Control
|
||||
double memory = Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024);
|
||||
string memoryDisplay = memory > 1024 ? Math.Round(memory / 1024, 2).ToString() + " GB" : memory.ToString() + " MB";
|
||||
RAM.Text = memoryDisplay;
|
||||
DisplaySurvivalStats();
|
||||
}
|
||||
|
||||
public void ExitGame()
|
||||
@@ -121,6 +126,11 @@ public partial class UIHandler : Control
|
||||
private void DisplayRobotAlarm()
|
||||
{
|
||||
string messages = "";
|
||||
if (GameData.survival.isDead)
|
||||
{
|
||||
messages += GameData.survival.currentStatus + "\r";
|
||||
}
|
||||
|
||||
foreach (Robot robot in GameData.robots)
|
||||
{
|
||||
if (robot.currentMessage.Length > 0)
|
||||
@@ -141,4 +151,12 @@ public partial class UIHandler : Control
|
||||
codingWindow.SetRobot(robot);
|
||||
OpenUIElement(codingWindow);
|
||||
}
|
||||
|
||||
private void DisplaySurvivalStats()
|
||||
{
|
||||
energyLabel.Text = $"Energy: {GameData.survival.energy:0}/{GameData.survival.maxEnergy:0}";
|
||||
waterLabel.Text = $"Water: {GameData.survival.thirst:0}/{GameData.survival.maxThirst:0}";
|
||||
hungerLabel.Text = $"Food: {GameData.survival.hunger:0}/{GameData.survival.maxHunger:0}";
|
||||
survivalStatus.Text = GameData.survival.currentStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ public partial class RobotDisplay : PanelContainer
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
string programName = robot.currentProgram ?? "";
|
||||
if (programName != currentScript.Text)
|
||||
string status = $"{programName} | Heat {robot.heat:0}% | Maintenance {robot.maintenance:0}%";
|
||||
if (status != currentScript.Text)
|
||||
{
|
||||
currentScript.Text = programName;
|
||||
currentScript.Text = status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user