Exemple #1
0
    public void StartCurveMove(string str_param)
    {
        string[] param_list = str_param.Split(' ');
        m_SectionList.Clear();
        int section_num = 0;

        while (param_list.Length >= 7 * (section_num + 1))
        {
            MoveSectionInfo section = new MoveSectionInfo();
            section.moveTime    = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 0]);
            section.speedVect.x = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 1]);
            section.speedVect.y = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 2]);
            section.speedVect.z = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 3]);
            section.accelVect.x = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 4]);
            section.accelVect.y = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 5]);
            section.accelVect.z = (float)System.Convert.ToDouble(param_list[(section_num * 7) + 6]);
            m_SectionList.Add(section);
            section_num++;
        }
        if (m_SectionList.Count == 0)
        {
            return;
        }
        CalNewSpeedWithTarget();
        m_SectionList[0].startTime      = Time.time;
        m_SectionList[0].lastUpdateTime = Time.time;
        m_SectionList[0].curSpeedVect   = m_SectionList[0].speedVect;
        m_IsCurveMoving = true;
    }
Exemple #2
0
    private void UpdateCurveMove()
    {
        if (!m_IsCurveMoving)
        {
            return;
        }

        if (m_SectionList.Count == 0)
        {
            StopCurveMove();
            return;
        }

        float           now         = Time.time;
        MoveSectionInfo cur_section = m_SectionList[0];

        if (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(cur_section.curSpeedVect, cur_section.accelVect, used_time);
            m_SectionList.RemoveAt(0);
            if (m_SectionList.Count > 0)
            {
                cur_section                = m_SectionList[0];
                cur_section.startTime      = end_time;
                cur_section.lastUpdateTime = end_time;
                cur_section.curSpeedVect   = cur_section.speedVect;
            }
            else
            {
                StopCurveMove();
            }
        }
        else
        {
            cur_section.curSpeedVect   = Move(cur_section.curSpeedVect, cur_section.accelVect, now - cur_section.lastUpdateTime);
            cur_section.lastUpdateTime = now;
        }
    }