public void LaunchWave() { CancelInvoke("LaunchWave"); if (randomSpawning) { currentObjectNum = Random.Range(0, totalSpawnObjects - 1); } else { currentObjectNum++; // loop back to 0 when we reach the end of the current 'run' of things to spawn if (currentObjectNum > totalSpawnObjects - 1) { currentObjectNum = 0; // you could also implement something to tell game control that all waves have finished if // you were making a game that only lasted until that happens } } // create an object GameObject tempObj = SpawnController.Instance.SpawnGO(spawnObjectPrefabs[currentObjectNum], Vector3.zero, Quaternion.identity); WaveProperties tempProps = tempObj.GetComponent <WaveProperties>(); currentWave = tempProps.enemiesInWave; // play a spawn sound effect, which should be a 2d sound so that its position doesn't matter BaseSoundController.Instance.PlaySoundByIndex(4, Vector3.zero); }
void InitializeFloor() { FloorID = 0; CurrentFloor = Floors[FloorID]; spawnArea = CurrentFloor.GetComponent <FloorProperties>().GetSpawnArea(); globalTimer = 0f; spawnTimer = 0f; currentWave = ScriptableObject.Instantiate <WaveProperties>(WaveTypes[0]); currentWave.InitializeWaveProperties(); }
IEnumerator spawnNewWave() { Stats.rounds++; Debug.Log("New wave..."); WaveProperties wave = waves[waveCounts]; for (int i = 0; i <= wave.count; i++) { spawnEnemy(wave.enemy); yield return(new WaitForSeconds(1f / wave.rate)); } waveCounts++; }
static void Main(string[] args) { Toolbox.Logging.PrintGreeting(); WaveProperties properties = GetWaveProperties(args); if (properties.Error == null) { Task.Run(() => CalculateWave(properties.Singularity, properties.Bailout, properties.Interval, properties.WaveFactor)); } else { Toolbox.Logging.PrintUsage(properties.Error.Message); } Console.Read(); }
IEnumerator SpawnWave(WaveProperties wave) { Debug.Log("Spawning Wave: " + wave.name); state = SpawnState.SPAWNING; for (int i = 0; i < wave.Amount; i++) { SpawnEnemy(wave.Enemy); yield return(new WaitForSeconds(1.0f / wave.Rate)); } state = SpawnState.WAITING; yield break; }
// Update is called once per frame void Update() { switch (playState) { case PlayState._Begin: { InitializeFloor(); playState = PlayState._Play; break; } case PlayState._Play: { globalTimer += Time.deltaTime; if (WaveTypes.Count > 0) { if (currentWave.CheckCurrentWave()) { Debug.Log("Checking no of enemies: "); // Frequent (check for random or specific switch (currentWave.waveType) { case WaveProperties.WaveType._Random: { switch (currentWave.frequency) { case WaveProperties.Frequency._Frequent: { if (currentWave.CheckSpawnTimer()) { if (currentWave.GetNoOfEnemies() > 0) { Debug.Log("Checking no of enemies: " + currentWave.GetNoOfEnemies()); // This is where set Enemy checks for current enemy List <EnemyType.EnemyTypes> randomEnemyTypes = currentWave.GetCurrentEnemyType(); if (randomEnemyTypes != null) { SpawnRandomEnemy(randomEnemyTypes); Debug.Log("Enemy Type set to an instance of enemy"); } else { Debug.Log("Enemies is null"); } } } break; } case WaveProperties.Frequency._NonFrequent: { int NoOfEnemies = currentWave.GetNoOfEnemies(); if (NoOfEnemies != 0) { List <EnemyType.EnemyTypes> randomEnemyTypes = currentWave.GetCurrentEnemyType(); if (randomEnemyTypes != null) { for (int enemies = 0; enemies < NoOfEnemies; enemies++) { //Debug.Log("Checking no of enemies: " + currentWave.GetNoOfEnemies()); // This is where set Enemy checks for current enemy SpawnRandomEnemy(randomEnemyTypes); Debug.Log("Enemy Type set to an instance of enemy"); //SpawnEnemy(currentWave.GetCurrentEnemyType()); } } } break; } } break; } case WaveProperties.WaveType._Specific: { break; } case WaveProperties.WaveType._Variable: { break; } } } else if (spawnedEnemies.Count <= 0) { WaveTypes.RemoveAt(0); if (WaveTypes.Count >= 0) { currentWave = ScriptableObject.Instantiate <WaveProperties>(WaveTypes[0]); } } } else { Debug.Log("You have cleared the floor"); playState = PlayState._FloorCleared; } break; } case PlayState._FloorCleared: { break; } case PlayState._NextFloor: { break; } case PlayState._Defeat: { break; } case PlayState._StageCleared: { break; } } }