Improve game over conditions
This commit is contained in:
@@ -4,6 +4,16 @@ using System.Linq;
|
||||
|
||||
public partial class GameManager : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void OnGameOverEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void OnP1GameOverEventHandler();
|
||||
[Signal]
|
||||
public delegate void OnP2GameOverEventHandler();
|
||||
|
||||
public int NumberOfPlayers;
|
||||
|
||||
public bool IsP1SelectingCharacter = true;
|
||||
public bool IsP2SelectingCharacter = true;
|
||||
|
||||
@@ -18,7 +28,8 @@ public partial class GameManager : Node
|
||||
[Export]
|
||||
public Character _p2SelectedCharacter;
|
||||
|
||||
public bool P1GameOver = false;
|
||||
private bool _p1GameOver = false;
|
||||
private bool _p2GameOver = false;
|
||||
|
||||
private int _p1CharacterIndex = 0;
|
||||
private int _p2CharacterIndex = 0;
|
||||
@@ -42,6 +53,34 @@ public partial class GameManager : Node
|
||||
_p1SelectedCharacter?.QueueFree();
|
||||
_p1CharacterIndex = 0;
|
||||
}
|
||||
|
||||
public void SetP1GameOver(bool isGameOver)
|
||||
{
|
||||
_p1GameOver = isGameOver;
|
||||
if (isGameOver)
|
||||
{
|
||||
EmitSignal(SignalName.OnP1GameOver);
|
||||
CheckForOverallGameOver();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsP1GameOver => _p1GameOver;
|
||||
|
||||
public void SetP2GameOver(bool isGameOver)
|
||||
{
|
||||
_p2GameOver = isGameOver;
|
||||
if (isGameOver)
|
||||
{
|
||||
EmitSignal(SignalName.OnP2GameOver);
|
||||
CheckForOverallGameOver();
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForOverallGameOver()
|
||||
{
|
||||
if (_p1GameOver && _p2GameOver)
|
||||
EmitSignal(SignalName.OnGameOver);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Character : CharacterBody3D
|
||||
|
||||
Reference in New Issue
Block a user