新Feedback系统
This commit is contained in:
@@ -232,67 +232,12 @@ namespace Cielonos.MainGame.Characters
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void PlayGetHitAnimation(string getHitAnimPrefix, out float animDuration,
|
||||
Vector3 direction = default, string funcAnimName = "")
|
||||
public virtual void PlayGetHitAnimation(string funcAnimName, out float animDuration,
|
||||
Vector3 direction = default)
|
||||
{
|
||||
bool useCustomFuncAnim = !string.IsNullOrEmpty(funcAnimName);
|
||||
int fullBodyActionIndex = animator.GetLayerIndex("FullBodyAction");
|
||||
|
||||
if (useCustomFuncAnim)
|
||||
{
|
||||
fullBodyFuncAnimSm.Play(funcAnimName);
|
||||
animDuration = fullBodyFuncAnimSm.currentClip.length;
|
||||
return;
|
||||
}
|
||||
|
||||
string getHitAnim = getHitAnimPrefix + "Front";
|
||||
string getHitFrontAnim = getHitAnimPrefix + "Front";
|
||||
float normalizedTransitionDuration = 0.1f / animator.GetCurrentAnimatorStateInfo(fullBodyActionIndex).length;
|
||||
animDuration = 0f;
|
||||
if (animator.HasState(fullBodyActionIndex, Animator.StringToHash(getHitAnim)))
|
||||
{
|
||||
direction.y = 0;
|
||||
direction = direction.normalized;
|
||||
float angle = Vector3.SignedAngle(transform.forward, direction, Vector3.up);
|
||||
|
||||
string directionStr = angle switch
|
||||
{
|
||||
> -45f and <= 45f => "Back",
|
||||
> 45f and <= 135f => "Left",
|
||||
> -135f and <= -45f => "Right",
|
||||
_ => "Front"
|
||||
};
|
||||
|
||||
getHitAnim = getHitAnimPrefix + directionStr;
|
||||
if (direction == default || !animator.HasState(fullBodyActionIndex, Animator.StringToHash(getHitAnim)))
|
||||
{
|
||||
animator.CrossFade(getHitFrontAnim, normalizedTransitionDuration, fullBodyActionIndex, 0);
|
||||
animDuration = mapper.GetClip(getHitFrontAnim).length;
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.CrossFade(getHitAnim, normalizedTransitionDuration, fullBodyActionIndex, 0);
|
||||
animDuration = mapper.GetClip(getHitAnim).length;
|
||||
}
|
||||
}
|
||||
else if (animator.HasState(fullBodyActionIndex, Animator.StringToHash(getHitAnimPrefix)))
|
||||
{
|
||||
getHitAnim = getHitAnimPrefix;
|
||||
animator.CrossFade(getHitAnim, normalizedTransitionDuration, fullBodyActionIndex, 0);
|
||||
animDuration = mapper.GetClip(getHitAnim).length;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (animator.HasState(fullBodyActionIndex, Animator.StringToHash("GetHit")))
|
||||
{
|
||||
animator.CrossFade("GetHit", normalizedTransitionDuration, fullBodyActionIndex, 0);
|
||||
animDuration = mapper.GetClip("GetHit").length;
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.CrossFade("Empty", 0.1f, fullBodyActionIndex, 0);
|
||||
}
|
||||
}
|
||||
fullBodyFuncAnimSm.Play(funcAnimName);
|
||||
animDuration = fullBodyFuncAnimSm.currentData.Interval(IntervalType.ActionDisruption).StartTime;
|
||||
//animDuration = fullBodyFuncAnimSm.currentData.Interval(IntervalType.Active).EndTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user