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

77 lines
2.9 KiB
C#

using SHADE;
using SHADE_Scripting.Audio;
using System;
public class PlayerRunState : BaseState
{
private float timer;
private float delay = 0.25f;
private bool left = true;
public PlayerRunState(StateMachine stateMachine) : base(stateMachine)
{
stateName = "Run State";
}
public override void OnEnter()
{
//Debug.Log("WALK ENTER");
timer = delay;
machine.GetScript<PlayerController>().playLandedAnimation = false;
machine.GetScript<PlayerController>().Leftsmoke.EmissionCount = machine.GetScript<PlayerController>().smokeCount * 4;
machine.GetScript<PlayerController>().Rightsmoke.EmissionCount = machine.GetScript<PlayerController>().smokeCount * 4;
if (PlayerAnimations.Instance)
{
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerRunClip);
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerRunClip);
}
}
public override void update()
{
//Debug.Log("WALKING");
timer += Time.DeltaTimeF;
if (timer > delay)
{
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);
machine.GetScript<PlayerController>().Leftsmoke.Emit();
left = false;
}
else
{
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;
}
AudioHandler.audioClipHandlers["footsteps"].Play();
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");
}
}