Esempio n. 1
0
    public MapState Apply(ApplicableOperator op)
    {
        this.applicableConnections.Remove(op);
        RoomDoor roomDoor  = op.sourceRoomDoor;
        RoomDoor otherRoom = op.connectionRoomDoor;

        openDoors.Remove(roomDoor);
        lastDoor = roomDoor;
        otherRoom.room.roomId = rooms.Count;
        MapState newState = new MapState();

        foreach (Room room in rooms)
        {
            if (room.roomId == roomDoor.room.roomId)
            {
                Room clonedRoom = roomDoor.room.clone();
                Door clonedDoor = clonedRoom.GetDoor(roomDoor.door.doorId);
                Room.ConnectDoors(clonedRoom, clonedDoor, otherRoom.room, otherRoom.door);
                newState.AddRoom(clonedRoom);
            }
            else
            {
                newState.AddRoom(room.clone());
            }
        }
        newState.AddRoom(otherRoom.room);
        return(newState);
    }
Esempio n. 2
0
    public MapState clone()
    {
        MapState state = new MapState();

        foreach (Room room in rooms)
        {
            state.AddRoom(room.clone());
        }
        return(state);
    }