예제 #1
0
 void ClearSpawnedAreas()
 {
     //enemies does not despawn with grids
     if (spawnedGridParent != null)
     {
         Destroy(spawnedGridParent.gameObject);
         spawnedGridParent = null;
     }
 }
예제 #2
0
        void SpawnNextWave()
        {
            ClearSpawnedAreas();

            waveIndex++;

            if (waveIndex >= waveStatsHolders.Length)
            {
                //game over
                OnAllWavesFinished?.Invoke();
                return;
            }

            //get scriptable with grids definition
            WaveHolder waveStats = waveStatsHolders[waveIndex];

            //GridParent->GridArea[]
            var gridsCount = waveStats.GridParent.Grids.Length;

            //spawn grid parent with all grids inside
            spawnedGridParent = Instantiate(waveStats.GridParent) as GridParent;

            //now iterate through all grids
            for (int i = 0; i < gridsCount; i++)
            {
                GridArea area = spawnedGridParent.Grids[i];

                if (waveStats.AutoPositionRows)
                {
                    area.transform.position = playableArea.TopGridSpawnPosition - Vector3.up * i * gridsYOffset;
                }

                area.Initialize();
            }

            currentWave = new Wave(spawnedGridParent, waveStats);

            OnWaveTriggered?.Invoke(currentWave);
        }
예제 #3
0
 public Wave(GridParent spawnedGridParent, WaveHolder waveSettings)
 {
     this.gridParent   = spawnedGridParent;
     this.waveSettings = waveSettings;
 }