You've already forked Darklings-FightingGame
mirror of
https://github.com/izzy2lost/Darklings-FightingGame.git
synced 2026-03-10 11:35:19 -07:00
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using UnityEngine;
|
|
|
|
public class DashState : State
|
|
{
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
{
|
|
player.position = new Vector2(player.position.x, (float)DemonicsPhysics.GROUND_POINT);
|
|
if (!player.enter)
|
|
{
|
|
player.enter = true;
|
|
player.sound = "Dash";
|
|
player.animationFrames = 0;
|
|
if (player.dashDirection > 0)
|
|
{
|
|
Vector2 effectPosition = new Vector2(player.position.x - 1, player.position.y);
|
|
player.SetEffect("Dash", effectPosition, false);
|
|
}
|
|
else
|
|
{
|
|
Vector2 effectPosition = new Vector2(player.position.x + 1, player.position.y);
|
|
player.SetEffect("Dash", effectPosition, true);
|
|
}
|
|
player.dashFrames = 15;
|
|
player.velocity = new Vector2(player.dashDirection * (float)player.playerStats.DashForce, 0);
|
|
}
|
|
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)
|
|
{
|
|
Vector2 effectPosition = new Vector2(player.position.x - 1, player.position.y);
|
|
player.SetEffect("Ghost", player.position, false);
|
|
}
|
|
else
|
|
{
|
|
Vector2 effectPosition = new Vector2(player.position.x + 1, player.position.y);
|
|
player.SetEffect("Ghost", player.position, true);
|
|
}
|
|
}
|
|
player.dashFrames--;
|
|
}
|
|
else
|
|
{
|
|
player.velocity = Vector2.zero;
|
|
player.enter = false;
|
|
if (player.direction.x * player.flip > 0)
|
|
{
|
|
player.sound = "Run";
|
|
player.state = "Run";
|
|
}
|
|
else
|
|
{
|
|
player.state = "Idle";
|
|
}
|
|
}
|
|
}
|
|
}
|