Exemple #1
0
    private void StopGame()
    {
        isPause = true;
        waveManager.Activate(false);
        playerController.Activate(false);
        cameraManager.Activate(false);
        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");

        enemyControllers = new List <EnemyController>();
        foreach (GameObject enemy in enemies)
        {
            EnemyController temp = enemy.GetComponent <EnemyController>();
            temp.Activate(false);
            enemyControllers.Add(temp);
        }
    }
    private void SpawnEnemy(EnemyController enemyPrefab, EnemyType enemyType)
    {
        EnemyController pooledEnemyController = _enemyPool.FirstOrDefault(enemy => enemy.IsActive == false && enemy.EnemyType == enemyType);

        Vector2 position = new Vector2(_spawnPositionX, Random.Range(_spawnPositionYRange.x, _spawnPositionYRange.y));

        if (pooledEnemyController == null)
        {
            GameObject enemyGameObject = Instantiate(enemyPrefab.gameObject, position, Quaternion.identity, _enemyContainer.transform);

            pooledEnemyController = enemyGameObject.GetComponent <EnemyController>();
            pooledEnemyController.Initialize(_castleController);

            _enemyPool.Add(pooledEnemyController);
        }

        pooledEnemyController.Activate(position);
    }
 void StartGame()
 {
     player.Activate();
     enemyController.Activate();
     CameraManager.ActiveCamera("TPSView");
 }