private void spawnCustomWaveTitans() { if (this.customWaves.ContainsKey(this.currentWave)) { WaveSpawnInfo info = this.customWaves[this.currentWave]; if (info.spawnByRatio) { for (int i = 0; i < info.amountToSpawn; i++) { AbnormalType type = this.getAbnormalTypeByRatio(info.nRatio, info.aRatio, info.jRatio, info.cRatio, info.pRatio); float size = UnityEngine.Random.Range(info.sizeMin, info.sizeMax);; Vector3 pos = this.spawnLocations[UnityEngine.Random.Range(0, this.spawnLocations.Length)]; this.spawnTitan(type, size, pos, this.qUp); } } else { foreach (string s in info.toSpawn) { int amount = int.Parse(s.Substring(0, s.Length - 1));//This could cause an exception if the string is malformed, but f**k it AbnormalType type = TitanSize.getTitanType(s[s.Length - 1]); for (int i = 0; i < amount; i++) { float size = UnityEngine.Random.Range(info.sizeMin, info.sizeMax);; Vector3 pos = this.spawnLocations[UnityEngine.Random.Range(0, this.spawnLocations.Length)]; this.spawnTitan(type, size, pos, this.qUp); } } } } }
public void setCustomWave(int wave, int amount, params string[] titans) { WaveSpawnInfo info = new WaveSpawnInfo(); info.spawnByRatio = false; info.amountToSpawn = titans.Length; //not used info.toSpawn = titans; this.customWaves[wave - 1] = info; }
public void setCustomWaveRatio(int wave, int titanAmount, float nr, float ar, float jr, float cr, float pr) { WaveSpawnInfo info = new WaveSpawnInfo(); info.amountToSpawn = titanAmount; info.spawnByRatio = true; info.nRatio = nr; info.aRatio = ar; info.jRatio = jr; info.cRatio = cr; info.pRatio = pr; this.customWaves[wave - 1] = info; }
/// <summary> /// Routine for handling spawning /// </summary> /// <param name="info"></param> /// <returns></returns> private IEnumerator spawnRoutine(WaveSpawnInfo info) { BoardManager board = getLocalBoardManager(); if (!board) { // Be sure to null this (see isWaveInProgress) m_spawnRoutine = null; yield break; } int remainingSpawns = info.m_count; while (remainingSpawns > 0) { spawnMonster(board); // We want to call onWaveFinished as // soon as the last monster is spawned --remainingSpawns; if (remainingSpawns <= 0) { break; } yield return(new WaitForSeconds(info.m_spawnInterval)); } // This may call initWave (it shouldn't), so we null out // spawnRoutine after so any call to initWave falls out if (onWaveFinished != null) { onWaveFinished.Invoke(); } m_spawnRoutine = null; }