65 lines
2.5 KiB
C#
65 lines
2.5 KiB
C#
using System;
|
||
using Sirenix.OdinInspector;
|
||
using SLSUtilities.FunctionalAnimation;
|
||
using UnityEngine;
|
||
using UnityEngine.Serialization;
|
||
|
||
namespace Cielonos.MainGame.FunctionalAnimation
|
||
{
|
||
[Serializable]
|
||
public class SwitchFuncAnim : FuncAnimPayloadBase
|
||
{
|
||
public string animationName;
|
||
|
||
[Tooltip("是否启用高级设置")]
|
||
public bool advancedSettings;
|
||
[ShowIf("advancedSettings")]
|
||
[Tooltip("用于Update Event,是否在落地时切换动画")]
|
||
public bool switchWhenLanding;
|
||
[ShowIf("advancedSettings")]
|
||
[Tooltip("如果switchWhenLanding为true,是否覆盖地面检测的长度")]
|
||
public bool overrideGroundDetection;
|
||
[FormerlySerializedAs("overrideGroundDetectionLength")]
|
||
[ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")]
|
||
[Tooltip("覆盖地面检测的长度乘数")]
|
||
public float groundDetectionLengthMultiplier = 1f;
|
||
[ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")]
|
||
[Tooltip("覆盖地面检测的偏移")]
|
||
public float groundDetectionOffset = 0f;
|
||
|
||
public override void Invoke()
|
||
{
|
||
var data = character.animationSc.fullBodyFuncAnimSm.collection[animationName];
|
||
float animationSpeedMultiplier = 1f;
|
||
if (data.animInfo.tags.Contains("Attack") && data.animInfo.isAffectedBySpeedMultiplier)
|
||
{
|
||
animationSpeedMultiplier = character.attributeSm[CharacterAttribute.AttackSpeed];
|
||
}
|
||
|
||
if (!advancedSettings)
|
||
{
|
||
character.animationSc.fullBodyFuncAnimSm.Play(animationName, animationSpeedMultiplier);
|
||
}
|
||
else
|
||
{
|
||
if (switchWhenLanding)
|
||
{
|
||
if (overrideGroundDetection)
|
||
{
|
||
if (character.movementSc.groundDetector.DetectGround(groundDetectionLengthMultiplier, groundDetectionOffset))
|
||
{
|
||
character.animationSc.fullBodyFuncAnimSm.Play(animationName, animationSpeedMultiplier);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (character.movementSc.groundDetector.DetectGround())
|
||
{
|
||
character.animationSc.fullBodyFuncAnimSm.Play(animationName, animationSpeedMultiplier);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |