Files

105 lines
3.5 KiB
C#
Raw Normal View History

2023-01-12 19:12:56 +02:00
using UnityEngine;
2022-12-29 14:40:06 +02:00
public class RedFrenzyState : State
{
public override void UpdateLogic(PlayerNetwork player)
{
if (!player.enter)
{
2023-01-09 18:16:00 +02:00
SetTopPriority(player);
CheckFlip(player);
2022-12-29 14:40:06 +02:00
player.enter = true;
player.sound = "Vanish";
player.animationFrames = 0;
player.animation = "RedFrenzy";
2023-01-11 00:22:37 +02:00
player.canChainAttack = false;
player.dashFrames = 0;
player.healthRecoverable = player.health;
2022-12-29 14:40:06 +02:00
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
2023-01-11 00:22:37 +02:00
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
2022-12-29 14:40:06 +02:00
}
2023-01-09 18:16:00 +02:00
player.velocity = DemonicsVector2.Zero;
2023-01-11 00:22:37 +02:00
player.dashFrames++;
2023-01-12 19:12:56 +02:00
if (!player.hitstop)
2023-01-09 18:16:00 +02:00
{
player.animationFrames++;
player.attackFrames--;
}
2023-01-11 00:22:37 +02:00
if (player.dashFrames == 7)
2023-01-10 18:39:07 +02:00
{
2023-01-19 19:06:45 +02:00
player.invisible = true;
2023-01-11 00:22:37 +02:00
player.SetEffect("VanishDisappear", player.position);
GameSimulation.Hitstop = 26;
2023-01-23 18:31:58 +02:00
HitstopFully(player);
HitstopFully(player.otherPlayer);
2023-01-10 18:39:07 +02:00
}
2023-01-11 00:22:37 +02:00
if (player.dashFrames == 22)
2023-01-10 18:39:07 +02:00
{
2023-01-11 00:22:37 +02:00
player.position = new DemonicsVector2(player.otherPlayer.position.x - (22 * player.flip), player.otherPlayer.position.y);
player.SetEffect("VanishAppear", player.position);
2023-01-10 18:39:07 +02:00
}
2023-01-11 00:22:37 +02:00
if (player.dashFrames == 33)
2023-01-10 18:39:07 +02:00
{
2023-01-19 19:06:45 +02:00
player.invisible = false;
2023-01-11 00:22:37 +02:00
player.sound = player.attackNetwork.attackSound;
2023-01-10 18:39:07 +02:00
}
2022-12-29 14:40:06 +02:00
ToIdleState(player);
2023-01-11 00:22:37 +02:00
ToHurtState(player);
2022-12-29 14:40:06 +02:00
}
private void ToIdleState(PlayerNetwork player)
{
if (player.attackFrames <= 0)
{
2023-01-11 00:22:37 +02:00
player.dashFrames = 0;
2023-01-23 18:31:58 +02:00
EnterState(player, "Idle");
2022-12-29 14:40:06 +02:00
}
}
2023-01-11 00:22:37 +02:00
private void ToHurtState(PlayerNetwork player)
{
2023-01-19 19:06:45 +02:00
if (IsColliding(player))
2023-01-11 00:22:37 +02:00
{
player.attackHurtNetwork = player.otherPlayer.attackNetwork;
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Throw)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Grabbed");
2023-01-11 00:22:37 +02:00
return;
}
if (DemonicsPhysics.IsInCorner(player))
{
player.otherPlayer.knockback = 0;
player.otherPlayer.pushbackStart = player.otherPlayer.position;
player.otherPlayer.pushbackEnd = new DemonicsVector2(player.otherPlayer.position.x + (player.attackHurtNetwork.knockbackForce * -player.otherPlayer.flip), DemonicsPhysics.GROUND_POINT);
player.otherPlayer.pushbackDuration = player.attackHurtNetwork.knockbackDuration;
}
if (IsBlocking(player))
{
if (player.direction.y < 0)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "BlockLow");
2023-01-11 00:22:37 +02:00
}
else
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Block");
2023-01-11 00:22:37 +02:00
}
}
else
{
if (player.attackHurtNetwork.hardKnockdown)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Airborne");
2023-01-11 00:22:37 +02:00
}
else
{
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Hurt");
2023-01-11 00:22:37 +02:00
}
else
{
2023-01-23 18:31:58 +02:00
EnterState(player, "HurtAir");
2023-01-11 00:22:37 +02:00
}
}
}
}
}
2022-12-29 14:40:06 +02:00
}