Files

49 lines
2.0 KiB
C#
Raw Normal View History

2023-01-10 18:39:07 +02:00
using UnityEngine;
2023-01-09 18:16:00 +02:00
public class ThrowState : State
{
public override void UpdateLogic(PlayerNetwork player)
{
if (!player.enter)
{
2023-01-19 17:07:46 +02:00
if (player.direction.x < 0 && player.flip == 1 || player.direction.x > 0 && player.flip == -1)
2023-01-10 18:39:07 +02:00
{
player.flip *= -1;
}
2023-01-09 18:16:00 +02:00
player.enter = true;
player.animationFrames = 0;
2023-01-10 18:39:07 +02:00
player.animation = "Throw";
player.attackFrames = DemonicsAnimator.GetMaxAnimationFrames(player.playerStats._animation, player.animation);
2023-01-09 18:16:00 +02:00
}
2023-01-10 18:39:07 +02:00
player.otherPlayer.pushbox.active = false;
2023-01-09 18:16:00 +02:00
player.animationFrames++;
2023-01-10 18:39:07 +02:00
player.attackFrames--;
DemonicsVector2 grabPoint = player.player.PlayerAnimator.GetGrabPoint(player.animation, player.animationFrames);
player.otherPlayer.position = new DemonicsVector2(player.position.x + (grabPoint.x * player.flip), player.position.y + grabPoint.y);
2023-01-16 13:26:54 +02:00
if (player.player.PlayerAnimator.GetThrowArcanaEnd(player.animation, player.animationFrames) && player.otherPlayer.state == "Grabbed")
{
}
2023-01-10 18:39:07 +02:00
ToIdleState(player);
}
private void ToIdleState(PlayerNetwork player)
{
if (player.attackFrames <= 0)
{
2023-01-23 18:31:58 +02:00
if (player.position.x >= DemonicsPhysics.WALL_RIGHT_POINT && player.flip == 1)
{
player.position = new DemonicsVector2(DemonicsPhysics.WALL_RIGHT_POINT - player.pushbox.size.x, player.position.y);
}
else if (player.position.x <= DemonicsPhysics.WALL_LEFT_POINT && player.flip == -1)
{
player.position = new DemonicsVector2(DemonicsPhysics.WALL_LEFT_POINT + player.pushbox.size.x, player.position.y);
}
2023-01-16 13:26:54 +02:00
ThrowEnd(player.otherPlayer);
2023-01-10 18:39:07 +02:00
if (player.attackNetwork.cameraShakerNetwork.timer > 0)
{
CameraShake.Instance.Shake(player.attackNetwork.cameraShakerNetwork);
}
player.sound = "Impact1";
2023-01-23 18:31:58 +02:00
EnterState(player, "Idle");
2023-01-10 18:39:07 +02:00
}
2023-01-09 18:16:00 +02:00
}
}