private void ReshapeRooms()
    {
        for (int i = 0; i < _roomList.Count; i++)
        {
            if (_roomList[i].GetCellsList().Count < minRoomSize)
            {
                Room removedRoom = _roomList[i];
                _roomList.Remove(removedRoom);
                if (removedRoom.GetNeighbor().Count > 0)
                {
                    int  index      = Random.Range(0, removedRoom.GetNeighbor().Count - 1);
                    Room mergedRoom = removedRoom.GetNeighbor()[index];
                    mergedRoom.RemoveNeighbor(removedRoom);
                    foreach (Cell cell in removedRoom.GetCellsList())
                    {
                        mergedRoom.AddCell(cell);
                        cell.ReshapeCell(mergedRoom);
                    }
                }
            }
        }

        foreach (Room room in _roomList)
        {
            room.ResetNeighbor();
        }
        FindRoomNeighbor();
    }
    private void AddNewRoom(Cell cell)
    {
        Room room = new Room();

        _roomList.Add(room);
        cell.Room = room;
        room.AddCell(cell);
        _actualRoomCellsStack.Push(cell);
    }
Beispiel #3
0
    void Next(LogicCell curCell)
    {
        curRoom.AddCell(curCell, LCache, M.House.GetCell(curCell.Position));
        processed.Add(curCell);


        M.House.ForEachWall(curCell.Position, (WallPoint wp, WallController wc, Corner corn) => {
            if (wc == null)
            {
                return;
            }
            if (wc.WallObject is DoorController)
            {
                Door door = null;
                if (!Doors.TryGetValue(wp.toInt(), out door))
                {
                    door = new Door(wp);
                    Doors.Add(wp.toInt(), door);
                }

                door.AddRoom(curRoom);
                curRoom.AddDoor(door);
            }
            else if (wc.WallObject is EntranceController)
            {
                curRoom.Entrance = true;
            }
            else if (wc.WallObject is GarageGateController)
            {
                curRoom.GarageGate = true;
            }
            else if (wc.WallObject is WindowController)
            {
                WindowController window = wc.WallObject as WindowController;
                curRoom.NorthWindows   |= window.North;
                curRoom.SouthWindows   |= window.South;
                curRoom.EastWindows    |= window.East;
                curRoom.WestWindows    |= window.West;
            }
        });

        foreach (LogicCell nc in curCell.ReachableCells)
        {
            if (!processed.Contains(nc))
            {
                Next(nc);
            }
        }
    }