Added final features for this release. Now only polishing (if needed) remains.
Features: Sacrifice-Node, Maintain-Node, Options for screen type, lightcolor and soundvolume, tied in sound effects, game pause when menu is open, visibly open up gate when opening it.
This commit is contained in:
@@ -58,6 +58,7 @@ public partial class UIHandler : Control
|
||||
public void HandleMenuButton()
|
||||
{
|
||||
OpenUIElement(menu);
|
||||
GameData.isPaused = menu.Visible || options.Visible;
|
||||
}
|
||||
|
||||
public void HandleMenu()
|
||||
@@ -67,7 +68,9 @@ public partial class UIHandler : Control
|
||||
|
||||
public void ShowOptions()
|
||||
{
|
||||
menu.Hide();
|
||||
OpenUIElement(options);
|
||||
GameData.isPaused = options.Visible;
|
||||
}
|
||||
|
||||
public void HandleMapButton()
|
||||
@@ -101,6 +104,7 @@ public partial class UIHandler : Control
|
||||
RAM.Text = memoryDisplay;
|
||||
DisplaySurvivalStats();
|
||||
DisplayWorldStats();
|
||||
DisplayLoseCondition();
|
||||
}
|
||||
|
||||
public void ExitGame()
|
||||
@@ -123,6 +127,7 @@ public partial class UIHandler : Control
|
||||
|
||||
public void OpenUIElement(Control element)
|
||||
{
|
||||
SoundManager.PlayButton();
|
||||
if (element.Visible)
|
||||
{
|
||||
element.Hide();
|
||||
@@ -141,6 +146,11 @@ public partial class UIHandler : Control
|
||||
if (child == element) continue;
|
||||
child.Visible = false;
|
||||
}
|
||||
|
||||
if (element != menu && element != options)
|
||||
{
|
||||
GameData.isPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayRobotAlarm()
|
||||
@@ -201,15 +211,28 @@ public partial class UIHandler : Control
|
||||
unlockLayer.Disabled = !GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1);
|
||||
}
|
||||
|
||||
private void DisplayLoseCondition()
|
||||
{
|
||||
if (!GameData.HasNoRobotRecovery()) return;
|
||||
|
||||
ShowGameOver("No robots remain and no robot can be spawned from inventory.");
|
||||
}
|
||||
|
||||
public void UnlockLayer()
|
||||
{
|
||||
if (GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1))
|
||||
{
|
||||
int openedLayer = GameData.lowestLayer;
|
||||
foreach (Ingredient ingredient in GameData.map[GameData.lowestLayer].gateIngredients)
|
||||
{
|
||||
GameData.inventory.RemoveItem(ingredient.Item, ingredient.Amount);
|
||||
}
|
||||
GameData.lowestLayer++;
|
||||
World world = GetNodeOrNull<World>("/root/Main/World");
|
||||
if (world != null)
|
||||
{
|
||||
world.OpenGate(openedLayer);
|
||||
}
|
||||
if (GameData.lowestLayer == GameData.ruinSize)
|
||||
{
|
||||
gameOver.Show();
|
||||
@@ -218,9 +241,14 @@ public partial class UIHandler : Control
|
||||
}
|
||||
|
||||
public void ShowGameOver()
|
||||
{
|
||||
ShowGameOver($"You died!\rReason: {GameData.survival.deathReason}\rBetter luck next time.");
|
||||
}
|
||||
|
||||
public void ShowGameOver(string message)
|
||||
{
|
||||
if (gameOver.Visible) return;
|
||||
gameOver.GetNode<RichTextLabel>("./VBoxContainer/Content").Text = $"[font_size=32]You died!\rReason: {GameData.survival.deathReason}\rBetter luck next time.\r";
|
||||
gameOver.GetNode<RichTextLabel>("./VBoxContainer/Content").Text = $"[font_size=32]{message}\r";
|
||||
gameOver.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,8 @@ public partial class CodingWindow : PanelContainer
|
||||
|
||||
public void LoadProgram(int index)
|
||||
{
|
||||
if (index <= 0) return;
|
||||
|
||||
ClearWindow();
|
||||
string scriptContent = FileHandler.LoadProgram(availableScripts.GetItemText(index));
|
||||
string[] nodes = scriptContent.Split(";");
|
||||
@@ -151,6 +153,22 @@ public partial class CodingWindow : PanelContainer
|
||||
availableScripts.Select(0);
|
||||
}
|
||||
|
||||
public void DeleteProgram()
|
||||
{
|
||||
string filename = scriptName.Text;
|
||||
int selectedIndex = availableScripts.GetSelectedId();
|
||||
if (selectedIndex > 0)
|
||||
{
|
||||
filename = availableScripts.GetItemText(selectedIndex);
|
||||
}
|
||||
|
||||
if (filename.Length <= 0) return;
|
||||
if (!FileHandler.DeleteProgram(filename)) return;
|
||||
|
||||
ClearWindow();
|
||||
SetupScriptOptions();
|
||||
}
|
||||
|
||||
public void SaveProgram()
|
||||
{
|
||||
string result = "";
|
||||
|
||||
@@ -89,6 +89,14 @@ public partial class NodeDisplay : PanelContainer
|
||||
result.node = new ElseNode();
|
||||
result.LoadElse(nodeSanitized);
|
||||
break;
|
||||
case "maintain":
|
||||
result.node = new MaintainNode();
|
||||
result.LoadMaintain(nodeSanitized);
|
||||
break;
|
||||
case "sacrifice":
|
||||
result.node = new SacrificeNode();
|
||||
result.LoadSacrifice(nodeSanitized);
|
||||
break;
|
||||
default:
|
||||
result.QueueFree();
|
||||
return null;
|
||||
@@ -99,6 +107,10 @@ public partial class NodeDisplay : PanelContainer
|
||||
|
||||
private void LoadElse(string content) { }
|
||||
|
||||
private void LoadMaintain(string content) { }
|
||||
|
||||
private void LoadSacrifice(string content) { }
|
||||
|
||||
private void LoadIf(string content)
|
||||
{
|
||||
HBoxContainer valueContainer = GetNode<HBoxContainer>("./EditorDisplay/VBoxContainer/Values");
|
||||
|
||||
@@ -2,6 +2,8 @@ using Godot;
|
||||
|
||||
public partial class MainMenu : Control
|
||||
{
|
||||
[Export] private PanelContainer options;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
UIStyle.Apply(this);
|
||||
@@ -26,4 +28,11 @@ public partial class MainMenu : Control
|
||||
{
|
||||
GetTree().Quit();
|
||||
}
|
||||
|
||||
public void OnOptionsPressed()
|
||||
{
|
||||
if (options == null) return;
|
||||
|
||||
options.Show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using Godot;
|
||||
|
||||
public partial class OptionsMenu : PanelContainer
|
||||
{
|
||||
private readonly Vector2 panelSize = new Vector2(420, 260);
|
||||
|
||||
[Export] private OptionButton screenMode;
|
||||
[Export] private HSlider soundVolume;
|
||||
[Export] private ColorPickerButton lightColor;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CenterPanel();
|
||||
SetupScreenModes();
|
||||
screenMode.Select(GameData.screenMode);
|
||||
soundVolume.Value = GameData.soundVolume * 100f;
|
||||
lightColor.Color = GameData.lightColor;
|
||||
ApplyScreenMode(GameData.screenMode);
|
||||
SoundManager.SetMasterVolume(GameData.soundVolume);
|
||||
}
|
||||
|
||||
private void SetupScreenModes()
|
||||
{
|
||||
screenMode.Clear();
|
||||
screenMode.AddItem("Fullscreen");
|
||||
screenMode.AddItem("Windowed");
|
||||
screenMode.AddItem("Windowed Fullscreen");
|
||||
screenMode.Select(2);
|
||||
}
|
||||
|
||||
public void OnScreenModeSelected(int index)
|
||||
{
|
||||
GameData.screenMode = index;
|
||||
ApplyScreenMode(index);
|
||||
}
|
||||
|
||||
private void ApplyScreenMode(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
|
||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, false);
|
||||
break;
|
||||
case 1:
|
||||
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
|
||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, false);
|
||||
break;
|
||||
case 2:
|
||||
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
|
||||
DisplayServer.WindowSetFlag(DisplayServer.WindowFlags.Borderless, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSoundVolumeChanged(double value)
|
||||
{
|
||||
GameData.soundVolume = (float)value / 100f;
|
||||
SoundManager.SetMasterVolume(GameData.soundVolume);
|
||||
}
|
||||
|
||||
public void OnLightColorChanged(Color color)
|
||||
{
|
||||
GameData.lightColor = color;
|
||||
LightHandler.RedrawLights(color);
|
||||
}
|
||||
|
||||
public void CloseOptions()
|
||||
{
|
||||
Hide();
|
||||
GameData.isPaused = false;
|
||||
}
|
||||
|
||||
private void CenterPanel()
|
||||
{
|
||||
CustomMinimumSize = panelSize;
|
||||
SetAnchorsPreset(LayoutPreset.Center);
|
||||
OffsetLeft = -panelSize.X / 2f;
|
||||
OffsetTop = -panelSize.Y / 2f;
|
||||
OffsetRight = panelSize.X / 2f;
|
||||
OffsetBottom = panelSize.Y / 2f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://ca1rfge0y3y4i
|
||||
Reference in New Issue
Block a user