Refactor Player and Character
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
public partial class StageGUI : Control
|
||||
{
|
||||
[Signal]
|
||||
public delegate void OnCharacterSelectionMadeEventHandler();
|
||||
public delegate void OnCharacterSelectionMadeEventHandler(Player player);
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
@@ -14,7 +15,7 @@ public partial class StageGUI : Control
|
||||
|
||||
public void OnCharacterSelect()
|
||||
{
|
||||
if (_gameManager.IsP1GameOver)
|
||||
if (_gameManager.IsGameOver)
|
||||
return;
|
||||
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
@@ -23,27 +24,26 @@ public partial class StageGUI : Control
|
||||
wheel1.FocusMode = FocusModeEnum.All;
|
||||
wheel1.GrabFocus();
|
||||
wheel1.Visible = true;
|
||||
_gameManager.IsP1SelectingCharacter = true;
|
||||
_gameManager.IsSelectingCharacter = true;
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
|
||||
|
||||
if (wheel1.HasFocus())
|
||||
{
|
||||
if (Input.IsActionJustPressed("p1_right"))
|
||||
_gameManager.SetP1ToNextCharacter();
|
||||
_gameManager.SetToNextCharacter(_gameManager.Players.ElementAt(0));
|
||||
if (Input.IsActionJustPressed("p1_left"))
|
||||
_gameManager.SetP1ToPreviousCharacter();
|
||||
_gameManager.SetToPreviousCharacter(_gameManager.Players.ElementAt(0));
|
||||
|
||||
if (Input.IsActionJustPressed("p1_fire"))
|
||||
{
|
||||
GD.Print("Selected character");
|
||||
wheel1.ReleaseFocus();
|
||||
wheel1.Hide();
|
||||
_gameManager.IsP1SelectingCharacter = false;
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade);
|
||||
_gameManager.IsSelectingCharacter = false;
|
||||
EmitSignal(SignalName.OnCharacterSelectionMade, _gameManager.Players.ElementAt(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user