Example #1
0
        private Scenary RandomizeGreenScenary(float value, int row, int col)
        {
            float newBush = (value / 5) * 2;
            float newTree = (value / 5) * 4;
            float newRock = value;
            float rand    = Random.value;

            Vector3 spawnPos = gameZone.GetWorldPosition(row, col);

            spawnPos.y = GameZone.GetGroundLevel(row, col);

            if (rand <= newBush)
            {
                Instantiate(GetRandomBush(), spawnPos, RandomQuaternion());
                return(Scenary.Bush);
            }
            else if (rand <= newTree)
            {
                Instantiate(GetRandomTree(), spawnPos, RandomQuaternion());
                return(Scenary.Tree);
            }
            else if (rand <= newRock)
            {
                Instantiate(GetRandomRock(), spawnPos, RandomQuaternion());
                return(Scenary.Rock);
            }

            return(Scenary.Empty);
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            GameZone gameZone = (GameZone)target;

            DrawDefaultInspector();

            gameZone.WaterThresholdIndex = EditorGUILayout.Popup("Water threshold", gameZone.WaterThresholdIndex, gameZone.GetRegionNames());
            EditorGUILayout.LabelField("Noise Map Seed", EditorStyles.boldLabel);
            gameZone.RandomNoiseSeed = EditorGUILayout.Toggle("Random Seed", gameZone.RandomNoiseSeed);

            using (new EditorGUI.DisabledScope(gameZone.RandomNoiseSeed))
            {
                gameZone.NoiseSeed = EditorGUILayout.IntField("Seed", gameZone.NoiseSeed);
            }

            if (GUI.changed)
            {
                // To update the variables after changing in the GUI.
                EditorUtility.SetDirty(gameZone);
                EditorSceneManager.MarkSceneDirty(gameZone.gameObject.scene);
            }
        }