Initial character select implementation

This commit is contained in:
2023-09-03 15:06:39 -07:00
parent a15973a621
commit f7417d0afd
26 changed files with 269 additions and 154 deletions

47
Scripts/StageGUI.cs Normal file
View File

@@ -0,0 +1,47 @@
using Godot;
public partial class StageGUI : Control
{
[Signal]
public delegate void OnCharacterSelectionMadeEventHandler();
private GameManager _gameManager;
public override void _Ready()
{
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
}
public void OnCharacterSelect()
{
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
var wheel2 = GetNode<TextureRect>("CharacterSelect/Wheel2");
wheel1.FocusMode = FocusModeEnum.All;
wheel1.GrabFocus();
wheel1.Visible = true;
_gameManager.IsP1SelectingCharacter = true;
}
public override void _Process(double delta)
{
var wheel1 = GetNode<TextureRect>("CharacterSelect/Wheel");
if (wheel1.HasFocus())
{
if (Input.IsActionJustPressed("p1_right"))
_gameManager.SetP1ToNextCharacter();
if (Input.IsActionJustPressed("p1_left"))
_gameManager.SetP1ToPreviousCharacter();
if (Input.IsActionJustPressed("p1_fire"))
{
GD.Print("Selected character");
wheel1.ReleaseFocus();
wheel1.Hide();
_gameManager.IsP1SelectingCharacter = false;
EmitSignal(SignalName.OnCharacterSelectionMade);
}
}
}
}