Browse Source

修改特效时长规则,以编辑器设置的EffectTimeMS优先,当使用默认值0时,才考虑读取特效绑定脚本参数

大爷 1 year ago
parent
commit
d4cd6f65cf

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

@@ -234,7 +234,7 @@ namespace ET
                         vecTemp.Set(unit.ZoneObject.X, unit.ZoneObject.Y, unit.ZoneObject.Z);
                     }
 
-                    EventSystem.Instance.Publish<PlayEffectEvent>(PlayEffectEvent.Static.Clone(hitEffect, e.ObjectID, vecTemp, 0, roation));
+                    EventSystem.Instance.Publish<PlayEffectEvent>(PlayEffectEvent.Static.Clone(hitEffect, e.ObjectID, vecTemp, roation));
                 }
             });
             eventHandler.AddListener<PlayerPKModeChangeEventB2C>((ev) =>

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

@@ -16,7 +16,7 @@ namespace ET.Client
         public override void OnEvent(PlayEffectEvent args)
         {
             vecTemp.Set(args.Pos.X, args.Pos.Y, args.Pos.Z);
-            EffectMgr.Instance.PlayEffect(args.Effect, args.HostId, vecTemp, args.Time, args.Rotation).Coroutine();
+            EffectMgr.Instance.PlayEffect(args.Effect, args.HostId, vecTemp, args.Rotation).Coroutine();
         }
     }
 
@@ -45,9 +45,10 @@ namespace ET.Client
             }
         }
 
-        public async ETTask<uint> PlayEffect(LaunchEffect effect, uint HostId, Vector3 pos, float time = 0f, float rotation = 0f)
+        public async ETTask<uint> PlayEffect(LaunchEffect effect, uint HostId, Vector3 pos, float rotation = 0f)
         {
             var starttime = Time.realtimeSinceStartup;
+            float time = EffectPlayInfo.TIME_DEFAULT;
 
             GameObject go = null;
             if (!effect.Name.IsNullOrWhitespace())
@@ -64,9 +65,23 @@ namespace ET.Client
                 }
 
                 go = await GameObjectPool.Instance.Acquire("Effect_" + effect.Name);
-                var timeComponent = go.GetComponent<EffectTime>();
-                if (time == 0f) time = timeComponent != null ? timeComponent.duration : EffectPlayInfo.TIME_DEFAULT;
-                if (time < 0f) time = EffectPlayInfo.TIME_FOREVER;
+
+                if (effect.EffectTimeMS > 0)
+                {
+                    time = effect.EffectTimeMS / 1000.0f;
+                }
+                else if (effect.EffectTimeMS < 0)
+                {
+                    time = EffectPlayInfo.TIME_FOREVER;
+                }
+                else
+                {
+                    var timeComponent = go.GetComponent<EffectTime>();
+                    if (timeComponent != null && timeComponent.duration > 0)
+                    {
+                        time = timeComponent.duration;
+                    }
+                }
                 setupEffect(go, effect, render, pos, rotation);
             }
             else if(!effect.SoundName.IsNullOrWhitespace())

+ 1 - 3
Unity/Assets/Scripts/Codes/Model/Client/EventTypeClient.cs

@@ -68,16 +68,14 @@ namespace ET
             public LaunchEffect Effect;
             public uint HostId;
             public CommonLang.Geometry.Vector3 Pos;
-            public float Time;
             public float Rotation;
 
             public static PlayEffectEvent Static = new PlayEffectEvent();
-            public PlayEffectEvent Clone(LaunchEffect effect, uint hostId, CommonLang.Geometry.Vector3 pos, float time = 0f, float rotation = 0f)
+            public PlayEffectEvent Clone(LaunchEffect effect, uint hostId, CommonLang.Geometry.Vector3 pos, float rotation = 0f)
             {
                 Effect = effect;
                 HostId = hostId;
                 Pos = pos;
-                Time = time;
                 Rotation = rotation;
 
                 return this;