IEnumerator spawnWave(OneWave theWave) { waveState = 3; totalEnemies = theWave.enemy1Count + theWave.enemy2Count + theWave.enemy3Count; enemiesText.text = "Enemies Remaining: " + totalEnemies; for (int i = 0; i < theWave.enemy1Count; i++) { spawnEnemy(theWave.enemy1); yield return(new WaitForSeconds(1f / theWave.spawnRate)); } for (int i = 0; i < theWave.enemy2Count; i++) { spawnEnemy(theWave.enemy2); yield return(new WaitForSeconds(1f / theWave.spawnRate)); } for (int i = 0; i < theWave.enemy3Count; i++) { spawnEnemy(theWave.enemy3); yield return(new WaitForSeconds(1f / theWave.spawnRate)); } waveState = 2; yield break; }
public void AddWave(OneWave wave) { List <OneWave> waveList = new List <OneWave>(waves); waveList.Add(wave); waves = waveList.ToArray(); }
static void ExportSeason() { GameObject fishSeasonObj = Selection.activeGameObject; if (fishSeasonObj == null) { Debug.LogError("no seasonobj selected!"); return; } FishSeason fishseason = new FishSeason(); OneWave oneWave = new OneWave(); fishseason.AddWave(oneWave); oneWave.speed = 20; oneWave.pathid = 5; oneWave.rootea = fishSeasonObj.transform.localEulerAngles; int fishcellscnt = fishSeasonObj.transform.childCount; for (int i = 0; i < fishcellscnt; i++) { Transform child = fishSeasonObj.transform.GetChild(i); if (child.name == "HeadModel") { oneWave.ea = child.eulerAngles; oneWave.o = fishSeasonObj.transform.position; continue; } WaveFish wavefish = new WaveFish(); wavefish.fkid = child.GetComponent <FishId>().fishKindId; wavefish.p = child.position; wavefish.s = child.localScale; oneWave.AddWaveFish(wavefish); } string destpath = EditorUtility.SaveFilePanel("", "Assets/Resources/SeasonConfigs/", "untitled", "bytes"); if (destpath.Length > 0) { string json = JsonUtility.ToJson(fishseason); FileStream fs = new FileStream(destpath, FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.Write(json); sw.Flush(); fs.Close(); AssetDatabase.Refresh(); } }