From 754ceacd8ab62e7094f1827ae45ea16a502725ad Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 6 Aug 2021 19:02:03 +0800 Subject: *curve --- Assets/Scripts/Unit/AnimationData.cs | 54 ++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'Assets/Scripts/Unit/AnimationData.cs') diff --git a/Assets/Scripts/Unit/AnimationData.cs b/Assets/Scripts/Unit/AnimationData.cs index 211e9acb..6035978d 100644 --- a/Assets/Scripts/Unit/AnimationData.cs +++ b/Assets/Scripts/Unit/AnimationData.cs @@ -6,6 +6,25 @@ using UnityEngine; using UnityEditor; #endif +// 不要修改枚举的顺序,只能在后面新加,不能删除 + +public enum EAnimationToogle +{ + Combo = 0, // 连击 + SuperArmor = 1, //霸体 +} + +[Serializable] +public class ToggleTimeDictionary : SerializableDictionary { } + +public enum EAnimationCurve +{ + TimeScale = 0, // +} + +[Serializable] +public class CurveDictionary : SerializableDictionary { } + // 某个动画的数据,包括帧事件、碰撞盒、速度曲线 [CreateAssetMenu(fileName = "Animation Data")] public class AnimationData : ScriptableObject @@ -22,15 +41,20 @@ public class AnimationData : ScriptableObject public List defendBoxes; // 对应的进度的播放速度,默认是1 - public AnimationCurve curve; + [UnityEngine.Serialization.FormerlySerializedAs("curve")] + public AnimationCurve speedCurve; - public const int FPS = 30; + public CurveDictionary curves; + + public ToggleTimeDictionary toggles; + + public const int FPS = 30; public AnimationData() { Keyframe frame0 = new Keyframe(0, 1); Keyframe frame1 = new Keyframe(1, 1); - curve = new AnimationCurve(frame0, frame1); + speedCurve = new AnimationCurve(frame0, frame1); } public List GetColliderBoxesByType(ColliderBox.EColliderType type) @@ -51,6 +75,30 @@ public class AnimationData : ScriptableObject return null; } + public bool HasCurve(EAnimationCurve curve) + { + return curves != null && curves.ContainsKey(curve); + } + + public AnimationCurve GetCurve(EAnimationCurve curve) + { + if (!HasCurve(curve)) + return null; + return curves[curve]; + } + + public bool HasToggle(EAnimationToogle toggle) + { + return toggles != null && toggles.ContainsKey(toggle); + } + + public bool IsToggleOpen(EAnimationToogle toggle, float normalizedTime) + { + if (!HasToggle(toggle)) + return false; + return toggles[toggle].y <= normalizedTime && normalizedTime >= toggles[toggle].x; + } + public ColliderInfo GetColliderInfo(ColliderBox.EColliderType type, int index, float playbackTime) { return GetColliderInfoByFrame(type, index, playbackTime * FPS); -- cgit v1.1-26-g67d0