2022-12-26 03:47:56 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class IdleState : GroundParentState
|
|
|
|
|
{
|
|
|
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
|
|
|
{
|
2022-12-30 14:07:58 +02:00
|
|
|
if (!player.enter)
|
|
|
|
|
{
|
|
|
|
|
player.enter = true;
|
|
|
|
|
player.animationFrames = 0;
|
|
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
player.animation = "Idle";
|
|
|
|
|
player.animationFrames++;
|
2022-12-31 20:46:52 +02:00
|
|
|
player.velocity = DemonicsVector2.Zero;
|
2023-01-07 23:17:55 +02:00
|
|
|
CheckFlip(player);
|
|
|
|
|
base.UpdateLogic(player);
|
2022-12-26 03:47:56 +02:00
|
|
|
ToWalkState(player);
|
|
|
|
|
ToJumpState(player);
|
|
|
|
|
ToJumpForwardState(player);
|
|
|
|
|
ToCrouchState(player);
|
2022-12-31 20:46:52 +02:00
|
|
|
ToDashState(player);
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToCrouchState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.direction.y < 0)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Crouch");
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ToJumpState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.direction.y > 0)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Jump");
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ToJumpForwardState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.direction.y > 0 && player.direction.x != 0)
|
|
|
|
|
{
|
2022-12-31 20:46:52 +02:00
|
|
|
player.jumpDirection = (int)player.direction.x;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "JumpForward");
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ToWalkState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.direction.x != 0)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Walk");
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-31 20:46:52 +02:00
|
|
|
private void ToDashState(PlayerNetwork player)
|
2022-12-26 03:47:56 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
if (player.inputBuffer.CurrentInput().pressed)
|
2022-12-26 03:47:56 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
if (player.inputBuffer.CurrentInput().inputEnum == InputEnum.ForwardDash)
|
2023-01-18 21:41:03 +02:00
|
|
|
{
|
|
|
|
|
player.dashDirection = 1;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Dash");
|
|
|
|
|
|
2023-01-18 21:41:03 +02:00
|
|
|
}
|
2023-01-23 18:31:58 +02:00
|
|
|
else if (player.inputBuffer.CurrentInput().inputEnum == InputEnum.BackDash)
|
2023-01-18 21:41:03 +02:00
|
|
|
{
|
|
|
|
|
player.dashDirection = -1;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Dash");
|
2023-01-18 21:41:03 +02:00
|
|
|
}
|
2023-01-01 02:09:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-18 21:41:03 +02:00
|
|
|
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|