2023-01-02 22:29:32 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-12-26 03:47:56 +02:00
|
|
|
public class DeathState : State
|
|
|
|
|
{
|
2023-01-27 02:16:02 +02:00
|
|
|
//TODO: Refactor frame checks
|
2022-12-26 03:47:56 +02:00
|
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (!player.enter)
|
|
|
|
|
{
|
2023-01-28 16:02:34 +02:00
|
|
|
if (!SceneSettings.IsTrainingMode)
|
|
|
|
|
GameSimulation.Run = false;
|
2023-01-27 15:20:51 +02:00
|
|
|
GameSimulation.GlobalHitstop = 1;
|
2023-01-08 18:48:39 +02:00
|
|
|
player.velocity = DemonicsVector2.Zero;
|
2022-12-26 03:47:56 +02:00
|
|
|
player.enter = true;
|
|
|
|
|
player.animationFrames = 0;
|
|
|
|
|
player.player.StopShakeCoroutine();
|
2023-01-01 04:39:49 +02:00
|
|
|
GameplayManager.Instance.RoundOver(false);
|
2023-01-08 05:07:16 +02:00
|
|
|
player.healthRecoverable = 0;
|
2023-01-10 18:39:07 +02:00
|
|
|
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
|
2023-01-27 02:16:02 +02:00
|
|
|
ResetCombo(player);
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
2023-03-11 17:47:08 +02:00
|
|
|
if (player.position.y > DemonicsPhysics.GROUND_POINT)
|
|
|
|
|
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.GRAVITY);
|
|
|
|
|
else
|
|
|
|
|
player.velocity = new DemonicsVector2(player.velocity.x, 0);
|
2023-01-27 02:16:02 +02:00
|
|
|
player.animation = "Death";
|
2022-12-26 03:47:56 +02:00
|
|
|
player.animationFrames++;
|
2023-04-06 15:16:02 +03:00
|
|
|
if (player.animationFrames >= 255)
|
2023-01-03 00:31:55 +02:00
|
|
|
{
|
2023-01-28 16:02:34 +02:00
|
|
|
if (player.otherPlayer.state != "Taunt" && player.otherPlayer.health > 0)
|
2023-01-03 00:31:55 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player.otherPlayer, "Taunt");
|
2023-01-03 00:31:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-02 22:29:32 +02:00
|
|
|
if (SceneSettings.IsTrainingMode)
|
2023-01-02 19:59:46 +02:00
|
|
|
{
|
2023-04-06 15:16:02 +03:00
|
|
|
if (player.animationFrames >= 95)
|
2023-01-02 22:29:32 +02:00
|
|
|
{
|
2023-01-28 17:42:01 +02:00
|
|
|
player.invincible = false;
|
2023-01-08 18:48:39 +02:00
|
|
|
ResetPlayer(player);
|
|
|
|
|
ResetPlayer(player.otherPlayer);
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Idle");
|
2023-01-02 22:29:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-04-06 15:16:02 +03:00
|
|
|
if (player.animationFrames >= 375)
|
2023-01-02 22:29:32 +02:00
|
|
|
{
|
2023-03-11 15:57:01 +02:00
|
|
|
GameSimulation.Timer = GameSimulation._timerMax;
|
2023-01-28 17:42:01 +02:00
|
|
|
player.invincible = false;
|
2023-01-08 18:48:39 +02:00
|
|
|
ResetPlayer(player);
|
|
|
|
|
ResetPlayer(player.otherPlayer);
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Taunt");
|
|
|
|
|
EnterState(player.otherPlayer, "Taunt");
|
2023-01-02 22:29:32 +02:00
|
|
|
}
|
2023-01-02 19:59:46 +02:00
|
|
|
}
|
2023-01-12 19:12:56 +02:00
|
|
|
if (!player.hitstop)
|
2023-01-08 18:48:39 +02:00
|
|
|
{
|
|
|
|
|
Knockback(player);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void Knockback(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.attackHurtNetwork.knockbackDuration > 0 && player.knockback <= player.attackHurtNetwork.knockbackDuration)
|
|
|
|
|
{
|
|
|
|
|
DemonicsFloat ratio = (DemonicsFloat)player.knockback / (DemonicsFloat)player.attackHurtNetwork.knockbackDuration;
|
|
|
|
|
DemonicsFloat distance = player.pushbackEnd.x - player.pushbackStart.x;
|
|
|
|
|
DemonicsFloat nextX = DemonicsFloat.Lerp(player.pushbackStart.x, player.pushbackEnd.x, ratio);
|
|
|
|
|
DemonicsFloat baseY = DemonicsFloat.Lerp(player.pushbackStart.y, player.pushbackEnd.y, (nextX - player.pushbackStart.x) / distance);
|
|
|
|
|
DemonicsFloat arc = player.attackHurtNetwork.knockbackArc * (nextX - player.pushbackStart.x) * (nextX - player.pushbackEnd.x) / ((-0.25f) * distance * distance);
|
|
|
|
|
DemonicsVector2 nextPosition = DemonicsVector2.Zero;
|
|
|
|
|
if (player.attackHurtNetwork.softKnockdown)
|
|
|
|
|
{
|
|
|
|
|
nextPosition = new DemonicsVector2(nextX, baseY + arc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nextPosition = new DemonicsVector2(nextX, baseY + arc);
|
|
|
|
|
}
|
|
|
|
|
player.position = nextPosition;
|
|
|
|
|
player.knockback++;
|
|
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
}
|