Files

120 lines
4.2 KiB
C#
Raw Permalink 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);
2023-10-01 17:21:54 +03:00
DemonVector2 effectPosition = new(player.position.x, player.position.y + 20);
player.SetParticle("RedFrenzy", effectPosition);
2023-10-01 17:21:54 +03:00
player.player.PlayerAnimator.ArmorMaterial();
UpdateFramedata(player);
return;
}
if (!player.hitstop)
{
player.animationFrames++;
player.attackFrames--;
2022-12-29 14:40:06 +02:00
}
2023-07-02 23:17:37 +03:00
player.velocity = DemonVector2.Zero;
2023-01-11 00:22:37 +02:00
player.dashFrames++;
2023-04-01 22:50:26 +03:00
UpdateFramedata(player);
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-07-02 23:17:37 +03:00
player.position = new DemonVector2(player.otherPlayer.position.x - (22 * player.flip), player.otherPlayer.position.y);
2023-01-11 00:22:37 +02:00
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-03-12 14:03:00 +02:00
if (player.position.y > DemonicsPhysics.GROUND_POINT)
EnterState(player, "Fall");
else
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 (player.attackNetwork.superArmor > 0 && !player.player.PlayerAnimator.InRecovery(player.animation, player.animationFrames))
{
SuperArmorHurt(player);
return;
}
2023-01-11 00:22:37 +02:00
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-11 00:22:37 +02:00
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
}