2023-04-27 16:09:52 +03:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-12-26 03:47:56 +02:00
|
|
|
public class AttackState : State
|
|
|
|
|
{
|
2023-06-26 17:34:59 +03:00
|
|
|
private readonly int _guardBreakSelfDamage = 350;
|
2022-12-26 03:47:56 +02:00
|
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (!player.enter)
|
|
|
|
|
{
|
2023-01-29 15:10:49 +02:00
|
|
|
if (player.juggleBounce & player.isAir)
|
|
|
|
|
{
|
2023-10-01 13:19:40 +03:00
|
|
|
player.position = new DemonVector2(player.position.x, player.position.y + 7);
|
2023-01-29 15:10:49 +02:00
|
|
|
player.juggleBounce = false;
|
|
|
|
|
}
|
2023-07-23 15:47:34 +03:00
|
|
|
player.attackNetwork.guardBreak = false;
|
2023-06-16 14:43:45 +03:00
|
|
|
if (player.attackNetwork.attackType == AttackTypeEnum.Break)
|
|
|
|
|
{
|
2023-07-19 17:10:21 +03:00
|
|
|
if (player.healthRecoverable == player.health)
|
|
|
|
|
{
|
2023-07-23 15:47:34 +03:00
|
|
|
player.attackNetwork.guardBreak = true;
|
2023-07-19 17:10:21 +03:00
|
|
|
if (player.health > _guardBreakSelfDamage)
|
|
|
|
|
player.health -= _guardBreakSelfDamage;
|
|
|
|
|
else
|
|
|
|
|
player.health = 1;
|
|
|
|
|
player.healthRecoverable -= _guardBreakSelfDamage - 100;
|
|
|
|
|
player.player.StartShakeContact();
|
|
|
|
|
player.player.PlayerUI.Damaged();
|
|
|
|
|
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
|
|
|
|
|
DemonVector2 effectPosition = new DemonVector2(player.position.x, player.position.y + 20);
|
|
|
|
|
player.SetParticle("GuardBreak", effectPosition);
|
|
|
|
|
}
|
2023-06-26 17:34:59 +03:00
|
|
|
//CheckTrainingComboEnd(player);
|
2023-06-16 14:43:45 +03:00
|
|
|
}
|
2023-01-01 02:09:37 +02:00
|
|
|
player.animationFrames = 0;
|
2022-12-26 03:47:56 +02:00
|
|
|
SetTopPriority(player);
|
2023-01-04 17:56:46 +02:00
|
|
|
player.canChainAttack = false;
|
2022-12-26 03:47:56 +02:00
|
|
|
player.enter = true;
|
2023-01-14 19:39:35 +02:00
|
|
|
player.hitbox.enter = false;
|
2023-01-05 16:37:41 +02:00
|
|
|
player.sound = player.attackNetwork.attackSound;
|
|
|
|
|
player.animation = player.attackNetwork.name;
|
|
|
|
|
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
|
2023-04-04 21:43:30 +03:00
|
|
|
UpdateFramedata(player);
|
|
|
|
|
return;
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
2023-04-11 16:22:19 +03:00
|
|
|
if (player.animationFrames == 0)
|
2023-07-01 23:48:47 +03:00
|
|
|
player.inputBuffer.triggers[player.inputBuffer.indexTrigger].frame = 0;
|
2023-04-18 23:23:24 +03:00
|
|
|
if (player.dashFrames <= 0)
|
|
|
|
|
player.dashDirection = 0;
|
2022-12-26 03:47:56 +02:00
|
|
|
if (!player.isAir)
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = new DemonVector2(player.attackNetwork.travelDistance.x * (DemonFloat)player.flip, (DemonFloat)player.attackNetwork.travelDistance.y);
|
2022-12-26 03:47:56 +02:00
|
|
|
else
|
|
|
|
|
{
|
2023-04-18 23:23:24 +03:00
|
|
|
if (player.dashFrames > 0)
|
|
|
|
|
Dash(player);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
player.dashDirection = 0;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = new DemonVector2(player.velocity.x, player.velocity.y - (float)DemonicsPhysics.GRAVITY);
|
2023-04-18 23:23:24 +03:00
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
2023-04-04 21:43:30 +03:00
|
|
|
if (!player.hitstop)
|
|
|
|
|
{
|
|
|
|
|
AttackCancel(player);
|
|
|
|
|
}
|
2023-01-08 18:48:39 +02:00
|
|
|
if (!player.isAir)
|
|
|
|
|
{
|
|
|
|
|
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-01-08 18:48:39 +02:00
|
|
|
player.position = nextPosition;
|
|
|
|
|
player.knockback++;
|
2023-01-11 00:22:37 +02:00
|
|
|
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-01-11 00:22:37 +02: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-01-11 00:22:37 +02:00
|
|
|
}
|
2023-01-08 18:48:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-01 16:29:28 +03:00
|
|
|
UpdateFramedata(player);
|
2023-01-07 23:17:55 +02:00
|
|
|
ToJumpState(player);
|
|
|
|
|
ToJumpForwardState(player);
|
2022-12-26 03:47:56 +02:00
|
|
|
ToIdleState(player);
|
2023-01-06 23:10:53 +02:00
|
|
|
ToIdleFallState(player);
|
2023-01-09 00:34:18 +02:00
|
|
|
ToHurtState(player);
|
2023-01-14 19:39:35 +02:00
|
|
|
Shadow(player);
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
2023-01-14 19:39:35 +02:00
|
|
|
|
2023-04-18 23:23:24 +03:00
|
|
|
private void Dash(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
bool forwardDash = player.dashDirection * player.flip == 1 ? true : false;
|
|
|
|
|
int startUpFrames = forwardDash ? 9 : 13;
|
|
|
|
|
int recoveryFrames = forwardDash ? 2 : 3;
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonFloat dashforce = forwardDash ? player.playerStats.DashAirForce : player.playerStats.DashBackAirForce;
|
2023-04-18 23:23:24 +03:00
|
|
|
if (player.dashFrames < startUpFrames && player.dashFrames > recoveryFrames)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = new DemonVector2(player.dashDirection * dashforce, 0);
|
2023-04-18 23:23:24 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = new DemonVector2(player.dashDirection * (dashforce - (DemonFloat)1), 0);
|
2023-04-18 23:23:24 +03:00
|
|
|
}
|
|
|
|
|
if (player.dashFrames % 3 == 0)
|
|
|
|
|
{
|
|
|
|
|
if (player.flip > 0)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonVector2 effectPosition = new DemonVector2(player.position.x - 1, player.position.y);
|
2023-04-18 23:23:24 +03:00
|
|
|
player.SetEffect("Ghost", player.position, false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonVector2 effectPosition = new DemonVector2(player.position.x + 1, player.position.y);
|
2023-04-18 23:23:24 +03:00
|
|
|
player.SetEffect("Ghost", player.position, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
player.dashFrames--;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 18:31:58 +02:00
|
|
|
private void AttackCancel(PlayerNetwork player)
|
|
|
|
|
{
|
2023-04-04 21:43:30 +03:00
|
|
|
player.animationFrames++;
|
|
|
|
|
player.attackFrames--;
|
2023-01-23 18:31:58 +02:00
|
|
|
if (player.canChainAttack)
|
|
|
|
|
{
|
2023-07-01 23:48:47 +03:00
|
|
|
InputItemNetwork input = player.inputBuffer.CurrentTrigger();
|
2023-04-27 16:09:52 +03:00
|
|
|
if (input.frame != 0)
|
2023-01-23 18:31:58 +02:00
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if ((DemonFloat)player.position.y > DemonicsPhysics.GROUND_POINT)
|
2023-01-23 18:31:58 +02:00
|
|
|
{
|
|
|
|
|
player.isAir = true;
|
|
|
|
|
}
|
2023-04-27 16:09:52 +03:00
|
|
|
if (input.inputEnum == InputEnum.Special)
|
2023-01-23 18:31:58 +02:00
|
|
|
{
|
|
|
|
|
Arcana(player, player.isAir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-04-27 16:09:52 +03:00
|
|
|
if (input.inputEnum == InputEnum.Heavy && input.inputDirection != InputDirectionEnum.Down && player.attackInput != InputEnum.Light)
|
|
|
|
|
return;
|
2023-01-23 18:31:58 +02:00
|
|
|
if (!(player.attackInput == InputEnum.Medium && player.isCrouch))
|
|
|
|
|
{
|
2023-04-27 16:09:52 +03:00
|
|
|
if (input.inputEnum != InputEnum.Throw)
|
2023-01-23 18:31:58 +02:00
|
|
|
{
|
2023-04-27 16:09:52 +03:00
|
|
|
if (!(player.attackInput == InputEnum.Heavy && !player.isCrouch && input.inputEnum == InputEnum.Heavy && player.direction.y >= 0))
|
2023-01-23 18:31:58 +02:00
|
|
|
{
|
|
|
|
|
Attack(player, player.isAir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 13:12:53 +02:00
|
|
|
private void ToJumpState(PlayerNetwork player)
|
|
|
|
|
{
|
2023-01-14 19:39:35 +02:00
|
|
|
if (player.attackNetwork.jumpCancelable && player.canChainAttack || player.isAir && player.canDoubleJump && player.canChainAttack)
|
2022-12-27 13:12:53 +02:00
|
|
|
{
|
|
|
|
|
if (player.direction.y > 0)
|
|
|
|
|
{
|
2023-01-28 17:42:01 +02:00
|
|
|
if (player.isAir)
|
|
|
|
|
{
|
|
|
|
|
player.canDoubleJump = false;
|
|
|
|
|
}
|
2023-01-29 15:10:49 +02:00
|
|
|
player.juggleBounce = true;
|
2022-12-27 13:12:53 +02:00
|
|
|
player.isCrouch = false;
|
|
|
|
|
player.isAir = false;
|
|
|
|
|
GameSimulation.Hitstop = 0;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Jump");
|
2022-12-27 13:12:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ToJumpForwardState(PlayerNetwork player)
|
|
|
|
|
{
|
2023-01-14 19:39:35 +02:00
|
|
|
if (player.attackNetwork.jumpCancelable && player.canChainAttack || player.isAir && player.canDoubleJump && player.canChainAttack)
|
2022-12-27 13:12:53 +02:00
|
|
|
{
|
|
|
|
|
if (player.direction.y > 0 && player.direction.x != 0)
|
|
|
|
|
{
|
2023-01-28 17:42:01 +02:00
|
|
|
if (player.isAir)
|
|
|
|
|
{
|
|
|
|
|
player.canDoubleJump = false;
|
|
|
|
|
}
|
2022-12-31 20:46:52 +02:00
|
|
|
player.jumpDirection = (int)player.direction.x;
|
2023-01-29 15:10:49 +02:00
|
|
|
player.juggleBounce = true;
|
2022-12-27 13:12:53 +02:00
|
|
|
player.isCrouch = false;
|
|
|
|
|
player.isAir = false;
|
|
|
|
|
GameSimulation.Hitstop = 0;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "JumpForward");
|
2022-12-27 13:12:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
private void ToIdleFallState(PlayerNetwork player)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if (player.isAir && (DemonFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonFloat)player.velocity.y <= (DemonFloat)0)
|
2022-12-26 03:47:56 +02:00
|
|
|
{
|
2023-06-27 17:23:24 +03:00
|
|
|
player.SetParticle("Fall", player.position);
|
2023-01-23 18:31:58 +02:00
|
|
|
player.sound = "Landed";
|
2023-01-07 23:17:55 +02:00
|
|
|
player.inPushback = false;
|
2022-12-26 03:47:56 +02:00
|
|
|
player.isCrouch = false;
|
|
|
|
|
player.isAir = false;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Idle");
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void ToIdleState(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.attackFrames <= 0)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if (player.isAir || (DemonFloat)player.position.y > DemonicsPhysics.GROUND_POINT)
|
2023-01-06 23:10:53 +02:00
|
|
|
{
|
|
|
|
|
player.isCrouch = false;
|
|
|
|
|
player.isAir = false;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Fall");
|
2023-01-06 23:10:53 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (player.direction.y < 0)
|
|
|
|
|
{
|
|
|
|
|
player.isCrouch = false;
|
|
|
|
|
player.isAir = false;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Crouch");
|
2023-01-06 23:10:53 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
player.isCrouch = false;
|
|
|
|
|
player.isAir = false;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Idle");
|
2023-01-06 23:10:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-09 18:16:00 +02:00
|
|
|
|
2023-01-09 00:34:18 +02:00
|
|
|
private void ToHurtState(PlayerNetwork player)
|
|
|
|
|
{
|
2023-01-20 17:59:16 +02:00
|
|
|
if (IsColliding(player))
|
2023-01-09 00:34:18 +02:00
|
|
|
{
|
2023-01-17 23:48:42 +02:00
|
|
|
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;
|
|
|
|
|
}
|
2023-01-17 00:02:29 +02:00
|
|
|
if (player.attackHurtNetwork.moveName == "Shadowbreak")
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Knockback");
|
2023-01-17 00:02:29 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2023-06-10 01:06:31 +03:00
|
|
|
if (player.attackNetwork.superArmor > 0 && !player.player.PlayerAnimator.InRecovery(player.animation, player.animationFrames))
|
2023-01-09 18:16:00 +02:00
|
|
|
{
|
2023-06-19 13:55:25 +03:00
|
|
|
SuperArmorHurt(player);
|
2023-01-09 18:16:00 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2023-01-09 00:34:18 +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-09 00:34:18 +02:00
|
|
|
player.otherPlayer.pushbackDuration = player.attackHurtNetwork.knockbackDuration;
|
|
|
|
|
}
|
2023-01-14 19:39:35 +02:00
|
|
|
|
2023-05-05 13:51:37 +03:00
|
|
|
player.player.PlayerUI.DisplayNotification(NotificationTypeEnum.Punish);
|
2023-01-20 17:59:16 +02:00
|
|
|
if (player.attackHurtNetwork.hardKnockdown)
|
2023-01-09 00:34:18 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Airborne");
|
2023-01-09 00:34:18 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if ((DemonFloat)player.position.y <= DemonicsPhysics.GROUND_POINT)
|
2023-01-09 00:34:18 +02:00
|
|
|
{
|
|
|
|
|
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Hurt");
|
2023-01-09 00:34:18 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "HurtAir");
|
2023-01-09 00:34:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-20 17:59:16 +02:00
|
|
|
else
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "HurtAir");
|
2023-01-20 17:59:16 +02:00
|
|
|
}
|
2023-01-09 00:34:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|