Beeg checkin
This commit is contained in:
32
Levels/Scripts/AreaExit.cs
Normal file
32
Levels/Scripts/AreaExit.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
public partial class AreaExit : Node3D
|
||||
{
|
||||
[Export]
|
||||
private int _levelIndex;
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
|
||||
}
|
||||
|
||||
|
||||
private void OnExitEntered(Node3D node)
|
||||
{
|
||||
if (node is Controls)
|
||||
{
|
||||
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);
|
||||
|
||||
GD.Print("Exit reached");
|
||||
|
||||
if (!_gameManager.Players.Any(x => x.CharactersLeftOnStage.Any()))
|
||||
_gameManager.OnLevelClear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user