Exemple #1
0
    //creates the grid once a button is pressed
    public void CreateGrid()
    {
        //if a grid already exists
        if (currentGrid != null)
        {
            //destroy the current map
            Destroy(currentGrid);
        }
        //if the controls UI hasnt been turned off
        if (ControlsOpen == true)
        {
            //set the controls UI to be active
            ControlsUI.gameObject.SetActive(true);
            //if the by step option has been selected
            if (byStepToggle.isOn)
            {
                //set the step counter UI to active
                StepCounter.SetActive(true);
            }
            else
            {
                //deactivate the step counter UI
                StepCounter.SetActive(false);
            }
        }
        //disactivate the map options UI
        SliderUI.gameObject.SetActive(false);
        //create the game object responsible for creating the grid in the world
        currentGrid = Instantiate(Grid, transform.position, Quaternion.identity);
        //retreive the grids Generating island component
        GeneratingIsland gridCreation = currentGrid.GetComponent <GeneratingIsland>();

        //set the grids generation values
        gridCreation.SetValues((int)cellularPasses.value, (int)landChance.value, (int)MountainAgentsSlider.value, (int)ActionsSlider.value, byStepToggle.isOn, StepCounterText, StepTaskText);
        //create the map using the set values
        gridCreation.MapCreation();
    }