2023-01-10 18:39:07 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-12-29 14:40:06 +02:00
|
|
|
public class BlueFrenzyState : State
|
|
|
|
|
{
|
|
|
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (!player.enter)
|
|
|
|
|
{
|
2023-01-09 18:16:00 +02:00
|
|
|
player.sound = "ParryStart";
|
|
|
|
|
SetTopPriority(player);
|
|
|
|
|
CheckFlip(player);
|
2022-12-29 14:40:06 +02:00
|
|
|
player.enter = true;
|
|
|
|
|
player.animationFrames = 0;
|
|
|
|
|
player.animation = "Parry";
|
|
|
|
|
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
|
2023-04-04 21:43:30 +03:00
|
|
|
UpdateFramedata(player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!player.hitstop)
|
|
|
|
|
{
|
|
|
|
|
player.animationFrames++;
|
|
|
|
|
player.attackFrames--;
|
|
|
|
|
if (player.pushbackDuration > 0 && player.knockback <= player.pushbackDuration)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonFloat ratio = (DemonFloat)player.knockback / (DemonFloat)player.pushbackDuration;
|
|
|
|
|
DemonFloat nextX = DemonFloat.Lerp(player.pushbackStart.x, player.pushbackEnd.x, ratio);
|
|
|
|
|
DemonVector2 nextPosition = new DemonVector2(nextX, player.position.y);
|
2023-04-04 21:43:30 +03:00
|
|
|
player.position = nextPosition;
|
|
|
|
|
player.knockback++;
|
|
|
|
|
if (player.position.x >= DemonicsPhysics.WALL_RIGHT_POINT)
|
2023-07-02 23:17:37 +03:00
|
|
|
player.position = new DemonVector2(DemonicsPhysics.WALL_RIGHT_POINT, player.position.y);
|
2023-04-04 21:43:30 +03:00
|
|
|
else if (player.position.x <= DemonicsPhysics.WALL_LEFT_POINT)
|
2023-07-02 23:17:37 +03:00
|
|
|
player.position = new DemonVector2(DemonicsPhysics.WALL_LEFT_POINT, player.position.y);
|
2023-04-04 21:43:30 +03:00
|
|
|
}
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|
2023-04-01 16:29:28 +03:00
|
|
|
UpdateFramedata(player);
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = DemonVector2.Zero;
|
2023-04-01 22:50:26 +03:00
|
|
|
|
2023-01-09 18:16:00 +02:00
|
|
|
bool isParrying = player.player.PlayerAnimator.GetParrying(player.animation, player.animationFrames);
|
2023-10-15 01:54:30 +03:00
|
|
|
if (isParrying)
|
|
|
|
|
player.player.PlayerAnimator.ParryMaterial();
|
|
|
|
|
else
|
|
|
|
|
player.player.PlayerAnimator.NormalMaterial();
|
|
|
|
|
|
2023-02-22 23:28:16 +02:00
|
|
|
if (IsColliding(player))
|
2023-01-09 18:16:00 +02:00
|
|
|
{
|
2023-03-01 23:07:04 +02:00
|
|
|
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Throw)
|
|
|
|
|
{
|
|
|
|
|
EnterState(player, "Grabbed");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-01-09 18:16:00 +02:00
|
|
|
if (isParrying)
|
|
|
|
|
Parry(player);
|
|
|
|
|
else
|
|
|
|
|
ToHurtState(player);
|
|
|
|
|
}
|
2022-12-29 14:40:06 +02:00
|
|
|
ToIdleState(player);
|
2023-02-22 20:02:39 +02:00
|
|
|
ToParryState(player, isParrying);
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|
|
|
|
|
private void ToIdleState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.attackFrames <= 0)
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Idle");
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|
2023-02-22 20:02:39 +02:00
|
|
|
private void ToParryState(PlayerNetwork player, bool isParrying)
|
|
|
|
|
{
|
2023-07-01 23:48:47 +03:00
|
|
|
if (player.inputBuffer.CurrentTrigger().pressed && player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Parry)
|
2023-02-22 20:02:39 +02:00
|
|
|
if (isParrying)
|
|
|
|
|
EnterState(player, "BlueFrenzy");
|
|
|
|
|
}
|
2023-01-09 18:16:00 +02:00
|
|
|
|
|
|
|
|
private void Parry(PlayerNetwork player)
|
|
|
|
|
{
|
2023-11-03 15:51:19 +02:00
|
|
|
player.animationFrames = 6;
|
2023-05-07 18:21:13 +03:00
|
|
|
int parryDistance = 37;
|
2023-01-09 18:16:00 +02:00
|
|
|
player.sound = "Parry";
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonVector2 hurtEffectPosition = new DemonVector2(player.position.x + (20 * player.flip), player.position.y + 25);
|
2023-07-01 23:48:47 +03:00
|
|
|
player.SetParticle("Parry", hurtEffectPosition);
|
2023-01-09 18:16:00 +02:00
|
|
|
player.otherPlayer.canChainAttack = true;
|
2023-10-11 02:25:05 +03:00
|
|
|
GameSimulation.Hitstop = 13;
|
|
|
|
|
CameraShake.Instance.Shake(new CameraShakerNetwork() { intensity = 10, timer = 0.12f });
|
2023-01-11 00:22:37 +02:00
|
|
|
if (DemonicsPhysics.IsInCorner(player.otherPlayer))
|
|
|
|
|
{
|
|
|
|
|
player.knockback = 0;
|
|
|
|
|
player.pushbackStart = player.position;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.pushbackEnd = new DemonVector2(player.position.x + (parryDistance * -player.flip), DemonicsPhysics.GROUND_POINT);
|
2023-01-11 00:22:37 +02:00
|
|
|
player.pushbackDuration = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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 + (parryDistance * -player.otherPlayer.flip), DemonicsPhysics.GROUND_POINT);
|
2023-01-11 00:22:37 +02:00
|
|
|
player.otherPlayer.pushbackDuration = 10;
|
|
|
|
|
}
|
2023-01-09 18:16:00 +02:00
|
|
|
player.health = player.healthRecoverable;
|
|
|
|
|
}
|
|
|
|
|
private void ToHurtState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
player.attackHurtNetwork = player.otherPlayer.attackNetwork;
|
|
|
|
|
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-09 18:16:00 +02:00
|
|
|
player.otherPlayer.pushbackDuration = player.attackHurtNetwork.knockbackDuration;
|
|
|
|
|
}
|
2023-10-15 01:54:30 +03:00
|
|
|
if (player.attackHurtNetwork.hardKnockdown)
|
|
|
|
|
EnterState(player, "Airborne");
|
2023-01-09 18:16:00 +02:00
|
|
|
else
|
|
|
|
|
{
|
2023-10-15 01:54:30 +03:00
|
|
|
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
|
|
|
|
|
EnterState(player, "Hurt");
|
2023-01-09 18:16:00 +02:00
|
|
|
else
|
2023-10-15 01:54:30 +03:00
|
|
|
EnterState(player, "HurtAir");
|
2023-01-09 18:16:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-29 14:40:06 +02:00
|
|
|
}
|