You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using UnityEngine;
|
|
|
|
public class WalkState : GroundParentState
|
|
{
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
{
|
|
if (!player.enter)
|
|
{
|
|
player.enter = true;
|
|
player.animationFrames = 0;
|
|
}
|
|
player.position = new Vector2(player.position.x, (float)DemonicsPhysics.GROUND_POINT);
|
|
CheckFlip(player);
|
|
player.canDoubleJump = true;
|
|
player.animation = "Walk";
|
|
player.animationFrames++;
|
|
player.velocity = new Vector2(player.direction.x * (float)player.playerStats.SpeedWalk, 0);
|
|
ToIdleState(player);
|
|
ToJumpState(player);
|
|
ToJumpForwardState(player);
|
|
ToCrouchState(player);
|
|
}
|
|
private void ToCrouchState(PlayerNetwork player)
|
|
{
|
|
if (player.direction.y < 0)
|
|
{
|
|
player.enter = false;
|
|
player.state = "Crouch";
|
|
}
|
|
}
|
|
private void ToJumpState(PlayerNetwork player)
|
|
{
|
|
if (player.direction.y > 0)
|
|
{
|
|
player.enter = false;
|
|
player.state = "Jump";
|
|
}
|
|
}
|
|
private void ToJumpForwardState(PlayerNetwork player)
|
|
{
|
|
if (player.direction.y > 0 && player.direction.x != 0)
|
|
{
|
|
player.dashDirection = (int)player.direction.x;
|
|
player.enter = false;
|
|
player.state = "JumpForward";
|
|
}
|
|
}
|
|
private void ToIdleState(PlayerNetwork player)
|
|
{
|
|
if (player.direction.x == 0)
|
|
{
|
|
player.enter = false;
|
|
player.state = "Idle";
|
|
}
|
|
}
|
|
public override bool ToDashState(PlayerNetwork player)
|
|
{
|
|
if (player.canDash)
|
|
{
|
|
player.enter = false;
|
|
player.state = "Dash";
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
} |