private void Tank_HitKolobokEvent(object sender, EventArgs e) { if (e is HitTankEventArgs) { HitTankEventArgs hitTankEventArgs = e as HitTankEventArgs; for (int i = 0; i < hitTankEventArgs.positionsOfShot.Count; i++) { if (IsHitBorder(hitTankEventArgs.positionsOfShot[i].CurrentPosition)) { hitTankEventArgs.positionsOfShot[i] = null; hitTankEventArgs.positionsOfShot.Remove(hitTankEventArgs.positionsOfShot[i]); IsGameOver = true; } } } }
private void Shot_HitTankEvent(object sender, EventArgs e) { if (e is HitTankEventArgs) { HitTankEventArgs hitTankEventArgs = e as HitTankEventArgs; for (int i = 0; i < hitTankEventArgs.positionsOfShot.Count; i++) { if (IsHitBorder(hitTankEventArgs.positionsOfShot[i].CurrentPosition)) { positionOfKill = CurrentPosition; CreateRandomLocation(); hitTankEventArgs.positionsOfShot[i] = null; hitTankEventArgs.positionsOfShot.Remove(hitTankEventArgs.positionsOfShot[i]); } } } }
private void OnHitKolobok(HitTankEventArgs e) { EventHandler hitKolobokEvent = HitKolobokEvent; hitKolobokEvent?.Invoke(this, e); }
private void HitKolobok() { HitTankEventArgs hitTankEventArgs = new HitTankEventArgs(positionsOfShot); OnHitKolobok(hitTankEventArgs); }