Exemple #1
0
 private void HandleAsteroidSpawned(AsteroidComponent asteroidComponent)
 {
     if (!_transformList.Contains(asteroidComponent.transform))
     {
         _transformList.Add(asteroidComponent.transform);
     }
 }
Exemple #2
0
 private void HandleAsteroidDespawned(AsteroidComponent asteroidComponent, GameEntityTag despawner)
 {
     if (_transformList.Contains(asteroidComponent.transform))
     {
         _transformList.Remove(asteroidComponent.transform);
     }
 }
        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);
                    }
                }
            }
        }
Exemple #4
0
        private void HandleAsteroidDespawned(AsteroidComponent asteroid, GameEntityTag gameEntityTag)
        {
            if (gameEntityTag != GameEntityTag.BULLET)
            {
                return;
            }
            if (!_canAddScore)
            {
                return;
            }

            int score = _asteroidScoreDataSource.GetScore(asteroid.AsteroidData.AsteroidID);

            _scoreSystem.AddScore(score);
        }
Exemple #5
0
        private void HandleAsteroidDespawned(AsteroidComponent asteroidComponent, GameEntityTag gameEntityTag)
        {
            _bookKeepingInGameData.AsteroidCount.Value--;

            if (_bookKeepingInGameData.AsteroidCount.Value < 0)
            {
                throw new System.ArgumentException("Asteroid count value cannot be negative");
            }

            if (_bookKeepingInGameData.AsteroidCount.Value == 0)
            {
                _bookKeepingInGameData.CurrentStage.Value++;
                SpawnWave();
            }
        }
Exemple #6
0
 private void DespawnAsteroid(AsteroidComponent asteroidComponent, GameEntityTag despawner)
 {
     _spawnedAsteroids.Remove(asteroidComponent);
     _gameSignals.AsteroidDespawnedSignal.Fire(asteroidComponent, despawner);
     _multiplePrefabMemoryPool.DespawnObject(asteroidComponent.gameObject);
 }
Exemple #7
0
 private void HandleAsteroidSpawned(AsteroidComponent asteroidComponent)
 {
     _bookKeepingInGameData.AsteroidCount.Value++;
 }
 private async void HandleAsteroidDespawned(AsteroidComponent asteroid, GameEntityTag despawner)
 {
     await TryToSpawnAsteroidSplit(asteroid);
 }