Files

51 lines
1.4 KiB
C#
Raw Normal View History

2022-12-27 13:12:53 +02:00
using UnityEngine;
2022-12-28 14:10:45 +02:00
public class BlockAirState : BlockParentState
2022-12-27 13:12:53 +02:00
{
private readonly int _extraLandBlockStun = 4;
2022-12-28 14:10:45 +02:00
public override void UpdateLogic(PlayerNetwork player)
2022-12-27 13:12:53 +02:00
{
2022-12-28 14:10:45 +02:00
base.UpdateLogic(player);
player.animation = "BlockAir";
player.animationFrames++;
ToFallState(player);
2023-01-07 23:17:55 +02:00
}
protected override void AfterHitstop(PlayerNetwork player)
{
base.AfterHitstop(player);
2022-12-28 14:10:45 +02:00
ToIdleState(player);
2023-01-07 23:17:55 +02:00
}
private void ToIdleState(PlayerNetwork player)
{
2023-01-20 17:59:16 +02:00
if (player.attackHurtNetwork.knockbackArc > 0 && player.knockback <= 1)
return;
2023-07-02 23:17:37 +03:00
if ((DemonFloat)player.position.y <= DemonicsPhysics.GROUND_POINT)
2023-01-07 23:17:55 +02:00
{
player.player.StopShakeCoroutine();
CheckTrainingComboEnd(player);
2023-01-07 23:17:55 +02:00
if (player.stunFrames <= 0)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Idle");
}
2023-01-07 23:17:55 +02:00
else
{
player.stunFrames = player.attackHurtNetwork.blockStun + _extraLandBlockStun;
2023-07-02 23:17:37 +03:00
player.velocity = DemonVector2.Zero;
2023-01-07 23:17:55 +02:00
player.animationFrames = 0;
2023-01-23 18:31:58 +02:00
EnterState(player, "Block");
2023-01-07 23:17:55 +02:00
}
}
2022-12-28 14:10:45 +02:00
}
private void ToFallState(PlayerNetwork player)
{
if (player.stunFrames <= 0)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Fall");
}
2022-12-28 14:10:45 +02:00
}
protected override void OnEnter(PlayerNetwork player)
2022-12-27 13:12:53 +02:00
{
2022-12-28 14:10:45 +02:00
base.OnEnter(player);
}
}