예제 #1
0
 public bool FindPath(int startNodeX, int startNodeZ, int endNodeX, int endNodeZ)
 {
     ++nowversion;
     m_startNode   = m_grid.GetNode(startNodeX, startNodeZ);
     m_endNode     = m_grid.GetNode(endNodeX, endNodeZ);
     m_startNode.g = 0;
     m_open.Clear();
     return(Search());
 }
예제 #2
0
        public PathGrid Clone()
        {
            PathGrid gird = new PathGrid(this.m_gridX, this.m_gridZ);

            for (int i = 0; i < m_gridX; ++i)
            {
                for (int j = 0; j < m_gridZ; ++j)
                {
                    gird.GetNode(i, j).walkable = this.GetNode(i, j).walkable;
                }
            }
            return(gird);
        }
예제 #3
0
        public virtual bool GetWalkable(PathGrid grid)
        {
            bool flag = false;

            foreach (Vector3 v in m_spanPosArray)
            {
                int nodeX = Mathf.FloorToInt(v.x / world.cellSize);
                int nodeY = Mathf.FloorToInt(v.z / world.cellSize);
                if (nodeX < 0 || nodeX > grid.gridX - 1)
                {
                    return(false);
                }
                if (nodeY < 0 || nodeY > grid.gridZ - 1)
                {
                    return(false);
                }
                flag = grid.GetNode(nodeX, nodeY).walkable;
                if (!flag)
                {
                    return(false);
                }
            }
            return(true);
        }