using System.Collections; using System.Collections.Generic; using UnityEngine; // 某个动画的数据,包括帧事件、碰撞盒 [CreateAssetMenu(fileName = "Animation Data")] public class AnimationData : ScriptableObject { public string animationName; public string animationPath; public List animationEvents; public List hurtBoxes; public List hitBoxes; public List throwBoxes; public List blockBoxes; public List defendBoxes; public int GetBoxesCount() { int hurt = hurtBoxes != null ? hurtBoxes.Count : 0; int hit = hitBoxes != null ? hitBoxes.Count : 0; int thro = throwBoxes != null ? throwBoxes.Count : 0; int block = blockBoxes != null ? blockBoxes.Count : 0; int defend = defendBoxes != null ? defendBoxes.Count : 0; return hurt + hit + thro + block + defend; } public void AddBox(List boxList, ColliderData box) { if (boxList == null) { boxList = new List(); return; } boxList.Add(box); } public void DeleteBox(ColliderData box) { if (hurtBoxes != null) hurtBoxes.Remove(box); if (hitBoxes != null) hitBoxes.Remove(box); if (throwBoxes != null) throwBoxes.Remove(box); if (blockBoxes != null) blockBoxes.Remove(box); if (defendBoxes != null) defendBoxes.Remove(box); } public ColliderData GetColliderByIndex(int index) { if (hurtBoxes != null && hurtBoxes.Count > index) return hurtBoxes[index]; else index -= hurtBoxes.Count; if (hitBoxes != null && hitBoxes.Count > index) return hitBoxes[index]; else index -= hitBoxes.Count; if (throwBoxes != null && throwBoxes.Count > index) return throwBoxes[index]; else index -= throwBoxes.Count; if (blockBoxes != null && blockBoxes.Count > index) return blockBoxes[index]; else index -= blockBoxes.Count; if (defendBoxes != null && defendBoxes.Count > index) return defendBoxes[index]; else index -= defendBoxes.Count; return null; } }