示例#1
0
 private void ReverseSyncObjects()
 {
     if (syncReversesObjects != null)
     {
         for (int i = 0, len = syncReversesObjects.Length; i < len; i++)
         {
             TwoPointsMotion syncObj = syncReversesObjects[i];
             if (syncObj)
             {
                 syncObj.SetReverseGotoTarget();
             }
         }
     }
 }
示例#2
0
    private void Start()
    {
        //把自身添加到所有同步反转的对象的同步列表
        for (int i = 0, len = syncReversesObjects.Length; i < len; i++)
        {
            TwoPointsMotion syncObj = syncReversesObjects[i];
            if (syncObj)
            {
                AddSelfToSyncReversesObject(syncObj);
            }
        }

        //记录起始点
        if (startTransform)
        {
            m_positionRecord = startTransform.position;
        }
        else
        {
            m_positionRecord = transform.position;
        }

        //记录目标点
        m_targetRecord = targetTransform.position;

        //设置首次运动的目标
        if (isFirstToTarget)
        {
            m_currentGotoTarget = m_targetRecord;
        }
        else
        {
            m_currentGotoTarget = m_positionRecord;
        }

        //记录初始位置
        m_lastPosition = transform.position;
    }
示例#3
0
    /// <summary>
    /// 添加自己到同步反转的对象
    /// </summary>
    /// <param name="syncObj"></param>
    private void AddSelfToSyncReversesObject(TwoPointsMotion syncObj)
    {
        bool isOtherListNull = syncObj.syncReversesObjects == null;

        if (isOtherListNull || System.Array.IndexOf(syncObj.syncReversesObjects, this) < 0)
        {
            if (isOtherListNull)
            {
                syncObj.syncReversesObjects = new TwoPointsMotion[] { this };
            }
            else
            {
                int len = syncObj.syncReversesObjects.Length;

                TwoPointsMotion[] list = new TwoPointsMotion[len + 1];
                System.Array.Copy(syncObj.syncReversesObjects, list, len);

                list[len] = this;

                syncObj.syncReversesObjects = list;
            }
        }
    }