diff options
Diffstat (limited to 'Assets/Scripts')
-rw-r--r-- | Assets/Scripts/Unit/TimelineEventProxy.cs | 140 | ||||
-rw-r--r-- | Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs | 145 | ||||
-rw-r--r-- | Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs.meta | 11 |
3 files changed, 156 insertions, 140 deletions
diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index e750def2..de6e6b0b 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -162,144 +162,4 @@ public partial class TimelineEventProxy }
}
- #region Event Handles -
- void EventEffect(AnimationEventBase animEvent) - { - EventEffect effect = animEvent as EventEffect; - if (effect == null) - return; - string path = effect.effectPath; - if (path == null || path == "") - return; - GameObject prefab = ResourceManager.Instance.LoadAsset<GameObject>(path); - if (prefab != null) - { - GameObject root = new GameObject(); - - GameObject go = GameObject.Instantiate(prefab); - go.transform.SetParent(root.transform); - FxClear onClear = root.AddComponent<FxClear>();
- onClear.gameObject.name = prefab.name + "(Clone)";
-
- PlayEffectInfo info = new PlayEffectInfo();
- info.path = path;
- info.playEffectType = EffectPlayTypes.Oneshot;
- info.posOffset = effect.position;
- info.rot = effect.rotation;
- info.scale = effect.scale;
- info.bAttached = effect.attached;
- if(effect.attached)
- {
- if(effect.attachNode == global::EventEffect.EAttachNode.Unit)
- {
- info.rootTr = m_Root;
- }
- else if(effect.attachNode == global::EventEffect.EAttachNode.Bone)
- {
- if(m_UnitModel != null)
- {
- info.rootTr = m_UnitModel.Find(effect.bone);
- }
- }
- }
-
- onClear.Initialize(info);
-#if UNITY_EDITOR
- if (isInEditMode && registerParticleSystem != null)
- {
- registerParticleSystem(onClear); - }
- onClear.gameObject.transform.SetParent(Root_Particles.transform);
-#endif
- } - } - - void EventCamera_Shake(AnimationEventBase animEvent) - { - - } - - void EventProjectile(AnimationEventBase animEvent)
- {
- EventProjectile e = animEvent as EventProjectile;
- if (e == null)
- return;
- string projectilePath = e.projectilePath;
- if (projectilePath == null || projectilePath == "")
- return;
- GameObject prefab = ResourceManager.Instance.LoadAsset<GameObject>(projectilePath);
- if(prefab == null)
- {
- LogHelper.LogError("缺少对应的projectile, " + projectilePath);
- return;
- }
- if(prefab.GetComponent<Projectile>() == null)
- {
- LogHelper.LogError("没有projectile脚本");
- return;
- }
- GameObject obj = GameObject.Instantiate(prefab);
- Projectile projectile = obj.GetComponent<Projectile>();
- ProjectileInfo info = new ProjectileInfo();
- info.name = e.name;
- info.tag = e.tag;
- info.moveType = e.moveType;
- info.owner = owner;
- info.position = m_Root.transform.position + e.posOffset;
- info.rotation = e.rotation;
- info.scale = e.scale;
- if (owner)
- {
- info.velocity = owner.transform.rotation * e.velocity;
- }
- else
- {
- info.velocity = e.velocity;
- }
- info.acceleration = e.acceleration;
- info.lifetime = e.lifeTime;
- info.sparkPath = e.sparkPath;
- projectile.Initialize(info);
-
-#if UNITY_EDITOR
- if(isInEditMode && registerProjectile != null)
- {
- registerProjectile(projectile);
- }
- obj.transform.SetParent(Root_Projectiles.transform);
-#endif
- }
-
- void EventMesh_AfterImage(AnimationEventBase animEvent)
- {
-#if UNITY_EDITOR
- if (isInEditMode)
- return;
-#endif
- EventMesh_AfterImage afterImage = animEvent as EventMesh_AfterImage;
- if (afterImage == null)
- return ;
- string avatarPath = owner.unitParts.afterImageAvatarPath;
- GameObject go = ResourceManager.Instance.LoadAsset<GameObject>(avatarPath);
- if(go)
- {
- GameObject instance = GameObject.Instantiate(go);
- AfterImageAvatar avatar = instance.GetOrAddComponent<AfterImageAvatar>();
- if(!avatar)
- {
- GameObject.DestroyImmediate(instance);
- return;
- }
- avatar.Initialize(owner);
- }
- }
-
- void EventUnit_SetPosition(AnimationEventBase animEvent)
- {
- // 在unitState回调里处理
- }
-
- #endregion -
}
\ No newline at end of file diff --git a/Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs b/Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs new file mode 100644 index 00000000..119cf105 --- /dev/null +++ b/Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs @@ -0,0 +1,145 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +// Timeline Event Handlers +public partial class TimelineEventProxy +{ + + void EventEffect(AnimationEventBase animEvent) + { + EventEffect effect = animEvent as EventEffect; + if (effect == null) + return; + string path = effect.effectPath; + if (path == null || path == "") + return; + GameObject prefab = ResourceManager.Instance.LoadAsset<GameObject>(path); + if (prefab != null) + { + GameObject root = new GameObject(); + + GameObject go = GameObject.Instantiate(prefab); + go.transform.SetParent(root.transform); + FxClear onClear = root.AddComponent<FxClear>(); + onClear.gameObject.name = prefab.name + "(Clone)"; + + PlayEffectInfo info = new PlayEffectInfo(); + info.path = path; + info.playEffectType = EffectPlayTypes.Oneshot; + info.posOffset = effect.position; + info.rot = effect.rotation; + info.scale = effect.scale; + info.bAttached = effect.attached; + if (effect.attached) + { + if (effect.attachNode == global::EventEffect.EAttachNode.Unit) + { + info.rootTr = m_Root; + } + else if (effect.attachNode == global::EventEffect.EAttachNode.Bone) + { + if (m_UnitModel != null) + { + info.rootTr = m_UnitModel.Find(effect.bone); + } + } + } + + onClear.Initialize(info); +#if UNITY_EDITOR + if (isInEditMode && registerParticleSystem != null) + { + registerParticleSystem(onClear); + } + onClear.gameObject.transform.SetParent(Root_Particles.transform); +#endif + } + } + + void EventCamera_Shake(AnimationEventBase animEvent) + { + + } + + void EventProjectile(AnimationEventBase animEvent) + { + EventProjectile e = animEvent as EventProjectile; + if (e == null) + return; + string projectilePath = e.projectilePath; + if (projectilePath == null || projectilePath == "") + return; + GameObject prefab = ResourceManager.Instance.LoadAsset<GameObject>(projectilePath); + if (prefab == null) + { + LogHelper.LogError("缺少对应的projectile, " + projectilePath); + return; + } + if (prefab.GetComponent<Projectile>() == null) + { + LogHelper.LogError("没有projectile脚本"); + return; + } + GameObject obj = GameObject.Instantiate(prefab); + Projectile projectile = obj.GetComponent<Projectile>(); + ProjectileInfo info = new ProjectileInfo(); + info.name = e.name; + info.tag = e.tag; + info.moveType = e.moveType; + info.owner = owner; + info.position = m_Root.transform.position + e.posOffset; + info.rotation = e.rotation; + info.scale = e.scale; + if (owner) + { + info.velocity = owner.transform.rotation * e.velocity; + } + else + { + info.velocity = e.velocity; + } + info.acceleration = e.acceleration; + info.lifetime = e.lifeTime; + info.sparkPath = e.sparkPath; + projectile.Initialize(info); + +#if UNITY_EDITOR + if (isInEditMode && registerProjectile != null) + { + registerProjectile(projectile); + } + obj.transform.SetParent(Root_Projectiles.transform); +#endif + } + + void EventMesh_AfterImage(AnimationEventBase animEvent) + { +#if UNITY_EDITOR + if (isInEditMode) + return; +#endif + EventMesh_AfterImage afterImage = animEvent as EventMesh_AfterImage; + if (afterImage == null) + return; + string avatarPath = owner.unitParts.afterImageAvatarPath; + GameObject go = ResourceManager.Instance.LoadAsset<GameObject>(avatarPath); + if (go) + { + GameObject instance = GameObject.Instantiate(go); + AfterImageAvatar avatar = instance.GetOrAddComponent<AfterImageAvatar>(); + if (!avatar) + { + GameObject.DestroyImmediate(instance); + return; + } + avatar.Initialize(owner); + } + } + + void EventUnit_SetPosition(AnimationEventBase animEvent) + { + // 在unitState回调里处理 + } + +}
\ No newline at end of file diff --git a/Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs.meta b/Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs.meta new file mode 100644 index 00000000..8ac28875 --- /dev/null +++ b/Assets/Scripts/Unit/TimelineEventProxy_Handlers.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e3ae1078c8bcc2f4299aaa231266363e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |