Example #1
0
    /// <summary>
    /// Initialise the worldGeneratorScript object.
    /// Get the number of rooms and algorithm iterations integeres from the script and set the values for the input fields.
    /// </summary>
    void Awake()
    {
        dungeonGenerator = GameObject.FindGameObjectWithTag("DungeonGenerator");
        if (dungeonGenerator != null)
        {
            if (dungeonGenerator.GetComponent <RoomBasedGenerator>() != null && dungeonGenerator.GetComponent <RoomBasedGenerator>().enabled)
            {
                worldGeneratorScript = dungeonGenerator.GetComponent <RoomBasedGenerator>();
            }
            else
            {
                noDungeonGenerator = true;
            }
        }
        else
        {
            noDungeonGenerator = true;
        }

        if (!noDungeonGenerator)
        {
            numOfRoomsInputField.text           = worldGeneratorScript.GetNumberOfRooms().ToString();
            expansionRoomsNumberInputField.text = worldGeneratorScript.GetNumberOfExpansionRooms().ToString();
            seedInputField.text = worldGeneratorScript.GetSeed().ToString();
            allowLoops.isOn     = worldGeneratorScript.GetAllowLoops();
            allowLoops.enabled  = true;
        }
        else
        {
            numOfRoomsInputField.text           = "0";
            expansionRoomsNumberInputField.text = "0";
            seedInputField.text = "0";
        }
        DisableInput();
    }
Example #2
0
    /// <summary>
    /// Sets a random value for the parameters in the script, after which it updates the parameters in the UI.
    /// Level reset function is called after the parameters are updated.
    /// </summary>
    public void RandomizeParameters()
    {
        RandomItem random = new RandomItem();

        worldGeneratorScript.SetNumberOfExpansionRooms(random.GetSystemRandom(5, 15));
        worldGeneratorScript.SetNumberOfRooms(random.GetSystemRandom(5, 15));
        int newSeed = random.GetSystemRandom(1, 9999);

        while (worldGeneratorScript.GetSeed() == newSeed)
        {
            newSeed = random.GetSystemRandom(1, 9999);
        }
        worldGeneratorScript.SetSeed(newSeed);
        worldGeneratorScript.ResetLevel();
    }