SetCurSectionDuration() публичный Метод

public SetCurSectionDuration ( long duration ) : void
duration long
Результат void
        private string m_Type = "anim"; //anim/impact

        #endregion Fields

        #region Methods

        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;
            if (null == senderObj) return false;
            Scene scene = senderObj.Scene;
            EntityInfo obj = senderObj.GfxObj;
            if (null == obj) return false;
            if (curSectionTime < StartTime) {
                return true;
            }
            if (0 == m_Type.CompareTo("anim")) {
            } else if (0 == m_Type.CompareTo("impact")) {
                int time = scene.EntityController.GetImpactDuration(senderObj.ActorId, senderObj.SkillId, senderObj.Seq);
                if (time > 0) {
                    instance.SetCurSectionDuration((long)time + m_DeltaTime);
                } else {
                    LogSystem.Warn("adjustsectionduration impact duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                }
            } else {
                int time = TryGetTimeFromConfig(instance);
                if (time > 0) {
                    instance.SetCurSectionDuration((long)time + m_DeltaTime);
                } else {
                    LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                }
            }
            return false;
        }
 static public int SetCurSectionDuration(IntPtr l)
 {
     try {
         SkillSystem.SkillInstance self = (SkillSystem.SkillInstance)checkSelf(l);
         System.Int64 a1;
         checkType(l, 2, out a1);
         self.SetCurSectionDuration(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
 {
     GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;
     if (null == senderObj) return false;
     Scene scene = senderObj.Scene;
     EntityInfo obj = senderObj.GfxObj;
     if (null == obj) return false;
     if (curSectionTime < StartTime) {
         return true;
     }
     if (m_LastKeepTime <= 0 || m_LastKeepTime + m_Interval >= curSectionTime) {
         m_LastKeepTime = curSectionTime;
         int time = scene.EntityController.GetImpactDuration(senderObj.ActorId, senderObj.SkillId, senderObj.Seq);
         if (time > 0) {
             instance.SetCurSectionDuration((long)time + m_DeltaTime);
         } else {
             LogSystem.Warn("adjustsectionduration impact duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
         }
     }
     return true;
 }
        private string m_Type = "anim"; //anim/impact

        #endregion Fields

        #region Methods

        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;
            if (null == senderObj) return false;
            GameObject obj = senderObj.GfxObj;
            if (null == obj) return false;
            if (curSectionTime < StartTime) {
                return true;
            }
            if (0 == m_Type.CompareTo("anim")) {
                Animator animator = obj.GetComponentInChildren<Animator>();
                if (null != animator) {
                    float length = 0;
                    int layerCount = animator.layerCount;
                    for (int i = 0; i < layerCount; ++i) {
                        AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(i);
                        //LogSystem.Info("adjustsectionduration anim, skill id:{0} dsl skill id:{1}, length:{2} normalized time:{3} loop:{4} layer:{5} layer count:{6}", senderObj.SkillId, instance.DslSkillId, stateInfo.length, stateInfo.normalizedTime, stateInfo.loop, i, layerCount);

                        if (length < stateInfo.length && !float.IsInfinity(stateInfo.length))
                            length = stateInfo.length;
                    }
                    if (length > Geometry.c_FloatPrecision) {
                        long newDuration = (long)(length * 1000) + m_DeltaTime;
                        if (instance.CurSectionDuration < newDuration)
                            instance.SetCurSectionDuration(newDuration);
                    } else {
                        //LogSystem.Warn("adjustsectionduration anim length is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                        return true;
                    }
                }
            } else if (0 == m_Type.CompareTo("impact")) {
                int time = EntityController.Instance.GetImpactDuration(senderObj.ActorId, senderObj.SkillId, senderObj.Seq);
                if (time > 0) {
                    long newDuration = (long)time + m_DeltaTime;
                    if (instance.CurSectionDuration < newDuration)
                        instance.SetCurSectionDuration(newDuration);
                } else {
                    LogSystem.Warn("adjustsectionduration impact duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                }
            } else {
                bool handled = false;
                Animator animator = obj.GetComponentInChildren<Animator>();
                if (null != animator && null != animator.runtimeAnimatorController) {
                    float length = 0;
                    var clips = animator.runtimeAnimatorController.animationClips;
                    for (int i = 0; i < clips.Length; ++i) {
                        if (clips[i].name == m_Type) {
                            length = clips[i].length;
                            handled = true;
                            break;
                        }
                    }
                    if (length > Geometry.c_FloatPrecision) {
                        long newDuration = (long)(length * 1000) + m_DeltaTime;
                        if (instance.CurSectionDuration < newDuration)
                            instance.SetCurSectionDuration(newDuration);
                    } else {
                        LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1} type:{2}", senderObj.SkillId, instance.DslSkillId, m_Type);
                    }
                }
                if (!handled) {
                    int time = TryGetTimeFromConfig(instance);
                    if (time > 0) {
                        long newDuration = (long)time + m_DeltaTime;
                        if (instance.CurSectionDuration < newDuration)
                            instance.SetCurSectionDuration(newDuration);
                    } else {
                        LogSystem.Warn("adjustsectionduration variable time is 0, skill id:{0} dsl skill id:{1} type:{2}", senderObj.SkillId, instance.DslSkillId, m_Type);
                    }
                }
            }
            return false;
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;
            if (null == senderObj) {
                return false;
            }
            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill) {
                return false;//track只能在impact或buff里使用
            }
            GameObject obj = senderObj.GfxObj;
            if (null != obj) {
                if (curSectionTime >= StartTime) {
                    if (!m_IsStarted) {
                        m_IsStarted = true;
                        Vector3 dest;
                        string trackBone = m_TrackBone.Get(instance);
                        m_BoneTransform = Utility.FindChildRecursive(obj.transform, trackBone);
                        if (null != m_BoneTransform) {
                            dest = m_BoneTransform.position;
                        } else {
                            dest = obj.transform.position;
                            dest.y += 1.5f;
                            LogSystem.Warn("[skill:{0} dsl skill id:{1}] track bone {2} can't find.", senderObj.SkillId, instance.DslSkillId, trackBone);
                        }
                        m_StartPos = EntityController.Instance.GetImpactSenderPosition(senderObj.ActorId, senderObj.SkillId, senderObj.Seq);
                        dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f);
                        object speedObj;
                        if (instance.Variables.TryGetValue("emitSpeed", out speedObj)) {
                            m_Speed = (float)speedObj;
                        } else {
                            return false;
                        }
                        float duration = m_Duration.Get(instance);
                        if (duration > Geometry.c_FloatPrecision) {
                            float d = duration / 1000.0f;
                            m_Lifetime = d;
                            m_Speed = (dest - m_StartPos).magnitude / m_Lifetime;
                        } else {
                            m_Lifetime = 1.0f;
                            if (m_Speed > Geometry.c_FloatPrecision) {
                                m_Lifetime = (dest - m_StartPos).magnitude / m_Speed;
                            }
                        }
                        long newSectionDuration = StartTime + (long)(m_Lifetime * 1000);
                        if (instance.CurSectionDuration < newSectionDuration) {
                            instance.SetCurSectionDuration(newSectionDuration);
                        }
                        Quaternion dir;
                        object dirObj;
                        if (instance.Variables.TryGetValue("emitDir", out dirObj)) {
                            dir = (Quaternion)dirObj;
                        } else {
                            dir = Quaternion.identity;
                        }
                        Vector3 scale;
                        object scaleObj;
                        if (instance.Variables.TryGetValue("emitScale", out scaleObj)) {
                            scale = (Vector3)scaleObj;
                        } else {
                            scale = Vector3.one;
                        }
                        Vector3 lookDir = dest - m_StartPos;
                        Quaternion q = Quaternion.LookRotation(lookDir);
                        m_ControlPos = m_StartPos + Vector3.Scale(q * dir * Vector3.forward, scale * lookDir.magnitude * 0.5f);
                        string effectPath = SkillParamUtility.RefixResourceVariable("emitEffect", instance, senderObj.ConfigData.resources);
                        m_Effect = ResourceSystem.Instance.NewObject(effectPath, m_Lifetime) as GameObject;
                        if (null != m_Effect) {
                            senderObj.TrackEffectObj = m_Effect;
                            TriggerUtil.SetObjVisible(m_Effect, true);
                            m_Effect.SetActive(false);
                            m_Effect.transform.position = m_StartPos;
                            m_Effect.transform.localRotation = q;
                            m_Effect.SetActive(true);
                        } else {
                            if (string.IsNullOrEmpty(effectPath)) {
                                LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect is empty.", senderObj.SkillId, instance.DslSkillId);
                            } else {
                                LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect {2} can't find.", senderObj.SkillId, instance.DslSkillId, effectPath);
                            }
                        }
                    } else if (null != m_Effect) {
                        if (!m_NotMove && !m_IsHit) {
                            Vector3 dest;
                            if (null != m_BoneTransform) {
                                dest = m_BoneTransform.position;
                            } else {
                                dest = obj.transform.position;
                                dest.y += 1.5f;
                            }
                            dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f);
                            //m_Effect.transform.position = Vector3.MoveTowards(m_Effect.transform.position, dest, m_RealSpeed * Time.deltaTime);
                            m_Effect.transform.position = Utility.GetBezierPoint(m_StartPos, m_ControlPos, dest, (curSectionTime - StartTime) / 1000.0f / m_Lifetime);
                            if ((dest - m_Effect.transform.position).sqrMagnitude <= 0.01f) {
                                m_HitEffectRotation = Quaternion.LookRotation(m_StartPos - dest);
                                if (m_NoImpact) {
                                    instance.SetVariable("hitEffectRotation", m_HitEffectRotation);
                                } else {
                                    int impactId = EntityController.Instance.GetTrackSendImpact(senderObj.ActorId, senderObj.Seq, instance.Variables);
                                    Dictionary<string, object> args;
                                    TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
                                    if (args.ContainsKey("hitEffectRotation"))
                                        args["hitEffectRotation"] = m_HitEffectRotation;
                                    else
                                        args.Add("hitEffectRotation", m_HitEffectRotation);
                                    EntityController.Instance.TrackSendImpact(senderObj.ActorId, senderObj.SkillId, senderObj.Seq, impactId, args);
                                    int senderId, targetId;
                                    EntityController.Instance.CalcSenderAndTarget(senderObj, out senderId, out targetId);
                                }
                                m_IsHit = true;
                            }
                        }
                        if (curSectionTime > StartTime + m_Lifetime * 1000) {
                            m_Effect.SetActive(false);
                            ResourceSystem.Instance.RecycleObject(m_Effect);
                            m_Effect = null;
                            instance.StopCurSection();
                            return false;
                        }
                    } else {
                        return false;
                    }

                    //GameFramework.LogSystem.Debug("EmitEffectTriger:{0}", m_EffectPath);
                    return true;
                } else {
                    return true;
                }
            } else {
                instance.StopCurSection();
                return false;
            }
        }