Files

47 lines
2.2 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-10 18:39:07 +02:00
if (player.inputBuffer.inputItems[0].inputDirection.x < 0 && player.flip == 1 || player.inputBuffer.inputItems[0].inputDirection.x > 0 && player.flip == -1)
{
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);
ToIdleState(player);
}
private void ToIdleState(PlayerNetwork player)
{
if (player.attackFrames <= 0)
{
if (player.attackNetwork.cameraShakerNetwork.timer > 0)
{
CameraShake.Instance.Shake(player.attackNetwork.cameraShakerNetwork);
}
player.enter = false;
player.state = "Idle";
player.sound = "Impact1";
player.otherPlayer.enter = false;
player.otherPlayer.state = "HardKnockdown";
player.otherPlayer.combo++;
player.otherPlayer.health -= CalculateDamage(player.otherPlayer.attackHurtNetwork.damage, player.otherPlayer.playerStats.Defense);
player.otherPlayer.healthRecoverable -= CalculateRecoverableDamage(player.otherPlayer.attackHurtNetwork.damage, player.otherPlayer.playerStats.Defense);
player.otherPlayer.player.PlayerUI.Damaged();
player.otherPlayer.player.PlayerUI.UpdateHealthDamaged(player.otherPlayer.healthRecoverable);
player.otherPlayer.player.OtherPlayerUI.IncreaseCombo(player.combo);
player.otherPlayer.pushbox.active = true;
}
2023-01-09 18:16:00 +02:00
}
}