当前位置: 首页>>代码示例>>C#>>正文


C# SkillInstance.SetCurSectionDuration方法代码示例

本文整理汇总了C#中SkillSystem.SkillInstance.SetCurSectionDuration方法的典型用法代码示例。如果您正苦于以下问题:C# SkillInstance.SetCurSectionDuration方法的具体用法?C# SkillInstance.SetCurSectionDuration怎么用?C# SkillInstance.SetCurSectionDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkillSystem.SkillInstance的用法示例。


在下文中一共展示了SkillInstance.SetCurSectionDuration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        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;
        }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:34,代码来源:SectionTrigger.cs

示例2: Execute

        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;
        }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:79,代码来源:SectionTrigger.cs

示例3: Execute

        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);
//.........这里部分代码省略.........
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:101,代码来源:ImpactTrigger.cs


注:本文中的SkillSystem.SkillInstance.SetCurSectionDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。