protected override void Load(CallData callData)
        {
            int sectionNum = 0;

            if (callData.GetParamNum() >= 2)
            {
                float startDistance = (float)System.Convert.ToDouble(callData.GetParamId(0));
                float startAngle    = (float)System.Convert.ToDouble(callData.GetParamId(1));

                m_StartPos = new Vector3(startDistance, 0, startAngle);
            }


            while (callData.GetParamNum() >= 5 * (sectionNum + 1) + 2)
            {
                MoveSectionInfo section = new MoveSectionInfo();
                section.moveTime    = (float)System.Convert.ToDouble(callData.GetParamId(sectionNum * 5 + 2));
                section.speedVect.x = (float)System.Convert.ToDouble(callData.GetParamId(sectionNum * 5 + 3));
                section.speedVect.z = (float)System.Convert.ToDouble(callData.GetParamId(sectionNum * 5 + 4));
                section.accelVect.x = (float)System.Convert.ToDouble(callData.GetParamId(sectionNum * 5 + 5));
                section.accelVect.z = (float)System.Convert.ToDouble(callData.GetParamId(sectionNum * 5 + 6));
                m_SectionList.Add(section);
                sectionNum++;
            }
        }
Beispiel #2
0
        protected override void Load(ScriptableData.CallData callData)
        {
            if (callData.GetParamNum() > 0)
            {
                // m_IsLockRotate = bool.Parse(callData.GetParamId(0));
            }
            m_SectionList.Clear();
            int section_num = 0;

            while (callData.GetParamNum() >= 7 * (section_num + 1) + 1)
            {
                MoveSectionInfo section = new MoveSectionInfo();
                section.moveTime    = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 1));
                section.speedVect.x = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 2));
                section.speedVect.y = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 3));
                section.speedVect.z = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 4));
                section.accelVect.x = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 5));
                section.accelVect.y = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 6));
                section.accelVect.z = (float)System.Convert.ToDouble(callData.GetParamId((section_num * 7) + 7));
                m_SectionList.Add(section);
                section_num++;
            }
            if (m_SectionList.Count == 0)
            {
                return;
            }
            m_IsCurveMoving = true;
        }
Beispiel #3
0
        public MoveSectionInfo Clone()
        {
            MoveSectionInfo copy = new MoveSectionInfo();

            copy.moveTime  = moveTime;
            copy.speedVect = speedVect;
            copy.accelVect = accelVect;
            return(copy);
        }
        public void Load(float startDistance, float startAngle, params float[] args)
        {
            m_StartPos = new Vector3(startDistance, 0, startAngle);

            for (int i = 0; i < args.Length; i += 5)
            {
                MoveSectionInfo section = new MoveSectionInfo();
                section.moveTime    = args[i];
                section.speedVect.x = args[i + 1];
                section.speedVect.z = args[i + 2];
                section.accelVect.x = args[i + 3];
                section.accelVect.z = args[i + 4];
                m_SectionList.Add(section);
            }
        }
Beispiel #5
0
        public void Load(int direction, params float[] args)
        {
            m_DirectionType = (DirectionType)direction;

            m_SectionList.Clear();
            for (int i = 0; i < args.Length; i += 7)
            {
                MoveSectionInfo section = new MoveSectionInfo();
                section.moveTime    = args[i];
                section.speedVect.x = args[i + 1];
                section.speedVect.y = args[i + 2];
                section.speedVect.z = args[i + 3];
                section.accelVect.x = args[i + 4];
                section.accelVect.y = args[i + 5];
                section.accelVect.z = args[i + 6];
                m_SectionList.Add(section);
            }
            m_IsCurveMoving = true;
        }
Beispiel #6
0
        protected override ExecResult ExecCommand(IInstance instance, long delta)
        {
            GameEntity target = instance.Target as GameEntity;

            if (target == null)
            {
                return(ExecResult.Finished);
            }
            GameEntity sender = Contexts.sharedInstance.game.GetEntityWithId(instance.SenderId);

            if (sender == null)
            {
                return(ExecResult.Finished);
            }
            if (!m_IsCurveMoving)
            {
                instance.Velocity = Vector3.zero;
                return(ExecResult.Finished);
            }
            if (!m_IsInited)
            {
                Init(sender, target, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving   = false;
                instance.Velocity = Vector3.zero;
                return(ExecResult.Finished);
            }

            if (m_AlwaysUpdateDirection)
            {
                m_RotateDir = UpdateRotation(instance, sender, target, m_DirectionType);
            }


            m_ElapsedTime += delta;
            float           realTime    = m_ElapsedTime / 1000.0f;
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (realTime - 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(instance, target, m_RotateDir, 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(instance, target, m_RotateDir, cur_section.curSpeedVect, cur_section.accelVect, realTime - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = realTime;
            }
            return(ExecResult.Parallel);
        }