Added random seed and ability to enter a seed. Also added a simple/small tutorial screen and unified the UI with UIStyle.cs
This commit is contained in:
@@ -29,6 +29,7 @@ public partial class UIHandler : Control
|
||||
private bool receivedRobotJumpSignal = false;
|
||||
public override void _Ready()
|
||||
{
|
||||
UIStyle.Apply(this);
|
||||
robotList.OnRobotJumpTo += OnRobotJumpTo;
|
||||
}
|
||||
|
||||
@@ -177,6 +178,10 @@ public partial class UIHandler : Control
|
||||
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;
|
||||
survivalStatus.Modulate = GameData.survival.currentStatus.Contains("critical")
|
||||
? UIStyle.GetWarningColor()
|
||||
: Colors.White;
|
||||
|
||||
if (GameData.survival.isDead)
|
||||
{
|
||||
ShowGameOver();
|
||||
@@ -185,13 +190,14 @@ public partial class UIHandler : Control
|
||||
|
||||
private void DisplayWorldStats()
|
||||
{
|
||||
currentLayer.Text = $"Current layer: {GameData.currentLayer}/{GameData.ruinSize}";
|
||||
deepestLayer.Text = $"Deepest layer: {GameData.lowestLayer}";
|
||||
if(GameData.lowestLayer == GameData.ruinSize){
|
||||
currentLayer.Text = $"Layer: {GameData.currentLayer + 1}/{GameData.ruinSize}";
|
||||
deepestLayer.Text = $"Gate depth: {GameData.lowestLayer}";
|
||||
if (GameData.lowestLayer == GameData.ruinSize)
|
||||
{
|
||||
unlockLayer.Visible = false;
|
||||
return;
|
||||
}
|
||||
unlockLayer.TooltipText = "Needed items: \r" + GameData.map[GameData.lowestLayer].DisplayGateIngredients();
|
||||
unlockLayer.TooltipText = "Gate requirements:\r" + GameData.map[GameData.lowestLayer].DisplayGateIngredients();
|
||||
unlockLayer.Disabled = !GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1);
|
||||
}
|
||||
|
||||
@@ -213,8 +219,8 @@ public partial class UIHandler : Control
|
||||
|
||||
public void ShowGameOver()
|
||||
{
|
||||
if(gameOver.Visible) return;
|
||||
gameOver.GetNode<RichTextLabel>("./VBoxContainer/Content").Text = $"[font_size=32]You died! \r Reason: {GameData.survival.deathReason} \r Better luck next time \r";
|
||||
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.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
using Godot;
|
||||
|
||||
public static class UIStyle
|
||||
{
|
||||
private static readonly Color Background = new Color("#101317");
|
||||
private static readonly Color Surface = new Color("#171d22");
|
||||
private static readonly Color SurfaceStrong = new Color("#202a31");
|
||||
private static readonly Color SurfaceSoft = new Color("#25343d");
|
||||
private static readonly Color Accent = new Color("#6ec6b8");
|
||||
private static readonly Color AccentStrong = new Color("#9be7d8");
|
||||
private static readonly Color Warning = new Color("#d69b5a");
|
||||
private static readonly Color Text = new Color("#e8f0ed");
|
||||
private static readonly Color MutedText = new Color("#aab8b4");
|
||||
|
||||
public static void Apply(Control root)
|
||||
{
|
||||
if (root == null) return;
|
||||
|
||||
ApplyToControl(root);
|
||||
|
||||
foreach (Node child in root.GetChildren())
|
||||
{
|
||||
Control control = child as Control;
|
||||
if (control != null)
|
||||
{
|
||||
Apply(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyToControl(Control control)
|
||||
{
|
||||
PanelContainer panel = control as PanelContainer;
|
||||
if (panel != null)
|
||||
{
|
||||
StylePanel(panel);
|
||||
}
|
||||
|
||||
Button button = control as Button;
|
||||
if (button != null)
|
||||
{
|
||||
StyleButton(button);
|
||||
}
|
||||
|
||||
LineEdit lineEdit = control as LineEdit;
|
||||
if (lineEdit != null)
|
||||
{
|
||||
StyleLineEdit(lineEdit);
|
||||
}
|
||||
|
||||
OptionButton optionButton = control as OptionButton;
|
||||
if (optionButton != null)
|
||||
{
|
||||
StyleButton(optionButton);
|
||||
}
|
||||
|
||||
RichTextLabel label = control as RichTextLabel;
|
||||
if (label != null)
|
||||
{
|
||||
StyleLabel(label);
|
||||
}
|
||||
|
||||
TextureButton textureButton = control as TextureButton;
|
||||
if (textureButton != null)
|
||||
{
|
||||
StyleTextureButton(textureButton);
|
||||
}
|
||||
|
||||
TextureRect textureRect = control as TextureRect;
|
||||
if (textureRect != null)
|
||||
{
|
||||
textureRect.CustomMinimumSize = new Vector2(26, 26);
|
||||
}
|
||||
}
|
||||
|
||||
private static void StylePanel(PanelContainer panel)
|
||||
{
|
||||
Color color = Surface;
|
||||
|
||||
if (panel.Name.ToString().Contains("Header") || panel.Name.ToString().Contains("Footer"))
|
||||
{
|
||||
color = Background;
|
||||
}
|
||||
|
||||
if (panel.Name.ToString().Contains("GameOver") || panel.Name.ToString().Contains("Menu"))
|
||||
{
|
||||
color = SurfaceStrong;
|
||||
}
|
||||
|
||||
StyleBoxFlat style = CreateBox(color, Accent, 1, 8);
|
||||
panel.AddThemeStyleboxOverride("panel", style);
|
||||
}
|
||||
|
||||
private static void StyleButton(Button button)
|
||||
{
|
||||
button.CustomMinimumSize = new Vector2(112, 34);
|
||||
button.AddThemeStyleboxOverride("normal", CreateBox(SurfaceSoft, Accent, 1, 6));
|
||||
button.AddThemeStyleboxOverride("hover", CreateBox(new Color("#314750"), AccentStrong, 1, 6));
|
||||
button.AddThemeStyleboxOverride("pressed", CreateBox(new Color("#1a2b30"), AccentStrong, 1, 6));
|
||||
button.AddThemeStyleboxOverride("focus", CreateBox(new Color(0, 0, 0, 0), AccentStrong, 1, 6));
|
||||
button.AddThemeColorOverride("font_color", Text);
|
||||
button.AddThemeColorOverride("font_hover_color", AccentStrong);
|
||||
button.AddThemeColorOverride("font_pressed_color", AccentStrong);
|
||||
button.AddThemeColorOverride("font_disabled_color", MutedText);
|
||||
}
|
||||
|
||||
private static void StyleLineEdit(LineEdit lineEdit)
|
||||
{
|
||||
lineEdit.CustomMinimumSize = new Vector2(120, 34);
|
||||
lineEdit.AddThemeStyleboxOverride("normal", CreateBox(new Color("#11191d"), Accent, 1, 6));
|
||||
lineEdit.AddThemeStyleboxOverride("focus", CreateBox(new Color("#142126"), AccentStrong, 1, 6));
|
||||
lineEdit.AddThemeColorOverride("font_color", Text);
|
||||
lineEdit.AddThemeColorOverride("font_placeholder_color", MutedText);
|
||||
}
|
||||
|
||||
private static void StyleLabel(RichTextLabel label)
|
||||
{
|
||||
label.AddThemeColorOverride("default_color", Text);
|
||||
label.AddThemeColorOverride("font_shadow_color", new Color("#00000080"));
|
||||
}
|
||||
|
||||
private static void StyleTextureButton(TextureButton textureButton)
|
||||
{
|
||||
textureButton.CustomMinimumSize = new Vector2(38, 38);
|
||||
textureButton.Modulate = Text;
|
||||
textureButton.SelfModulate = Text;
|
||||
textureButton.StretchMode = TextureButton.StretchModeEnum.KeepAspectCentered;
|
||||
}
|
||||
|
||||
private static StyleBoxFlat CreateBox(Color color, Color borderColor, int borderWidth, int radius)
|
||||
{
|
||||
StyleBoxFlat style = new StyleBoxFlat
|
||||
{
|
||||
BgColor = color,
|
||||
BorderColor = borderColor,
|
||||
BorderWidthTop = borderWidth,
|
||||
BorderWidthBottom = borderWidth,
|
||||
BorderWidthLeft = borderWidth,
|
||||
BorderWidthRight = borderWidth,
|
||||
CornerRadiusTopLeft = radius,
|
||||
CornerRadiusTopRight = radius,
|
||||
CornerRadiusBottomLeft = radius,
|
||||
CornerRadiusBottomRight = radius,
|
||||
ContentMarginLeft = 8,
|
||||
ContentMarginRight = 8,
|
||||
ContentMarginTop = 6,
|
||||
ContentMarginBottom = 6
|
||||
};
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
public static Color GetWarningColor()
|
||||
{
|
||||
return Warning;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dkygddm6k0hjw
|
||||
Reference in New Issue
Block a user