private void StartButton_Click(object sender, EventArgs e) { _isRunning = !_isRunning; SetUI(_isRunning); if (_isRunning) { AutoTimer.Start(); } else { AutoTimer.Stop(); } }
/// <summary> /// Update shooting. /// </summary> void UpdateShooting() { // Check if ShootingCooldown is at max if (ShootingCooldown.AtMax) { ShootingCooldown.Stop(); // Chooses the enemy that shoots List <Enemy> enemies = Scene.GetEntities <Enemy>(); int EnemyNumber = rnd.Next(1, enemies.Count); // Create bullet BoxCollider collider = new BoxCollider(enemyBullet.Width, enemyBullet.Height, Tags.Enemy); Bullet bullet = new Bullet(6.0f, enemies[EnemyNumber - 1].Position, collider); bullet.AddGraphic(enemyBullet); Scene.Add(bullet); // Reset ShootingCooldown ShootingCooldown.Max = rnd.Next(2000, 5000); ShootingCooldown.Start(); } }
/// <summary> /// Ažuriraj pucanje /// </summary> void AzurirajPucanje() { // Check if ShootingCooldown is at max if (IntervalPucanja.AtMax) { IntervalPucanja.Stop(); Random rnd = new Random(); // Chooses the enemy that shoots List <Neprijatelj> neprijatelji = Scene.GetEntities <Neprijatelj>(); int RedniBrojNeprijatelja = rnd.Next(1, neprijatelji.Count); // Create bullet BoxCollider collider = new BoxCollider(NeprijateljskiMetak.Width, NeprijateljskiMetak.Height, Oznake.Neprijatelj); Metak metak = new Metak(6.0f, neprijatelji[RedniBrojNeprijatelja - 1].Position, collider); metak.AddGraphic(NeprijateljskiMetak); Scene.Add(metak); // Reset ShootingCooldown IntervalPucanja.Max = rnd.Next(2000, 5000); IntervalPucanja.Start(); } }