Example #1
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);
            }
        }
Example #2
0
        private 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);
            }
        }
 public CellMapViewWithMapData(CellManager cellMgr, int radius)
 {
     m_Radius             = radius;
     m_CellMgr            = cellMgr;
     m_CellNumPerCellView = 2 * radius - 1;
     m_MaxRowCount        = m_CellMgr.GetMaxRow() / m_CellNumPerCellView;
     m_MaxColCount        = m_CellMgr.GetMaxCol() / m_CellNumPerCellView;
     m_RadiusLength       = (2 * m_Radius - 1) * m_CellMgr.GetCellWidth() / 2;
     m_CellAttrs          = new byte[m_MaxRowCount, m_MaxColCount];
     InitCellAttr();
 }
Example #4
0
        private void MarkLevelLine(List <Vector3> pts, CellManager cellMgr, byte level)
        {
            List <CellPos> pos_list = cellMgr.GetCellsCrossByPolyline(pts);

            foreach (CellPos pos in pos_list)
            {
                byte status         = cellMgr.GetCellStatus(pos.row, pos.col);
                byte typeAndSubType = BlockType.GetBlockTypeWithoutLevel(status);
                cellMgr.SetCellStatus(pos.row, pos.col, (byte)(typeAndSubType | level));
            }
        }
Example #5
0
        private void MarkLevelArea(List <Vector3> pts, CellManager cellMgr, byte level)
        {
            List <CellPos> cells = cellMgr.GetCellsInPolygon(pts);

            foreach (CellPos cell in cells)
            {
                byte status         = cellMgr.GetCellStatus(cell.row, cell.col);
                byte typeAndSubType = BlockType.GetBlockTypeWithoutLevel(status);
                cellMgr.SetCellStatus(cell.row, cell.col, (byte)(typeAndSubType | level));
            }
        }
Example #6
0
 public CellMapView(CellManager cellMgr, int radius)
 {
     m_Radius             = radius;
     m_CellNumPerCellView = 2 * radius - 1;
     m_CellMgr            = cellMgr;
     m_MaxRowCount        = m_CellMgr.GetMaxRow() / m_CellNumPerCellView;
     m_MaxColCount        = m_CellMgr.GetMaxCol() / m_CellNumPerCellView;
     m_RadiusLength       = (2 * m_Radius - 1) * m_CellMgr.GetCellWidth() / 2;
     if (radius > 1)
     {
         m_Delegation = new CellMapViewWithMapData(cellMgr, radius);
     }
 }
Example #7
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, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_OBSTACLE | BlockType.LEVEL_GROUND));
                }
            }
            //打开可行走区
            foreach (TiledData data in walk_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleArea(pts, cellMgr, (byte)(BlockType.NOT_BLOCK | BlockType.LEVEL_GROUND));
            }
            //标记阻挡区
            foreach (TiledData data in obstacle_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleArea(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_OBSTACLE | BlockType.LEVEL_GROUND));
            }
            //标记阻挡线
            foreach (TiledData data in obstacle_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleLine(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_OBSTACLE | BlockType.LEVEL_GROUND));
            }
            //标记防弹区
            foreach (TiledData data in shotproof_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleArea(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_SHOTPROOF | BlockType.LEVEL_GROUND));
            }
            //标记防弹线
            foreach (TiledData data in shotproof_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleLine(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_SHOTPROOF | BlockType.LEVEL_GROUND));
            }
            //标记路障区
            foreach (TiledData data in roadblock_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleArea(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_ROADBLOCK | BlockType.LEVEL_GROUND));
            }
            //标记路障线
            foreach (TiledData data in roadblock_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleLine(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_ROADBLOCK | BlockType.LEVEL_GROUND));
            }
            //标记能量墙阻挡区
            foreach (TiledData data in energywall_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleArea(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_ENERGYWALL | BlockType.LEVEL_GROUND));
            }
            //标记能量墙阻挡线
            foreach (TiledData data in energywall_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkObstacleLine(pts, cellMgr, (byte)(BlockType.STATIC_BLOCK | BlockType.SUBTYPE_ENERGYWALL | BlockType.LEVEL_GROUND));
            }

            //标记视野阻挡区
            foreach (TiledData data in blinding_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkBlindingArea(pts, cellMgr, BlockType.BLINDING_BLINDING);
            }
            //标记视野阻挡线
            foreach (TiledData data in blinding_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkBlindingLine(pts, cellMgr, BlockType.BLINDING_BLINDING);
            }

            //标记地下二层
            foreach (TiledData data in underfloor2_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_UNDERFLOOR_2);
            }
            foreach (TiledData data in underfloor2_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_UNDERFLOOR_2);
            }
            //标记地下一层
            foreach (TiledData data in underfloor1_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_UNDERFLOOR_1);
            }
            foreach (TiledData data in underfloor1_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_UNDERFLOOR_1);
            }
            //标记二楼
            foreach (TiledData data in floor1_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_FLOOR_1);
            }
            foreach (TiledData data in floor1_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_FLOOR_1);
            }
            //标记三楼
            foreach (TiledData data in floor2_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_FLOOR_2);
            }
            foreach (TiledData data in floor2_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_FLOOR_2);
            }
            //标记四楼
            foreach (TiledData data in floor3_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_FLOOR_3);
            }
            foreach (TiledData data in floor3_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_FLOOR_3);
            }
            //标记五楼
            foreach (TiledData data in floor4_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_FLOOR_4);
            }
            foreach (TiledData data in floor4_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_FLOOR_4);
            }
            //标记六楼
            foreach (TiledData data in blindage_area_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelArea(pts, cellMgr, BlockType.LEVEL_FLOOR_BLINDAGE);
            }
            foreach (TiledData data in blindage_line_list_)
            {
                List <Vector3> pts = data.GetPoints();
                MarkLevelLine(pts, cellMgr, BlockType.LEVEL_FLOOR_BLINDAGE);
            }
        }