2023-03-22 22:52:43 +08:00
|
|
|
using SHADE;
|
2023-03-10 17:21:49 +08:00
|
|
|
using SHADE_Scripting.Audio;
|
2022-11-20 16:27:39 +08:00
|
|
|
using System;
|
|
|
|
|
|
|
|
public class PlayerWalkState : BaseState
|
|
|
|
{
|
2022-11-21 21:01:44 +08:00
|
|
|
private float timer;
|
2023-03-22 21:31:40 +08:00
|
|
|
private float delay = 0.4f;
|
2023-03-23 00:38:25 +08:00
|
|
|
private bool left = true;
|
2023-03-14 17:18:52 +08:00
|
|
|
public PlayerWalkState(StateMachine stateMachine) : base(stateMachine)
|
2022-11-20 16:27:39 +08:00
|
|
|
{
|
|
|
|
stateName = "Walk State";
|
|
|
|
}
|
|
|
|
public override void OnEnter()
|
|
|
|
{
|
|
|
|
//Debug.Log("WALK ENTER");
|
2022-11-21 21:01:44 +08:00
|
|
|
timer = delay;
|
2023-03-23 16:49:41 +08:00
|
|
|
machine.GetScript<PlayerController>().Leftsmoke.EmissionCount = machine.GetScript<PlayerController>().smokeCount;
|
|
|
|
machine.GetScript<PlayerController>().Rightsmoke.EmissionCount = machine.GetScript<PlayerController>().smokeCount;
|
2023-03-14 17:18:52 +08:00
|
|
|
|
|
|
|
machine.GetScript<PlayerController>().playLandedAnimation = false;
|
|
|
|
|
2023-03-10 16:26:52 +08:00
|
|
|
if (PlayerAnimations.Instance)
|
|
|
|
{
|
2023-03-14 17:18:52 +08:00
|
|
|
if (!machine.GetScript<PlayerController>().holdItem)
|
2023-03-10 16:26:52 +08:00
|
|
|
{
|
2023-03-14 17:18:52 +08:00
|
|
|
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);
|
2023-03-10 16:26:52 +08:00
|
|
|
}
|
2023-03-14 17:18:52 +08:00
|
|
|
else
|
2023-03-10 16:26:52 +08:00
|
|
|
{
|
2023-03-14 17:18:52 +08:00
|
|
|
Debug.LogError("Missing playercontroller in walk state");
|
2023-03-10 16:26:52 +08:00
|
|
|
}
|
|
|
|
}
|
2022-11-20 16:27:39 +08:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2023-03-23 00:38:25 +08:00
|
|
|
if (left)
|
|
|
|
{
|
|
|
|
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
|
|
|
|
machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets.y);
|
|
|
|
else
|
|
|
|
machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().Leftsmoke.AngularOffsets.y);
|
2023-03-22 22:52:43 +08:00
|
|
|
|
2023-03-23 00:38:25 +08:00
|
|
|
machine.GetScript<PlayerController>().Leftsmoke.Emit();
|
|
|
|
left = false;
|
|
|
|
}
|
2023-03-22 22:52:43 +08:00
|
|
|
else
|
2023-03-23 00:38:25 +08:00
|
|
|
{
|
|
|
|
if (machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y > 0.0f)
|
|
|
|
machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y - (MathF.PI * 1.5f), machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets.y);
|
|
|
|
else
|
|
|
|
machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets = new Vector2(machine.GetScript<PlayerController>().tranform.LocalEulerAngles.y + (MathF.PI * 0.5f), machine.GetScript<PlayerController>().Rightsmoke.AngularOffsets.y);
|
|
|
|
|
|
|
|
machine.GetScript<PlayerController>().Rightsmoke.Emit();
|
|
|
|
left = true;
|
|
|
|
}
|
2023-03-22 22:52:43 +08:00
|
|
|
|
2023-03-10 17:21:49 +08:00
|
|
|
AudioHandler.audioClipHandlers["footsteps"].Play();
|
2022-11-21 21:01:44 +08:00
|
|
|
timer = 0;
|
|
|
|
}
|
2022-11-20 16:27:39 +08:00
|
|
|
}
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|