diff --git a/player/player.cs b/player/player.cs index 9724da2..483a090 100644 --- a/player/player.cs +++ b/player/player.cs @@ -24,18 +24,22 @@ public partial class player : Camera3D private TextureProgressBar _nuke, _pr, _kash; [Export] - private Label _chatter; + private Label _chatter, _timer; [Export] private AudioStreamPlayer _sndChtr, _sndBtn; [Export] private Timer _tmrChtr, _tmrCashGen; + + [Export] + private Button _btnEnd, _btnNukes, _btnPR, _btnKashCow; 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 int KashFlow { get; set; } + private int GameTime { get; set; } = 60; private string Chatter { @@ -63,7 +67,10 @@ public partial class player : Camera3D _tmrChtr.Start(); _tmrChtr.Timeout += () => Chatter = ""; _tmrCashGen.Timeout += MakeMoney; - + _btnEnd.Pressed += () => _sndBtn.Play(); + _btnNukes.Pressed += () => { _sndBtn.Play(); ChangeScore(30, -5, 10, 0);}; + _btnPR.Pressed += () => { _sndBtn.Play(); ChangeScore(5, 10, 0, 0);}; + _btnKashCow.Pressed += () => { _sndBtn.Play(); ChangeScore(6, 0, 0, 1);}; Chatter = "The enemy is stockpiling weapons of mass destruction."; } @@ -157,13 +164,22 @@ public partial class player : Camera3D else if (Kash <= 0) gameover = true; else if (Nukes >= 100) + _btnEnd.Pressed += () => { _sndBtn.Play(); Nuke();}; + + if (GameTime <= 0) gameover = true; - + if (gameover) Chatter = "Game Over."; } public void ChangeScore(int price, int pr, int nukes, int isCashCow) { + if (price > Kash) { + Chatter = "Not enough money."; + CheckGame(); + return; + } + if (isCashCow > 1) isCashCow = 1; else if (isCashCow < -1) @@ -177,7 +193,9 @@ public partial class player : Camera3D } private void MakeMoney() { - Kash += KashFlow * 10; + Kash += KashFlow * 2; + GameTime--; + _timer.Set("text", GameTime.ToString()); CheckGame(); } @@ -203,4 +221,6 @@ public partial class player : Camera3D } } } + + public void Nuke() {} } diff --git a/player/player.tscn b/player/player.tscn index 4c774e8..942b89d 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -70,7 +70,7 @@ font_size = 12 [sub_resource type="SphereMesh" id="SphereMesh_mtv4x"] -[node name="player" type="Camera3D" node_paths=PackedStringArray("_con", "_mousePosLabel", "_cursorPosLabel", "_cursor", "_cursorPoint", "_nuke", "_pr", "_kash", "_chatter", "_sndChtr", "_sndBtn", "_tmrChtr", "_tmrCashGen")] +[node name="player" type="Camera3D" node_paths=PackedStringArray("_con", "_mousePosLabel", "_cursorPosLabel", "_cursor", "_cursorPoint", "_nuke", "_pr", "_kash", "_chatter", "_timer", "_sndChtr", "_sndBtn", "_tmrChtr", "_tmrCashGen", "_btnEnd", "_btnNukes", "_btnPR", "_btnKashCow")] attributes = SubResource("CameraAttributesPhysical_1ejpb") script = ExtResource("1_of2l4") _con = NodePath("HUD/Debug info/Label") @@ -82,10 +82,15 @@ _nuke = NodePath("HUD/Buttons and info/NukeBar") _pr = NodePath("HUD/Buttons and info/PrBar") _kash = NodePath("HUD/Buttons and info/KashBar") _chatter = NodePath("HUD/lbl_Chatter") +_timer = NodePath("HUD/Time") _sndChtr = NodePath("snd_Chatter") _sndBtn = NodePath("snd_Button") _tmrChtr = NodePath("tmr_Chatter") _tmrCashGen = NodePath("tmr_kash") +_btnEnd = NodePath("HUD/Buttons and info/btn_boom") +_btnNukes = NodePath("HUD/Buttons and info/btn_nukes") +_btnPR = NodePath("HUD/Buttons and info/btn_pr") +_btnKashCow = NodePath("HUD/Buttons and info/btn_kashcow") [node name="HUD" type="Control" parent="."] layout_mode = 3 @@ -344,6 +349,20 @@ Cost: 6M$. Cost: 5M$. PR: -5%. Cost: 30M$." label_settings = SubResource("LabelSettings_adeuk") +[node name="Time" type="Label" parent="HUD"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -133.0 +offset_top = -389.0 +offset_right = -90.0 +offset_bottom = -366.0 +grow_horizontal = 0 +grow_vertical = 0 + [node name="cursor" type="RayCast3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.17786) target_position = Vector3(0, 0, -999)