/// <summary> /// 连接房子 /// </summary> private void TunnelRooms() { if (m_roomList.Count == 0) { return; } m_starGrid.Init(m_size.x, m_size.y); //读取所有房子的站位数据到寻路地图中 foreach (var room in m_roomList) { for (int c = 0; c < room.NumCols; c++) { for (int r = 0; r < room.NumRows; r++) { var pos = room.GetTilePosition(c, r); m_starGrid.SetWalkable(pos, false); } } } for (int i = 0; i < m_roomList.Count - 1; i++) { if (Random.value > 0.5) { continue; } TunnelTwoRoom(m_roomList[i], m_roomList[i + 1]); } }
private void CopyWalkableData(int range, CStarGrid grid, Vector2Int center) { int startCol = center.x - range; int startRow = center.y - range; for (int c = 0; c < m_grid.NumCols; c++) { for (int r = 0; r < m_grid.NumRows; r++) { bool w = grid.IsWalkable(startCol + c, startRow + r); m_grid.SetWalkable(c, r, w); } } }