| | |
| | | /// </summary> |
| | | public class MotionBase |
| | | { |
| | | public static float MotionTimeScale = 2f; |
| | | |
| | | public static List<string> AttackMotionList = new List<string> |
| | | { |
| | | MotionName.attack.ToString(), |
| | |
| | | private Spine.TrackEntry currentTrackEntry; |
| | | |
| | | #region 初始化方法 |
| | | |
| | | |
| | | /// <summary> |
| | | /// 初始化动画组件 |
| | | /// </summary> |
| | |
| | | public virtual void Init(SkeletonGraphic skeletonGraphic) |
| | | { |
| | | this.skeletonGraphic = skeletonGraphic; |
| | | |
| | | |
| | | if (skeletonGraphic != null) |
| | | { |
| | | spineAnimationState = skeletonGraphic.AnimationState; |
| | | spineAnimationState.TimeScale = MotionTimeScale; |
| | | skeletonGraphic.timeScale = MotionTimeScale; |
| | | |
| | | skeleton = skeletonGraphic.Skeleton; |
| | | |
| | | |
| | | // 设置动画混合时间 |
| | | if (spineAnimationState != null) |
| | | { |
| | | spineAnimationState.Data.DefaultMix = defaultMixDuration; |
| | | } |
| | | |
| | | |
| | | // 播放默认动画 |
| | | PlayAnimation(MotionName.idle, true); |
| | | |
| | | |
| | | // 设置动画事件监听 |
| | | SetupAnimationHandlers(); |
| | | } |
| | |
| | | { |
| | | Debug.LogError("缺少SkeletonGraphic组件!"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public virtual void Release() |
| | |
| | | |
| | | public virtual void Pause() |
| | | { |
| | | if (currentTrackEntry != null) |
| | | currentTrackEntry.TimeScale = 0f; |
| | | spineAnimationState.TimeScale = 0f; |
| | | skeletonGraphic.timeScale = 0f; |
| | | } |
| | | |
| | | public virtual void Resume() |
| | | { |
| | | if (currentTrackEntry != null) |
| | | currentTrackEntry.TimeScale = 1f; |
| | | spineAnimationState.TimeScale = MotionTimeScale; |
| | | skeletonGraphic.timeScale = MotionTimeScale; |
| | | } |
| | | |
| | | #endregion |