Initial Checkin of Code
This commit is contained in:
parent
19b557ee9b
commit
0bee2ee47b
44 changed files with 7965 additions and 0 deletions
63
Library/Characters/States/PlayerRoamState.cs
Normal file
63
Library/Characters/States/PlayerRoamState.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using Godot;
|
||||
using PokemonLike.Library.Support;
|
||||
using PokemonLike.Library.Utilities;
|
||||
|
||||
namespace PokemonLike.Library.Characters.States;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PlayerRoamState : State
|
||||
{
|
||||
[ExportCategory("State Vars")]
|
||||
[Export] public PlayerInput PlayerInput;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
GetInputDirection();
|
||||
GetInput(delta);
|
||||
}
|
||||
|
||||
public void GetInputDirection()
|
||||
{
|
||||
if (Input.IsActionJustPressed("move_up"))
|
||||
{
|
||||
PlayerInput.Direction = Vector2.Up;
|
||||
PlayerInput.TargetPosition = new Vector2(0, -Globals.Instance.GRID_SIZE);
|
||||
}
|
||||
else if (Input.IsActionJustPressed("move_down"))
|
||||
{
|
||||
PlayerInput.Direction = Vector2.Down;
|
||||
PlayerInput.TargetPosition = new Vector2(0, Globals.Instance.GRID_SIZE);
|
||||
}
|
||||
else if (Input.IsActionJustPressed("move_left"))
|
||||
{
|
||||
PlayerInput.Direction = Vector2.Left;
|
||||
PlayerInput.TargetPosition = new Vector2(-Globals.Instance.GRID_SIZE, 0);
|
||||
}
|
||||
else if (Input.IsActionJustPressed("move_right"))
|
||||
{
|
||||
PlayerInput.Direction = Vector2.Right;
|
||||
PlayerInput.TargetPosition = new Vector2(Globals.Instance.GRID_SIZE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetInput(double delta)
|
||||
{
|
||||
if (Modules.IsActionJustReleased())
|
||||
{
|
||||
if (PlayerInput.HoldTime > PlayerInput.HoldThreshold)
|
||||
PlayerInput.EmitSignal(CharacterInput.SignalName.Walk);
|
||||
else
|
||||
PlayerInput.EmitSignal(CharacterInput.SignalName.Turn);
|
||||
PlayerInput.HoldThreshold = 0.0f;
|
||||
}
|
||||
|
||||
if (Modules.IsActionPressed())
|
||||
{
|
||||
PlayerInput.HoldTime += delta;
|
||||
|
||||
if (PlayerInput.HoldTime > PlayerInput.HoldThreshold)
|
||||
PlayerInput.EmitSignal(CharacterInput.SignalName.Walk);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1
Library/Characters/States/PlayerRoamState.cs.uid
Normal file
1
Library/Characters/States/PlayerRoamState.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c5nu12q4or8pw
|
||||
Loading…
Add table
Add a link
Reference in a new issue