Пример #1
0
 public void reset()
 {
     //m_id = 0;
     m_state = State.Unknown;
     m_nearestVert = null;
     m_distance = float.MaxValue;
     m_bNeighborValid = false;
     m_pStopPoint = null;
     m_vertsIdVec.Clear();
 }
Пример #2
0
 protected void buildPath(Vertex endVert)
 {
     Vertex vert = endVert;
     while (vert != null)
     {
         m_pathList.Insert(0, vert);
         vert = vert.m_nearestVert;
     }
     m_pathList.Insert(0, m_startVert);      // 把最初的顶点放进去
 }
Пример #3
0
        public void init(int xCount, int yCount, float gridWidth, float gridHeight)
        {
            m_xCount = xCount;
            m_yCount = yCount;
            m_gridWidth = gridWidth;
            m_gridHeight = gridHeight;

            m_vertsCount = m_xCount * m_yCount;

            int idx = 0;
            Vertex pVertex = null;

            for (idx = 0; idx < m_vertsCount; ++idx)
            {
                pVertex = new Vertex();
                m_vertsVec.Add(pVertex);
                pVertex.reset();
                pVertex.m_id = idx;
            }
        }
Пример #4
0
        protected bool isStraightBetweenVert(Vertex startVert, Vertex endVert)
        {
            int minX = int.MaxValue;
            int minY = int.MaxValue;
            int maxX = int.MinValue;
            int maxY = int.MinValue;

            int startX = 0;
            int startY = 0;
            int endX = 0;
            int endY = 0;

            int curId = 0;

            convVertIdToXY(startVert.m_id, ref startX, ref startY);
            convVertIdToXY(endVert.m_id, ref endX, ref endY);

            minX = Math.Min(startX, endX);
            minY = Math.Min(startY, endY);
            maxX = Math.Max(startX, endX);
            maxY = Math.Max(startY, endY);

            for (int yIdx = minY; yIdx <= maxY; ++yIdx)
            {
                for (int xIdx = minX; xIdx <= maxX; ++xIdx)
                {
                    curId = convXYToVertId(xIdx, yIdx);
                    if (m_vertsVec[curId].m_pStopPoint != null)
                    {
                        return false;
                    }
                }
            }

            return true;
        }