Example #1
0
        private async UniTask TryToSpawnAsteroidSplit(AsteroidComponent asteroid)
        {
            var splitData = _asteroidAssetSource.GetAsteroidSplitData(asteroid.AsteroidData.AsteroidID);

            if (splitData != null)
            {
                Vector2 spawnPos = asteroid.transform.position;

                int count = splitData.SplitCountData.Length;
                for (int i = 0; i < count; i++)
                {
                    int spawnCount   = Random.Range(splitData.SplitCountData[i].MinCount, splitData.SplitCountData[i].MaxCount + 1);
                    var asteroidData = _asteroidAssetSource.GetAsteroidData(splitData.SplitCountData[i].AsteroidID);

                    Vector2 baseDirection = new Vector2(Random.Range(0.1f, 1f), Random.Range(0.1f, 1f));

                    for (int j = 0; j < spawnCount; j++)
                    {
                        float   randomRotate  = Random.Range(360 * j / spawnCount, 360 * (j + 1) / spawnCount);
                        Vector2 moveDirection = (Quaternion.Euler(0, 0, randomRotate) * baseDirection);
                        await _asteroidSpawnerSystem.SpawnAsteroid(asteroidData, moveDirection, spawnPos);
                    }
                }
            }
        }
Example #2
0
        private void SpawnWave()
        {
            _bookKeepingInGameData.AsteroidCount.Value = 0;

            var currentStageWave = _asteroidAssetSource.GetStageWaveData(_bookKeepingInGameData.CurrentStage.Value);

            if (currentStageWave == null)
            {
                throw new System.NullReferenceException($"Stage Wave Data null on stage {_bookKeepingInGameData.CurrentStage.Value}");
            }

            int asteroidTypeCount = currentStageWave.SpawnAsteroidDataList.Count;

            for (int i = 0; i < asteroidTypeCount; i++)
            {
                int          spawnCount   = Random.Range(currentStageWave.SpawnAsteroidDataList[i].MinSpawnCount, currentStageWave.SpawnAsteroidDataList[i].MaxSpawnCount + 1);
                AsteroidData asteroidData = _asteroidAssetSource.GetAsteroidData(currentStageWave.SpawnAsteroidDataList[i].AsteroidID);
                for (int j = 0; j < spawnCount; j++)
                {
                    _asteroidSpawnerSystem.SpawnAsteroidAtOutOfScreenPosition(asteroidData);
                }
            }
        }