Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Globals/StageProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class StageProducer : Node
public static RandomNumberGenerator GlobalRng = new RandomNumberGenerator();
private ulong _seed;
private ulong _lastRngState;
private bool _isInitialized = false;
public static bool IsInitialized;

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

CurRoom = Map.GetRooms()[0];
_isInitialized = true;
IsInitialized = true;
}

public static void ChangeCurRoom(MapGrid.Room room)
Expand All @@ -53,7 +53,7 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
switch (nextStage)
{
case Stages.Title:
_isInitialized = false;
IsInitialized = false;
GetTree().ChangeSceneToFile("res://scenes/SceneTransitions/TitleScreen.tscn");
break;
case Stages.Battle:
Expand All @@ -73,7 +73,7 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1)
break;
case Stages.Map:
GetTree().ChangeSceneToFile("res://scenes/Maps/cartographer.tscn");
if (!_isInitialized)
if (!IsInitialized)
{
StartGame();
}
Expand Down
16 changes: 12 additions & 4 deletions scenes/BattleDirector/scripts/BattleDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ private void CheckBattleStatus(PuppetTemplate puppet)
{
if (puppet == Player)
{
GD.Print("Player is Dead");
Audio.StreamPaused = true;
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Title);
LostBattle();
return;
}

Expand All @@ -215,12 +213,22 @@ private void CheckBattleStatus(PuppetTemplate puppet)
}
}

private void LostBattle()
{
GD.Print("Player is Dead");
Audio.StreamPaused = true;
AddChild(GD.Load<PackedScene>("res://scenes/UI/EndScreen.tscn").Instantiate());
GetTree().Paused = true;
}

private void ShowRewardSelection(int amount)
{
string type = "Note";
if (StageProducer.Config.RoomType == Stages.Boss)
type = "Relic";
RewardSelect.CreateSelection(this, Player.Stats, amount, type).Selected += EndBattle;
var rewardSelect = RewardSelect.CreateSelection(this, Player.Stats, amount, type);
rewardSelect.GetNode<Label>("%TopLabel").Text = "You win!";
rewardSelect.Selected += EndBattle;
}

#endregion
Expand Down
14 changes: 14 additions & 0 deletions scenes/Maps/scripts/Cartographer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public override void _Ready()
{
DrawMap();
GetViewport().GuiFocusChanged += UpdateFocus;
if (StageProducer.CurRoom.Type == Stages.Boss && StageProducer.CurRoom.Children.Length == 0)
{
WinStage();
}
}

public override void _Process(double delta)
Expand Down Expand Up @@ -123,4 +127,14 @@ private void EnterStage(int roomIdx, Button button)
tween.Finished += () =>
GetNode<StageProducer>("/root/StageProducer").TransitionFromRoom(roomIdx);
}

private void WinStage()
{
GD.Print("Player is Dead");
EndScreen es = GD.Load<PackedScene>("res://scenes/UI/EndScreen.tscn")
.Instantiate<EndScreen>();
AddChild(es);
es.TopLabel.Text = "You Win!";
GetTree().Paused = true;
}
}
84 changes: 84 additions & 0 deletions scenes/UI/EndScreen.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[gd_scene load_steps=2 format=3 uid="uid://hjho5n2f8rkf"]

[ext_resource type="Script" path="res://scenes/UI/scripts/EndScreen.cs" id="1_37m3y"]

[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("buttons", "TopLabel")]
process_mode = 2
script = ExtResource("1_37m3y")
buttons = [NodePath("MarginContainer2/VBoxContainer/MarginContainer/Restart"), NodePath("MarginContainer2/VBoxContainer/MarginContainer2/Title"), NodePath("MarginContainer2/VBoxContainer/MarginContainer3/Quit")]
TopLabel = NodePath("MarginContainer2/VBoxContainer/TopLabel")

[node name="ColorRect" type="ColorRect" parent="."]
offset_right = 640.0
offset_bottom = 360.0
color = Color(0.24, 0.24, 0.24, 0.854902)

[node name="MarginContainer2" type="MarginContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 200
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 200
theme_override_constants/margin_bottom = 20

[node name="ColorRect" type="ColorRect" parent="MarginContainer2"]
layout_mode = 2
color = Color(0.172833, 0.172833, 0.172833, 0.945)

[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer2"]
layout_mode = 2

[node name="TopLabel" type="Label" parent="MarginContainer2/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "Game Over!"
horizontal_alignment = 1

[node name="HSeparator" type="HSeparator" parent="MarginContainer2/VBoxContainer"]
layout_mode = 2

[node name="MarginContainer" type="MarginContainer" parent="MarginContainer2/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20

[node name="Restart" type="Button" parent="MarginContainer2/VBoxContainer/MarginContainer"]
layout_mode = 2
focus_neighbor_top = NodePath("../../MarginContainer3/Quit")
focus_neighbor_bottom = NodePath("../../MarginContainer2/Title")
text = "Restart"

[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer2/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20

[node name="Title" type="Button" parent="MarginContainer2/VBoxContainer/MarginContainer2"]
layout_mode = 2
focus_neighbor_top = NodePath("../../MarginContainer/Restart")
focus_neighbor_bottom = NodePath("../../MarginContainer3/Quit")
text = "Quit To Title"

[node name="MarginContainer3" type="MarginContainer" parent="MarginContainer2/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20

[node name="Quit" type="Button" parent="MarginContainer2/VBoxContainer/MarginContainer3"]
layout_mode = 2
focus_neighbor_top = NodePath("../../MarginContainer2/Title")
focus_neighbor_bottom = NodePath("../../MarginContainer/Restart")
text = "Quit Game"
9 changes: 8 additions & 1 deletion scenes/UI/RewardSelectionUI.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50

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

[node name="TopLabel" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "Rewards!"
horizontal_alignment = 1

[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
Expand Down
37 changes: 37 additions & 0 deletions scenes/UI/scripts/EndScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using FunkEngine;
using Godot;

public partial class EndScreen : CanvasLayer
{
[Export]
private Button[] buttons;

[Export] public Label TopLabel;

public override void _Ready()
{
buttons[0].Pressed += Restart;
buttons[1].Pressed += QuitToMainMenu;
buttons[2].Pressed += Quit;
buttons[0].GrabFocus();
}

private void Restart()
{
GetTree().Paused = false;
StageProducer.IsInitialized = false;
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Map);
}

private void Quit()
{
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Quit);
}

private void QuitToMainMenu()
{
GetTree().Paused = false;
GetNode<StageProducer>("/root/StageProducer").TransitionStage(Stages.Title);
}
}
8 changes: 6 additions & 2 deletions scenes/UI/scripts/RewardSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public override void _Process(double delta)

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

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

public static RewardSelect CreateSelection(
Expand Down
Loading