Sfoglia il codice sorgente

支持单位播放死亡特效

大爷 1 anno fa
parent
commit
c875d095ce

+ 21 - 49
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/BattleMgr.cs

@@ -157,44 +157,6 @@ namespace ET
             return UnitTemplateIdHash.ContainsKey(tid) ? UnitTemplateIdHash[tid] : null;
         }
 
-        public async ETTask ProcessLauncheffectTag(uint objectid, string tag)
-        {
-            //Effect支持Tag设置Event,格式:Event:事件名(事件参数)
-            Match m = Regex.Match(tag, @"^@(\w+)\(([\w\d\s_,]+)\)");
-            if (m.Groups.Count >= 3)
-            {
-                string name = m.Groups[1].Value;
-                string param = m.Groups[2].Value;
-                switch (name)
-                {
-                    case "ChangeMode":
-                        var ps = param.Split(',');
-                        if (ps.Length > 1)
-                        {
-                            try
-                            {
-                                var delay = Convert.ToInt32(ps[1]);
-                                await TimerComponent.Instance.WaitAsync(delay);
-                                EventSystem.Instance.Publish(ChangeModeEvent.Static.Clone(objectid, ps[0]));
-                            }
-                            catch
-                            {
-                                Log.Error($"effect tag param error: {tag}");
-                            }
-                        }
-                        else
-                        {
-                            EventSystem.Instance.Publish(ChangeModeEvent.Static.Clone(objectid, param));
-                        }
-                        return;
-                    default:
-                        Log.Error($"effect unknow tag: {tag}");
-                        return;
-                }
-            }
-            Log.Error($"effect illegal tag: {tag}");
-        }
-
         private void registerEventHandler()
         {
             //actor===================
@@ -218,11 +180,6 @@ namespace ET
                     if (launcheffect != null)
                     {
                         EventSystem.Instance.Publish(PlayEffectEvent.Static.Clone(launcheffect, unit.Id, CommonLang.Geometry.Vector3.Zero));
-
-                        if(!launcheffect.Tag.IsNullOrWhitespace() )
-                        {
-                            ProcessLauncheffectTag(e.ObjectID, launcheffect.Tag).Coroutine();
-                        }
                     }
                 }
             });
@@ -234,19 +191,34 @@ namespace ET
                 var e = ev as UnitDeadEvent;
                 Log.Debug($"Unit({e.object_id}) dead");
 
-                EventSystem.Instance.Publish<PlayAnimatorEvent>(PlayAnimatorEvent.Static.Clone(
-                    e.ObjectID, AnimatorEventType.Dead));
-
                 var unit = UnitMgr.Instance.GetUnit(e.ObjectID);
                 if(unit != null && unit is BattleUnit bunit)
                 {
-                    var launcheffect = bunit.ZUnit.Info.DeadActionEffect;
+                    EventSystem.Instance.Publish<PlayAnimatorEvent>(PlayAnimatorEvent.Static.Clone(
+    e.ObjectID, AnimatorEventType.Dead));
+
+                    var launcheffect = bunit.ZUnit.Info.DeadEffect;
                     if (launcheffect != null)
                     {
-                        EventSystem.Instance.Publish<PlayEffectEvent>(PlayEffectEvent.Static.Clone(launcheffect, unit.Id, CommonLang.Geometry.Vector3.Zero));
+                        if (launcheffect.BindBody)
+                        {
+                            vecTemp.Set(0, 0, 0);
+                        }
+                        else
+                        {
+                            vecTemp.Set(unit.ZoneObject.X, unit.ZoneObject.Y, unit.ZoneObject.Z);
+                        }
+                        EventSystem.Instance.Publish(PlayEffectEvent.Static.Clone(launcheffect, unit.Id, vecTemp));
+                    }
+
+                    //TODO: 在死亡动作播放完毕之后播放此特效
+                    launcheffect = bunit.ZUnit.Info.DeadAnimationEndEffect;
+                    if (launcheffect != null)
+                    {
+                        vecTemp.Set(unit.ZoneObject.X, unit.ZoneObject.Y, unit.ZoneObject.Z);
+                        EventSystem.Instance.Publish(PlayEffectEvent.Static.Clone(launcheffect, unit.Id, vecTemp));
                     }
                 }
-                //TODO: 过几秒后,自行清理尸体
             });
             eventHandler.AddListener<UnitRebirthEvent>((ev) =>
             {

+ 65 - 20
Unity/Assets/Scripts/Codes/HotfixView/Client/Effect/EffectMgr.cs

@@ -5,6 +5,7 @@ using CommonLang;
 using Sirenix.Utilities;
 using ET.EventType;
 using System.Collections.Generic;
+using System;
 
 namespace ET.Client
 {
@@ -17,6 +18,70 @@ namespace ET.Client
         {
             vecTemp.Set(args.Pos.X, args.Pos.Y, args.Pos.Z);
             EffectMgr.Instance.PlayEffect(args.Effect, args.HostId, vecTemp, args.Rotation).Coroutine();
+
+            var tag = args.Effect.Tag;
+            if (!tag.IsNullOrWhitespace())
+            {
+                ProcessLauncheffectTag(args.HostId, args.Effect.Tag).Coroutine();
+            }
+        }
+
+        public async ETTask ProcessLauncheffectTag(uint objectid, string tag)
+        {
+            //Effect支持Tag设置Event,格式:Event:事件名(事件参数)
+            Match m = Regex.Match(tag, @"^@(\w+)\(([\w\d\s_,]+)\)");
+            if (m.Groups.Count >= 3)
+            {
+                string name = m.Groups[1].Value;
+                string param = m.Groups[2].Value;
+                switch (name)
+                {
+                    case "ChangeMode":
+                        var ps = param.Split(',');
+                        if (ps.Length > 1)
+                        {
+                            try
+                            {
+                                var delay = Convert.ToInt32(ps[1]);
+                                await TimerComponent.Instance.WaitAsync(delay);
+                                EventSystem.Instance.Publish(ChangeModeEvent.Static.Clone(objectid, ps[0]));
+                            }
+                            catch
+                            {
+                                Log.Error($"effect tag param error: {tag}");
+                            }
+                        }
+                        else
+                        {
+                            EventSystem.Instance.Publish(ChangeModeEvent.Static.Clone(objectid, param));
+                        }
+                        return;
+                    default:
+                        Log.Error($"effect unknow tag: {tag}");
+                        return;
+                }
+            }
+            Log.Error($"effect illegal tag: {tag}");
+
+            /*if (!string.IsNullOrEmpty(effectData.Tag))
+            {
+                //Effect支持Tag设置Event,格式:Event:事件名(事件参数)
+                Match m = Regex.Match(effectData.Tag, @"^Event:(\w+)\((.*)\)");
+                if (m.Groups.Count >= 3)
+                {
+                    string eventName = m.Groups[1].Value;
+                    string eventParam = m.Groups[2].Value;
+                    if (!string.IsNullOrEmpty(eventName))
+                    {
+                        Log.Error("Not support: Effect({0}) Triggle event:{1}", effectData.Name, effectData.Tag);
+                        EventManager.Fire("Event." + eventName, new Dictionary<string, object>()
+                        {
+                            {"param", eventParam},
+                            {"position", gt.position}
+                        });
+                    }
+                }
+            }*/
         }
     }
 
@@ -158,26 +223,6 @@ namespace ET.Client
             var scale = effectData.ScaleToBodySize != 0 ? effectData.ScaleToBodySize : 1f;
             vecTemp.Set(scale, scale, scale);
             gt.localScale = vecTemp;
-
-            if (!string.IsNullOrEmpty(effectData.Tag))
-            {
-                //Effect支持Tag设置Event,格式:Event:事件名(事件参数)
-                Match m = Regex.Match(effectData.Tag, @"^Event:(\w+)\((.*)\)");
-                if (m.Groups.Count >= 3)
-                {
-                    string eventName = m.Groups[1].Value;
-                    string eventParam = m.Groups[2].Value;
-                    if (!string.IsNullOrEmpty(eventName))
-                    {
-                        Log.Error("Not support: Effect({0}) Triggle event:{1}", effectData.Name, effectData.Tag);
-                        /*EventManager.Fire("Event." + eventName, new Dictionary<string, object>()
-                        {
-                            {"param", eventParam},
-                            {"position", gt.position}
-                        });*/
-                    }
-                }
-            }
             go.SetActive(true);
 
             if (!effectData.SoundName.IsNullOrWhitespace())

+ 9 - 2
Unity/Assets/Scripts/Codes/HotfixView/Client/Scene/GameObjectPool.cs

@@ -78,9 +78,13 @@ namespace ET.Client
 
                 if(unit.FootCircleEffect != null) CacheLaunchEffect(unit.FootCircleEffect, ref effectlist, ref soundlist);
                 if (unit.SpawnEffect != null) CacheLaunchEffect(unit.SpawnEffect, ref effectlist, ref soundlist);
-                if (unit.DeadActionEffect != null) CacheLaunchEffect(unit.DeadActionEffect, ref effectlist, ref soundlist);
+                if (unit.DeadAnimationEndEffect != null) CacheLaunchEffect(unit.DeadAnimationEndEffect, ref effectlist, ref soundlist);
                 if (unit.DeadEffect != null) CacheLaunchEffect(unit.DeadEffect, ref effectlist, ref soundlist);
                 if (unit.HitBreakEffect != null) CacheLaunchEffect(unit.HitBreakEffect, ref effectlist, ref soundlist);
+                if (unit.ChangeForceEffect != null) CacheLaunchEffect(unit.ChangeForceEffect, ref effectlist, ref soundlist);
+                if (unit.CrushEffect != null) CacheLaunchEffect(unit.CrushEffect, ref effectlist, ref soundlist);
+                if (unit.DamageEffect != null) CacheLaunchEffect(unit.DamageEffect, ref effectlist, ref soundlist);
+                if (unit.RemovedEffect != null) CacheLaunchEffect(unit.RemovedEffect, ref effectlist, ref soundlist);
 
                 if (!unit.PreloadResources.IsNullOrWhitespace() )
                 {
@@ -129,7 +133,10 @@ namespace ET.Client
                         }
                         if (kf.Spell != null)
                         {
-                            CacheSpellEffect(templates, kf.Spell.SpellID, ref effectlist, ref soundlist);
+                            for (var i = 0; i < kf.Spell.Count; i++)
+                            {
+                                CacheSpellEffect(templates, kf.Spell.SpellID, ref effectlist, ref soundlist);
+                            }
                         }
                     }
                 }