SHADE_Y3/Assets/Scripts/Gameplay/Player/PlayerStates/UT_PlayerIdleState.cs

101 lines
3.7 KiB
C#

using SHADE;
using System;
public class PlayerIdleState : BaseState
{
protected PlayerController player;
public PlayerIdleState(StateMachine stateMachine) : base(stateMachine)
{
stateName = "Idle State";
}
public override void OnEnter()
{
if (PlayerAnimations.Instance)
{
if (!machine.GetScript<PlayerController>().playLandedAnimation)
{
if (!machine.GetScript<PlayerController>().holdItem)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
}
else
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
}
else
{
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
{
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
{
if (!machine.GetScript<PlayerController>().holdItem)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
else
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
machine.GetScript<PlayerController>().playLandedAnimation = false;
}
});
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
{
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
{
if (!machine.GetScript<PlayerController>().holdItem)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
else
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
});
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
{
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
{
if (!machine.GetScript<PlayerController>().holdItem)
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
else
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
});
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
{
if (x.FinishedClip == PlayerAnimations.Instance.playerJumpEndClip)
{
if (!machine.GetScript<PlayerController>().holdItem)
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
else
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
}
});
}
}
}
public override void update()
{
//Debug.Log("WALKING");
}
public override void fixedUpdate()
{
//Debug.Log("FIXED WALKING");
}
public override void OnExit()
{
//Debug.Log("WALK EXIT");
}
public override void onTriggerEnter(CollisionInfo info)
{
//Debug.Log("TRIGGER");
}
}