Files

192 lines
7.9 KiB
C#
Raw Normal View History

2022-12-26 03:47:56 +02:00
using UnityEngine;
public class ArcanaState : State
{
public override void UpdateLogic(PlayerNetwork player)
{
if (!player.enter)
{
if (player.CurrentState != this)
return;
2023-02-15 12:31:21 +02:00
SetTopPriority(player);
2023-01-12 19:12:56 +02:00
player.dashFrames = 0;
if (player.attackNetwork.name.Contains("R"))
2023-11-30 20:43:04 +02:00
{
player.arcanaGauge -= PlayerStatsSO.ARCANA_MULTIPLIER;
2023-11-30 20:43:04 +02:00
DemonVector2 effectPosition = new(player.position.x, player.position.y + 20);
player.SetParticle("Arcana", effectPosition);
}
2022-12-26 03:47:56 +02:00
player.enter = true;
2022-12-27 13:12:53 +02:00
player.canChainAttack = false;
2023-01-07 23:17:55 +02:00
player.animation = player.attackNetwork.name;
player.sound = player.attackNetwork.attackSound;
2022-12-26 03:47:56 +02:00
player.animationFrames = 0;
2023-01-14 19:39:35 +02:00
player.hitbox.enter = false;
2023-11-30 20:43:04 +02:00
2022-12-26 03:47:56 +02:00
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
2023-07-02 23:17:37 +03:00
player.velocity = new DemonVector2(player.attackNetwork.travelDistance.x * (DemonFloat)player.flip, (DemonFloat)player.attackNetwork.travelDistance.y);
2023-01-15 13:05:14 +02:00
player.InitializeProjectile(player.attackNetwork.moveName, player.attackNetwork, player.attackNetwork.projectileSpeed, player.attackNetwork.projectilePriority, player.attackNetwork.projectileDestroyOnHit);
player.invincible = player.player.PlayerAnimator.GetInvincible(player.animation, player.animationFrames);
if (player.invincible)
player.player.PlayerUI.DisplayNotification(NotificationTypeEnum.Reversal);
2023-10-01 17:21:54 +03:00
if (player.attackNetwork.superArmor > 0)
player.player.PlayerAnimator.ArmorMaterial();
UpdateFramedata(player);
return;
}
if (!player.hitstop)
{
if (player.attackNetwork.travelDistance.y > 0)
{
player.canChainAttack = false;
2023-07-02 23:17:37 +03:00
player.velocity = new DemonVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.GRAVITY);
ToIdleFallState(player);
}
player.animationFrames++;
player.attackFrames--;
2022-12-26 03:47:56 +02:00
}
2023-01-19 19:06:45 +02:00
player.invincible = player.player.PlayerAnimator.GetInvincible(player.animation, player.animationFrames);
2023-11-14 16:34:15 +02:00
player.invincible = player.player.PlayerAnimator.GetInvincible(player.animation, player.animationFrames);
2023-11-30 20:43:04 +02:00
if (player.invincible)
player.player.PlayerAnimator.InvincibleMaterial();
else if (player.attackNetwork.superArmor > 0)
player.player.PlayerAnimator.ArmorMaterial();
2023-10-01 17:21:54 +03:00
else
2023-11-30 20:43:04 +02:00
player.player.PlayerAnimator.NormalMaterial();
UpdateFramedata(player);
2022-12-26 03:47:56 +02:00
ToIdleState(player);
2023-01-12 19:12:56 +02:00
Projectile(player);
2023-01-09 00:34:18 +02:00
ToHurtState(player);
// if (!player.hitstop)
// AttackCancel(player);
2022-12-26 03:47:56 +02:00
}
2023-01-12 19:12:56 +02:00
private void Projectile(PlayerNetwork player)
{
if (player.dashFrames == 0)
{
bool isProjectile = player.player.PlayerAnimator.GetProjectile(player.animation, player.animationFrames);
if (isProjectile)
{
player.dashFrames = 1;
if (player.flip == 1)
{
player.SetProjectile(player.attackNetwork.moveName,
2023-07-02 23:17:37 +03:00
new DemonVector2(player.position.x + (player.attackNetwork.projectilePosition.x * player.flip), player.position.y + player.attackNetwork.projectilePosition.y), false);
2023-01-12 19:12:56 +02:00
}
else
{
player.SetProjectile(player.attackNetwork.moveName,
2023-07-02 23:17:37 +03:00
new DemonVector2(player.position.x + (player.attackNetwork.projectilePosition.x * player.flip), player.position.y + player.attackNetwork.projectilePosition.y), true);
2023-01-12 19:12:56 +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 && player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonFloat)player.velocity.y <= (DemonFloat)0)
2022-12-26 03:47:56 +02:00
{
player.canChainAttack = false;
2023-06-27 17:23:24 +03:00
player.SetParticle("Fall", player.position);
player.sound = "Landed";
CheckTrainingGauges(player);
2023-01-19 19:06:45 +02:00
player.invincible = false;
2023-01-12 19:12:56 +02:00
player.dashFrames = 0;
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 AttackCancel(PlayerNetwork player)
{
if (player.canChainAttack)
{
// InputItemNetwork input = player.inputBuffer.CurrentTrigger();
// if (input.frame != 0)
// {
// if ((DemonFloat)player.position.y > DemonicsPhysics.GROUND_POINT)
// player.isAir = true;
// if (input.inputEnum == InputEnum.Special)
// Arcana(player, player.isAir);
// }
}
}
2022-12-26 03:47:56 +02:00
private void ToIdleState(PlayerNetwork player)
{
if (player.attackFrames <= 0)
{
player.canChainAttack = false;
2023-01-19 19:06:45 +02:00
CheckTrainingGauges(player);
2023-01-12 19:12:56 +02:00
player.dashFrames = 0;
2023-01-08 23:39:08 +02:00
if (player.isAir || player.position.y > DemonicsPhysics.GROUND_POINT)
2022-12-26 03:47:56 +02:00
{
2023-06-27 17:23:24 +03:00
player.invincible = 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, "Fall");
2022-12-26 03:47:56 +02:00
}
else
{
2023-06-27 17:23:24 +03:00
if (player.invincible)
{
player.SetParticle("Fall", player.position);
player.sound = "Landed";
}
player.invincible = 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
}
}
}
2023-01-09 00:34:18 +02:00
private void ToHurtState(PlayerNetwork player)
{
if (IsColliding(player))
2023-01-09 00:34:18 +02:00
{
player.canChainAttack = false;
if (player.attackNetwork.superArmor > 0 && !player.player.PlayerAnimator.InRecovery(player.animation, player.animationFrames))
{
SuperArmorHurt(player);
return;
}
2023-01-12 19:12:56 +02:00
player.dashFrames = 0;
2023-01-09 00:34:18 +02:00
player.enter = false;
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-18 21:41:03 +02:00
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Throw)
2023-01-23 18:31:58 +02:00
EnterState(player, "Grabbed");
2023-01-14 19:39:35 +02:00
if (player.attackHurtNetwork.moveName == "Shadowbreak")
2023-01-23 18:31:58 +02:00
EnterState(player, "Knockback");
2023-01-09 00:34:18 +02:00
if (IsBlocking(player))
{
if (player.direction.y < 0)
2023-01-23 18:31:58 +02:00
EnterState(player, "BlockLow");
2023-01-09 00:34:18 +02:00
else
2023-01-23 18:31:58 +02:00
EnterState(player, "Block");
2023-01-09 00:34:18 +02:00
}
else
{
player.player.PlayerUI.DisplayNotification(NotificationTypeEnum.Punish);
2023-01-09 00:34:18 +02:00
if (player.attackHurtNetwork.hardKnockdown)
2023-01-23 18:31:58 +02:00
EnterState(player, "Airborne");
2023-01-09 00:34:18 +02:00
else
{
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
if (player.position.y <= DemonicsPhysics.GROUND_POINT)
EnterState(player, "Hurt");
else
EnterState(player, "HurtAir");
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
}
}
}
}
2022-12-26 03:47:56 +02:00
}