private void ModelShipChangedEventHandler(object sender, ShipChangedEventArgs e) { if (!e.Killed) { if (e.ShipUpdated is Invader) { Invader invader = e.ShipUpdated as Invader; if (!_invaders.ContainsKey(invader)) { FrameworkElement invaderControl = InvadersHelper.InvaderFactory((int)invader.InvaderType, invader.Size.Width, invader.Size.Height, Scale, _timer.Interval); _sprites.Add(invaderControl); _invaders.Add(invader, invaderControl); InvadersHelper.SetCanvasLocation(invaderControl, invader.Location.X, invader.Location.Y, Scale); } else { FrameworkElement invaderControl = _invaders[invader]; InvadersHelper.MoveElementOnCanvas(invaderControl, invader.Location.X, invader.Location.Y, Scale); InvadersHelper.ResizeElement((AnimatedImage)invaderControl, invader.Size.Width, invader.Size.Height, Scale); } } else if (e.ShipUpdated is Player) { Player player = e.ShipUpdated as Player; if (_playerFlashing && !_model.PlayerDying) { _playerFlashing = false; AnimatedImage playerControl = (AnimatedImage)_playerControl; playerControl.StopFlashing(); } if (_playerControl == null) { _playerControl = InvadersHelper.PlayerFactory(player.Size.Width, player.Size.Height, Scale, _timer.Interval); _sprites.Add(_playerControl); InvadersHelper.SetCanvasLocation(_playerControl, player.Location.X, player.Location.Y, Scale); } else { InvadersHelper.MoveElementOnCanvas(_playerControl, player.Location.X, player.Location.Y, Scale); InvadersHelper.ResizeElement((AnimatedImage)_playerControl, player.Size.Width, player.Size.Height, Scale); } } } else { // Invader killed if (e.ShipUpdated is Invader) { Invader invader = e.ShipUpdated as Invader; if (_invaders.ContainsKey(invader)) { AnimatedImage invaderControl = (AnimatedImage)_invaders[invader]; invaderControl.InvaderShot(_timeLimitInvadersFadeoutSeconds); _shotInvaders.Add(invaderControl, DateTime.Now); _invaders.Remove(invader); } } // Player killed else if (e.ShipUpdated is Player) { Player player = e.ShipUpdated as Player; AnimatedImage playerControl = (AnimatedImage)_playerControl; playerControl.StartFlashing(); _playerFlashing = true; } } }
private void _model_ShipChanged(object sender, ShipChangedEventArgs e) { throw new NotImplementedException(); }