void ModelVehicleChangedEventHandler(object sender, MilitaryVehicleChangedEventArgs e) { if (!e.Killed) { if (e.MilitaryVehcileUpdated is Aircraft) { Aircraft aircraft = e.MilitaryVehcileUpdated as Aircraft; if (!_aircrafts.ContainsKey(aircraft)) { FrameworkElement aircraftControl = VehicleDefenceHelper.AircraftControlFactory(aircraft, Scale); _aircrafts[aircraft] = aircraftControl; _sprites.Add(aircraftControl); } else { FrameworkElement aircraftControl = _aircrafts[aircraft]; VehicleDefenceHelper.MoveElementOnCanvas(aircraftControl, aircraft.Location.X * Scale, aircraft.Location.Y * Scale); VehicleDefenceHelper.ResizeElement(aircraftControl, aircraft.Size.Width * Scale, aircraft.Size.Height * Scale); } } else if (e.MilitaryVehcileUpdated is Player) { if (_playerFlashing) { _playerFlashing = false; AnimatedImage control = _playerControl as AnimatedImage; if (control != null) { control.StopFlashing(); } } Player player = e.MilitaryVehcileUpdated as Player; if (_playerControl == null) { _playerControl = VehicleDefenceHelper.PlayerControlFactory(player, Scale); _sprites.Add(_playerControl); } else { VehicleDefenceHelper.MoveElementOnCanvas(_playerControl, player.Location.X * Scale, player.Location.Y * Scale); VehicleDefenceHelper.ResizeElement(_playerControl, player.Size.Width * Scale, player.Size.Height * Scale); } } } else { if (e.MilitaryVehcileUpdated is Aircraft) { Aircraft aircraft = e.MilitaryVehcileUpdated as Aircraft; if (!_aircrafts.ContainsKey(aircraft)) { return; } AnimatedImage aircraftControl = _aircrafts[aircraft] as AnimatedImage; if (aircraftControl != null) { aircraftControl.AircraftShot(); _shotAircrafts[aircraftControl] = DateTime.Now; _aircrafts.Remove(aircraft); } } else if (e.MilitaryVehcileUpdated is Player) { AnimatedImage control = _playerControl as AnimatedImage; if (control != null) { control.StartFlashing(); } _playerFlashing = true; } } }