ConvertToSecond() static private method

static private ConvertToSecond ( long delta ) : float
delta long
return float
コード例 #1
0
        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 (null != senderObj.TrackEffectObj)
            {
                obj = senderObj.TrackEffectObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (curSectionTime > StartTime + m_RemainTime)
            {
                return(false);
            }
            obj.transform.Rotate(m_RotateSpeed * TriggerUtil.ConvertToSecond(delta));
            return(true);
        }
コード例 #2
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            EntityInfo obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (curSectionTime > StartTime + m_RemainTime)
            {
                return(false);
            }
            float dir = obj.GetMovementStateInfo().GetFaceDir();

            dir = (dir + Geometry.DegreeToRadian(m_RotateSpeed.Y) * TriggerUtil.ConvertToSecond(delta)) % (float)(2 * Math.PI);
            obj.GetMovementStateInfo().SetFaceDir(dir);
            return(true);
        }
コード例 #3
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            m_Myself = senderObj.GfxObj;
            if (null == m_Myself)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (m_IsExecuted && curSectionTime > (StartTime + m_RemainTime))
            {
                return(false);
            }
            Vector3 pos = m_Myself.transform.position;

            m_Target = senderObj.TargetGfxObj;
            if (!m_IsExecuted && (null == m_Target && !string.IsNullOrEmpty(m_SelectTargetType)))
            {
                TargetManager mgr = instance.CustomDatas.GetData <TargetManager>();
                if (null == mgr)
                {
                    mgr = new TargetManager();
                    instance.CustomDatas.AddData(mgr);
                }
                int targetId = EntityController.Instance.SelectTargetForSkill(m_SelectTargetType, senderObj.ObjId, senderObj.ConfigData, senderObj.Seq, mgr.Targets);
                if (targetId > 0)
                {
                    mgr.Add(targetId);
                    m_Target = EntityController.Instance.GetGameObject(targetId);
                    senderObj.TargetObjId  = targetId;
                    senderObj.TargetGfxObj = m_Target;
                }
            }
            if (null != m_Target)
            {
                m_IsExecuted = true;
                if (!m_IsHaveRotateSpeed || m_RotateSpeed.y == 0)
                {
                    TriggerUtil.Lookat(m_Myself, m_Target.transform.position);
                }
                else
                {
                    float maxRotateDelta = m_RotateSpeed.y * TriggerUtil.ConvertToSecond(delta);
                    TriggerUtil.Lookat(m_Myself, m_Target.transform.position, maxRotateDelta);
                }
            }
            return(true);
        }
コード例 #4
0
        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);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= StartTime + m_Duration)
            {
                if (!Prepare(senderObj, obj, targetObj))
                {
                    return(false);
                }
                float   t         = (float)(int)(curSectionTime - StartTime) / 1000.0f;
                float   disty     = m_YVelocity * t - m_G * t * t / 2;
                float   dist      = TriggerUtil.ConvertToSecond(delta) * m_Velocity;
                Vector3 targetPos = obj.transform.position + m_Forward * dist;
                targetPos.y = m_InitY + disty;
                TriggerUtil.MoveObjTo(obj, targetPos);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        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);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= StartTime + m_RealDuration)
            {
                if (!Prepare(senderObj, instance, obj, targetObj))
                {
                    return(false);
                }
                if (null != m_Curve && m_Curve.keys.Length >= 2)
                {
                    float   time      = Mathf.Clamp01((curSectionTime - StartTime) * 1.0f / m_RealDuration);
                    float   val       = m_Curve.Evaluate(time);
                    Vector3 targetPos = Vector3.SlerpUnclamped(new Vector3(m_StartPos.x, m_StartPos.y, m_StartPos.z), new Vector3(m_TargetPos.x, m_StartPos.y, m_StartPos.z), val);
                    if (!m_IsFreeMove)
                    {
                        if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos))
                        {
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                        else
                        {
                            targetPos = TriggerUtil.GetGroundPos(targetPos);
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                    }
                    else
                    {
                        TriggerUtil.MoveObjTo(obj, targetPos);
                    }
                }
                else
                {
                    float   dist      = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity;
                    Vector3 targetPos = obj.transform.position + m_Forward * dist;
                    if (!m_IsFreeMove)
                    {
                        if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos))
                        {
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                        else
                        {
                            targetPos = TriggerUtil.GetGroundPos(targetPos);
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                    }
                    else
                    {
                        TriggerUtil.MoveObjTo(obj, targetPos);
                    }
                }
                return(true);
            }
            else
            {
                Vector3 diff = m_TargetPos - obj.transform.position;
                if (diff.sqrMagnitude > 0.01f)
                {
                    Vector3 targetPos = m_TargetPos;
                    if (!m_IsFreeMove)
                    {
                        if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos))
                        {
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                        else
                        {
                            targetPos = TriggerUtil.GetGroundPos(targetPos);
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                    }
                    else
                    {
                        TriggerUtil.MoveObjTo(obj, targetPos);
                    }
                }
                return(false);
            }
        }
コード例 #6
0
        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 (null != senderObj.TrackEffectObj)
            {
                obj = senderObj.TrackEffectObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (!m_IsCurveMoving)
            {
                return(false);
            }
            if (!m_IsInited)
            {
                Init(senderObj, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving = false;
                return(false);
            }
            m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale));
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (m_Now - cur_section.startTime > cur_section.moveTime)
            {
                float end_time  = cur_section.startTime + cur_section.moveTime;
                float used_time = end_time - cur_section.lastUpdateTime;
                cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time);
                m_SectionListCopy.RemoveAt(0);
                if (m_SectionListCopy.Count > 0)
                {
                    cur_section                = m_SectionListCopy[0];
                    cur_section.startTime      = end_time;
                    cur_section.lastUpdateTime = end_time;
                    cur_section.curSpeedVect   = cur_section.speedVect;
                }
                else
                {
                    m_IsCurveMoving = false;
                }
            }
            else
            {
                cur_section.curSpeedVect   = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = m_Now;
            }
            return(true);
        }
コード例 #7
0
        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);
            }
            bool isTower = scene.EntityController.GetEntityType(senderObj.GfxObj) == (int)EntityTypeEnum.Tower;

            if (isTower)
            {
                return(false);
            }
            if (!m_TargetChecked)
            {
                m_TargetChecked = true;

                m_RealDuration = m_Duration;
                m_RealVelocity = m_Velocity;
                if (m_RealDuration <= 0)
                {
                    m_RealDuration += instance.CurSectionDuration;
                }
                if (m_RealDuration <= 0)
                {
                    LogSystem.Warn("jump duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                    return(false);
                }
                EntityInfo targetObj = senderObj.TargetGfxObj;
                if (null != targetObj)
                {
                    Vector3 srcPos               = obj.GetMovementStateInfo().GetPosition3D();
                    Vector3 targetPos            = targetObj.GetMovementStateInfo().GetPosition3D();
                    float   degree               = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.X, srcPos.Z), new ScriptRuntime.Vector2(targetPos.X, targetPos.Z));
                    ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(targetPos.X, targetPos.Z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.X, m_Offset.Z), degree);
                    targetPos = new Vector3(newPos.X, targetPos.Y + m_Offset.Y, newPos.Y);
                    if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity)
                    {
                        m_RealVelocity = (long)(1000.0f * (targetPos - srcPos).Length() / m_RealDuration);
                    }
                    else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime)
                    {
                        m_RealDuration = (long)(1000.0f * (targetPos - targetPos).Length() / m_RealVelocity);
                        CalcYVelocityAndG();
                    }
                    m_Forward = targetPos - srcPos;
                    m_Forward.Normalize();
                }
                else
                {
                    m_Forward = Geometry.GetRotate(new Vector3(0, 0, 1), obj.GetMovementStateInfo().GetFaceDir());
                }
                m_InitY = obj.GetMovementStateInfo().PositionY;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= m_RealDuration)
            {
                float   t         = (float)(int)(curSectionTime - StartTime) / 1000.0f;
                float   disty     = m_YVelocity * t - m_G * t * t / 2;
                float   dist      = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity;
                Vector3 targetPos = obj.GetMovementStateInfo().GetPosition3D() + m_Forward * dist;
                targetPos.Y = m_InitY + disty;

                TriggerUtil.MoveObjTo(obj, targetPos);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
0
        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);
            }
            bool isTower = scene.EntityController.GetEntityType(senderObj.GfxObj) == (int)EntityTypeEnum.Tower;

            if (isTower)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (!m_IsCurveMoving)
            {
                return(false);
            }
            if (!m_IsInited)
            {
                Init(obj, senderObj.TargetGfxObj, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving = false;
                return(false);
            }

            m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale));
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (m_Now - cur_section.startTime > cur_section.moveTime)
            {
                float end_time  = cur_section.startTime + cur_section.moveTime;
                float used_time = end_time - cur_section.lastUpdateTime;
                cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time);
                m_SectionListCopy.RemoveAt(0);
                if (m_SectionListCopy.Count > 0)
                {
                    cur_section                = m_SectionListCopy[0];
                    cur_section.startTime      = end_time;
                    cur_section.lastUpdateTime = end_time;
                    cur_section.curSpeedVect   = cur_section.speedVect;
                }
                else
                {
                    m_IsCurveMoving = false;
                }
            }
            else
            {
                cur_section.curSpeedVect   = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = m_Now;
            }
            return(true);
        }
コード例 #9
0
        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);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            bool isTower = !EntityController.Instance.IsMovableEntity(obj);

            if (isTower)
            {
                return(false);
            }
            if (!m_TargetChecked)
            {
                m_TargetChecked = true;
                m_RealDuration  = m_Duration;
                m_RealVelocity  = m_Velocity;
                if (m_RealDuration <= 0)
                {
                    m_RealDuration += instance.CurSectionDuration;
                }
                if (m_RealDuration <= 0)
                {
                    LogSystem.Warn("jump duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                    return(false);
                }
                if (null != targetObj || m_IsForRoundMove)
                {
                    Vector3 srcPos    = obj.transform.position;
                    Vector3 targetPos = Vector3.zero;
                    if (null != targetObj)
                    {
                        targetPos = targetObj.transform.position;
                    }
                    if (m_IsForRoundMove)
                    {
                        TriggerUtil.GetSkillStartPosition(srcPos, senderObj.ConfigData, instance, senderObj.ActorId, senderObj.TargetActorId, ref targetPos);
                    }
                    if (targetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                    {
                        float degree = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.x, srcPos.z), new ScriptRuntime.Vector2(targetPos.x, targetPos.z));
                        ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree);
                        targetPos   = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y);
                        m_TargetPos = targetPos;
                        if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity)
                        {
                            m_RealVelocity = (long)(1000.0f * (targetPos - srcPos).magnitude / m_RealDuration);
                        }
                        else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime)
                        {
                            m_RealDuration = (long)(1000.0f * (targetPos - srcPos).magnitude / m_RealVelocity);
                            CalcYVelocityAndG();
                        }
                        m_Forward   = targetPos - srcPos;
                        m_Forward.y = 0;
                        m_Forward.Normalize();
                    }
                    else
                    {
                        m_Forward = obj.transform.forward;
                    }
                }
                else
                {
                    m_Forward = obj.transform.forward;
                }
                m_InitY = obj.transform.position.y;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= StartTime + m_RealDuration)
            {
                float   t         = (float)(int)(curSectionTime - StartTime) / 1000.0f;
                float   disty     = m_YVelocity * t - m_G * t * t / 2;
                float   dist      = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity;
                Vector3 targetPos = obj.transform.position + m_Forward * dist;
                targetPos.y = m_InitY + disty;
                TriggerUtil.MoveObjTo(obj, targetPos);
                return(true);
            }
            else
            {
                Vector3 srcPos = obj.transform.position;
                if (m_IsForRoundMove && m_TargetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                {
                    srcPos = m_TargetPos;
                }
                obj.transform.position = new Vector3(srcPos.x, m_InitY, srcPos.z);
                return(false);
            }
        }
コード例 #10
0
        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 (null != senderObj.TrackEffectObj)
            {
                obj = senderObj.TrackEffectObj;
            }
            bool isTower = !EntityController.Instance.IsMovableEntity(obj);

            if (isTower)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (!m_IsCurveMoving)
            {
                if (m_IsForRoundMove && m_TargetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                {
                    obj.transform.position = m_TargetPos;
                }
                return(false);
            }
            if (!m_IsInited)
            {
                Init(senderObj, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving = false;
                return(false);
            }
            m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale));
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (m_Now - cur_section.startTime > cur_section.moveTime)
            {
                float end_time  = cur_section.startTime + cur_section.moveTime;
                float used_time = end_time - cur_section.lastUpdateTime;
                cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time);
                m_SectionListCopy.RemoveAt(0);
                if (m_SectionListCopy.Count > 0)
                {
                    cur_section                = m_SectionListCopy[0];
                    cur_section.startTime      = end_time;
                    cur_section.lastUpdateTime = end_time;
                    cur_section.curSpeedVect   = cur_section.speedVect;
                }
                else
                {
                    m_IsCurveMoving = false;
                }
            }
            else
            {
                cur_section.curSpeedVect   = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = m_Now;
            }
            return(true);
        }
コード例 #11
0
        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_IsExecuted && curSectionTime > (StartTime + m_RemainTime))
            {
                return(false);
            }

            Vector3    pos    = obj.GetMovementStateInfo().GetPosition3D();
            EntityInfo target = senderObj.TargetGfxObj;

            if (!m_IsExecuted && (null == target || !string.IsNullOrEmpty(m_SelectTargetType)))
            {
                if (string.IsNullOrEmpty(m_SelectTargetType))
                {
                    int targetType = scene.EntityController.GetTargetType(senderObj.ActorId, senderObj.ConfigData, senderObj.Seq);
                    if (targetType == (int)SkillTargetType.Friend || targetType == (int)SkillTargetType.RandFriend)
                    {
                        m_RealSelectTargetType = "randfriend";
                    }
                    else
                    {
                        m_RealSelectTargetType = "randenemy";
                    }
                }
                TargetManager mgr = instance.CustomDatas.GetData <TargetManager>();
                if (null == mgr)
                {
                    mgr = new TargetManager();
                    instance.CustomDatas.AddData(mgr);
                }
                int targetId = scene.EntityController.SelectTargetForSkill(m_RealSelectTargetType, senderObj.ActorId, senderObj.ConfigData, senderObj.Seq, mgr.Targets);
                if (targetId > 0)
                {
                    mgr.Add(targetId);
                    target = scene.EntityController.GetGameObject(targetId);
                    senderObj.TargetActorId = targetId;
                    senderObj.TargetGfxObj  = target;
                }
            }
            if (null != target)
            {
                m_IsExecuted = true;
                if (!m_IsHaveRotateSpeed || m_RotateSpeed.Y == 0)
                {
                    TriggerUtil.Lookat(scene, obj, target.GetMovementStateInfo().GetPosition3D());
                }
                else
                {
                    float maxRotateDelta = m_RotateSpeed.Y * TriggerUtil.ConvertToSecond(delta);
                    TriggerUtil.Lookat(scene, obj, target.GetMovementStateInfo().GetPosition3D(), maxRotateDelta);
                }
            }
            return(true);
        }