From 11564bb073c4f18297ee3728b4ae1379e95501ed Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Sun, 11 Jun 2023 14:02:32 -0400 Subject: [PATCH] ! --- player/player.cs | 43 +++++++++++++++++++++++++++++++++++++++---- player/player.tscn | 16 ++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/player/player.cs b/player/player.cs index 7bfb519..5651530 100644 --- a/player/player.cs +++ b/player/player.cs @@ -5,6 +5,7 @@ public partial class player : Camera3D { private const string _path = "/root/player/"; + [Export] private Label _con; [Export] @@ -30,12 +31,13 @@ public partial class player : Camera3D private AudioStreamPlayer _sndChtr, _sndBtn; [Export] - private Timer _tmrChtr; + private Timer _tmrChtr, _tmrCashGen; - private float Nuke { get => (float)_nuke.Value; set => _nuke.Value = value; } + private float Nukes { get => (float)_nuke.Value; set => _nuke.Value = value; } private float PR { get => (float)_pr.Value; set => _pr.Value = value; } private float Kash { get => (float)_kash.Value; set => _kash.Value = value; } - + private int KashFlow { get; set; } = 1; + private string Chatter { get => _chatter.Get("text").ToString(); set @@ -62,8 +64,9 @@ public partial class player : Camera3D } _tmrChtr.Start(); _tmrChtr.Timeout += () => Chatter = ""; + _tmrCashGen.Timeout += MakeMoney; } - + public override void _Process(double delta) { Vector3 rot = this.Rotation; @@ -147,6 +150,38 @@ public partial class player : Camera3D } } + + private void CheckGame() { + bool gameover = false; + + if (PR <= 0) + gameover = true; + else if (Kash <= 0) + gameover = true; + else if (Nukes >= 100) + gameover = true; + + if (gameover) + Chatter = "Game Over."; + } + + public void ChangeScore(int price, int pr, int nukes, int isCashCow) { + if (isCashCow > 1) + isCashCow = 1; + else if (isCashCow < -1) + isCashCow = -1; + + Nukes += nukes; + PR += pr; + Kash -= price; + KashFlow += isCashCow; + CheckGame(); + } + + private void MakeMoney() { + Kash += KashFlow * 10; + CheckGame(); + } public void HandleBuilding() { diff --git a/player/player.tscn b/player/player.tscn index 96c656b..672f620 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -68,7 +68,7 @@ height = 255 [sub_resource type="LabelSettings" id="LabelSettings_pws5q"] font_size = 28 -[node name="player" type="Camera3D" node_paths=PackedStringArray("_con", "_mousePosLabel", "_cursorPosLabel", "_cursor", "_cursorPoint", "_nuke", "_pr", "_kash", "_chatter", "_sndChtr", "_sndBtn", "_tmrChtr")] +[node name="player" type="Camera3D" node_paths=PackedStringArray("_con", "_mousePosLabel", "_cursorPosLabel", "_cursor", "_cursorPoint", "_nuke", "_pr", "_kash", "_chatter", "_sndChtr", "_sndBtn", "_tmrChtr", "_tmrCashGen")] attributes = SubResource("CameraAttributesPhysical_1ejpb") script = ExtResource("1_of2l4") _con = NodePath("Debug info/Label") @@ -83,6 +83,7 @@ _chatter = NodePath("lbl_Chatter") _sndChtr = NodePath("snd_Chatter") _sndBtn = NodePath("snd_Button") _tmrChtr = NodePath("tmr_Chatter") +_tmrCashGen = NodePath("tmr_kash") [node name="Debug info" type="Control" parent="."] visible = false @@ -133,6 +134,8 @@ offset_right = 1841.0 offset_bottom = 919.0 value = 50.0 rounded = true +allow_greater = true +allow_lesser = true fill_mode = 3 texture_under = SubResource("GradientTexture2D_2xkee") texture_progress = SubResource("GradientTexture2D_d5w6a") @@ -144,6 +147,8 @@ offset_right = 1869.0 offset_bottom = 919.0 value = 50.0 rounded = true +allow_greater = true +allow_lesser = true fill_mode = 3 texture_under = SubResource("GradientTexture2D_7myfq") texture_progress = SubResource("GradientTexture2D_kdame") @@ -153,8 +158,11 @@ offset_left = 1873.0 offset_top = 664.0 offset_right = 1897.0 offset_bottom = 919.0 -value = 50.0 +max_value = 1000.0 +value = 5.0 rounded = true +allow_greater = true +allow_lesser = true fill_mode = 3 texture_under = SubResource("GradientTexture2D_18k81") texture_progress = SubResource("GradientTexture2D_nfg3s") @@ -214,3 +222,7 @@ stream = ExtResource("3_00x5l") [node name="tmr_Chatter" type="Timer" parent="."] wait_time = 3.0 +one_shot = true + +[node name="tmr_kash" type="Timer" parent="."] +autostart = true