Пример #1
0
        public void ReturnTheProperValue_WhenGetBedsMethodIsCalled()
        {
            // Arrange & Act
            var regularRoom = new RegularRoom(1, 2, false, "Sea", 222, 5);

            // Assert
            Assert.AreEqual(2, regularRoom.Beds);
        }
        public void ThrowsArgumentException_WhenInvalidValueIsPassed(int capacity)
        {
            // Arrange
            var regularRoom = new RegularRoom(1, 2, false, "Sea", 222, 5);

            // Act & Assert
            Assert.ThrowsException <ArgumentException>(() => regularRoom.Capacity = capacity);
        }
Пример #3
0
        public void SetProperOnFloor_WhenInvalidValueIsPassed(int floor)
        {
            // Arrange
            var regularRoom = new RegularRoom(1, 2, false, "Sea", 222, 5);

            // Act & Assert
            Assert.ThrowsException <ArgumentException>(() => regularRoom.OnFloor = floor);
        }
        public void SetProperOnFloor_WhenTheObjectIsConstructed()
        {
            // Arrange
            var regularRoom = new RegularRoom(1, 2, false, "Sea", 222, 5);

            // Assert
            Assert.AreEqual(5, regularRoom.OnFloor);
        }
Пример #5
0
        private void Paint()
        {
            level.MarkForClearing();
            level.Fill(Tile.WallA);

            var room = new RegularRoom();

            if (fixedSize)
            {
                room.Resize(Math.Min(level.Width, roomWidth) + 1, Math.Min(level.Height, roomHeight) + 1);
            }
            else
            {
                room.SetSizeWithLimit(level.Width, level.Height);
            }

            room.SetPos((int)Math.Floor((level.Width - room.GetWidth()) / 2f), (int)Math.Floor((level.Height - room.GetHeight()) / 2f));

            if (currentFloor == 0)
            {
                room.PaintFloor(level);
            }
            else if (currentFloor > 1)
            {
                FloorRegistry.Paint(level, room, currentFloor - 2);
            }

            if (currentWall == 0)
            {
                room.Paint(level);
            }
            else if (currentWall > 1)
            {
                WallRegistry.Paint(level, room, null, currentWall - 2);
            }

            level.TileUp();
        }
Пример #6
0
    private RegularRoom createRandomRegularRoom(List<ConcreteRoom> createdRooms, List<Vector2> candidateNeighbors, List<Vector2> lastInsertedNeighbors , float linearFactor, Dungeon dungeon)
    {
        Vector2 pivot = getRandomNeighbor(candidateNeighbors, lastInsertedNeighbors, linearFactor);
        RegularRoom auxRoom = new RegularRoom((int)pivot.x, (int)pivot.y, dungeon.width, dungeon.height);

        //don't allow duplicate room creation
        while(createdRooms.IndexOf(auxRoom) >= 0)
        {
            pivot = getRandomNeighbor(candidateNeighbors, lastInsertedNeighbors, linearFactor);
            auxRoom = new RegularRoom((int)pivot.x, (int)pivot.y, dungeon.width, dungeon.height);
        }

        return auxRoom;
    }