2022-12-29 14:40:06 +02:00
|
|
|
public class GrabState : State
|
|
|
|
|
{
|
|
|
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
|
|
|
{
|
2023-04-04 21:43:30 +03:00
|
|
|
|
2022-12-29 14:40:06 +02:00
|
|
|
if (!player.enter)
|
|
|
|
|
{
|
2023-01-10 18:39:07 +02:00
|
|
|
SetTopPriority(player);
|
|
|
|
|
CheckFlip(player);
|
2022-12-29 14:40:06 +02:00
|
|
|
player.enter = true;
|
2023-01-15 13:05:14 +02:00
|
|
|
player.hitbox.enter = false;
|
2022-12-29 14:40:06 +02:00
|
|
|
player.animationFrames = 0;
|
2023-01-10 18:39:07 +02:00
|
|
|
player.animation = "Grab";
|
|
|
|
|
player.sound = "Hit";
|
|
|
|
|
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
|
2023-04-04 21:43:30 +03:00
|
|
|
UpdateFramedata(player);
|
|
|
|
|
return;
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|
2023-04-01 16:29:28 +03:00
|
|
|
UpdateFramedata(player);
|
2023-04-04 21:43:30 +03:00
|
|
|
player.animationFrames++;
|
|
|
|
|
player.attackFrames--;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = DemonVector2.Zero;
|
2023-04-01 22:50:26 +03:00
|
|
|
|
2023-01-10 18:39:07 +02:00
|
|
|
ToIdleState(player);
|
2023-01-17 23:48:42 +02:00
|
|
|
ToHurtState(player);
|
2023-01-10 18:39:07 +02:00
|
|
|
}
|
|
|
|
|
private void ToIdleState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.attackFrames <= 0)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Idle");
|
2023-01-10 18:39:07 +02:00
|
|
|
}
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|
2023-01-17 23:48:42 +02:00
|
|
|
private void ToHurtState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (IsColliding(player))
|
|
|
|
|
{
|
|
|
|
|
player.enter = false;
|
|
|
|
|
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Throw)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Grabbed");
|
2023-01-17 23:48:42 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (DemonicsPhysics.IsInCorner(player))
|
|
|
|
|
{
|
|
|
|
|
player.otherPlayer.knockback = 0;
|
|
|
|
|
player.otherPlayer.pushbackStart = player.otherPlayer.position;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.otherPlayer.pushbackEnd = new DemonVector2(player.otherPlayer.position.x + (player.attackHurtNetwork.knockbackForce * -player.otherPlayer.flip), DemonicsPhysics.GROUND_POINT);
|
2023-01-17 23:48:42 +02:00
|
|
|
player.otherPlayer.pushbackDuration = player.attackHurtNetwork.knockbackDuration;
|
|
|
|
|
}
|
|
|
|
|
player.player.StopShakeCoroutine();
|
|
|
|
|
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
|
|
|
|
|
if (player.attackHurtNetwork.hardKnockdown)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Airborne");
|
2023-01-17 23:48:42 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Hurt");
|
2023-01-17 23:48:42 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "HurtAir");
|
2023-01-17 23:48:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|