diff options
-rw-r--r-- | Assets/ActionTool/ActionToolGizmos.cs | 87 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionData.cs | 2 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionEditorStyles.cs | 6 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionPreviewEditor.cs | 2 | ||||
-rw-r--r-- | Assets/Data/AnimationData/Erika/Take 001.asset | 53 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Collider/ColliderData.cs | 41 |
6 files changed, 151 insertions, 40 deletions
diff --git a/Assets/ActionTool/ActionToolGizmos.cs b/Assets/ActionTool/ActionToolGizmos.cs index dfbbae0a..eda72b1c 100644 --- a/Assets/ActionTool/ActionToolGizmos.cs +++ b/Assets/ActionTool/ActionToolGizmos.cs @@ -2,20 +2,83 @@ using System.Collections.Generic;
using UnityEngine;
-public class ActionToolGizmos : MonoBehaviour
+namespace ActionTool
{
- private void OnDrawGizmos()
+ public class ActionToolGizmos : MonoBehaviour
{
- Gizmos.color = Color.yellow;
- Gizmos.DrawCube(transform.position, new Vector3(0.1f, 0.1f, 0.1f));
-
- Gizmos.color = Color.red;
- Gizmos.DrawLine(Vector3.zero, Vector3.right * 1000);
- Gizmos.color = Color.green;
- Gizmos.DrawLine(Vector3.zero, Vector3.up * 1000);
- Gizmos.color = Color.blue;
- Gizmos.DrawLine(-Vector3.forward * 1000, Vector3.forward * 1000);
- }
+ AnimationData m_AnimationData;
+
+ float m_CurAnimFrame;
+
+ public void SetAnimationData(AnimationData data)
+ {
+ m_AnimationData = data;
+ }
+
+ public void SetCurAnimFrame(float frame)
+ {
+ m_CurAnimFrame = frame;
+ }
+
+ void OnDrawGizmos()
+ {
+ DrawRoot();
+ DrawAxis();
+ DrawColliders();
+ }
+
+ void DrawRoot()
+ {
+ Gizmos.color = Color.yellow;
+ Gizmos.DrawCube(transform.position, new Vector3(0.1f, 0.1f, 0.1f));
+ }
+ void DrawAxis()
+ {
+ Gizmos.color = Color.red;
+ Gizmos.DrawLine(Vector3.zero, Vector3.right * 1000);
+ Gizmos.color = Color.green;
+ Gizmos.DrawLine(Vector3.zero, Vector3.up * 1000);
+ Gizmos.color = Color.blue;
+ Gizmos.DrawLine(-Vector3.forward * 1000, Vector3.forward * 1000);
+ }
+
+ void DrawColliders()
+ {
+ if (m_AnimationData == null)
+ return;
+ DrawBoxes(m_AnimationData.hurtBoxes, Color.green);
+ DrawBoxes(m_AnimationData.hitBoxes, Color.red);
+ }
+
+ void DrawBoxes(List<ColliderData> boxes, Color color)
+ {
+ if (boxes != null && boxes.Count > 0)
+ {
+ for (int i = 0; i < boxes.Count; ++i)
+ {
+ var box = boxes[i];
+ if (box != null)
+ {
+ var info = box.GetColliderInfo(m_CurAnimFrame);
+ if (!info.active)
+ continue;
+ Vector3 pos = info.position;
+ switch (box.pivot)
+ {
+ case ColliderBox.Pivot.MiddleBottom:
+ pos.y += info.size.y / 2;
+ break;
+ }
+ pos += transform.position;
+ Gizmos.color = color * 0.5f;
+ Gizmos.DrawCube(pos, info.size);
+ }
+ }
+ }
+
+ }
+
+ }
}
diff --git a/Assets/ActionTool/Editor/ActionData.cs b/Assets/ActionTool/Editor/ActionData.cs index 958e2c53..c00dd269 100644 --- a/Assets/ActionTool/Editor/ActionData.cs +++ b/Assets/ActionTool/Editor/ActionData.cs @@ -144,6 +144,8 @@ namespace ActionTool m_CurAnimFrame %= m_TotalFrame;
}
+ ActionManager.gizmos.SetCurAnimFrame(m_CurAnimFrame);
+
SampleFrame();
RunEvent();
diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs index fbc543ae..1943a74f 100644 --- a/Assets/ActionTool/Editor/ActionEditorStyles.cs +++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs @@ -44,12 +44,12 @@ namespace ActionTool InitStyle(out textSmall, GUI.skin.label, s => {
s.fontSize = 8;
});
- InitStyle(out boxToggle, GUI.skin.button, s => {
+ InitStyle(out boxToggle, EditorStyles.miniButtonLeft, s => {
s.fontSize = 8;
s.normal.textColor = Color.white;
- s.normal.background = null;
+ //s.normal.background = null;
s.active.textColor = Color.white;
- s.active.background = null;
+ //s.active.background = null;
});
InitStyle(out keyFrameButton, GUI.skin.button, s => {
s.fontSize = 8;
diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 858b28e2..d236770e 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -218,7 +218,7 @@ namespace ActionTool Rect rect = new Rect(0, y, 20, 15);
for(int i = 0; i < sampleCount; i++)
{
- rect.x = kTimeLineViewXOffset + i * kFrameWidth - ((i >= 10) ? 7 : 3);
+ rect.x = kTimeLineViewXOffset + i * kFrameWidth - ((i >= 10) ? 7 : 5);
if(i % 5 == 0)
{
Color c = GUI.color;
diff --git a/Assets/Data/AnimationData/Erika/Take 001.asset b/Assets/Data/AnimationData/Erika/Take 001.asset index 44378329..16700c41 100644 --- a/Assets/Data/AnimationData/Erika/Take 001.asset +++ b/Assets/Data/AnimationData/Erika/Take 001.asset @@ -22,41 +22,50 @@ MonoBehaviour: - frame: 0 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} - - frame: 82 + size: {x: 1, y: 1.3, z: 0.5} + - frame: 7 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} - hitBoxes: - - type: 0 - pivot: 1 - frames: - - frame: 23 + size: {x: 1, y: 1, z: 0.5} + - frame: 12 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} - - type: 0 - pivot: 1 - frames: + size: {x: 1, y: 1, z: 0.5} + - frame: 20 + active: 1 + position: {x: 0, y: 0, z: 0} + size: {x: 1, y: 0.7, z: 0.5} + - frame: 22 + active: 1 + position: {x: 0, y: 0, z: 0} + size: {x: 1, y: 0.76, z: 0.5} - frame: 24 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} - - frame: 37 + size: {x: 1, y: 1.3, z: 0.5} + - frame: 30 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} - - type: 0 - pivot: 1 - frames: - - frame: 32 + size: {x: 1, y: 1.4, z: 0.5} + - frame: 40 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} - - frame: 37 + size: {x: 1, y: 1.3, z: 0.5} + - frame: 45 + active: 1 + position: {x: 0, y: 0, z: 0} + size: {x: 1, y: 0.7, z: 0.5} + - frame: 82 active: 1 position: {x: 0, y: 0, z: 0} - size: {x: 1, y: 1, z: 1} + size: {x: 1, y: 1.3, z: 0.5} + hitBoxes: + - type: 0 + pivot: 1 + frames: [] + - type: 0 + pivot: 1 + frames: [] throwBoxes: [] blockBoxes: [] defendBoxes: [] diff --git a/Assets/Scripts/Unit/Collider/ColliderData.cs b/Assets/Scripts/Unit/Collider/ColliderData.cs index b4ae17c5..0b79d04a 100644 --- a/Assets/Scripts/Unit/Collider/ColliderData.cs +++ b/Assets/Scripts/Unit/Collider/ColliderData.cs @@ -35,10 +35,47 @@ public class ColliderData this.frames = new List<ColliderFrame>();
}
- public ColliderInfo GetColliderInfo()
+ public ColliderInfo GetColliderInfo(float frame)
{
ColliderInfo info = new ColliderInfo();
-
+ info.active = false; // default
+ int previous = 0;
+ int end = -1;
+ for (int i = 0; i < frames.Count; ++i)
+ {
+ if(frame >= frames[i].frame)
+ {
+ previous = frames[i].frame;
+ }
+ if(frames[i].frame > frame)
+ {
+ end = frames[i].frame;
+ break;
+ }
+ }
+ if(end == -1)
+ {
+ if(type == ColliderBox.EColliderType.HurtBox)
+ {
+ ColliderFrame pre = frames.Find(s => s.frame == previous);
+ if (pre == null)
+ return info;
+ info.active = pre.active;
+ info.position = pre.position;
+ info.size = pre.size;
+ }
+ }
+ else
+ {
+ ColliderFrame pre = frames.Find(s => s.frame == previous);
+ ColliderFrame next = frames.Find(s => s.frame == end);
+ if (pre == null || next == null)
+ return info;
+ info.active = pre.active;
+ float t = (frame - previous) / (end - previous);
+ info.position = Vector3.Lerp(pre.position, next.position, t);
+ info.size = Vector3.Lerp(pre.size, next.size, t);
+ }
return info;
}
|