Example #1
0
 void Initiate(Room originRoom)
 {
     originRoom.OpenAllEntrances(); originRoom.Initialize(originRoom.transform.position);
     //SpawnRooms(Random.Range((int)m_data.GetRoomAmountCap().x + rooms.Count, (int)m_data.GetRoomAmountCap().y + rooms.Count));
     SpawnRooms(Random.Range(5, 15));
     //AdjustEntrances();
     builder.Build(rooms);
 }
Example #2
0
        public void ReturnTheCorrectTimeslotUnavailableValuesIfIfNAreSupplied()
        {
            var expected = new List <int>();
            var target   = new RoomBuilder();

            var count = 25.GetRandom(10);

            for (int i = 0; i < count; i++)
            {
                int expectedTimeslot = Int32.MaxValue.GetRandom();
                expected.Add(expectedTimeslot);
                target.AddTimeslotUnavailable(expectedTimeslot);
            }

            var actualRoom = target.Build(Int32.MaxValue.GetRandom());

            Assert.True(expected.HasSameValues(actualRoom.UnavailableForTimeslots));
        }
Example #3
0
        public void ReturnATimeslotsUnavailableCollectionWithNValuesIfNAreSupplied()
        {
            var expected = new List <int>();
            var target   = new RoomBuilder();

            var count = 25.GetRandom(10);

            for (int i = 0; i < count; i++)
            {
                int expectedTimeslot = Int32.MaxValue.GetRandom();
                expected.Add(expectedTimeslot);
                target.AddTimeslotUnavailable(expectedTimeslot);
            }

            var actualRoom = target.Build(Int32.MaxValue.GetRandom());

            Assert.Equal(count, actualRoom.UnavailableForTimeslots.Count());
        }
    public void GenerateLevel(LevelManager level, int currentFloor, Vector2 RoomSize)
    {
        System.DateTime before = System.DateTime.Now;

        rooms.Add(Instantiate(RoomPrefab, Vector3.zero, Quaternion.identity, transform));
        rooms[0].Initialize(RoomSize);

        SpawnRooms(UnityEngine.Random.Range((int)(MinMaxAmountOfRooms.x + currentFloor * floorSizeMultiplier),
                                            (int)(MinMaxAmountOfRooms.y + currentFloor * floorSizeMultiplier)), RoomSize);

        level.firstRoom = rooms[0];
        level.lastRoom  = rooms[rooms.Count - 1];

        LockDoors(rooms[rooms.Count - 1], RoomSize);
        builder.Build(rooms, level, RoomSize);

        System.DateTime after    = System.DateTime.Now;
        System.TimeSpan duration = after.Subtract(before);
        Debug.Log("Time to generate: " + duration.TotalMilliseconds + " milliseconds, which is: " + duration.TotalSeconds + " seconds");
    }