diff options
Diffstat (limited to 'Assets/Scripts/Unit/Collider/ColliderData.cs')
-rw-r--r-- | Assets/Scripts/Unit/Collider/ColliderData.cs | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/Assets/Scripts/Unit/Collider/ColliderData.cs b/Assets/Scripts/Unit/Collider/ColliderData.cs index 744e6a45..b4ae17c5 100644 --- a/Assets/Scripts/Unit/Collider/ColliderData.cs +++ b/Assets/Scripts/Unit/Collider/ColliderData.cs @@ -3,13 +3,20 @@ using System.Collections; using System.Collections.Generic;
using UnityEngine;
+public struct ColliderInfo
+{
+ public bool active;
+ public Vector3 position;
+ public Vector3 size;
+}
+
[Serializable]
public class ColliderData
{
[Serializable]
public class ColliderFrame
{
- public int frameIndex;
+ public int frame;
public bool active;
public Vector3 position;
public Vector3 size;
@@ -20,4 +27,58 @@ public class ColliderData public ColliderBox.Pivot pivot;
public List<ColliderFrame> frames;
+
+ public ColliderData(ColliderBox.EColliderType type, ColliderBox.Pivot pivot)
+ {
+ this.type = type;
+ this.pivot = pivot;
+ this.frames = new List<ColliderFrame>();
+ }
+
+ public ColliderInfo GetColliderInfo()
+ {
+ ColliderInfo info = new ColliderInfo();
+
+ return info;
+ }
+
+ public void AddFrame(int frameIndex)
+ {
+ if (frames == null)
+ frames = new List<ColliderFrame>();
+ ColliderFrame frame = new ColliderFrame();
+ frame.frame = frameIndex;
+ frame.active = true;
+ frame.position = Vector3.zero;
+ frame.size = Vector3.one;
+ frames.Add(frame);
+ frames.Sort((a, b) => {
+ if (a == null)
+ return 1;
+ if (b == null)
+ return -1;
+ if (a.frame < b.frame)
+ return -1;
+ if (a.frame > b.frame)
+ return 1;
+ return 0;
+ });
+ }
+
+ public void DeleteFrame(int frameIndex)
+ {
+ if (frames == null)
+ return;
+ ColliderFrame frame = null;
+ foreach(var f in frames)
+ {
+ if (f.frame == frameIndex)
+ frame = f;
+ }
+ if(frame != null)
+ {
+ frames.Remove(frame);
+ }
+ }
+
}
|