Set game over for character condition
This commit is contained in:
@@ -8,9 +8,9 @@ public partial class GameManager : Node
|
||||
public bool IsP2SelectingCharacter = true;
|
||||
|
||||
[Export]
|
||||
private Array<PackedScene> _p1Characters;
|
||||
public Array<PackedScene> _p1Characters;
|
||||
[Export]
|
||||
private Array<PackedScene> _p2Characters;
|
||||
public Array<PackedScene> _p2Characters;
|
||||
|
||||
[Export]
|
||||
public Character _p1SelectedCharacter;
|
||||
@@ -18,6 +18,8 @@ public partial class GameManager : Node
|
||||
[Export]
|
||||
public Character _p2SelectedCharacter;
|
||||
|
||||
public bool P1GameOver = false;
|
||||
|
||||
private int _p1CharacterIndex = 0;
|
||||
private int _p2CharacterIndex = 0;
|
||||
|
||||
@@ -27,15 +29,19 @@ public partial class GameManager : Node
|
||||
|
||||
public void OnP1CharacterSelected()
|
||||
{
|
||||
if (_p1SelectedCharacter != null)
|
||||
_p1SelectedCharacter.QueueFree();
|
||||
|
||||
var selectedPlayer = _p1Characters[_p1CharacterIndex].Instantiate();
|
||||
_p1SelectedCharacter = selectedPlayer as Character;
|
||||
GetTree().Root.AddChild(_p1SelectedCharacter);
|
||||
var playerSpawnPoint = GetNode<SpawnPoint>("P1SpawnPoint");
|
||||
playerSpawnPoint.SetPlayerPosition(_p1SelectedCharacter);
|
||||
}
|
||||
|
||||
public void RemoveP1Character()
|
||||
{
|
||||
_p1Characters.Remove(_p1Characters.ElementAt(_p1CharacterIndex));
|
||||
_p1SelectedCharacter?.QueueFree();
|
||||
_p1CharacterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Character : CharacterBody3D
|
||||
|
||||
Reference in New Issue
Block a user