You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
105 lines
3.7 KiB
C#
105 lines
3.7 KiB
C#
using UnityEngine;
|
|
|
|
|
|
public class ArcanaState : State
|
|
{
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
{
|
|
if (!player.enter)
|
|
{
|
|
player.arcana -= PlayerStatsSO.ARCANA_MULTIPLIER;
|
|
player.enter = true;
|
|
player.canChainAttack = false;
|
|
player.animation = player.attackNetwork.name;
|
|
player.sound = player.attackNetwork.attackSound;
|
|
player.animationFrames = 0;
|
|
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
|
|
player.velocity = new DemonicsVector2(player.attackNetwork.travelDistance.x * (DemonicsFloat)player.flip, (DemonicsFloat)player.attackNetwork.travelDistance.y);
|
|
}
|
|
ToIdleState(player);
|
|
if (GameSimulation.Hitstop <= 0)
|
|
{
|
|
if (player.attackNetwork.travelDistance.y > 0)
|
|
{
|
|
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.GRAVITY);
|
|
ToIdleFallState(player);
|
|
}
|
|
player.animationFrames++;
|
|
player.attackFrames--;
|
|
}
|
|
ToHurtState(player);
|
|
}
|
|
private void ToIdleFallState(PlayerNetwork player)
|
|
{
|
|
if (player.isAir && player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0)
|
|
{
|
|
player.isCrouch = false;
|
|
player.isAir = false;
|
|
player.enter = false;
|
|
player.state = "Idle";
|
|
}
|
|
}
|
|
private void ToIdleState(PlayerNetwork player)
|
|
{
|
|
if (player.attackFrames <= 0)
|
|
{
|
|
player.enter = false;
|
|
if (player.isAir || player.position.y > DemonicsPhysics.GROUND_POINT)
|
|
{
|
|
player.isCrouch = false;
|
|
player.isAir = false;
|
|
player.state = "Fall";
|
|
}
|
|
else
|
|
{
|
|
player.isCrouch = false;
|
|
player.isAir = false;
|
|
player.state = "Idle";
|
|
}
|
|
}
|
|
}
|
|
private void ToHurtState(PlayerNetwork player)
|
|
{
|
|
if (!player.otherPlayer.canChainAttack && DemonicsCollider.Colliding(player.otherPlayer.hitbox, player.hurtbox))
|
|
{
|
|
player.enter = false;
|
|
player.attackHurtNetwork = player.otherPlayer.attackNetwork;
|
|
if (DemonicsPhysics.IsInCorner(player))
|
|
{
|
|
player.otherPlayer.knockback = 0;
|
|
player.otherPlayer.pushbackStart = player.otherPlayer.position;
|
|
player.otherPlayer.pushbackEnd = new DemonicsVector2(player.otherPlayer.position.x + (player.attackHurtNetwork.knockbackForce * -player.otherPlayer.flip), DemonicsPhysics.GROUND_POINT);
|
|
player.otherPlayer.pushbackDuration = player.attackHurtNetwork.knockbackDuration;
|
|
}
|
|
if (IsBlocking(player))
|
|
{
|
|
if (player.direction.y < 0)
|
|
{
|
|
player.state = "BlockLow";
|
|
}
|
|
else
|
|
{
|
|
player.state = "Block";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (player.attackHurtNetwork.hardKnockdown)
|
|
{
|
|
player.state = "Airborne";
|
|
}
|
|
else
|
|
{
|
|
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
|
|
{
|
|
player.state = "Hurt";
|
|
}
|
|
else
|
|
{
|
|
player.state = "HurtAir";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |