Skip to content

Commit c13cbb3

Browse files
committed
Added clearer win/lose screens
1 parent f4c4e15 commit c13cbb3

6 files changed

Lines changed: 148 additions & 11 deletions

File tree

Globals/StageProducer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public partial class StageProducer : Node
1010
public static RandomNumberGenerator GlobalRng = new RandomNumberGenerator();
1111
private ulong _seed;
1212
private ulong _lastRngState;
13-
private bool _isInitialized = false;
13+
public static bool IsInitialized;
1414

1515
private Stages _curStage = Stages.Title; //TODO: State Machine kinda deal?
1616
private Node _curScene;
@@ -34,7 +34,7 @@ public void StartGame()
3434
PlayerStats = new PlayerStats();
3535

3636
CurRoom = Map.GetRooms()[0];
37-
_isInitialized = true;
37+
IsInitialized = true;
3838
}
3939

4040
public static void ChangeCurRoom(MapGrid.Room room)
@@ -53,7 +53,7 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
5353
switch (nextStage)
5454
{
5555
case Stages.Title:
56-
_isInitialized = false;
56+
IsInitialized = false;
5757
GetTree().ChangeSceneToFile("res://scenes/SceneTransitions/TitleScreen.tscn");
5858
break;
5959
case Stages.Battle:
@@ -73,7 +73,7 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
7373
break;
7474
case Stages.Map:
7575
GetTree().ChangeSceneToFile("res://scenes/Maps/cartographer.tscn");
76-
if (!_isInitialized)
76+
if (!IsInitialized)
7777
{
7878
StartGame();
7979
}

scenes/BattleDirector/scripts/BattleDirector.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ private void CheckBattleStatus(PuppetTemplate puppet)
200200
{
201201
if (puppet == Player)
202202
{
203-
GD.Print("Player is Dead");
204-
Audio.StreamPaused = true;
205-
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Title);
203+
LostBattle();
206204
return;
207205
}
208206

@@ -215,12 +213,22 @@ private void CheckBattleStatus(PuppetTemplate puppet)
215213
}
216214
}
217215

216+
private void LostBattle()
217+
{
218+
GD.Print("Player is Dead");
219+
Audio.StreamPaused = true;
220+
AddChild(GD.Load<PackedScene>("res://scenes/UI/LoseScreen.tscn").Instantiate());
221+
GetTree().Paused = true;
222+
}
223+
218224
private void ShowRewardSelection(int amount)
219225
{
220226
string type = "Note";
221227
if (StageProducer.Config.RoomType == Stages.Boss)
222228
type = "Relic";
223-
RewardSelect.CreateSelection(this, Player.Stats, amount, type).Selected += EndBattle;
229+
var rewardSelect = RewardSelect.CreateSelection(this, Player.Stats, amount, type);
230+
rewardSelect.GetNode<Label>("%TopLabel").Text = "You win!";
231+
rewardSelect.Selected += EndBattle;
224232
}
225233

226234
#endregion

scenes/UI/LoseScreen.tscn

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://hjho5n2f8rkf"]
2+
3+
[ext_resource type="Script" path="res://scenes/UI/scripts/LoseScreen.cs" id="1_13iue"]
4+
5+
[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("buttons")]
6+
process_mode = 2
7+
script = ExtResource("1_13iue")
8+
buttons = [NodePath("MarginContainer2/VBoxContainer/MarginContainer/Restart"), NodePath("MarginContainer2/VBoxContainer/MarginContainer2/Title"), NodePath("MarginContainer2/VBoxContainer/MarginContainer3/Quit")]
9+
10+
[node name="ColorRect" type="ColorRect" parent="."]
11+
offset_right = 640.0
12+
offset_bottom = 360.0
13+
color = Color(0.24, 0.24, 0.24, 0.854902)
14+
15+
[node name="MarginContainer2" type="MarginContainer" parent="."]
16+
anchors_preset = 15
17+
anchor_right = 1.0
18+
anchor_bottom = 1.0
19+
grow_horizontal = 2
20+
grow_vertical = 2
21+
theme_override_constants/margin_left = 200
22+
theme_override_constants/margin_top = 20
23+
theme_override_constants/margin_right = 200
24+
theme_override_constants/margin_bottom = 20
25+
26+
[node name="ColorRect" type="ColorRect" parent="MarginContainer2"]
27+
layout_mode = 2
28+
color = Color(0.172833, 0.172833, 0.172833, 0.945)
29+
30+
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer2"]
31+
layout_mode = 2
32+
33+
[node name="TopLabel" type="Label" parent="MarginContainer2/VBoxContainer"]
34+
unique_name_in_owner = true
35+
layout_mode = 2
36+
theme_override_font_sizes/font_size = 20
37+
text = "Game Over!"
38+
horizontal_alignment = 1
39+
40+
[node name="HSeparator" type="HSeparator" parent="MarginContainer2/VBoxContainer"]
41+
layout_mode = 2
42+
43+
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer2/VBoxContainer"]
44+
layout_mode = 2
45+
size_flags_vertical = 3
46+
theme_override_constants/margin_left = 20
47+
theme_override_constants/margin_top = 20
48+
theme_override_constants/margin_right = 20
49+
theme_override_constants/margin_bottom = 20
50+
51+
[node name="Restart" type="Button" parent="MarginContainer2/VBoxContainer/MarginContainer"]
52+
layout_mode = 2
53+
focus_neighbor_top = NodePath("../../MarginContainer3/Quit")
54+
focus_neighbor_bottom = NodePath("../../MarginContainer2/Title")
55+
text = "Restart"
56+
57+
[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer2/VBoxContainer"]
58+
layout_mode = 2
59+
size_flags_vertical = 3
60+
theme_override_constants/margin_left = 20
61+
theme_override_constants/margin_top = 20
62+
theme_override_constants/margin_right = 20
63+
theme_override_constants/margin_bottom = 20
64+
65+
[node name="Title" type="Button" parent="MarginContainer2/VBoxContainer/MarginContainer2"]
66+
layout_mode = 2
67+
focus_neighbor_top = NodePath("../../MarginContainer/Restart")
68+
focus_neighbor_bottom = NodePath("../../MarginContainer3/Quit")
69+
text = "Quit To Title"
70+
71+
[node name="MarginContainer3" type="MarginContainer" parent="MarginContainer2/VBoxContainer"]
72+
layout_mode = 2
73+
size_flags_vertical = 3
74+
theme_override_constants/margin_left = 20
75+
theme_override_constants/margin_top = 20
76+
theme_override_constants/margin_right = 20
77+
theme_override_constants/margin_bottom = 20
78+
79+
[node name="Quit" type="Button" parent="MarginContainer2/VBoxContainer/MarginContainer3"]
80+
layout_mode = 2
81+
focus_neighbor_top = NodePath("../../MarginContainer2/Title")
82+
focus_neighbor_bottom = NodePath("../../MarginContainer/Restart")
83+
text = "Quit Game"

scenes/UI/RewardSelectionUI.tscn

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ grow_vertical = 2
2424
size_flags_horizontal = 3
2525
size_flags_vertical = 3
2626
theme_override_constants/margin_left = 50
27-
theme_override_constants/margin_top = 50
27+
theme_override_constants/margin_top = 20
2828
theme_override_constants/margin_right = 50
2929
theme_override_constants/margin_bottom = 50
3030

@@ -34,6 +34,13 @@ layout_mode = 2
3434
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
3535
layout_mode = 2
3636

37+
[node name="TopLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer"]
38+
unique_name_in_owner = true
39+
layout_mode = 2
40+
theme_override_font_sizes/font_size = 20
41+
text = "Rewards!"
42+
horizontal_alignment = 1
43+
3744
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
3845
layout_mode = 2
3946
size_flags_vertical = 3

scenes/UI/scripts/LoseScreen.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using FunkEngine;
3+
using Godot;
4+
5+
public partial class LoseScreen : CanvasLayer
6+
{
7+
[Export]
8+
private Button[] buttons;
9+
10+
public override void _Ready()
11+
{
12+
buttons[0].Pressed += Restart;
13+
buttons[1].Pressed += QuitToMainMenu;
14+
buttons[2].Pressed += Quit;
15+
buttons[0].GrabFocus();
16+
}
17+
18+
private void Restart()
19+
{
20+
GetTree().Paused = false;
21+
StageProducer.IsInitialized = false;
22+
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Map);
23+
}
24+
25+
private void Quit()
26+
{
27+
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Quit);
28+
}
29+
30+
private void QuitToMainMenu()
31+
{
32+
GetTree().Paused = false;
33+
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Title);
34+
}
35+
}

scenes/UI/scripts/RewardSelect.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public override void _Process(double delta)
4949

5050
private void GenerateRelicChoices(int amount = 1)
5151
{
52+
if (amount < 1)
53+
GD.PushError("Error: In RewardSelect: amount < 1");
5254
//should probably change this so that the amount of relics offered can be changed when BD calls it
5355
//i.e less options when killing trash mobs/basic/weak enemies
5456
_rChoices = Scribe.GetRandomRelics(_player.CurRelics, amount);
@@ -59,12 +61,14 @@ private void GenerateRelicChoices(int amount = 1)
5961
button.Display(relic.Texture, relic.Tooltip, relic.Name);
6062
button.Pressed += () => OnRelicSelected(relic);
6163
ButtonContainer.AddChild(button);
62-
button.GrabFocus();
6364
}
65+
ButtonContainer.GetChild<Button>(0).GrabFocus();
6466
}
6567

6668
private void GenerateNoteChoices(int amount = 1)
6769
{
70+
if (amount < 1)
71+
GD.PushError("Error: In RewardSelect: amount < 1");
6872
//should probably change this so that the amount of relics offered can be changed when BD calls it
6973
//i.e less options when killing trash mobs/basic/weak enemies
7074
_nChoices = Scribe.GetRandomRewardNotes(amount);
@@ -75,8 +79,8 @@ private void GenerateNoteChoices(int amount = 1)
7579
button.Display(note.Texture, note.Tooltip, note.Name);
7680
button.Pressed += () => OnNoteSelected(note);
7781
ButtonContainer.AddChild(button);
78-
button.GrabFocus();
7982
}
83+
ButtonContainer.GetChild<Button>(0).GrabFocus();
8084
}
8185

8286
public static RewardSelect CreateSelection(

0 commit comments

Comments
 (0)