You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
general update
This commit is contained in:
@@ -3,19 +3,31 @@ using UnityEngine;
|
||||
|
||||
public class AttackState : State
|
||||
{
|
||||
public static Vector2 start;
|
||||
private static Vector2 end;
|
||||
private static int knockbackFrame;
|
||||
private static bool knock;
|
||||
private static bool b;
|
||||
private static bool opponentInCorner;
|
||||
public override void UpdateLogic(PlayerNetwork player)
|
||||
{
|
||||
AttackSO attack = PlayerComboSystem.GetComboAttack(player.playerStats, player.attackInput, player.isCrouch, player.isAir);
|
||||
if (!player.enter)
|
||||
{
|
||||
b = false;
|
||||
SetTopPriority(player);
|
||||
player.animationFrames = 0;
|
||||
player.canChainAttack = false;
|
||||
player.inputBuffer.inputItems[0].frame = 0;
|
||||
player.enter = true;
|
||||
player.animation = attack.name;
|
||||
player.sound = attack.attackSound;
|
||||
player.animationFrames = 0;
|
||||
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
|
||||
opponentInCorner = false;
|
||||
if (DemonicsPhysics.IsInCorner(player.otherPlayer))
|
||||
{
|
||||
opponentInCorner = true;
|
||||
}
|
||||
}
|
||||
if (!player.isAir)
|
||||
{
|
||||
@@ -25,12 +37,21 @@ public class AttackState : State
|
||||
{
|
||||
player.velocity = new Vector2(player.velocity.x, player.velocity.y - player.gravity);
|
||||
}
|
||||
|
||||
if (GameSimulation.Hitstop <= 0)
|
||||
{
|
||||
player.animationFrames++;
|
||||
player.attackFrames--;
|
||||
if (player.canChainAttack)
|
||||
{
|
||||
if (!b)
|
||||
{
|
||||
b = true;
|
||||
knockbackFrame = 0;
|
||||
start = player.position;
|
||||
end = new Vector2(player.position.x + (attack.knockbackForce.x * -player.flip), (float)DemonicsPhysics.GROUND_POINT - 0.5f);
|
||||
}
|
||||
knock = true;
|
||||
if (player.inputBuffer.inputItems[0].frame + 20 >= DemonicsWorld.Frame)
|
||||
{
|
||||
player.attackInput = player.inputBuffer.inputItems[0].inputEnum;
|
||||
@@ -44,6 +65,34 @@ public class AttackState : State
|
||||
player.state = "Attack";
|
||||
}
|
||||
}
|
||||
if (knock)
|
||||
{
|
||||
if (opponentInCorner)
|
||||
{
|
||||
if (attack.knockbackDuration > 0)
|
||||
{
|
||||
if (knockbackFrame <= attack.knockbackDuration)
|
||||
{
|
||||
float ratio = (float)knockbackFrame / (float)attack.knockbackDuration;
|
||||
float distance = end.x - start.x;
|
||||
float nextX = Mathf.Lerp(start.x, end.x, ratio);
|
||||
float baseY = Mathf.Lerp(start.y, end.y, (nextX - start.x) / distance);
|
||||
float arc = attack.knockbackArc * (nextX - start.x) * (nextX - end.x) / ((-0.25f) * distance * distance);
|
||||
Vector2 nextPosition = new Vector2(nextX, baseY + arc);
|
||||
if (attack.causesSoftKnockdown)
|
||||
{
|
||||
nextPosition = new Vector2(nextX, player.position.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPosition = new Vector2(nextX, baseY + arc);
|
||||
}
|
||||
player.position = nextPosition;
|
||||
knockbackFrame++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ToIdleState(player);
|
||||
ToIdleFallState(player);
|
||||
@@ -52,6 +101,7 @@ public class AttackState : State
|
||||
{
|
||||
if (player.isAir && (DemonicsFloat)player.position.y <= DemonicsPhysics.GROUND_POINT && (DemonicsFloat)player.velocity.y <= (DemonicsFloat)0)
|
||||
{
|
||||
knock = false;
|
||||
player.isCrouch = false;
|
||||
player.isAir = false;
|
||||
player.attackInput = InputEnum.Direction;
|
||||
@@ -63,6 +113,8 @@ public class AttackState : State
|
||||
{
|
||||
if (player.attackFrames <= 0)
|
||||
{
|
||||
knock = false;
|
||||
player.enter = false;
|
||||
if (player.isAir)
|
||||
{
|
||||
player.isCrouch = false;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HurtAirborneState : State
|
||||
{
|
||||
public static Vector2 start;
|
||||
private static Vector2 end;
|
||||
private static int knockbackFrame;
|
||||
public override void UpdateLogic(PlayerNetwork player)
|
||||
{
|
||||
AttackSO hurtAttack = player.player.OtherPlayer.CurrentAttack;
|
||||
if (!player.enter)
|
||||
{
|
||||
player.health -= hurtAttack.damage;
|
||||
player.player.SetHealth(player.health);
|
||||
player.player.PlayerUI.Damaged();
|
||||
player.player.OtherPlayerUI.IncreaseCombo();
|
||||
player.sound = hurtAttack.impactSound;
|
||||
player.SetEffect(hurtAttack.hurtEffect, hurtAttack.hurtEffectPosition);
|
||||
if (hurtAttack.cameraShaker != null && !hurtAttack.causesSoftKnockdown)
|
||||
{
|
||||
CameraShake.Instance.Shake(hurtAttack.cameraShaker);
|
||||
}
|
||||
player.animationFrames = 0;
|
||||
player.stunFrames = hurtAttack.hitStun;
|
||||
player.enter = true;
|
||||
player.velocity = Vector2.zero;
|
||||
player.animationFrames = 0;
|
||||
GameSimulation.Hitstop = hurtAttack.hitstop;
|
||||
start = player.position;
|
||||
end = new Vector2(player.position.x + (hurtAttack.knockbackForce.x * -player.flip), player.position.y + end.y);
|
||||
}
|
||||
if (GameSimulation.Hitstop <= 0)
|
||||
{
|
||||
float ratio = (float)knockbackFrame / (float)hurtAttack.knockbackDuration;
|
||||
float distance = end.x - start.x;
|
||||
float nextX = Mathf.Lerp(start.x, end.x, ratio);
|
||||
float baseY = Mathf.Lerp(start.y, end.y, (nextX - start.x) / distance);
|
||||
float arc = hurtAttack.knockbackArc * (nextX - start.x) * (nextX - end.x) / ((-0.25f) * distance * distance);
|
||||
Vector2 nextPosition = new Vector2(nextX, baseY + arc);
|
||||
player.position = nextPosition;
|
||||
knockbackFrame++;
|
||||
ToIdleState(ratio, player);
|
||||
}
|
||||
player.animation = "HurtAir";
|
||||
player.animationFrames++;
|
||||
}
|
||||
private void ToIdleState(float ratio, PlayerNetwork player)
|
||||
{
|
||||
if (ratio >= 1)
|
||||
{
|
||||
player.enter = false;
|
||||
player.state = "Knockdown";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3e5c3f03f1122f44a00e9cd4f2718ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,75 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class HurtState : State
|
||||
{
|
||||
public static Vector2 start;
|
||||
private static Vector2 end;
|
||||
private static int knockbackFrame;
|
||||
public override void UpdateLogic(PlayerNetwork player)
|
||||
{
|
||||
AttackSO hurtAttack = PlayerComboSystem.GetComboAttack(player.playerStats, player.otherPlayer.attackInput, player.isCrouch, player.isAir);
|
||||
if (!player.enter)
|
||||
{
|
||||
player.health -= player.player.CalculateDamage(hurtAttack);
|
||||
player.player.SetHealth(player.player.CalculateDamage(hurtAttack));
|
||||
player.player.StartShakeContact();
|
||||
player.player.PlayerUI.Damaged();
|
||||
player.player.OtherPlayerUI.IncreaseCombo();
|
||||
player.enter = true;
|
||||
GameSimulation.Hitstop = hurtAttack.hitstop;
|
||||
player.sound = hurtAttack.impactSound;
|
||||
player.SetEffect(hurtAttack.hurtEffect, player.position);
|
||||
if (hurtAttack.cameraShaker != null && !hurtAttack.causesSoftKnockdown)
|
||||
{
|
||||
CameraShake.Instance.Shake(hurtAttack.cameraShaker);
|
||||
}
|
||||
player.animationFrames = 0;
|
||||
player.stunFrames = hurtAttack.hitStun;
|
||||
knockbackFrame = 0;
|
||||
start = player.position;
|
||||
end = new Vector2(player.position.x + (hurtAttack.knockbackForce.x * -player.flip), (float)DemonicsPhysics.GROUND_POINT - 0.5f);
|
||||
}
|
||||
player.animation = "Hurt";
|
||||
if (GameSimulation.Hitstop <= 0)
|
||||
{
|
||||
if (hurtAttack.knockbackDuration > 0)
|
||||
{
|
||||
float ratio = (float)knockbackFrame / (float)hurtAttack.knockbackDuration;
|
||||
float distance = end.x - start.x;
|
||||
float nextX = Mathf.Lerp(start.x, end.x, ratio);
|
||||
float baseY = Mathf.Lerp(start.y, end.y, (nextX - start.x) / distance);
|
||||
float arc = hurtAttack.knockbackArc * (nextX - start.x) * (nextX - end.x) / ((-0.25f) * distance * distance);
|
||||
Vector2 nextPosition = new Vector2(nextX, baseY + arc);
|
||||
if (hurtAttack.causesSoftKnockdown)
|
||||
{
|
||||
nextPosition = new Vector2(nextX, player.position.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextPosition = new Vector2(nextX, baseY + arc);
|
||||
}
|
||||
if (IsInCorner(player))
|
||||
{
|
||||
nextPosition = new Vector2(player.position.x, nextPosition.y);
|
||||
}
|
||||
player.position = nextPosition;
|
||||
knockbackFrame++;
|
||||
}
|
||||
player.player.StopShakeCoroutine();
|
||||
player.animationFrames++;
|
||||
player.stunFrames--;
|
||||
}
|
||||
ToIdleState(player);
|
||||
}
|
||||
private void ToIdleState(PlayerNetwork player)
|
||||
{
|
||||
if (player.stunFrames <= 0)
|
||||
{
|
||||
player.player.StopShakeCoroutine();
|
||||
player.player.OtherPlayer.StopComboTimer();
|
||||
player.player.PlayerUI.UpdateHealthDamaged();
|
||||
player.enter = false;
|
||||
player.state = "Idle";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48e912c5f14b6d949b71c218455016e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user