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)
|
||||
@@ -109,7 +113,7 @@ public partial class GameManager : Node
|
||||
GetTree().Root.RemoveChild(character);
|
||||
|
||||
GD.Print(Players.ElementAt(0).CharactersLeftOnStage.Select(x => x.Name).ToArray());
|
||||
|
||||
|
||||
Players.ElementAt(0)._characterIndex = 0;
|
||||
if (Players.ElementAt(0).CharactersLeftOnStage.Any())
|
||||
EmitSignal(SignalName.ReselectCharacter, Players.ElementAt(0));
|
||||
@@ -119,7 +123,7 @@ public partial class GameManager : Node
|
||||
{
|
||||
P2CharactersOut.Add(character);
|
||||
Players.ElementAt(1).CharactersLeftOnStage.Remove(character);
|
||||
|
||||
|
||||
GetTree().Root.RemoveChild(character);
|
||||
|
||||
Players.ElementAt(1)._characterIndex = 0;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user