private void AliensShoot( ref Player player, ref GameSound sound) { try { for (int i = 0; i < (this.rowCount_i * this.colCount_i); i++) { if ((this.aliens_s[i].X - (this.alienImage.Width / 2)) > (player.sprite.X) && (this.aliens_s[i].X - (this.alienImage.Width / 2)) < (player.sprite.X + player.sprite.Width)) { if (!this.shooting_s.ContainsValue(this.aliens_s[i]) && this.shooting_s.Count < this.count_i) { for (int a = 0; a < this.count_i; a++) { if (!this.bullets_s[a].Visible) { this.bullets_s[a].Visible = true; this.bullets_s[a].Position( (this.aliens_s[i].X + (this.aliens_s[i].Width / 2)), (this.aliens_s[i].Y + (this.aliens_s[i].Height / 2))); sound.PlayFire(); this.shooting_s.Add(this.bullets_s[a], this.aliens_s[i]); break; } } break; } } } } catch (Exception ex) { this.exception_ex = ex; } }
private void BulletUpdates( ref Backdrop backdrop, ref GameSound sound) { Sprite tempCollision_s = null; try { if (this.fire_bl) { for (int i = 0; i < this.count_i; i++) { if (!this.bullets_s[i].Visible) { this.bullets_s[i].Visible = true; sound.PlayFire(); break; } } this.fire_bl = false; } for (int i = 0; i < this.count_i; i++) { if (this.bullets_s[i].Visible) { if (this.bullets_s[i].Y > -(this.bullets_s[i].Height)) { this.bullets_s[i].Position( this.bullets_s[i].X, (this.bullets_s[i].Y - this.speed_i)); } else { this.misses_f++; this.bullets_s[i].Visible = false; } tempCollision_s = this.bullets_s[i].Collision(); if (tempCollision_s != null //&& tempCollision_s != this.player_s && !backdrop.sprites.Contains(tempCollision_s)) { this.hits_f++; this.score_i += 100; this.bullets_s[i].Visible = false; sound.PlayExplosion(); tempCollision_s.Visible = false; tempCollision_s = null; } } else { this.bullets_s[i].Position( (this.player_s.X + (this.player_s.Width / 2)), (this.player_s.Y + (this.player_s.Height / 2))); } } } catch (Exception ex) { this.exception_ex = ex; } }