Example #1
0
        private void PopulatePool()
        {
            SpawnableBase newLazer = lazerFactory.GetItem();

            newLazer.SetPool(lazerPool);
            newLazer.transform.SetParent(playerView.ShootPos);
            newLazer.gameObject.SetActive(false);
            lazerPool.SetInstance(newLazer);
        }
Example #2
0
        private IEnumerator Spawn()
        {
            while (true)
            {
                if (currentPool.IsPoolEmpty() == true)
                {
                    PopulatePool();
                }

                if (CanSpawn)
                {
                    SpawnableBase currAsteroid = currentPool.GetInctance();
                    currAsteroid.SetPool(currentPool);
                    currAsteroid.transform.position = levelView.SpawnPos[Random.Range(0, levelView.SpawnPos.Count)].position;
                    currAsteroid.gameObject.SetActive(true);
                }

                yield return(new WaitForSecondsRealtime(currentLevel.LevelData.spawnRate));
            }
        }