Files

125 lines
4.3 KiB
C#
Raw Normal View History

2022-12-26 03:47:56 +02:00
using UnityEngine;
public class DashState : State
{
public override void UpdateLogic(PlayerNetwork player)
{
if (!player.enter)
{
player.enter = true;
player.sound = "Dash";
2022-12-29 21:24:36 +02:00
player.animationFrames = 0;
2022-12-26 03:47:56 +02:00
if (player.dashDirection > 0)
{
2023-10-24 00:32:35 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x - 1, DemonicsPhysics.GROUND_POINT);
2023-07-03 20:04:17 +03:00
player.SetParticle("Dash", effectPosition, new Vector2(-90, 90));
2022-12-26 03:47:56 +02:00
}
else
{
2023-10-24 00:32:35 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x + 1, DemonicsPhysics.GROUND_POINT);
2023-07-03 20:04:17 +03:00
player.SetParticle("Dash", effectPosition, new Vector2(-90, -90));
2022-12-26 03:47:56 +02:00
}
player.dashFrames = 15;
2023-07-02 23:17:37 +03:00
player.velocity = new DemonVector2(player.dashDirection * player.playerStats.DashForce, 0);
return;
2022-12-26 03:47:56 +02:00
}
2023-01-07 23:17:55 +02:00
ToHurtState(player);
2022-12-26 03:47:56 +02:00
Dash(player);
}
private void Dash(PlayerNetwork player)
{
if (player.dashFrames > 0)
{
player.animationFrames = 0;
player.animation = "Dash";
if (player.dashFrames % 5 == 0)
{
if (player.flip > 0)
{
2023-07-02 23:17:37 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x - 1, player.position.y);
2022-12-31 20:46:52 +02:00
player.SetEffect("Ghost", effectPosition, false);
2022-12-26 03:47:56 +02:00
}
else
{
2023-07-02 23:17:37 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x + 1, player.position.y);
2022-12-31 20:46:52 +02:00
player.SetEffect("Ghost", effectPosition, true);
2022-12-26 03:47:56 +02:00
}
}
player.dashFrames--;
}
else
{
2023-07-02 23:17:37 +03:00
player.velocity = DemonVector2.Zero;
2023-01-23 18:31:58 +02:00
if (player.direction.x * player.flip > 0 && player.dashDirection == player.flip)
2022-12-26 03:47:56 +02:00
{
2023-01-23 18:31:58 +02:00
player.dashDirection = 0;
2022-12-26 03:47:56 +02:00
player.sound = "Run";
2023-01-23 18:31:58 +02:00
EnterState(player, "Run");
2022-12-26 03:47:56 +02:00
}
else
{
2023-01-23 18:31:58 +02:00
player.dashDirection = 0;
EnterState(player, "Idle");
2022-12-26 03:47:56 +02:00
}
}
}
2023-01-07 23:17:55 +02:00
private void ToHurtState(PlayerNetwork player)
{
2023-01-17 23:48:42 +02:00
if (IsColliding(player))
2023-01-07 23:17:55 +02:00
{
2023-01-17 23:48:42 +02:00
if (player.attackHurtNetwork.moveName == "Shadowbreak")
{
player.dashDirection = 0;
2023-01-23 18:31:58 +02:00
EnterState(player, "Knockback");
2023-01-17 23:48:42 +02:00
}
if (player.attackHurtNetwork.attackType == AttackTypeEnum.Throw)
{
bool forwardDash = player.dashDirection * player.flip == 1 ? true : false;
if (!forwardDash)
return;
player.dashDirection = 0;
2023-01-23 18:31:58 +02:00
EnterState(player, "Grabbed");
2023-01-17 23:48:42 +02:00
}
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-17 23:48:42 +02:00
player.otherPlayer.pushbackDuration = player.attackHurtNetwork.knockbackDuration;
}
if (IsBlocking(player))
{
player.dashDirection = 0;
2023-01-17 23:48:42 +02:00
if (player.direction.y < 0)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "BlockLow");
2023-01-17 23:48:42 +02:00
}
else
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Block");
2023-01-17 23:48:42 +02:00
}
}
else
{
player.dashDirection = 0;
2023-01-17 23:48:42 +02:00
if (player.attackHurtNetwork.hardKnockdown)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Airborne");
2023-01-17 23:48:42 +02:00
}
else
{
if (player.attackHurtNetwork.knockbackArc == 0 || player.attackHurtNetwork.softKnockdown)
{
2023-01-23 18:31:58 +02:00
EnterState(player, "Hurt");
2023-01-17 23:48:42 +02:00
}
else
{
2023-01-23 18:31:58 +02:00
EnterState(player, "HurtAir");
2023-01-17 23:48:42 +02:00
}
}
}
2023-01-07 23:17:55 +02:00
}
}
2022-12-26 03:47:56 +02:00
}