void SpawnMonsters(int waveIndex) { MonsterWave wave = _monsterWaves[waveIndex]; for (int i = 0; i < wave.monsters.Length; i++) { GameObject tmp = wave.monsters[i]; tmp.GetComponent <Pawn>().pos = wave.position[i]; Instantiate(wave.monsters[i], Vector3.zero, wave.monsters[i].transform.rotation); } }
private void Awake() { for (int i = 0; i < transform.childCount; i++) { MonsterWave wave = transform.GetChild(i).GetComponent <MonsterWave>(); wave.gameObject.SetActive(false); _waves.Add(wave); } _curWave = 0; StartWave(); }
IEnumerator RunGame() { GameManager.isPlaying = true; while (waveIndex < waves.Count) { waveIndex++; currentWave = waves[waveIndex]; nextWaveTime = Time.time + currentWave.time; for (int i = 0; i < currentWave.mobs.Count; i++) { for (int j = 0; j < currentWave.numbers[i]; j++) { string mobName = currentWave.mobs[i]; Vector3 spawnPos = GetRandomMobSpawnPosition(); StartCoroutine(SpawnInRandomTime(mobName, spawnPos)); } } yield return(new WaitForSeconds(currentWave.time)); } }
MonsterWave[,] setUpWaveArray() { #if UNITY_4 numOfWaves = Convert.ToInt32(levelTable.Rows[91].ItemArray[1]); #endif //each row of the wave array is a wave of monsters //each column is a monster attack structure, holding info on what type of monster is there, as well as the delay and number MonsterWave[,] newArray = new MonsterWave[numOfWaves, 6]; int grp; int cat; int lvl; int delayOffset = 14; int typeOffset = 97; #if UNITY_4 for (int i = 0; i < numOfWaves; i++) { for (int j = 0; j < 6; j++) { MonsterWave newMonster = new MonsterWave(); newMonster.delay = Convert.ToInt32(levelTable.Rows[j].ItemArray[(3 * i) + delayOffset]); newMonster.count = Convert.ToInt32(levelTable.Rows[j].ItemArray[(3 * i) + delayOffset + 1]); newMonster.type = Convert.ToInt32(levelTable.Rows[(j + typeOffset)].ItemArray[7]); grp = newMonster.type / 100; cat = newMonster.type / 10; cat = cat % 10; lvl = newMonster.type % 10; if (grp == 1) { if (cat == 1) { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[97].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[98].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[99].ItemArray[16]); } } else if (cat == 2) { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[100].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[101].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[102].ItemArray[16]); } } else { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[103].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[104].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[105].ItemArray[16]); } } } else if (grp == 2) { if (cat == 1) { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[106].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[107].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[108].ItemArray[16]); } } else if (cat == 2) { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[109].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[110].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[111].ItemArray[16]); } } else { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[112].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[113].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[114].ItemArray[16]); } } } else { if (cat == 1) { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[115].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[116].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[117].ItemArray[16]); } } else if (cat == 2) { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[118].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[119].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[120].ItemArray[16]); } } else { if (lvl == 1) { newMonster.name = Convert.ToString(levelTable.Rows[121].ItemArray[16]); } else if (lvl == 2) { newMonster.name = Convert.ToString(levelTable.Rows[122].ItemArray[16]); } else { newMonster.name = Convert.ToString(levelTable.Rows[123].ItemArray[16]); } } } if (newMonster.type == 0) { newMonster.name = "None"; } newArray[i, j] = newMonster; } typeOffset += 10; } #endif return(newArray); }