Esempio n. 1
0
    private void GenerateRoom()
    {
        // Immediately get next rnd numOfRooms but use current(max) roomWidth & roomHeight to calculate radius.
        numOfRooms.NextOdd();
        float radius = Mathf.Sqrt(numOfRooms.Current) * (roomWidth.Current + roomHeight.Current) / 6;

        for (int i = 0; i < numOfRooms.Current; i++)
        {
            // Populate dungeon room array
            //Vector2 roomCenter = MathUtils.GetRandomPointInCircle(radius);
            //Vector2 roomCenter = MathUtils.GetRandomPointInRect(radius * 1.2f, radius);
            Vector2 roomCenter = MathUtils.GetRandomPointInEclipse(radius, 2f, 1f);

            initialRoomList.Add(new DungeonRoomData
            {
                id     = i,
                center = roomCenter,
                width  = roomWidth.NextOdd(),
                height = roomHeight.NextOdd()
            });
        }
    }