2022-12-26 03:47:56 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class JumpState : AirParentState
|
|
|
|
|
{
|
|
|
|
|
public override void UpdateLogic(PlayerNetwork player)
|
|
|
|
|
{
|
|
|
|
|
if (!player.enter)
|
|
|
|
|
{
|
|
|
|
|
player.enter = true;
|
|
|
|
|
player.sound = "Jump";
|
|
|
|
|
player.SetEffect("Jump", player.position);
|
|
|
|
|
player.hasJumped = true;
|
|
|
|
|
player.animationFrames = 0;
|
2022-12-31 20:46:52 +02:00
|
|
|
player.velocity = new DemonicsVector2((DemonicsFloat)0, player.playerStats.JumpForce);
|
2022-12-26 03:47:56 +02:00
|
|
|
}
|
|
|
|
|
player.animation = "Jump";
|
|
|
|
|
player.animationFrames++;
|
2022-12-31 20:46:52 +02:00
|
|
|
player.velocity = new DemonicsVector2(player.velocity.x, player.velocity.y - DemonicsPhysics.GRAVITY);
|
2022-12-26 03:47:56 +02:00
|
|
|
base.UpdateLogic(player);
|
|
|
|
|
ToFallState(player);
|
|
|
|
|
}
|
|
|
|
|
private void ToFallState(PlayerNetwork player)
|
|
|
|
|
{
|
2022-12-31 20:46:52 +02:00
|
|
|
if (player.velocity.y <= (DemonicsFloat)0)
|
2022-12-26 03:47:56 +02:00
|
|
|
{
|
|
|
|
|
player.enter = false;
|
|
|
|
|
player.state = "Fall";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|