|
@@ -1,18 +1,18 @@
|
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
using Spine;
|
|
using Spine;
|
|
|
using Spine.Unity;
|
|
using Spine.Unity;
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
|
|
|
public class SkeletonDataReader : MonoBehaviour
|
|
public class SkeletonDataReader : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
private SkeletonMecanim skeletonMecanim;
|
|
private SkeletonMecanim skeletonMecanim;
|
|
|
- private Enemy ene;
|
|
|
|
|
|
|
+ private Character cha;
|
|
|
|
|
|
|
|
[ContextMenu("Play")]
|
|
[ContextMenu("Play")]
|
|
|
private void WriteData()
|
|
private void WriteData()
|
|
|
{
|
|
{
|
|
|
ReadData();
|
|
ReadData();
|
|
|
- ene = GetComponentInParent<Enemy>();
|
|
|
|
|
- ene.totalBeRepelValue = 30;
|
|
|
|
|
|
|
+ cha = GetComponentInParent<Character>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void ReadData()
|
|
private void ReadData()
|
|
@@ -40,13 +40,32 @@ public class SkeletonDataReader : MonoBehaviour
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ cha.attackKeys = new List<SpineAniKey>();
|
|
|
// 遍历所有动画
|
|
// 遍历所有动画
|
|
|
foreach (var animation in skeletonData.Animations)
|
|
foreach (var animation in skeletonData.Animations)
|
|
|
{
|
|
{
|
|
|
string animationName = animation.Name;
|
|
string animationName = animation.Name;
|
|
|
float animationDuration = animation.Duration;
|
|
float animationDuration = animation.Duration;
|
|
|
Debug.Log($"动画名称: {animationName}, 动画时长: {animationDuration}");
|
|
Debug.Log($"动画名称: {animationName}, 动画时长: {animationDuration}");
|
|
|
|
|
+ if (animationName == "die")
|
|
|
|
|
+ {
|
|
|
|
|
+ cha.totalDieKeepTime = animationDuration;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (animationName == "attack_summon")
|
|
|
|
|
+ {
|
|
|
|
|
+ cha.totalAttack_summonTime = animationDuration;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (animationName == "attack_march")
|
|
|
|
|
+ {
|
|
|
|
|
+ cha.totalAttack_marchTime = animationDuration;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ SpineAniKey sak;
|
|
|
|
|
+ sak.aniName = animationName;
|
|
|
|
|
+ sak.keys = new List<AttackKeyType>();
|
|
|
|
|
+ AttackKeyType akt = new AttackKeyType();
|
|
|
|
|
+ bool isStartKey = true;
|
|
|
|
|
+ bool canWrite = false;
|
|
|
// 遍历动画中的事件
|
|
// 遍历动画中的事件
|
|
|
foreach (var timeline in animation.Timelines)
|
|
foreach (var timeline in animation.Timelines)
|
|
|
{
|
|
{
|
|
@@ -54,12 +73,28 @@ public class SkeletonDataReader : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
foreach (var eventFrame in eventTimeline.Events)
|
|
foreach (var eventFrame in eventTimeline.Events)
|
|
|
{
|
|
{
|
|
|
- string eventName = eventFrame.Name;
|
|
|
|
|
|
|
+ string eventName = eventFrame.ToString();
|
|
|
float eventTime = eventFrame.Time;
|
|
float eventTime = eventFrame.Time;
|
|
|
Debug.Log($"事件名称: {eventName}, 事件时间: {eventTime}, 所在动画: {animationName}");
|
|
Debug.Log($"事件名称: {eventName}, 事件时间: {eventTime}, 所在动画: {animationName}");
|
|
|
|
|
+ if (isStartKey)
|
|
|
|
|
+ {
|
|
|
|
|
+ akt.startKeyName = eventName;
|
|
|
|
|
+ akt.startKeyTime = eventTime;
|
|
|
|
|
+ akt.attackType = KeyType.AttackStart;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ akt.endKeyName = eventName;
|
|
|
|
|
+ akt.endKeyTime = eventTime;
|
|
|
|
|
+ akt.endType = KeyType.AttackEnd;
|
|
|
|
|
+ sak.keys.Add(akt);
|
|
|
|
|
+ canWrite = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ isStartKey = !isStartKey;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if(canWrite) cha.attackKeys.Add(sak);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|