예제 #1
0
 public void GenerateObstacleInfo(CellManager cellMgr)
 {
     //标记所有格子为阻挡
     for (int row = 0; row < cellMgr.GetMaxRow(); row++)
     {
         for (int col = 0; col < cellMgr.GetMaxCol(); col++)
         {
             cellMgr.SetCellStatus(row, col, BlockType.STATIC_BLOCK);
         }
     }
     //打开可行走区
     foreach (TiledData data in walk_area_list_)
     {
         List <Vector3> pts = data.GetPoints();
         MapDataUtil.MarkObstacleArea(pts, cellMgr, BlockType.NOT_BLOCK);
     }
     //标记阻挡区
     foreach (TiledData data in obstacle_area_list_)
     {
         List <Vector3> pts = data.GetPoints();
         MapDataUtil.MarkObstacleArea(pts, cellMgr, BlockType.STATIC_BLOCK);
     }
     //标记阻挡线
     foreach (TiledData data in obstacle_line_list_)
     {
         List <Vector3> pts = data.GetPoints();
         MarkObstacleLine(pts, cellMgr, BlockType.STATIC_BLOCK);
     }
 }
예제 #2
0
        internal static void MarkObstacleArea(List <Vector3> pts, CellManager cellMgr, byte obstacle)
        {
            List <CellPos> cells = cellMgr.GetCellsInPolygon(pts);

            foreach (CellPos cell in cells)
            {
                cellMgr.SetCellStatus(cell.row, cell.col, obstacle);
            }
        }
예제 #3
0
        private void MarkObstacleLine(List <Vector3> pts, CellManager cellMgr, byte obstacle)
        {
            List <CellPos> pos_list = cellMgr.GetCellsCrossByPolyline(pts);

            foreach (CellPos pos in pos_list)
            {
                cellMgr.SetCellStatus(pos.row, pos.col, obstacle);
            }
        }
예제 #4
0
 public void GenerateObstacleInfoWithNavmesh(CellManager cellMgr)
 {
     //标记所有格子为阻挡
     for (int row = 0; row < cellMgr.GetMaxRow(); row++)
     {
         for (int col = 0; col < cellMgr.GetMaxCol(); col++)
         {
             cellMgr.SetCellStatus(row, col, BlockType.STATIC_BLOCK);
         }
     }
     //打开可行走区
     foreach (TriangleNode node in navmesh_triangle_list)
     {
         List <Vector3> pts = new List <Vector3>(node.Points);
         MapDataUtil.MarkObstacleArea(pts, cellMgr, BlockType.NOT_BLOCK);
     }
 }