Basic game over imp
This commit is contained in:
@@ -10,8 +10,6 @@ public partial class GameManager : Node
|
||||
[Signal]
|
||||
public delegate void ReselectCharacterEventHandler(Player player);
|
||||
|
||||
private bool _gameOver = false;
|
||||
|
||||
[Export]
|
||||
private Array<PackedScene> PlayerScenes;
|
||||
|
||||
@@ -86,6 +84,12 @@ public partial class GameManager : Node
|
||||
Players.ElementAt(0)._characterIndex = 0;
|
||||
if (Players.ElementAt(0).CharactersLeftOnStage.Any())
|
||||
EmitSignal(SignalName.ReselectCharacter, Players.ElementAt(0));
|
||||
|
||||
if (!P1CharactersOut.Any() && !Players.ElementAt(0).CharactersLeftOnStage.Any())
|
||||
SetGameOver(Players.ElementAt(0), true);
|
||||
|
||||
if (!P2CharactersOut.Any() && !Players.ElementAt(1).CharactersLeftOnStage.Any())
|
||||
SetGameOver(Players.ElementAt(1), true);
|
||||
}
|
||||
|
||||
public void RemoveCharacter(Character2 character)
|
||||
@@ -127,11 +131,12 @@ public partial class GameManager : Node
|
||||
EmitSignal(SignalName.ReselectCharacter, Players.ElementAt(1));
|
||||
}
|
||||
|
||||
public void SetGameOver(bool isGameOver)
|
||||
public void SetGameOver(Player player, bool isGameOver)
|
||||
{
|
||||
_gameOver = isGameOver;
|
||||
player.GameOver = isGameOver;
|
||||
if (isGameOver)
|
||||
EmitSignal(SignalName.OnGameOver);
|
||||
GD.Print($"Game over for {player.Name}");
|
||||
}
|
||||
|
||||
public void OnLevelClear()
|
||||
@@ -159,6 +164,4 @@ public partial class GameManager : Node
|
||||
foreach (var player in Players)
|
||||
EmitSignal(SignalName.ReselectCharacter, player);
|
||||
}
|
||||
|
||||
public bool IsGameOver => _gameOver;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ public partial class Player : Node3D
|
||||
|
||||
public int _characterIndex = 0;
|
||||
|
||||
public bool GameOver = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
foreach (var character in PlayableCharacterScenes)
|
||||
|
||||
@@ -16,12 +16,12 @@ public partial class StageGUI : Control
|
||||
|
||||
public void OnCharacterSelect(Player player)
|
||||
{
|
||||
if (_gameManager.IsGameOver)
|
||||
if (player.GameOver)
|
||||
return;
|
||||
|
||||
if (player == _gameManager.Players.ElementAt(0))
|
||||
{
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
wheel1.FocusMode = FocusModeEnum.All;
|
||||
wheel1.GrabFocus();
|
||||
wheel1.Visible = true;
|
||||
|
||||
Reference in New Issue
Block a user