Exemple #1
0
        private IEnumerator LoadLevel()
        {
            var asyncOperation = SceneManager.LoadSceneAsync(LevelScene, LoadSceneMode.Additive);

            while (!asyncOperation.isDone)
            {
                yield return(new WaitForEndOfFrame());
            }

            var scene           = SceneManager.GetSceneByName(LevelScene);
            var rootGameObjects = scene.GetRootGameObjects();

            _level          = rootGameObjects.SelectMany(root => root.GetComponentsInChildren <Level>()).First();
            LevelBoundaries = _level.GetLevelBounds();
            var anthills = rootGameObjects.SelectMany(root => root.GetComponentsInChildren <Anthill>()).ToList();

            StartCoroutine(SpawnSugarRoutine());
            StartCoroutine(SpawnApplesRoutine());
            StartCoroutine(SpawnBugsRoutine());

            foreach (var anthill in anthills)
            {
                SpawnAnts(anthill);
            }
        }