private void OnGUI() { GUILayout.Label("Wave settings", EditorStyles.boldLabel); // // ## Allows input of key wave information (e.g. enemy numbers, wave timer, etc.) // #################################################################################################### // timeBetweenEnemies = EditorGUILayout.FloatField("Time between enemies spawning", timeBetweenEnemies); variant1 = EditorGUILayout.IntField("Number of variant 1 enemies", variant1); variant2 = EditorGUILayout.IntField("Number of variant 2 enemies", variant2); variant3 = EditorGUILayout.IntField("Number of variant 3 enemies", variant3); waveLength = EditorGUILayout.FloatField("Wave length in secoonds", waveLength); // #################################################################################################### // if (GUILayout.Button("Spawn Wave")) { // // ## ON BUTTON PRESS // ## locates all 'spawners' in the scene and starts a 'wave' according to input values above // spawner = GameObject.FindGameObjectsWithTag("Spawner"); for (int i = 0; i < spawner.Length; i++) { spawner[i].GetComponent <spawnerScript>().startWave(timeBetweenEnemies, variant1, variant2, variant3); } waveData newWave = new waveData(0, timeBetweenEnemies, variant1, variant2, variant3, waveLength, 30); //creates object newWave of type waveData based on input values GameObject.FindGameObjectWithTag("spawnerManager").GetComponent <playStateControl>().initiateWave(newWave); //calls initiateWave within spawnerManager to allow timer, win and lose conditions to function } }
public void initiateWave(waveData wave) { // // ## Calls spawn script from Spawners in scene // ## Sets current state to waveActive // waveLength = wave.waveLength; waveTimer = 0; spawners = GameObject.FindGameObjectsWithTag("Spawner"); for (int i = 0; i < spawners.Length; i++) { spawners[i].GetComponent <spawnerScript>().startWave(waves[wavePointer]); } current = waveState.waveActive; }
public void startWave(waveData wave) { // // ## Initialises all variables needed each wave and calls coroutine (takes type waveData as a parameter) // numberSpawned = 0; var1Count = 0; var2Count = 0; var3Count = 0; variant1Spawn = wave.enemy1Numbers; variant2Spawn = wave.enemy2Numbers; variant3Spawn = wave.enemy3Numbers; spawning = true; timeBetween = wave.timeBetweenEnemySpawns; enemyNumbers = variant1Spawn + variant2Spawn + variant3Spawn; StartCoroutine(waveSpawn()); }
void setupLevel() { List<xmlWave> waves = xmldata.levels[findLevel(levelID)].waves; int wavesLength = waves.Count; wavedata = new List<waveData>(); for(int i = 0; i < wavesLength; i++) { int enemiesLength = waves[i].enemies.Count; waveData wd = new waveData(); for(int j = 0; j < enemiesLength; j++) { waveDataQueue wdq = new waveDataQueue(); wdq.amount = waves[i].enemies[j].amount; wdq.name = waves[i].enemies[j].name; wdq.spawnpoint = waves[i].enemies[j].spawnpoint; wd.enemies.Add(wdq); if(wd.spawninglist.Count < 1) { wd.spawninglist.Add(wdq.spawnpoint); } else { for(int l = 0; l < wd.spawninglist.Count; l++) { if(wd.spawninglist[l] == wdq.spawnpoint) { break; } if(l == wd.spawninglist.Count - 1) { wd.spawninglist.Add(wdq.spawnpoint); } } } wd.total += wdq.amount; } wd.left = wd.total; wd.floatleft = wd.total; wd.id = waves[i].id; wd.time = waves[i].time; wd.timeTotal = waves[i].time; wd.delay = waves[i].delay; wd.dead = waves[i].dead; wd.spawn = wd.total / wd.timeTotal; wavedata.Add(wd); } spawing = false; waiting = false; paused = true; waveMax = wavedata.Count; map.setBlinks(wavedata[0].spawninglist); nextText(true); }