Initial character select implementation
This commit is contained in:
47
Scripts/StageGUI.cs
Normal file
47
Scripts/StageGUI.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user