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

101 lines
3.7 KiB
C#
Raw Normal View History

using SHADE;
using System;
public class PlayerIdleState : BaseState
{
2023-03-14 17:18:52 +08:00
protected PlayerController player;
public PlayerIdleState(StateMachine stateMachine) : base(stateMachine)
{
stateName = "Idle State";
}
public override void OnEnter()
{
2023-03-10 16:26:52 +08:00
if (PlayerAnimations.Instance)
{
2023-03-14 17:18:52 +08:00
if (!machine.GetScript<PlayerController>().playLandedAnimation)
2023-03-10 16:26:52 +08:00
{
2023-03-14 17:18:52 +08:00
if (!machine.GetScript<PlayerController>().holdItem)
2023-03-10 19:40:48 +08:00
{
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);
}
2023-03-14 17:18:52 +08:00
else
2023-03-10 19:40:48 +08:00
{
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);
}
2023-03-10 16:26:52 +08:00
}
2023-03-14 17:18:52 +08:00
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);
}
});
}
2023-03-10 16:26:52 +08:00
}
}
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");
}
}