Refactor
This commit is contained in:
@@ -16,14 +16,11 @@ public partial class AreaExit : Node3D
|
||||
|
||||
private void OnExitEntered(Node3D node)
|
||||
{
|
||||
if (node is Controls)
|
||||
if (node.GetParent() is Player player)
|
||||
{
|
||||
if (node.GetType() == typeof(P1Controls) || node.GetType() == typeof(CapricornP1Controls))
|
||||
_gameManager.RemoveCharacterAndAddToExit((P1Controls)node);
|
||||
if (node.GetType() == typeof(P2Controls) || node.GetType() == typeof(CapricornP2Controls))
|
||||
_gameManager.RemoveCharacterAndAddToExit((P2Controls)node);
|
||||
_gameManager.RemoveCharacterAndAddToExit(player);
|
||||
|
||||
GD.Print("Exit reached");
|
||||
GD.Print($"Exit reached by {player.Name}");
|
||||
|
||||
if (!_gameManager.Players.Any(x => x.CharactersLeftOnStage.Any()))
|
||||
_gameManager.OnLevelClear();
|
||||
|
||||
@@ -7,7 +7,7 @@ public partial class Level : Node3D
|
||||
private List<BasicEnemy> _enemies;
|
||||
private GameManager _gameManager;
|
||||
|
||||
public override void _Ready()
|
||||
public override void _EnterTree()
|
||||
{
|
||||
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
|
||||
_enemies = GetNode("Enemies").GetChildren().OfType<BasicEnemy>().ToList();
|
||||
|
||||
Reference in New Issue
Block a user