This commit is contained in:
MarcEricMartel 2023-06-11 15:16:40 -04:00
parent 5527119426
commit a12679a730
2 changed files with 45 additions and 6 deletions

View File

@ -24,18 +24,22 @@ public partial class player : Camera3D
private TextureProgressBar _nuke, _pr, _kash; private TextureProgressBar _nuke, _pr, _kash;
[Export] [Export]
private Label _chatter; private Label _chatter, _timer;
[Export] [Export]
private AudioStreamPlayer _sndChtr, _sndBtn; private AudioStreamPlayer _sndChtr, _sndBtn;
[Export] [Export]
private Timer _tmrChtr, _tmrCashGen; private Timer _tmrChtr, _tmrCashGen;
[Export]
private Button _btnEnd, _btnNukes, _btnPR, _btnKashCow;
private float Nukes { 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 PR { get => (float)_pr.Value; set => _pr.Value = value; }
private float Kash { get => (float)_kash.Value; set => _kash.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 private string Chatter
{ {
@ -63,7 +67,10 @@ public partial class player : Camera3D
_tmrChtr.Start(); _tmrChtr.Start();
_tmrChtr.Timeout += () => Chatter = ""; _tmrChtr.Timeout += () => Chatter = "";
_tmrCashGen.Timeout += MakeMoney; _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."; Chatter = "The enemy is stockpiling weapons of mass destruction.";
} }
@ -157,13 +164,22 @@ public partial class player : Camera3D
else if (Kash <= 0) else if (Kash <= 0)
gameover = true; gameover = true;
else if (Nukes >= 100) else if (Nukes >= 100)
_btnEnd.Pressed += () => { _sndBtn.Play(); Nuke();};
if (GameTime <= 0)
gameover = true; gameover = true;
if (gameover) if (gameover)
Chatter = "Game Over."; Chatter = "Game Over.";
} }
public void ChangeScore(int price, int pr, int nukes, int isCashCow) { public void ChangeScore(int price, int pr, int nukes, int isCashCow) {
if (price > Kash) {
Chatter = "Not enough money.";
CheckGame();
return;
}
if (isCashCow > 1) if (isCashCow > 1)
isCashCow = 1; isCashCow = 1;
else if (isCashCow < -1) else if (isCashCow < -1)
@ -177,7 +193,9 @@ public partial class player : Camera3D
} }
private void MakeMoney() { private void MakeMoney() {
Kash += KashFlow * 10; Kash += KashFlow * 2;
GameTime--;
_timer.Set("text", GameTime.ToString());
CheckGame(); CheckGame();
} }
@ -203,4 +221,6 @@ public partial class player : Camera3D
} }
} }
} }
public void Nuke() {}
} }

View File

@ -70,7 +70,7 @@ font_size = 12
[sub_resource type="SphereMesh" id="SphereMesh_mtv4x"] [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") attributes = SubResource("CameraAttributesPhysical_1ejpb")
script = ExtResource("1_of2l4") script = ExtResource("1_of2l4")
_con = NodePath("HUD/Debug info/Label") _con = NodePath("HUD/Debug info/Label")
@ -82,10 +82,15 @@ _nuke = NodePath("HUD/Buttons and info/NukeBar")
_pr = NodePath("HUD/Buttons and info/PrBar") _pr = NodePath("HUD/Buttons and info/PrBar")
_kash = NodePath("HUD/Buttons and info/KashBar") _kash = NodePath("HUD/Buttons and info/KashBar")
_chatter = NodePath("HUD/lbl_Chatter") _chatter = NodePath("HUD/lbl_Chatter")
_timer = NodePath("HUD/Time")
_sndChtr = NodePath("snd_Chatter") _sndChtr = NodePath("snd_Chatter")
_sndBtn = NodePath("snd_Button") _sndBtn = NodePath("snd_Button")
_tmrChtr = NodePath("tmr_Chatter") _tmrChtr = NodePath("tmr_Chatter")
_tmrCashGen = NodePath("tmr_kash") _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="."] [node name="HUD" type="Control" parent="."]
layout_mode = 3 layout_mode = 3
@ -344,6 +349,20 @@ Cost: 6M$. Cost: 5M$. PR: -5%.
Cost: 30M$." Cost: 30M$."
label_settings = SubResource("LabelSettings_adeuk") 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="."] [node name="cursor" type="RayCast3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.17786) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1.17786)
target_position = Vector3(0, 0, -999) target_position = Vector3(0, 0, -999)