Пример #1
0
    void OnSwipe(SwipeGesture gesture)
    {
        searchType = SearchPathType.SwipeToWalk;
        swipeIndexList.Clear();
        swipeIndexListRaw.Clear();

        foreach (Vector2 item in gesture.VectorsInProgress)
        {
            Vector3 bgPos = CameraHelper.ScreenPosToBackgroundPos(item);
            int     index = m_pathGrid.GetCellIndexClamped(bgPos);
            if (m_pathGrid.IsBlocked(index))
            {
                continue;
            }

            if (swipeIndexListRaw.Count == 0)
            {
                swipeIndexListRaw.Add(index);
                continue;
            }

            if (swipeIndexListRaw[swipeIndexListRaw.Count - 1] != index)
            {
                swipeIndexListRaw.Add(index);
            }
        }

        swipeIndexList = m_pathGrid.CornerIndexs(swipeIndexListRaw);

        swipeIndexListIndex = 0;
        m_navigationAgent.MoveToIndex(swipeIndexList.ToArray());
    }
    void OnDrawGizmos()
    {
        Gizmos.color = m_obstructedCellColor;

        if (m_show && m_pathGrid != null)
        {
            for (int i = 0; i < m_pathGrid.NumberOfCells; i++)
            {
                if (m_pathGrid.IsBlocked(i))
                {
                    Vector3 cellPos   = m_pathGrid.GetCellCenter(i);
                    Vector3 cellSize3 = new Vector3(m_pathGrid.CellSize, 0.5f, m_pathGrid.CellSize);
                    Gizmos.DrawCube(cellPos, cellSize3);
                }
            }
        }
    }
Пример #3
0
    public static List <Vector3> PositionsByDirection(int gridIndex, int length, PathGrid.eNeighborDirection dirction, PathGrid grid)
    {
        //	UnityEngine.Debug.Log("Origin PosIndex:" + gridIndex);
        List <Vector3> Positions = new List <Vector3>();

        for (int i = 0; i < length; i++)
        {
            gridIndex = grid.GetNeighbor(gridIndex, dirction);
            if (grid.IsBlocked(gridIndex))
            {
                return(Positions);
            }
            Positions.Add(grid.GetPathNodePos(gridIndex));
            //	UnityEngine.Debug.Log("Search PosIndex:" + gridIndex);
        }
        return(Positions);
    }