private void SpawnEnemy(WaveComponent wc) { wc.Spawned++; Enemy spawnedEnemy = Instantiate(wc.EnemyPrefab, wc.WaypointsParentGO.GetChild(0).position, wc.WaypointsParentGO.GetChild(0).rotation); if (wc.WaypointsParentGO != null) { Debug.Log("Setting the path of the Enemy"); spawnedEnemy.WaypointsParentGO = wc.WaypointsParentGO; } }
// Update is called once per frame void Update() { if (currentWaveIdx >= waveComponents.Length) { return; } if (currentWave == null) { currentWave = waveComponents[currentWaveIdx]; currentWave.StartWave(); } if (currentWave.WaveFinished()) { currentWaveIdx++; currentWave = null; } }
private IEnumerator SpawnWave() { PlayerStats.m_Rounds++; WaveComponent wave = m_Waves [m_WaveNum]; m_EnemiesAlive = wave.m_Count; for (int i = 0; i < wave.m_Count; i++) { SpawnEnemies(wave.m_Enemy); yield return(new WaitForSeconds(1 / wave.m_Rate)); } m_WaveNum++; }
private void Awake() { rand = new System.Random(); Shuffle(enemiesOfTiers); foreach (EnemyOfTier eot in enemiesOfTiers) { SetEnemyStats(eot); WaveComponent wc = new WaveComponent(); wc.EnemyPrefab = eot.EnemyPrefab; wc.WaypointsParentGO = possiblePaths[rand.Next(0, possiblePaths.Length)]; wc.NumOfEnemies = rand.Next(eot.MinEnemiesOfTier, eot.MaxEnemiesOfTier); } }
public override void _Ready() { float angle = StartAngle; // Create components for (float x = -Length / 2; x <= Length / 2; x += Separation) { var target = new Vector2(x, ComputeY(angle)); var node = new WaveComponent(); AddChild(node); node.GlobalPosition = GlobalPosition + target; angle += AngularVelocity; components.Add(node); } }