2022-12-31 20:46:52 +02:00
|
|
|
using System;
|
2023-01-12 19:12:56 +02:00
|
|
|
using UnityEngine;
|
2023-12-04 14:02:21 +02:00
|
|
|
using static TrainingSettings;
|
2022-12-31 20:46:52 +02:00
|
|
|
|
|
|
|
|
[Serializable]
|
2022-12-26 03:47:56 +02:00
|
|
|
public class State
|
|
|
|
|
{
|
|
|
|
|
public virtual void UpdateLogic(PlayerNetwork player) { }
|
2023-03-07 16:42:36 +02:00
|
|
|
public virtual void Exit(PlayerNetwork player) { }
|
2022-12-29 19:32:58 +02:00
|
|
|
public virtual bool ToHurtState(PlayerNetwork player, AttackSO attack) { return false; }
|
|
|
|
|
public virtual bool ToBlockState(PlayerNetwork player, AttackSO attack) { return false; }
|
2023-04-04 21:43:30 +03:00
|
|
|
public string StateName { get; set; }
|
2022-12-26 03:47:56 +02:00
|
|
|
public void CheckFlip(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (player.otherPlayer.position.x > player.position.x)
|
|
|
|
|
{
|
|
|
|
|
player.flip = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (player.otherPlayer.position.x < player.position.x)
|
|
|
|
|
{
|
|
|
|
|
player.flip = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void SetTopPriority(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
player.spriteOrder = 1;
|
|
|
|
|
player.otherPlayer.spriteOrder = 0;
|
|
|
|
|
}
|
2023-09-05 11:44:57 +03:00
|
|
|
public bool IsBlocking(PlayerNetwork player, bool ignoreGuardBreak = false)
|
2023-01-07 23:17:55 +02:00
|
|
|
{
|
2023-09-05 11:44:57 +03:00
|
|
|
if (ignoreGuardBreak && player.attackHurtNetwork.guardBreak)
|
|
|
|
|
player.player.PlayerUI.DisplayNotification(NotificationTypeEnum.Lock);
|
|
|
|
|
if (player.attackHurtNetwork.guardBreak && !ignoreGuardBreak)
|
2023-01-19 17:07:46 +02:00
|
|
|
return false;
|
2023-04-25 21:03:02 +03:00
|
|
|
if (AIBlocking(player, player.attackHurtNetwork.attackType))
|
2023-01-19 17:07:46 +02:00
|
|
|
return true;
|
2023-01-20 17:59:16 +02:00
|
|
|
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Low && player.direction.y >= 0)
|
2023-01-07 23:17:55 +02:00
|
|
|
return false;
|
|
|
|
|
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Overhead && player.direction.y < 0)
|
|
|
|
|
return false;
|
|
|
|
|
if (player.flip == 1 && player.direction.x < 0 || player.flip == -1 && player.direction.x > 0)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-07-03 00:44:54 +03:00
|
|
|
protected bool RedFrenzy(PlayerNetwork player)
|
2023-01-18 21:41:03 +02:00
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if (player.inputBuffer.GetRedFrenzy())
|
2023-01-18 21:41:03 +02:00
|
|
|
if (player.healthRecoverable > player.health)
|
|
|
|
|
{
|
|
|
|
|
AttackSO attack = PlayerComboSystem.GetRedFrenzy(player.playerStats);
|
|
|
|
|
player.attackNetwork = SetAttack(player.attackInput, attack);
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "RedFrenzy");
|
2023-07-03 00:44:54 +03:00
|
|
|
return true;
|
2023-01-18 21:41:03 +02:00
|
|
|
}
|
2023-07-03 00:44:54 +03:00
|
|
|
return false;
|
2023-01-18 21:41:03 +02:00
|
|
|
}
|
2023-01-06 23:10:53 +02:00
|
|
|
protected void Attack(PlayerNetwork player, bool air = false)
|
|
|
|
|
{
|
2023-07-01 23:48:47 +03:00
|
|
|
if ((player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Light || player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Medium
|
|
|
|
|
|| player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Heavy))
|
2023-01-08 23:50:20 +02:00
|
|
|
{
|
2023-01-18 21:41:03 +02:00
|
|
|
player.pushbackDuration = 0;
|
2023-07-01 23:48:47 +03:00
|
|
|
player.attackInput = player.inputBuffer.CurrentTrigger().inputEnum;
|
2023-01-08 23:50:20 +02:00
|
|
|
player.isCrouch = false;
|
2023-01-18 21:41:03 +02:00
|
|
|
player.isAir = air;
|
2023-11-11 17:34:21 +02:00
|
|
|
if ((player.direction.y < 0) || player.inputBuffer.RecentDownInput())
|
2023-01-18 21:41:03 +02:00
|
|
|
player.isCrouch = true;
|
|
|
|
|
if (player.isAir)
|
|
|
|
|
player.isCrouch = false;
|
2024-01-08 23:13:48 +02:00
|
|
|
AttackSO attack = PlayerComboSystem.GetComboAttack(player.playerStats, player.attackInput, new Vector2(player.direction.x * player.flip, player.direction.y), player.isAir);
|
2023-02-27 16:15:20 +02:00
|
|
|
if (attack != null)
|
|
|
|
|
{
|
|
|
|
|
player.attackNetwork = SetAttack(player.attackInput, attack);
|
|
|
|
|
EnterState(player, "Attack");
|
|
|
|
|
}
|
2023-01-08 23:50:20 +02:00
|
|
|
}
|
2023-01-06 23:10:53 +02:00
|
|
|
}
|
2023-11-14 15:31:56 +02:00
|
|
|
protected void Arcana(PlayerNetwork player, bool air = false, bool skipCheck = false)
|
2023-01-07 23:17:55 +02:00
|
|
|
{
|
2023-11-14 15:31:56 +02:00
|
|
|
if (player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Special || skipCheck)
|
2023-01-07 23:17:55 +02:00
|
|
|
{
|
2023-07-01 23:48:47 +03:00
|
|
|
player.attackInput = player.inputBuffer.CurrentTrigger().inputEnum;
|
2023-01-17 23:48:42 +02:00
|
|
|
player.isAir = air;
|
|
|
|
|
player.isCrouch = false;
|
2023-11-14 15:31:56 +02:00
|
|
|
if ((player.direction.y < 0) || player.inputBuffer.RecentDownInput())
|
2023-01-17 23:48:42 +02:00
|
|
|
player.isCrouch = true;
|
2023-11-14 15:31:56 +02:00
|
|
|
//bool frenzied = player.inputBuffer.RecentTrigger(InputEnum.Throw);
|
|
|
|
|
bool frenzied = true;
|
|
|
|
|
if (player.arcanaGauge < PlayerStatsSO.ARCANA_MULTIPLIER)
|
|
|
|
|
frenzied = false;
|
2024-01-08 23:13:48 +02:00
|
|
|
ArcanaSO attack = PlayerComboSystem.GetArcana(player.playerStats, new Vector2(player.direction.x * player.flip, player.direction.y), player.isAir, frenzied);
|
2023-01-17 23:48:42 +02:00
|
|
|
if (attack != null)
|
|
|
|
|
{
|
2023-12-04 02:06:05 +02:00
|
|
|
player.canChainAttack = false;
|
2023-01-17 23:48:42 +02:00
|
|
|
player.attackNetwork = SetArcana(player.attackInput, attack);
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Arcana");
|
2023-01-17 23:48:42 +02:00
|
|
|
}
|
2023-01-16 13:26:54 +02:00
|
|
|
}
|
2023-01-07 23:17:55 +02:00
|
|
|
}
|
2023-01-15 13:05:14 +02:00
|
|
|
protected AttackNetwork SetArcana(InputEnum input, ArcanaSO attack)
|
2023-01-09 18:16:00 +02:00
|
|
|
{
|
2023-01-15 13:05:14 +02:00
|
|
|
AttackNetwork attackNetwork = new AttackNetwork()
|
2023-01-09 18:16:00 +02:00
|
|
|
{
|
|
|
|
|
damage = attack.damage,
|
2023-07-02 23:17:37 +03:00
|
|
|
travelDistance = new DemonVector2((DemonFloat)attack.travelDistance.x, (DemonFloat)attack.travelDistance.y),
|
2023-01-09 18:16:00 +02:00
|
|
|
name = attack.name,
|
2023-01-12 19:12:56 +02:00
|
|
|
moveName = attack.moveName,
|
2023-01-09 18:16:00 +02:00
|
|
|
attackSound = attack.attackSound,
|
|
|
|
|
hurtEffect = attack.hurtEffect,
|
2023-07-02 23:17:37 +03:00
|
|
|
knockbackForce = (DemonFloat)attack.knockbackForce.x,
|
2023-01-09 18:16:00 +02:00
|
|
|
knockbackDuration = attack.knockbackDuration,
|
|
|
|
|
hitstop = attack.hitstop,
|
|
|
|
|
impactSound = attack.impactSound,
|
|
|
|
|
hitStun = attack.hitStun,
|
2023-04-25 01:41:59 +03:00
|
|
|
blockStun = attack.blockStun,
|
2023-01-09 18:16:00 +02:00
|
|
|
knockbackArc = attack.knockbackArc,
|
|
|
|
|
jumpCancelable = attack.jumpCancelable,
|
|
|
|
|
softKnockdown = attack.causesSoftKnockdown,
|
|
|
|
|
hardKnockdown = attack.causesKnockdown,
|
2023-07-02 23:17:37 +03:00
|
|
|
projectilePosition = new DemonVector2((DemonFloat)attack.hitEffectPosition.x, (DemonFloat)attack.hitEffectPosition.y),
|
2023-01-15 13:05:14 +02:00
|
|
|
comboTimerStarter = input == InputEnum.Heavy ? ComboTimerStarterEnum.Red : ComboTimerStarterEnum.Yellow,
|
2023-01-12 19:12:56 +02:00
|
|
|
attackType = attack.attackTypeEnum,
|
2023-06-10 01:06:31 +03:00
|
|
|
superArmor = attack.superArmor,
|
2023-07-02 23:17:37 +03:00
|
|
|
projectileSpeed = (DemonFloat)attack.projectileSpeed,
|
2023-01-13 17:25:03 +02:00
|
|
|
projectileDestroyOnHit = attack.projectileDestroyOnHit,
|
|
|
|
|
projectilePriority = attack.projectilePriority
|
2023-01-12 19:12:56 +02:00
|
|
|
};
|
|
|
|
|
if (attack.cameraShaker != null)
|
|
|
|
|
{
|
2023-01-15 13:05:14 +02:00
|
|
|
attackNetwork.cameraShakerNetwork = new CameraShakerNetwork() { intensity = attack.cameraShaker.intensity, timer = attack.cameraShaker.timer };
|
2023-01-12 19:12:56 +02:00
|
|
|
}
|
2023-01-15 13:05:14 +02:00
|
|
|
return attackNetwork;
|
2023-01-12 19:12:56 +02:00
|
|
|
}
|
2023-01-15 13:05:14 +02:00
|
|
|
protected AttackNetwork SetAttack(InputEnum input, AttackSO attack)
|
2023-01-12 19:12:56 +02:00
|
|
|
{
|
2023-01-15 13:05:14 +02:00
|
|
|
AttackNetwork attackNetwork = new AttackNetwork()
|
2023-01-12 19:12:56 +02:00
|
|
|
{
|
|
|
|
|
damage = attack.damage,
|
2023-07-02 23:17:37 +03:00
|
|
|
travelDistance = new DemonVector2((DemonFloat)attack.travelDistance.x, (DemonFloat)attack.travelDistance.y),
|
2023-01-12 19:12:56 +02:00
|
|
|
name = attack.name,
|
|
|
|
|
moveName = attack.moveName,
|
|
|
|
|
attackSound = attack.attackSound,
|
|
|
|
|
hurtEffect = attack.hurtEffect,
|
2023-07-02 23:17:37 +03:00
|
|
|
knockbackForce = (DemonFloat)attack.knockbackForce.x,
|
2023-01-12 19:12:56 +02:00
|
|
|
knockbackDuration = attack.knockbackDuration,
|
|
|
|
|
hitstop = attack.hitstop,
|
|
|
|
|
impactSound = attack.impactSound,
|
|
|
|
|
hitStun = attack.hitStun,
|
2023-04-25 01:41:59 +03:00
|
|
|
blockStun = attack.blockStun,
|
2023-01-12 19:12:56 +02:00
|
|
|
knockbackArc = attack.knockbackArc,
|
|
|
|
|
jumpCancelable = attack.jumpCancelable,
|
|
|
|
|
softKnockdown = attack.causesSoftKnockdown,
|
|
|
|
|
hardKnockdown = attack.causesKnockdown,
|
2023-07-02 23:17:37 +03:00
|
|
|
projectilePosition = new DemonVector2((DemonFloat)attack.hitEffectPosition.x, (DemonFloat)attack.hitEffectPosition.y),
|
2023-01-15 13:05:14 +02:00
|
|
|
comboTimerStarter = input == InputEnum.Heavy ? ComboTimerStarterEnum.Red : ComboTimerStarterEnum.Yellow,
|
2023-01-09 18:16:00 +02:00
|
|
|
attackType = attack.attackTypeEnum,
|
2023-06-10 01:06:31 +03:00
|
|
|
superArmor = attack.superArmor,
|
2023-01-09 18:16:00 +02:00
|
|
|
};
|
2023-01-10 18:39:07 +02:00
|
|
|
if (attack.cameraShaker != null)
|
|
|
|
|
{
|
2023-01-15 13:05:14 +02:00
|
|
|
attackNetwork.cameraShakerNetwork = new CameraShakerNetwork() { intensity = attack.cameraShaker.intensity, timer = attack.cameraShaker.timer };
|
2023-01-10 18:39:07 +02:00
|
|
|
}
|
2023-01-15 13:05:14 +02:00
|
|
|
return attackNetwork;
|
2023-01-09 18:16:00 +02:00
|
|
|
}
|
2023-01-08 18:48:39 +02:00
|
|
|
public void ResetPlayer(PlayerNetwork player)
|
|
|
|
|
{
|
2023-11-26 13:48:40 +02:00
|
|
|
player.inputBuffer.AddTrigger(new InputItemNetwork()
|
|
|
|
|
{
|
|
|
|
|
inputEnum = InputEnum.Neutral,
|
|
|
|
|
frame = GameSimulation.FramesStatic,
|
|
|
|
|
time = GameSimulation.FramesStatic,
|
|
|
|
|
sequence = true,
|
|
|
|
|
pressed = true
|
|
|
|
|
});
|
2023-01-29 15:10:49 +02:00
|
|
|
player.dashDirection = 0;
|
2023-01-08 18:48:39 +02:00
|
|
|
player.healthRecoverable = 10000;
|
|
|
|
|
player.health = 10000;
|
2023-06-16 15:26:10 +03:00
|
|
|
player.shadowGauge = GameSimulation.maxShadowGauge;
|
2023-01-08 18:48:39 +02:00
|
|
|
player.player.PlayerUI.CheckDemonLimit(player.health);
|
|
|
|
|
player.enter = false;
|
2023-01-19 19:06:45 +02:00
|
|
|
CheckTrainingGauges(player);
|
2023-01-08 18:48:39 +02:00
|
|
|
}
|
2023-01-19 17:07:46 +02:00
|
|
|
public void ResetPlayerTraining(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
ResetPlayer(player);
|
|
|
|
|
ResetCombo(player);
|
|
|
|
|
GameSimulation.Hitstop = 0;
|
|
|
|
|
player.shadow.isOnScreen = false;
|
|
|
|
|
player.shadow.projectile.active = false;
|
|
|
|
|
for (int i = 0; i < player.projectiles.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
player.projectiles[i].active = false;
|
|
|
|
|
}
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Idle");
|
2023-01-19 17:07:46 +02:00
|
|
|
}
|
2023-01-17 00:02:29 +02:00
|
|
|
protected int CalculateDamage(PlayerNetwork player, int damage, float defense)
|
2023-01-09 18:16:00 +02:00
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonFloat calculatedDamage = (DemonFloat)damage / (DemonFloat)defense;
|
2023-01-17 00:02:29 +02:00
|
|
|
if (player.combo > 1)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonFloat damageScale = (DemonFloat)1;
|
2023-01-17 00:02:29 +02:00
|
|
|
for (int i = 0; i < player.combo; i++)
|
|
|
|
|
{
|
2023-07-09 04:00:35 +03:00
|
|
|
damageScale *= (DemonFloat)0.96;
|
2023-01-17 00:02:29 +02:00
|
|
|
}
|
|
|
|
|
calculatedDamage *= damageScale;
|
|
|
|
|
}
|
|
|
|
|
int calculatedIntDamage = (int)calculatedDamage;
|
|
|
|
|
SetResultAttack(player, calculatedIntDamage, player.attackHurtNetwork);
|
|
|
|
|
return calculatedIntDamage;
|
2023-01-09 18:16:00 +02:00
|
|
|
}
|
2023-01-17 00:02:29 +02:00
|
|
|
protected int CalculateRecoverableDamage(PlayerNetwork player, int damage, float defense)
|
2023-01-09 18:16:00 +02:00
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonFloat calculatedDamage = ((DemonFloat)damage / (DemonFloat)defense) - 120;
|
2023-01-17 00:02:29 +02:00
|
|
|
if (player.combo > 1)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonFloat damageScale = (DemonFloat)1;
|
2023-01-17 00:02:29 +02:00
|
|
|
for (int i = 0; i < player.combo; i++)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
damageScale *= (DemonFloat)0.97;
|
2023-01-17 00:02:29 +02:00
|
|
|
}
|
|
|
|
|
calculatedDamage *= damageScale;
|
|
|
|
|
}
|
|
|
|
|
int calculatedIntDamage = (int)calculatedDamage;
|
|
|
|
|
return calculatedIntDamage;
|
2023-01-09 18:16:00 +02:00
|
|
|
}
|
2023-01-17 00:02:29 +02:00
|
|
|
|
2023-04-01 16:29:28 +03:00
|
|
|
protected void UpdateFramedata(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.IsTrainingMode)
|
|
|
|
|
player.framedataEnum = player.player.PlayerAnimator.GetFramedata(player.animation, player.animationFrames);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 00:02:29 +02:00
|
|
|
private void SetResultAttack(PlayerNetwork player, int calculatedDamage, AttackNetwork attack)
|
|
|
|
|
{
|
|
|
|
|
player.otherPlayer.resultAttack.startUpFrames = attack.startup;
|
|
|
|
|
player.otherPlayer.resultAttack.activeFrames = attack.active;
|
|
|
|
|
player.otherPlayer.resultAttack.recoveryFrames = attack.recovery;
|
|
|
|
|
player.otherPlayer.resultAttack.attackTypeEnum = attack.attackType;
|
|
|
|
|
player.otherPlayer.resultAttack.damage = calculatedDamage;
|
|
|
|
|
player.otherPlayer.resultAttack.comboDamage += calculatedDamage;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 20:10:11 +02:00
|
|
|
protected void ThrowEnd(PlayerNetwork player)
|
|
|
|
|
{
|
2023-11-10 22:08:32 +02:00
|
|
|
CameraShake.Instance.ZoomDefault(0.05f);
|
2023-01-10 20:10:11 +02:00
|
|
|
player.combo++;
|
2023-01-17 00:02:29 +02:00
|
|
|
player.health -= CalculateDamage(player, player.attackHurtNetwork.damage, player.playerStats.Defense);
|
|
|
|
|
player.healthRecoverable -= CalculateRecoverableDamage(player, player.attackHurtNetwork.damage, player.playerStats.Defense);
|
2023-10-15 10:25:11 +03:00
|
|
|
player.player.PlayerUI.Damaged();
|
|
|
|
|
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
|
2023-01-10 20:10:11 +02:00
|
|
|
player.player.OtherPlayerUI.IncreaseCombo(player.combo);
|
2023-01-19 17:07:46 +02:00
|
|
|
if (player.position.x >= DemonicsPhysics.WALL_RIGHT_POINT)
|
2023-07-02 23:17:37 +03:00
|
|
|
player.position = new DemonVector2(DemonicsPhysics.WALL_RIGHT_POINT, player.position.y);
|
2023-01-19 17:07:46 +02:00
|
|
|
else if (player.position.x <= DemonicsPhysics.WALL_LEFT_POINT)
|
2023-07-02 23:17:37 +03:00
|
|
|
player.position = new DemonVector2(DemonicsPhysics.WALL_LEFT_POINT, player.position.y);
|
|
|
|
|
player.SetParticle(player.attackHurtNetwork.hurtEffect, new DemonVector2(player.position.x, player.position.y));
|
2023-10-11 02:25:05 +03:00
|
|
|
GameSimulation.Hitstop = 10;
|
2023-04-14 17:47:29 +03:00
|
|
|
HitstopFully(player);
|
|
|
|
|
HitstopFully(player.otherPlayer);
|
2023-01-19 17:07:46 +02:00
|
|
|
}
|
2023-01-23 18:31:58 +02:00
|
|
|
public void CheckTrainingComboEnd(PlayerNetwork player, bool skipCombo = false)
|
2023-01-19 17:07:46 +02:00
|
|
|
{
|
|
|
|
|
if (SceneSettings.IsTrainingMode)
|
|
|
|
|
{
|
|
|
|
|
if (GameplayManager.Instance.InfiniteHealth)
|
|
|
|
|
{
|
|
|
|
|
player.health = 10000;
|
|
|
|
|
player.healthRecoverable = 10000;
|
|
|
|
|
}
|
2023-01-26 18:52:03 +02:00
|
|
|
player.player.PlayerUI.CheckDemonLimit(player.health);
|
2023-01-23 18:31:58 +02:00
|
|
|
CheckTrainingGauges(player.otherPlayer, skipCombo);
|
2023-01-19 19:06:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-23 18:31:58 +02:00
|
|
|
public void CheckTrainingGauges(PlayerNetwork player, bool skipCombo = false)
|
2023-01-19 19:06:45 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
if (SceneSettings.IsTrainingMode && player.otherPlayer.combo == 0 || skipCombo)
|
2023-01-19 19:06:45 +02:00
|
|
|
{
|
2023-01-19 17:07:46 +02:00
|
|
|
if (GameplayManager.Instance.InfiniteArcana)
|
|
|
|
|
{
|
2023-01-19 19:06:45 +02:00
|
|
|
player.arcanaGauge = player.playerStats.Arcana;
|
2023-01-19 17:07:46 +02:00
|
|
|
}
|
|
|
|
|
if (GameplayManager.Instance.InfiniteAssist)
|
|
|
|
|
{
|
2023-06-16 15:26:10 +03:00
|
|
|
player.shadowGauge = GameSimulation.maxShadowGauge;
|
2023-01-19 17:07:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-19 19:06:45 +02:00
|
|
|
|
2023-01-23 18:31:58 +02:00
|
|
|
public void EnterState(PlayerNetwork player, string name, bool skipEnter = false)
|
|
|
|
|
{
|
2023-03-11 17:47:08 +02:00
|
|
|
if (!player.gotHit || name.Contains("Hurt") || name.Contains("Airborne") || name.Contains("Grabbed") || name.Contains("Block") || name.Contains("Knockback"))
|
2023-02-22 20:02:39 +02:00
|
|
|
{
|
2023-10-01 17:21:54 +03:00
|
|
|
player.player.PlayerAnimator.NormalMaterial();
|
2023-04-01 16:29:28 +03:00
|
|
|
player.framedataEnum = Demonics.FramedataTypesEnum.None;
|
2023-02-22 20:02:39 +02:00
|
|
|
player.enter = skipEnter;
|
|
|
|
|
player.state = name;
|
|
|
|
|
StateSimulation.SetState(player);
|
2023-04-04 21:43:30 +03:00
|
|
|
player.CurrentState.UpdateLogic(player);
|
2023-02-22 20:02:39 +02:00
|
|
|
}
|
2023-01-23 18:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void HitstopFully(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
player.hitstop = true;
|
|
|
|
|
player.shadow.projectile.hitstop = true;
|
|
|
|
|
for (int i = 0; i < player.projectiles.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
player.projectiles[i].hitstop = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 13:56:15 +02:00
|
|
|
public bool AIHurt(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.IsTrainingMode && player.isAi)
|
|
|
|
|
{
|
|
|
|
|
if (TrainingSettings.OnHit)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if ((DemonFloat)player.position.y > DemonicsPhysics.GROUND_POINT)
|
2023-03-06 13:56:15 +02:00
|
|
|
{
|
|
|
|
|
player.isAir = true;
|
|
|
|
|
}
|
2024-01-08 23:13:48 +02:00
|
|
|
AttackSO attack = PlayerComboSystem.GetComboAttack(player.playerStats, InputEnum.Light, Vector2.zero, player.isAir);
|
2023-03-06 13:56:15 +02:00
|
|
|
player.attackNetwork = SetAttack(InputEnum.Light, attack);
|
|
|
|
|
EnterState(player, "Attack");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-04-25 21:03:02 +03:00
|
|
|
public bool AIBlocking(PlayerNetwork player, AttackTypeEnum attackType)
|
2023-01-19 17:07:46 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
if (SceneSettings.IsTrainingMode && player.isAi)
|
2023-12-04 14:02:21 +02:00
|
|
|
{
|
|
|
|
|
bool canBlock = false;
|
|
|
|
|
if (TrainingSettings.Block == BlockType.BlockAlways)
|
|
|
|
|
canBlock = true;
|
|
|
|
|
if (TrainingSettings.Block == BlockType.BlockCount && TrainingSettings.BlockCountCurrent > 0)
|
|
|
|
|
{
|
|
|
|
|
TrainingSettings.BlockCountCurrent--;
|
|
|
|
|
canBlock = true;
|
|
|
|
|
}
|
|
|
|
|
if (canBlock)
|
2023-01-19 17:07:46 +02:00
|
|
|
{
|
2023-04-25 21:03:02 +03:00
|
|
|
if (attackType == AttackTypeEnum.Low)
|
|
|
|
|
player.direction.y = -1;
|
|
|
|
|
else
|
|
|
|
|
player.direction.y = 0;
|
2023-01-19 17:07:46 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2023-12-04 14:02:21 +02:00
|
|
|
}
|
|
|
|
|
TrainingSettings.BlockCountCurrent = TrainingSettings.BlockCount;
|
2023-01-19 17:07:46 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
protected void ResetCombo(PlayerNetwork player)
|
|
|
|
|
{
|
2023-05-28 16:29:38 +03:00
|
|
|
player.otherPlayer.shadow.usedInCombo = false;
|
2023-01-19 23:25:44 +02:00
|
|
|
player.otherPlayer.resultAttack.comboDamage = 0;
|
2023-01-19 17:07:46 +02:00
|
|
|
player.player.PlayerUI.SetComboTimerActive(false);
|
|
|
|
|
player.player.StopShakeCoroutine();
|
|
|
|
|
player.player.OtherPlayerUI.ResetCombo();
|
|
|
|
|
player.combo = 0;
|
2023-01-19 19:06:45 +02:00
|
|
|
player.comboLocked = false;
|
|
|
|
|
CheckTrainingComboEnd(player);
|
2023-01-10 20:10:11 +02:00
|
|
|
}
|
2023-01-12 19:12:56 +02:00
|
|
|
protected bool IsColliding(PlayerNetwork player)
|
|
|
|
|
{
|
2023-01-27 15:20:51 +02:00
|
|
|
if (player.invincible && player.health <= 0)
|
2023-01-19 19:06:45 +02:00
|
|
|
return false;
|
2023-01-19 02:51:24 +02:00
|
|
|
if (player.otherPlayer.shadow.projectile.active)
|
2023-01-14 19:39:35 +02:00
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
if (DemonicsCollider.Colliding(player.otherPlayer.shadow.projectile.hitbox, player.hurtbox) && !player.otherPlayer.shadow.projectile.hitbox.enter)
|
2023-01-14 19:39:35 +02:00
|
|
|
{
|
2023-01-19 02:51:24 +02:00
|
|
|
player.attackHurtNetwork = player.otherPlayer.shadow.projectile.attackNetwork;
|
|
|
|
|
GameSimulation.Hitstop = player.attackHurtNetwork.hitstop;
|
2023-06-10 00:31:51 +03:00
|
|
|
player.hitstop = true;
|
2023-01-23 18:31:58 +02:00
|
|
|
player.otherPlayer.shadow.projectile.hitstop = true;
|
|
|
|
|
player.otherPlayer.shadow.projectile.hitbox.enter = true;
|
2023-01-19 02:51:24 +02:00
|
|
|
player.otherPlayer.shadow.projectile.hitstop = true;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.hurtPosition = new DemonVector2(player.otherPlayer.shadow.projectile.hitbox.position.x + ((player.otherPlayer.shadow.projectile.hitbox.size.x / 2) * -player.flip), player.otherPlayer.shadow.projectile.hitbox.position.y);
|
2023-01-19 02:51:24 +02:00
|
|
|
if (player.otherPlayer.shadow.projectile.destroyOnHit)
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
player.otherPlayer.shadow.projectile.hitbox.enter = false;
|
2023-01-19 02:51:24 +02:00
|
|
|
player.otherPlayer.shadow.projectile.hitstop = false;
|
|
|
|
|
player.otherPlayer.shadow.projectile.animationFrames = 0;
|
|
|
|
|
player.otherPlayer.shadow.projectile.active = false;
|
|
|
|
|
player.otherPlayer.shadow.projectile.hitbox.active = false;
|
|
|
|
|
}
|
2023-02-22 20:02:39 +02:00
|
|
|
player.gotHit = true;
|
2023-01-19 02:51:24 +02:00
|
|
|
return true;
|
2023-01-14 19:39:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-12 19:12:56 +02:00
|
|
|
for (int i = 0; i < player.otherPlayer.projectiles.Length; i++)
|
|
|
|
|
{
|
2023-01-19 02:51:24 +02:00
|
|
|
if (player.otherPlayer.projectiles[i].active)
|
2023-01-12 19:12:56 +02:00
|
|
|
{
|
2023-01-19 02:51:24 +02:00
|
|
|
if (DemonicsCollider.Colliding(player.otherPlayer.projectiles[i].hitbox, player.hurtbox) && !player.otherPlayer.projectiles[i].hitbox.enter)
|
2023-01-12 19:12:56 +02:00
|
|
|
{
|
2023-01-19 02:51:24 +02:00
|
|
|
player.attackHurtNetwork = player.otherPlayer.projectiles[i].attackNetwork;
|
|
|
|
|
GameSimulation.Hitstop = player.attackHurtNetwork.hitstop;
|
|
|
|
|
player.hitstop = true;
|
|
|
|
|
player.otherPlayer.projectiles[i].hitbox.enter = true;
|
|
|
|
|
player.otherPlayer.projectiles[i].hitstop = true;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.hurtPosition = new DemonVector2(player.position.x, player.position.y + (player.pushbox.size.y / 2));
|
2023-01-19 02:51:24 +02:00
|
|
|
if (player.otherPlayer.projectiles[i].destroyOnHit)
|
|
|
|
|
{
|
|
|
|
|
player.otherPlayer.projectiles[i].hitbox.enter = false;
|
|
|
|
|
player.otherPlayer.projectiles[i].hitstop = false;
|
|
|
|
|
player.otherPlayer.projectiles[i].animationFrames = 0;
|
|
|
|
|
player.otherPlayer.projectiles[i].active = false;
|
|
|
|
|
player.otherPlayer.projectiles[i].hitbox.active = false;
|
|
|
|
|
}
|
2023-02-22 20:02:39 +02:00
|
|
|
player.gotHit = true;
|
2023-01-19 02:51:24 +02:00
|
|
|
return true;
|
2023-01-12 19:12:56 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-14 19:39:35 +02:00
|
|
|
if (DemonicsCollider.Colliding(player.otherPlayer.hitbox, player.hurtbox) && !player.otherPlayer.hitbox.enter)
|
2023-01-12 19:12:56 +02:00
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
if (player.otherPlayer.attackNetwork.attackType == AttackTypeEnum.Throw && player.stunFrames == 0 && (DemonFloat)player.position.y > DemonicsPhysics.GROUND_POINT)
|
2023-01-23 18:31:58 +02:00
|
|
|
return false;
|
2023-01-15 13:05:14 +02:00
|
|
|
player.attackHurtNetwork = player.otherPlayer.attackNetwork;
|
|
|
|
|
GameSimulation.Hitstop = player.attackHurtNetwork.hitstop;
|
2023-01-12 19:12:56 +02:00
|
|
|
player.hitstop = true;
|
2023-01-14 19:39:35 +02:00
|
|
|
player.otherPlayer.hitbox.enter = true;
|
2023-01-12 19:12:56 +02:00
|
|
|
player.otherPlayer.hitstop = true;
|
|
|
|
|
if (player.otherPlayer.isAir)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
player.hurtPosition = new DemonVector2(player.otherPlayer.hitbox.position.x + ((player.otherPlayer.hitbox.size.x / 2) * -player.flip) - (0.3f * -player.flip), player.otherPlayer.hitbox.position.y - (0.1f * -player.flip));
|
2023-01-12 19:12:56 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
player.hurtPosition = new DemonVector2(player.otherPlayer.hitbox.position.x + ((player.otherPlayer.hitbox.size.x / 2) * -player.flip) - (0.3f * -player.flip), player.otherPlayer.hitbox.position.y);
|
2023-01-12 19:12:56 +02:00
|
|
|
}
|
2023-02-22 20:02:39 +02:00
|
|
|
player.gotHit = true;
|
2023-01-12 19:12:56 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-01-14 19:39:35 +02:00
|
|
|
|
2023-06-19 13:55:25 +03:00
|
|
|
protected void SuperArmorHurt(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
player.attackNetwork.superArmor -= 1;
|
|
|
|
|
player.sound = "SuperArmor";
|
|
|
|
|
if (player.attackHurtNetwork.cameraShakerNetwork.timer > 0)
|
|
|
|
|
{
|
|
|
|
|
CameraShake.Instance.Shake(player.attackHurtNetwork.cameraShakerNetwork);
|
|
|
|
|
}
|
|
|
|
|
player.health -= CalculateDamage(player, player.attackHurtNetwork.damage, player.playerStats.Defense);
|
|
|
|
|
player.healthRecoverable -= CalculateRecoverableDamage(player, player.attackHurtNetwork.damage, player.playerStats.Defense);
|
|
|
|
|
player.otherPlayer.canChainAttack = true;
|
|
|
|
|
player.canChainAttack = false;
|
|
|
|
|
if (GameSimulation.Hitstop <= 0)
|
|
|
|
|
{
|
|
|
|
|
GameSimulation.Hitstop = player.attackHurtNetwork.hitstop;
|
|
|
|
|
}
|
2023-06-26 17:00:26 +03:00
|
|
|
player.SetParticle(player.attackHurtNetwork.hurtEffect, player.hurtPosition);
|
2023-06-19 13:55:25 +03:00
|
|
|
player.player.PlayerAnimator.SpriteSuperArmorEffect();
|
|
|
|
|
player.player.PlayerUI.Damaged();
|
|
|
|
|
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-14 19:39:35 +02:00
|
|
|
protected void Shadow(PlayerNetwork player)
|
|
|
|
|
{
|
2023-07-01 23:48:47 +03:00
|
|
|
if (player.inputBuffer.CurrentTrigger().pressed && player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Assist)
|
2023-01-14 19:39:35 +02:00
|
|
|
{
|
2023-06-16 15:26:10 +03:00
|
|
|
if (!player.shadow.isOnScreen && player.shadowGauge >= GameSimulation.maxShadowGauge / 2)
|
2023-01-18 21:41:03 +02:00
|
|
|
{
|
2023-01-20 17:59:16 +02:00
|
|
|
player.sound = "Shadow";
|
2023-05-28 16:29:38 +03:00
|
|
|
player.shadow.usedInCombo = true;
|
2023-01-18 21:41:03 +02:00
|
|
|
player.shadow.projectile.attackNetwork = SetAttack(player.attackInput, player.shadow.attack);
|
|
|
|
|
player.shadow.projectile.flip = player.flip == 1 ? false : true;
|
2023-01-23 18:31:58 +02:00
|
|
|
player.shadow.projectile.fire = true;
|
2023-01-18 21:41:03 +02:00
|
|
|
player.shadow.animationFrames = 0;
|
|
|
|
|
player.shadow.isOnScreen = true;
|
|
|
|
|
player.shadow.flip = player.flip;
|
2023-07-02 23:17:37 +03:00
|
|
|
player.shadow.position = new DemonVector2(player.position.x + (player.shadow.spawnPoint.x * player.flip), player.position.y + player.shadow.spawnPoint.y);
|
2023-06-16 15:26:10 +03:00
|
|
|
player.shadowGauge -= GameSimulation.maxShadowGauge / 2;
|
2023-01-18 21:41:03 +02:00
|
|
|
}
|
2023-01-14 19:39:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-19 02:51:24 +02:00
|
|
|
protected void ToShadowbreakState(PlayerNetwork player)
|
|
|
|
|
{
|
2023-07-01 23:48:47 +03:00
|
|
|
if (player.inputBuffer.CurrentTrigger().pressed && player.inputBuffer.CurrentTrigger().inputEnum == InputEnum.Assist)
|
2023-01-19 02:51:24 +02:00
|
|
|
{
|
2023-06-16 15:26:10 +03:00
|
|
|
if (player.shadowGauge == GameSimulation.maxShadowGauge)
|
2023-01-19 02:51:24 +02:00
|
|
|
{
|
2023-01-19 19:06:45 +02:00
|
|
|
ResetCombo(player);
|
2023-01-19 02:51:24 +02:00
|
|
|
player.player.PlayerUI.UpdateHealthDamaged(player.healthRecoverable);
|
2023-07-02 23:17:37 +03:00
|
|
|
player.velocity = DemonVector2.Zero;
|
2023-01-19 02:51:24 +02:00
|
|
|
player.shadowGauge -= 2000;
|
2023-01-23 18:31:58 +02:00
|
|
|
EnterState(player, "Shadowbreak");
|
2023-01-19 02:51:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-26 03:47:56 +02:00
|
|
|
};
|