Files

83 lines
3.0 KiB
C#
Raw Normal View History

2022-12-26 03:47:56 +02:00
using UnityEngine;
public class DashAirState : State
{
public override void UpdateLogic(PlayerNetwork player)
{
if (!player.enter)
{
2023-04-12 01:27:02 +03:00
bool forwardDash = player.dashDirection * player.flip == 1 ? true : false;
2023-07-03 20:04:17 +03:00
string dashParticle = forwardDash ? "DashAirForward" : "DashAirBackwards";
2022-12-26 03:47:56 +02:00
player.enter = true;
player.sound = "Dash";
2023-04-12 01:27:02 +03:00
player.animation = "DashAir";
2022-12-29 21:24:36 +02:00
player.animationFrames = 0;
2023-04-12 01:27:02 +03:00
player.canDoubleJump = false;
2022-12-26 03:47:56 +02:00
if (player.dashDirection > 0)
{
2023-07-03 20:04:17 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x + 20, player.position.y + 30);
player.SetParticle(dashParticle, effectPosition, new Vector2(0, 90));
2022-12-26 03:47:56 +02:00
}
else
{
2023-07-03 20:04:17 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x - 20, player.position.y + 30);
player.SetParticle(dashParticle, effectPosition, new Vector2(0, -90));
2022-12-26 03:47:56 +02:00
}
2023-04-12 01:27:02 +03:00
player.dashFrames = forwardDash == true ? 10 : 15;
2023-07-02 23:17:37 +03:00
player.velocity = new DemonVector2(player.dashDirection * (player.playerStats.DashForce - 0.5), 0);
2023-04-12 01:27:02 +03:00
player.dashFrames--;
return;
2022-12-26 03:47:56 +02:00
}
2023-04-12 01:27:02 +03:00
player.animationFrames++;
Dash(player);
2023-04-18 23:23:24 +03:00
ToAttackState(player);
}
public bool ToAttackState(PlayerNetwork player)
{
if (player.inputBuffer.CurrentTrigger().pressed)
2023-04-18 23:23:24 +03:00
{
Attack(player, true);
return true;
}
return false;
2022-12-26 03:47:56 +02:00
}
private void Dash(PlayerNetwork player)
{
if (player.dashFrames > 0)
{
2023-04-12 01:27:02 +03:00
bool forwardDash = player.dashDirection * player.flip == 1 ? true : false;
int startUpFrames = forwardDash ? 9 : 13;
int recoveryFrames = forwardDash ? 2 : 3;
2023-07-02 23:17:37 +03:00
DemonFloat dashforce = forwardDash ? player.playerStats.DashAirForce : player.playerStats.DashBackAirForce;
2023-04-12 01:27:02 +03:00
if (player.dashFrames < startUpFrames && player.dashFrames > recoveryFrames)
{
2023-07-02 23:17:37 +03:00
player.velocity = new DemonVector2(player.dashDirection * dashforce, 0);
2023-04-12 01:27:02 +03:00
}
else
{
2023-07-02 23:17:37 +03:00
player.velocity = new DemonVector2(player.dashDirection * (dashforce - (DemonFloat)1), 0);
2023-04-12 01:27:02 +03:00
}
if (player.dashFrames % 3 == 0)
2022-12-26 03:47:56 +02:00
{
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-26 03:47:56 +02:00
player.SetEffect("Ghost", player.position, false);
}
else
{
2023-07-02 23:17:37 +03:00
DemonVector2 effectPosition = new DemonVector2(player.position.x + 1, player.position.y);
2022-12-26 03:47:56 +02:00
player.SetEffect("Ghost", player.position, true);
}
}
player.dashFrames--;
}
else
{
2023-04-12 01:27:02 +03:00
player.dashDirection = 0;
2023-01-23 18:31:58 +02:00
EnterState(player, "Fall");
2022-12-26 03:47:56 +02:00
}
}
}