void StopEnemies() { foreach (GameObject EnemyTargetOfPlayer in spawner.EnemiesTargetOfPlayer) { EnemyController controller = EnemyTargetOfPlayer.GetComponent <EnemyController>(); controller.moveEnabled = false; } foreach (GameObject EnemyTargetOfWarehouse in spawner.EnemiesTargetOfWarehouse) { EnemyController controller = EnemyTargetOfWarehouse.GetComponent <EnemyController>(); controller.moveEnabled = false; } foreach (GameObject Mutant in spawner.Mutants) { MutantController controller = Mutant.GetComponent <MutantController>(); controller.mutantMoveEnabled = false; } }
bool SpawnEnemy() { maxEnemies = gameManager.GetmaxKill(); if (enemySpawnCount >= maxEnemies) { return(false); } else { int choosedIndex; if (gameManager.round >= mutantSpawnRound && mutantSpawnCount * mutantSpawnRound < gameManager.round) { choosedIndex = Random.Range(0, enemyPrefabs.Length); if (choosedIndex == 2) { mutantSpawnCount++; } } else { choosedIndex = Random.Range(0, enemyPrefabs.Length - 1); } if (choosedIndex == 0) { foreach (GameObject EnemyTargetOfPlayer in EnemiesTargetOfPlayer) { if (EnemyTargetOfPlayer.activeSelf == false) { EnemyTargetOfPlayer.transform.position = RandomPos(); EnemyTargetOfPlayer.SetActive(true); count = 0; break; } else { count++; } } if (count == EnemiesTargetOfPlayer.Count || EnemiesTargetOfPlayer.Count == 0) { GameObject EnemyTargetOfPlayer = Instantiate(enemyPrefabs[0], RandomPos(), Quaternion.identity); EnemiesTargetOfPlayer.Add(EnemyTargetOfPlayer); count = 0; } } if (choosedIndex == 1) { foreach (GameObject EnemyTargetOfWarehouse in EnemiesTargetOfWarehouse) { if (EnemyTargetOfWarehouse.activeSelf == false) { EnemyTargetOfWarehouse.transform.position = RandomPos(); EnemyTargetOfWarehouse.SetActive(true); count = 0; break; } else { count++; } } if (count == EnemiesTargetOfWarehouse.Count || EnemiesTargetOfWarehouse.Count == 0) { GameObject EnemyTargetOfWarehouse = Instantiate(enemyPrefabs[1], RandomPos(), Quaternion.identity); EnemiesTargetOfWarehouse.Add(EnemyTargetOfWarehouse); count = 0; } } if (choosedIndex == 2) { foreach (GameObject Mutant in Mutants) { if (Mutant.activeSelf == false) { Mutant.transform.position = RandomPos(); Mutant.SetActive(true); count = 0; break; } else { count++; } } if (count == Mutants.Count || Mutants.Count == 0) { GameObject Mutant = Instantiate(enemyPrefabs[2], RandomPos(), Quaternion.identity); Mutants.Add(Mutant); count = 0; } } enemySpawnCount++; return(true); } }