48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace Invector.vCharacterController.AI.FSMBehaviour
|
|
{
|
|
|
|
public class vAICheckAnimatorParameterFloat : vStateDecision
|
|
{
|
|
public override string categoryName
|
|
{
|
|
get { return "Custom Example/"; }
|
|
}
|
|
|
|
public override string defaultName
|
|
{
|
|
get { return "Check Animator Parameter Float"; }
|
|
}
|
|
|
|
protected enum CompareValueMethod
|
|
{
|
|
Greater, Less, Equal
|
|
}
|
|
[SerializeField]
|
|
protected CompareValueMethod compareMethod;
|
|
public float value;
|
|
public string parameterName = "TurnOnSpotDir";
|
|
|
|
public override bool Decide(vIFSMBehaviourController fsmBehaviour)
|
|
{
|
|
float angle = fsmBehaviour.aiController.animator.GetFloat(parameterName);
|
|
return CompareDistance(Mathf.Abs(angle), this.value);
|
|
}
|
|
|
|
private bool CompareDistance(float distA, float distB)
|
|
{
|
|
switch (compareMethod)
|
|
{
|
|
case CompareValueMethod.Equal:
|
|
return distA.Equals(distB);
|
|
case CompareValueMethod.Greater:
|
|
return distA > distB;
|
|
case CompareValueMethod.Less:
|
|
return distA < distB;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
}
|