Files

61 lines
1.9 KiB
C#
Raw Normal View History

2022-12-26 03:47:56 +02:00
using UnityEngine;
public class RunState : 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-31 20:46:52 +02:00
player.position = new DemonicsVector2(player.position.x, DemonicsPhysics.GROUND_POINT);
2022-12-26 03:47:56 +02:00
player.animation = "Run";
player.animationFrames++;
2022-12-31 20:46:52 +02:00
player.velocity = new DemonicsVector2(player.direction.x * player.playerStats.SpeedRun, 0);
2022-12-26 03:47:56 +02:00
if (DemonicsWorld.Frame % 5 == 0)
{
if (player.flip > 0)
{
2022-12-31 20:46:52 +02:00
DemonicsVector2 effectPosition = new DemonicsVector2(player.position.x - 1, player.position.y);
player.SetEffect("Ghost", effectPosition, false);
2022-12-26 03:47:56 +02:00
}
else
{
2022-12-31 20:46:52 +02:00
DemonicsVector2 effectPosition = new DemonicsVector2(player.position.x + 1, player.position.y);
player.SetEffect("Ghost", effectPosition, true);
2022-12-26 03:47:56 +02:00
}
}
ToIdleState(player);
ToJumpState(player);
ToJumpForwardState(player);
}
private void ToJumpState(PlayerNetwork player)
{
if (player.direction.y > 0)
{
2022-12-29 21:24:36 +02:00
player.enter = false;
2022-12-28 14:10:45 +02:00
player.soundStop = "Run";
2022-12-26 03:47:56 +02:00
player.state = "Jump";
}
}
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;
2022-12-29 21:24:36 +02:00
player.enter = false;
2022-12-28 14:10:45 +02:00
player.soundStop = "Run";
2022-12-26 03:47:56 +02:00
player.state = "JumpForward";
}
}
private void ToIdleState(PlayerNetwork player)
{
if (player.direction.x == 0)
{
2022-12-29 21:24:36 +02:00
player.enter = false;
2022-12-26 03:47:56 +02:00
player.soundStop = "Run";
player.state = "Idle";
}
}
}