You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
Minor update
This commit is contained in:
@@ -7,58 +7,42 @@ public class BlockAirState : BlockParentState
|
||||
base.UpdateLogic(player);
|
||||
player.animation = "BlockAir";
|
||||
player.animationFrames++;
|
||||
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.JUGGLE_GRAVITY);
|
||||
ToFallState(player);
|
||||
}
|
||||
protected override void AfterHitstop(PlayerNetwork player)
|
||||
{
|
||||
base.AfterHitstop(player);
|
||||
ToIdleState(player);
|
||||
ToBlockState(player);
|
||||
}
|
||||
private void ToIdleState(PlayerNetwork player)
|
||||
{
|
||||
if ((DemonicsFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0 && player.knockback > 1)
|
||||
{
|
||||
player.player.StopShakeCoroutine();
|
||||
if (player.stunFrames <= 0)
|
||||
{
|
||||
player.enter = false;
|
||||
player.state = "Idle";
|
||||
}
|
||||
else
|
||||
{
|
||||
player.stunFrames = player.attackHurtNetwork.hitStun;
|
||||
player.velocity = DemonicsVector2.Zero;
|
||||
player.animationFrames = 0;
|
||||
player.state = "Block";
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ToFallState(PlayerNetwork player)
|
||||
{
|
||||
if (player.stunFrames <= 0)
|
||||
{
|
||||
player.player.StopShakeCoroutine();
|
||||
player.enter = false;
|
||||
player.state = "Fall";
|
||||
}
|
||||
}
|
||||
private void ToIdleState(PlayerNetwork player)
|
||||
{
|
||||
if (player.stunFrames <= 0)
|
||||
{
|
||||
if ((DemonicsFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0)
|
||||
{
|
||||
player.player.StopShakeCoroutine();
|
||||
player.sound = "Landed";
|
||||
player.SetEffect("Fall", player.position);
|
||||
player.enter = false;
|
||||
player.state = "Idle";
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ToBlockState(PlayerNetwork player)
|
||||
{
|
||||
if (player.stunFrames > 0)
|
||||
{
|
||||
if ((DemonicsFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0)
|
||||
{
|
||||
BlockParentState.skipKnockback = true;
|
||||
player.player.StopShakeCoroutine();
|
||||
player.sound = "Landed";
|
||||
player.SetEffect("Fall", player.position);
|
||||
player.enter = true;
|
||||
player.state = "Block";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnter(PlayerNetwork player)
|
||||
{
|
||||
base.OnEnter(player);
|
||||
end = new DemonicsVector2(player.position.x + (hurtAttack.knockbackForce.x * -player.flip), player.position.y);
|
||||
}
|
||||
protected override void AfterHitstop(PlayerNetwork player)
|
||||
{
|
||||
base.AfterHitstop(player);
|
||||
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - 0.013f);
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,4 @@ public class BlockLowState : BlockParentState
|
||||
player.state = "Idle";
|
||||
}
|
||||
}
|
||||
protected override void OnEnter(PlayerNetwork player)
|
||||
{
|
||||
base.OnEnter(player);
|
||||
end = new DemonicsVector2(player.position.x + (hurtAttack.knockbackForce.x * -player.flip), DemonicsPhysics.GROUND_POINT - 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ using UnityEngine;
|
||||
public class BlockParentState : State
|
||||
{
|
||||
public static bool skipKnockback;
|
||||
protected AttackSO hurtAttack;
|
||||
protected DemonicsVector2 start;
|
||||
protected DemonicsVector2 end;
|
||||
protected int knockbackFrame;
|
||||
public override void UpdateLogic(PlayerNetwork player)
|
||||
{
|
||||
if (!player.enter)
|
||||
@@ -20,21 +16,22 @@ public class BlockParentState : State
|
||||
{
|
||||
AfterHitstop(player);
|
||||
}
|
||||
ToHurtState(player);
|
||||
}
|
||||
|
||||
protected virtual void OnEnter(PlayerNetwork player)
|
||||
{
|
||||
hurtAttack = PlayerComboSystem.GetComboAttack(player.otherPlayer.playerStats, player.otherPlayer.attackInput, player.otherPlayer.isCrouch, player.otherPlayer.isAir);
|
||||
player.otherPlayer.canChainAttack = true;
|
||||
player.player.StartShakeContact();
|
||||
player.enter = true;
|
||||
GameSimulation.Hitstop = hurtAttack.hitstop;
|
||||
GameSimulation.Hitstop = player.attackHurtNetwork.hitstop;
|
||||
player.sound = "Block";
|
||||
DemonicsVector2 hurtEffectPosition = new DemonicsVector2(player.position.x + (5 * player.flip), player.otherPlayer.hitbox.position.y);
|
||||
hurtAttack.hurtEffectPosition = new Vector2((float)hurtEffectPosition.x, (float)hurtEffectPosition.y);
|
||||
if (hurtAttack.isArcana)
|
||||
if (player.attackHurtNetwork.hardKnockdown)
|
||||
{
|
||||
player.SetEffect("Chip", hurtEffectPosition);
|
||||
player.player.SetHealth(player.player.CalculateDamage(hurtAttack));
|
||||
player.health -= 200;
|
||||
player.healthRecoverable -= 200;
|
||||
player.player.PlayerUI.Damaged();
|
||||
player.player.PlayerUI.UpdateHealthDamaged();
|
||||
}
|
||||
@@ -43,50 +40,70 @@ public class BlockParentState : State
|
||||
player.SetEffect("Block", hurtEffectPosition);
|
||||
}
|
||||
player.animationFrames = 0;
|
||||
player.stunFrames = hurtAttack.hitStun;
|
||||
knockbackFrame = 0;
|
||||
start = player.position;
|
||||
end = new DemonicsVector2(player.position.x + (hurtAttack.knockbackForce.x * -player.flip), DemonicsPhysics.GROUND_POINT - 0.5f);
|
||||
player.stunFrames = player.attackHurtNetwork.hitStun;
|
||||
player.knockback = 0;
|
||||
player.pushbackStart = player.position;
|
||||
player.pushbackEnd = new DemonicsVector2(player.position.x + (player.attackHurtNetwork.knockbackForce * -player.flip), DemonicsPhysics.GROUND_POINT);
|
||||
player.velocity = DemonicsVector2.Zero;
|
||||
}
|
||||
|
||||
protected virtual void AfterHitstop(PlayerNetwork player)
|
||||
{
|
||||
if (!skipKnockback)
|
||||
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.GRAVITY);
|
||||
if (player.attackHurtNetwork.knockbackDuration > 0 && player.knockback <= player.attackHurtNetwork.knockbackDuration)
|
||||
{
|
||||
if (hurtAttack.knockbackDuration > 0)
|
||||
{
|
||||
DemonicsFloat ratio = (DemonicsFloat)knockbackFrame / (DemonicsFloat)hurtAttack.knockbackDuration;
|
||||
DemonicsFloat distance = end.x - start.x;
|
||||
DemonicsFloat nextX = DemonicsFloat.Lerp(start.x, end.x, ratio);
|
||||
DemonicsFloat baseY = DemonicsFloat.Lerp(start.y, end.y, (nextX - start.x) / distance);
|
||||
DemonicsFloat arc = hurtAttack.knockbackArc * (nextX - start.x) * (nextX - end.x) / ((-0.25f) * distance * distance);
|
||||
DemonicsVector2 nextPosition = new DemonicsVector2(nextX, baseY + arc);
|
||||
nextPosition = new DemonicsVector2(nextX, player.position.y);
|
||||
player.position = nextPosition;
|
||||
knockbackFrame++;
|
||||
}
|
||||
DemonicsFloat ratio = (DemonicsFloat)player.knockback / (DemonicsFloat)player.attackHurtNetwork.knockbackDuration;
|
||||
DemonicsFloat nextX = DemonicsFloat.Lerp(player.pushbackStart.x, player.pushbackEnd.x, ratio);
|
||||
DemonicsVector2 nextPosition = DemonicsVector2.Zero;
|
||||
nextPosition = new DemonicsVector2(nextX, player.position.y);
|
||||
player.position = nextPosition;
|
||||
player.knockback++;
|
||||
}
|
||||
player.player.StopShakeCoroutine();
|
||||
player.stunFrames--;
|
||||
}
|
||||
public override bool ToHurtState(PlayerNetwork player, AttackSO attack)
|
||||
private void ToHurtState(PlayerNetwork player)
|
||||
{
|
||||
player.enter = false;
|
||||
player.state = "Hurt";
|
||||
return true;
|
||||
}
|
||||
public override bool ToBlockState(PlayerNetwork player, AttackSO attack)
|
||||
{
|
||||
player.enter = false;
|
||||
if (player.direction.y < 0)
|
||||
if (!player.otherPlayer.canChainAttack && DemonicsCollider.Colliding(player.otherPlayer.hitbox, player.hurtbox))
|
||||
{
|
||||
player.state = "BlockLow";
|
||||
player.enter = false;
|
||||
player.attackHurtNetwork = player.otherPlayer.attackNetwork;
|
||||
if (IsBlocking(player))
|
||||
{
|
||||
if ((DemonicsFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0)
|
||||
{
|
||||
if (player.direction.y < 0)
|
||||
{
|
||||
player.state = "BlockLow";
|
||||
}
|
||||
else
|
||||
{
|
||||
player.state = "Block";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.state = "BlockAir";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.attackHurtNetwork.hardKnockdown)
|
||||
{
|
||||
player.state = "Airborne";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
|
||||
{
|
||||
player.state = "Hurt";
|
||||
}
|
||||
else
|
||||
{
|
||||
player.state = "HurtAir";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.state = "Block";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,5 @@ public class BlockState : BlockParentState
|
||||
protected override void OnEnter(PlayerNetwork player)
|
||||
{
|
||||
base.OnEnter(player);
|
||||
end = new DemonicsVector2(player.position.x + (hurtAttack.knockbackForce.x * -player.flip), DemonicsPhysics.GROUND_POINT - 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user