예제 #1
0
        public void DespawnEnemy(EnemyComponent enemyComponent, GameEntityTag despawner)
        {
            spawnedEnemies.Remove(enemyComponent);

            _gameSignals.EnemyDespawnedSignal.Fire(enemyComponent, despawner);
            _multiplePrefabMemoryPool.DespawnObject(enemyComponent.gameObject);
        }
예제 #2
0
        public async UniTask <EnemyComponent> SpawnEnemy(EnemyData enemyData, Vector2 spawnPosition)
        {
            GameObject newEnemyGO = await _multiplePrefabMemoryPool.SpawnObject(enemyData.EnemyPrefab.gameObject, spawnPosition);

            EnemyComponent newEnemy = newEnemyGO.GetComponent <EnemyComponent>();

            newEnemy.Init();
            newEnemy.SetData(enemyData);
            spawnedEnemies.Add(newEnemy);

            _gameSignals.EnemySpawnedSignal.Fire(newEnemy);

            return(newEnemy);
        }
        private void HandleEnemyDespawned(EnemyComponent enemy, GameEntityTag gameEntityTag)
        {
            if (gameEntityTag != GameEntityTag.BULLET)
            {
                return;
            }
            if (!_canAddScore)
            {
                return;
            }

            int score = _asteroidScoreDataSource.GetScore(enemy.EnemyData.EnemyID);

            _scoreSystem.AddScore(score);
        }