//called when the tower fires and grabs a projectile and asign the correct method to the delegate and then calls the projectiles launch method. public virtual void OnFire() { Projectile currentProjectile = projectiles.GrabObject(); OnHit onHit = new OnHit(ReturnProjectile); currentProjectile.Launch(target, this, onHit); activeProjectiles.Add(currentProjectile); }
//spawns enemies in a set time interval untill it has spawned all the enemies for the current wave. private static void OnEnemySpawn(Object source, ElapsedEventArgs e) { Enemy toSpawn = enemiePool.GrabObject(); toSpawn.X = pathPoints[0].X; toSpawn.Y = pathPoints[0].Y; spawnedEnemies++; if (spawnedEnemies == enemiesToSpawn) { timer.Stop(); timer.Dispose(); } }