Fix multiplayer
This commit is contained in:
@@ -13,7 +13,7 @@ public partial class StageGUI : Control
|
||||
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
|
||||
}
|
||||
|
||||
public void OnCharacterSelect()
|
||||
public void OnCharacterSelect(Player player)
|
||||
{
|
||||
if (_gameManager.IsGameOver)
|
||||
return;
|
||||
@@ -21,30 +21,71 @@ public partial class StageGUI : Control
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
|
||||
wheel1.FocusMode = FocusModeEnum.All;
|
||||
wheel1.GrabFocus();
|
||||
wheel1.Visible = true;
|
||||
_gameManager.IsSelectingCharacter = true;
|
||||
if (player == _gameManager.Players.ElementAt(0))
|
||||
{
|
||||
wheel1.FocusMode = FocusModeEnum.All;
|
||||
wheel1.GrabFocus();
|
||||
wheel1.Visible = true;
|
||||
}
|
||||
else if (player == _gameManager.Players.ElementAt(1))
|
||||
{
|
||||
wheel2.FocusMode = FocusModeEnum.All;
|
||||
wheel2.GrabFocus();
|
||||
wheel2.Visible = true;
|
||||
}
|
||||
player.IsSelectingCharacter = true;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
if (wheel1.HasFocus())
|
||||
var playersCurrentlySelecting = _gameManager.Players.Where(x => x.IsSelectingCharacter);
|
||||
foreach (var player in playersCurrentlySelecting)
|
||||
{
|
||||
if (Input.IsActionJustPressed("p1_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(0));
|
||||
|
||||
if (Input.IsActionJustPressed("p1_fire"))
|
||||
if (player == _gameManager.Players.ElementAt(0))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
wheel1.ReleaseFocus();
|
||||
wheel1.Hide();
|
||||
_gameManager.IsSelectingCharacter = false;
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(0));
|
||||
|
||||
if (Input.IsActionJustPressed("p1_fire"))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
_gameManager.Players.ElementAt(0).IsSelectingCharacter = false;
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
wheel1.Hide();
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
if (player == _gameManager.Players.ElementAt(1))
|
||||
{
|
||||
if (Input.IsActionJustPressed("p2_right"))
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(1));
|
||||
if (Input.IsActionJustPressed("p2_left"))
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(1));
|
||||
|
||||
if (Input.IsActionJustPressed("p2_fire"))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
_gameManager.Players.ElementAt(1).IsSelectingCharacter = false;
|
||||
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
|
||||
wheel2.Hide();
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFirstPlayerCharacterSelect()
|
||||
{
|
||||
var player = _gameManager.Players.ElementAt(0);
|
||||
OnCharacterSelect(player);
|
||||
}
|
||||
|
||||
private void OnSecondPlayerCharacterSelect()
|
||||
{
|
||||
var player = _gameManager.Players.ElementAt(1);
|
||||
OnCharacterSelect(player);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user