Files
Cielonos/Assets/Scripts/MainGame/Base/FunctionalAnimation/Payloads/SwitchFuncAnim.cs

53 lines
1.8 KiB
C#
Raw Normal View History

2025-12-23 19:47:06 -05:00
using System;
2026-01-12 03:22:16 -05:00
using Sirenix.OdinInspector;
2025-11-25 08:19:33 -05:00
using SLSUtilities.FunctionalAnimation;
using UnityEngine;
namespace Cielonos.MainGame.FunctionalAnimation
{
2025-12-23 19:47:06 -05:00
[Serializable]
2025-11-25 08:19:33 -05:00
public class SwitchFuncAnim : FuncAnimPayloadBase
{
public string animationName;
2026-01-12 03:22:16 -05:00
[Tooltip("是否启用高级设置")]
public bool advancedSettings;
[ShowIf("advancedSettings")]
[Tooltip("用于Update Event是否在落地时切换动画")]
public bool switchWhenLanding;
[ShowIf("advancedSettings")]
[Tooltip("如果switchWhenLanding为true是否覆盖地面检测的长度")]
public bool overrideGroundDetection;
[ShowIf("advancedSettings"), ShowIf("overrideGroundDetection")]
[Tooltip("覆盖地面检测的长度")]
public float overrideGroundDetectionLength = 0.1f;
2025-11-25 08:19:33 -05:00
public override void Invoke()
{
2026-01-12 03:22:16 -05:00
if (!advancedSettings)
{
2026-01-17 11:35:49 -05:00
character.animationSc.fullBodyFuncAnimSm.Play(animationName);
2026-01-12 03:22:16 -05:00
}
else
{
if (switchWhenLanding)
{
if (overrideGroundDetection)
{
if (character.movementSc.groundDetector.DetectGround())
{
2026-01-17 11:35:49 -05:00
character.animationSc.fullBodyFuncAnimSm.Play(animationName);
2026-01-12 03:22:16 -05:00
}
}
else
{
if (character.movementSc.groundDetector.DetectGround(overrideGroundDetectionLength))
{
2026-01-17 11:35:49 -05:00
character.animationSc.fullBodyFuncAnimSm.Play(animationName);
2026-01-12 03:22:16 -05:00
}
}
}
}
2025-11-25 08:19:33 -05:00
}
}
}