76 lines
2.6 KiB
C#
76 lines
2.6 KiB
C#
using SHADE;
|
|
using SHADE_Scripting.Audio;
|
|
using System;
|
|
|
|
public class PlayerWalkState : BaseState
|
|
{
|
|
private float timer;
|
|
private float delay = 0.4f;
|
|
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
|
|
{
|
|
stateName = "Walk State";
|
|
}
|
|
public override void OnEnter()
|
|
{
|
|
//Debug.Log("WALK ENTER");
|
|
AudioHandler.audioClipHandlers["footsteps"].Play();
|
|
timer = delay;
|
|
|
|
machine.GetScript<PlayerController>().playLandedAnimation = false;
|
|
|
|
if (PlayerAnimations.Instance)
|
|
{
|
|
if (!machine.GetScript<PlayerController>().holdItem)
|
|
{
|
|
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
}
|
|
else if (machine.GetScript<PlayerController>().holdItem)
|
|
{
|
|
|
|
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("Missing playercontroller in walk state");
|
|
}
|
|
}
|
|
}
|
|
public override void update()
|
|
{
|
|
//Debug.Log("WALKING");
|
|
timer += Time.DeltaTimeF;
|
|
|
|
if (timer > delay)
|
|
{
|
|
|
|
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
|
|
machine.GetScript<PlayerController>().smoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().smoke.AngularOffsets.y);
|
|
else
|
|
machine.GetScript<PlayerController>().smoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().smoke.AngularOffsets.y);
|
|
|
|
AudioHandler.audioClipHandlers["footsteps"].Play();
|
|
machine.GetScript<PlayerController>().smoke.Emit();
|
|
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");
|
|
}
|
|
}
|
|
|