void DisplayWave(int number, WaveManagement.Army.Wave wave) { EditorGUILayout.BeginVertical(); GUILayout.Label("Wave " + number); GUILayout.Label("Worth " + wave.Bounty); for (int i = 0; i < wave.units.Count; i++) { if (wave.units[i].qty == 0) { wave.units.RemoveAt(i); } else if (wave.units[i].enemy != null) { DisplayUnit(wave.units[i]); } else { wave.units.RemoveAt(i); } } wave.units.Add(new WaveManagement.Army.Unit()); GameObject newUnit = EditorGUILayout.ObjectField(null, typeof(GameObject), false) as GameObject; if (newUnit != null) { wave.units.Add(new WaveManagement.Army.Unit() { enemy = newUnit, qty = 1, }); } EditorGUILayout.EndVertical(); }
IEnumerator SpawnWave(float startDelay, Army.Wave wave, float waveGap = 0f, int repetitions = 1) { runningSpawns++; if (startDelay > 0f) { yield return(new WaitForSeconds(startDelay)); } for (int r = 0; r < repetitions; r++) { foreach (var unit in wave.units) { for (int i = 0; i < unit.qty; i++) { var enemy = Instantiate(unit.enemy); enemy.transform.position = new Vector3(-25, -25); enemy.GetComponent <Attack.Enemy>().Level = unit.level; yield return(new WaitForSeconds(delayFor(unit.spawnRate) * SpawnRateFactor)); } if (waveGap > 0f) { yield return(new WaitForSeconds(waveGap)); } } } runningSpawns--; }
public void ShowWave(Army.Wave wave) { int hpMult = 100; if (DifficultySelector.Difficulty == Difficulty.easy) { hpMult = 70; } if (DifficultySelector.Difficulty == Difficulty.medium) { hpMult = 80; } Hide(); for (int i = 0; i < wave.units.Count; i++) { var enemy = wave.units[i].enemy.GetComponent <Attack.Enemy>(); if (enemy == false) { var rando = wave.units[i].enemy.GetComponent <SpawnRandom>(); if (rando) { enemy = rando.prefabs[0].GetComponent <Attack.Enemy>(); } } images[i].sprite = enemy.GetComponentInChildren <SpriteRenderer>(true).sprite; images[i].gameObject.SetActive(true); var text = images[i].GetComponentInChildren <Text>(true); if (text) { var tooltip = $"<b>{wave.units[i].qty}x lvl {wave.units[i].level} {enemy.name}</b> ({Attack.Enemy.HPFor(enemy.hits, wave.units[i].level)} hp)"; if (enemy.GetComponent <Attack.Enemy>().armor) { tooltip += "\nArmor: \u00BD Physical Damage."; } var regen = enemy.GetComponent <Attack.Regeration>(); if (regen) { tooltip += $"\nRegeneration 30% per second"; } text.text = tooltip; } } }
public Army GetArmy(int level, int complexity, int waves, int seed) { var rng = new System.Random(seed); var options = new List <ArmyCell>(); for (int i = 0; i < complexity; i++) { if (i == 0) { var list = new List <ArmyCell>(Enemies .Where(cell => cell.complexity == 0) .Where(cell => cell.minimumLevel <= level)); options.Add(list[rng.Next(list.Count)]); } else if (i == complexity - 1) { var list = new List <ArmyCell>(Enemies .Where(cell => cell.complexity > 0) .Where(cell => cell.minimumLevel <= level + waves / 3 && cell.minimumLevel > 1)); if (list.Count > 0) { options.Add(list[rng.Next(list.Count)]); } else { options.Add(Enemies .Where(cell => cell.complexity > 0) .Where(cell => cell.minimumLevel <= level) .First()); } } else { var list = new List <ArmyCell>(Enemies .Where(cell => cell.complexity < 2) .Where(cell => cell.minimumLevel <= level)); options.Add(list[rng.Next(list.Count)]); } } var army = CreateInstance <Army>(); army.waves = new List <Army.Wave>(); for (int i = 0; i < waves; i++) { int waveLevel = level + i / 2; var max = i < waves / 2 ? options.Count - 1 : options.Count; var wave = new Army.Wave(); if (i == waves - 1) { wave.units.Add(options[options.Count - 1].GetUnit(waveLevel)); wave.units.Add(options[0].GetUnit(level)); } else if (i < complexity - 1) { wave.units.Add(options[i].GetUnit(waveLevel)); } else { wave.units.Add(options[rng.Next(max)].GetUnit(waveLevel, rng.Next())); } army.waves.Add(wave); } return(army); }