Example #1
0
        public static bool GetPath(int frame, Vector3 startPos, Vector3 endPos, float speed, List <Vector3> pathList, List <Cell> cellList, List <int> frameList /*, ref int pathIndex*/)
        {
            Cell startCell = null;

            if (cellList.Count > 0)
            {
                startCell = m_Nav.GetCellInCellListByPos(startPos, cellList);
            }
            if (startCell == null)
            {
                startCell = m_Nav.FindCellByPos(startPos);
            }
            if (startCell == null)
            {
                startCell = FindCellOffset(startPos, 0.1f);
            }

            Cell endCell = m_Nav.FindCellByPos(endPos);

            if (startCell == null || endCell == null)
            {
                Debug.LogError(" find path cell is out range !  startcell = " + startCell + "  endCell = " + endCell);
                return(false);
            }

            List <Vector3> tempPathList = new List <Vector3>();

            TryGetPath(startCell, endCell, startPos, endPos, tempPathList, cellList);

            return(CalculatePath(tempPathList, endPos, frame, speed, pathList, frameList /*, ref pathIndex*/));
        }