Fix game over

This commit is contained in:
2023-09-06 17:41:53 -07:00
parent 5acfb9300c
commit aac5fbd297
14 changed files with 301 additions and 72 deletions

View File

@@ -1,7 +1,11 @@
using Godot;
using Godot.Collections;
public partial class GameOverService : Node
public partial class GameOverService : Control
{
[Signal]
public delegate void ReloadGameEventHandler();
private GameManager _gameManager;
public override void _EnterTree()
@@ -9,9 +13,9 @@ public partial class GameOverService : Node
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
}
public void OnGameOver(Player[] players)
public void OnGameOver(Array<Player> players)
{
GetNode<Control>("GameOver").Show();
Show();
var bgmPlayer = GetTree().Root.GetNode<BGMPlayer>("BgmPlayer");
bgmPlayer.SetBGMFromFilepath("Audio/BGM/GameOverTheme.wav");
bgmPlayer.PlayBGM();
@@ -19,7 +23,9 @@ public partial class GameOverService : Node
{
if (Input.IsActionJustPressed(player.PlayerInput.Fire()))
{
GetNode<Control>("GameOver").Hide(); GetTree().ReloadCurrentScene();
Hide();
_gameManager.IsGameOverScreenOn = false;
EmitSignal(SignalName.ReloadGame);
}
}
}

View File

@@ -1,4 +1,5 @@
using Godot;
using Godot.Collections;
using System.Linq;
public partial class StageGUI : Control
@@ -16,7 +17,7 @@ public partial class StageGUI : Control
[Signal]
public delegate void OnPlayerGameOverEventHandler(Player player);
[Signal]
public delegate void OnGameOverEventHandler();
public delegate void OnGameOverEventHandler(Array<Player> players);
private GameManager _gameManager;
@@ -65,9 +66,9 @@ public partial class StageGUI : Control
EmitSignal(SignalName.OnPlayerGameOver, player);
}
if (_gameManager.Players.All(x => x.GameOver))
if (!_gameManager.IsGameOverScreenOn && _gameManager.Players.All(x => x.GameOver))
{
EmitSignal(SignalName.OnGameOver);
EmitSignal(SignalName.OnGameOver, new Array<Player>(_gameManager.Players));
}
}

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://dq1gtd55p04do"]
[gd_scene load_steps=8 format=3 uid="uid://dq1gtd55p04do"]
[ext_resource type="Script" path="res://UI/StageGUI.cs" id="1_wr2m0"]
[ext_resource type="Texture2D" uid="uid://d18xmfbg47qpi" path="res://Textures/Portraits/blank-background.png" id="2_rh3al"]
@@ -7,7 +7,6 @@
[ext_resource type="Texture2D" uid="uid://1pgw8he4k5va" path="res://Textures/Portraits/pisces-bg-char.png" id="5_y2ln6"]
[ext_resource type="Texture2D" uid="uid://bacwvejc4hcou" path="res://Textures/Portraits/sag-bg-char.png" id="6_iltal"]
[ext_resource type="Texture2D" uid="uid://o7uu4efxf36e" path="res://Textures/Portraits/scorpio-bg-char.png" id="7_tgrf5"]
[ext_resource type="Texture2D" uid="uid://dveeywi80ux2l" path="res://UI/Game_Over.jpg" id="8_o0pnh"]
[node name="StageGUI" type="Control"]
process_mode = 3
@@ -189,21 +188,3 @@ offset_bottom = 540.0
grow_horizontal = 0
grow_vertical = 2
texture = ExtResource("7_tgrf5")
[node name="GameOver" type="Control" parent="."]
visible = false
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="GameOverScreen" type="TextureRect" parent="GameOver"]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
texture = ExtResource("8_o0pnh")
[connection signal="CapricornSelected" from="." to="CharacterSelect" method="OnCapricornSelected"]
[connection signal="OnPlayerGameOver" from="." to="CharacterSelect" method="OnPlayerGameOver"]
[connection signal="PiscesSelected" from="." to="CharacterSelect" method="OnPiscesSelected"]
[connection signal="SagittariusSelected" from="." to="CharacterSelect" method="OnSagittariusSelected"]
[connection signal="ScorpioSelected" from="." to="CharacterSelect" method="OnScorpioSelected"]