Files

60 lines
2.0 KiB
C#
Raw Normal View History

2022-12-26 03:47:56 +02:00
using UnityEngine;
public class ArcanaState : State
{
public override void UpdateLogic(PlayerNetwork player)
{
if (!player.enter)
{
2023-01-03 22:34:07 +02:00
player.arcana -= PlayerStatsSO.ARCANA_MULTIPLIER;
2022-12-26 03:47:56 +02:00
player.enter = true;
2022-12-27 13:12:53 +02:00
player.canChainAttack = false;
2023-01-07 23:17:55 +02:00
player.animation = player.attackNetwork.name;
player.sound = player.attackNetwork.attackSound;
2022-12-26 03:47:56 +02:00
player.animationFrames = 0;
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
2023-01-07 23:17:55 +02:00
player.velocity = new DemonicsVector2(player.attackNetwork.travelDistance.x * (DemonicsFloat)player.flip, (DemonicsFloat)player.attackNetwork.travelDistance.y);
2022-12-26 03:47:56 +02:00
}
ToIdleState(player);
if (GameSimulation.Hitstop <= 0)
{
2023-01-07 23:17:55 +02:00
if (player.attackNetwork.travelDistance.y > 0)
2022-12-27 13:12:53 +02:00
{
2023-01-07 23:17:55 +02:00
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.GRAVITY);
2022-12-27 13:12:53 +02:00
ToIdleFallState(player);
}
2022-12-26 03:47:56 +02:00
player.animationFrames++;
player.attackFrames--;
}
}
private void ToIdleFallState(PlayerNetwork player)
{
2023-01-07 23:17:55 +02:00
if (player.isAir && (DemonicsFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0)
2022-12-26 03:47:56 +02:00
{
player.isCrouch = false;
player.isAir = false;
player.enter = false;
player.state = "Idle";
}
}
private void ToIdleState(PlayerNetwork player)
{
if (player.attackFrames <= 0)
{
player.enter = false;
if (player.isAir)
{
player.isCrouch = false;
player.isAir = false;
player.state = "Fall";
}
else
{
player.isCrouch = false;
player.isAir = false;
player.state = "Idle";
}
}
}
}