summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/AnimationData.cs
blob: 72a3db24435ffcef27ae19bbbd7576015db6bb55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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<AnimationEventBase> animationEvents;

    public List<ColliderData> hurtBoxes;
    public List<ColliderData> hitBoxes;
    public List<ColliderData> throwBoxes;
    public List<ColliderData> blockBoxes;
    public List<ColliderData> 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(ref List<ColliderData> boxList, ColliderData box)
    {
        if (boxList == null)
        {
            boxList = new List<ColliderData>();
            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;
    }

}