using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Invincible_Samurai
{
public class AnimationTimeScaleController_TimeLength : StateMachineBehaviour
{
public float slowStart = 0.1f;
public float continuingTime = 0.2f;
public float slowValue = 0.1f;
float timeRecord;
bool hasTriggerStart = false, hasTriggerEnd = false;
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
hasTriggerStart = false;
hasTriggerEnd = false;
}
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (!hasTriggerStart)
{
if (stateInfo.normalizedTime > slowStart)
{
GameMgr.instance.SetToSlowTime(slowValue); //设置Time.timescale=slowValue
hasTriggerStart = true;
timeRecord = Time.unscaledTime;
//Debug.Log("减速开始" + stateInfo.normalizedTime);
}
}
else if (!hasTriggerEnd)
{
if (Time.unscaledTime - timeRecord > continuingTime)
{
GameMgr.instance.SetToNormalTime();设置Time.timescale=1
hasTriggerEnd = true;
//Debug.Log("减速结束" + stateInfo.normalizedTime);
}
}
}
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
hasTriggerStart = false;
hasTriggerEnd = false;
GameMgr.instance.SetToNormalTime();
}
}
}