Refactor Player and Character

This commit is contained in:
2023-09-04 06:42:02 -07:00
parent a8ea40dee8
commit c32bbfe45a
16 changed files with 132 additions and 206 deletions

View File

@@ -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));
}
}
}