From ffd1d5af496e0a0eff343b27c4f0f965bbbf79eb Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 31 Aug 2021 19:07:21 +0800 Subject: *projectile --- Assets/Scripts/Unit/TimelineEventProxy.cs | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'Assets/Scripts/Unit/TimelineEventProxy.cs') diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index 7a76cd73..51d437fe 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -7,7 +7,13 @@ using UnityEngine; // 执行帧事件 [DisallowMultipleComponent] public partial class TimelineEventProxy -{ +{ +#if UNITY_EDITOR // ActionTool里 + public bool isInEditMode; + public delegate void RegisterProjectileHandle(Projectile projectile); + public RegisterProjectileHandle registerProjectile; +#endif + public enum EEventType { EventCamera_Zoom, // 相机聚焦 @@ -118,4 +124,42 @@ public partial class TimelineEventProxy } + void EventProjectile(AnimationEventBase animEvent) + { + EventProjectile e = animEvent as EventProjectile; + if (e == null) + return; + string projectilePath = e.projectilePath; + GameObject prefab = ResourceManager.Instance.LoadAsset(projectilePath); + if(prefab == null) + { + LogHelper.LogError("缺少对应的projectile, " + projectilePath); + return; + } + if(prefab.GetComponent() == null) + { + LogHelper.LogError("没有projectile脚本"); + return; + } + GameObject obj = GameObject.Instantiate(prefab); + Projectile projectile = obj.GetComponent(); + ProjectileInfo info = new ProjectileInfo(); + info.owner = m_Owner; + info.position = m_Root.transform.position + e.posOffset; + info.rotation = e.rotation; + info.scale = e.scale; + info.direction = Vector3.right; + info.velocity = Vector3.right * 10f; + info.lifetime = 5; + info.sparkPath = e.sparkPath; + projectile.Initialize(info); + +#if UNITY_EDITOR + if(isInEditMode && registerProjectile != null) + { + registerProjectile(projectile); + } +#endif + } + } \ No newline at end of file -- cgit v1.1-26-g67d0