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

62 lines
1.6 KiB
C#
Raw Normal View History

using SHADE;
2023-03-10 17:21:49 +08:00
using SHADE_Scripting.Audio;
using System;
public class PlayerWalkState : BaseState
{
2022-11-21 21:01:44 +08:00
private float timer;
private float delay = 0.5f;
2023-03-10 16:26:52 +08:00
private bool holdItem;
public PlayerWalkState(StateMachine stateMachine, bool hi) : base(stateMachine)
{
stateName = "Walk State";
2023-03-10 16:26:52 +08:00
holdItem = hi;
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
2022-11-21 21:01:44 +08:00
timer = delay;
2023-03-10 16:26:52 +08:00
if (PlayerAnimations.Instance)
{
if (!holdItem)
{
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
if(PlayerAnimations.Instance.playerWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
}
else
{
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
if(PlayerAnimations.Instance.playerCarryWalkClip)
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
}
}
}
public override void update()
{
//Debug.Log("WALKING");
2022-11-21 21:01:44 +08:00
timer += Time.DeltaTimeF;
if (timer > delay)
2023-03-10 17:21:49 +08:00
{
AudioHandler.audioClipHandlers["footsteps"].Play();
2022-11-21 21:01:44 +08:00
timer = 0;
}
}
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");
}
}