void ModelShotMovedEventHandler(object sender, ShotMovedEventArgs e) { if (!e.Disappeared) { if (!_shots.ContainsKey(e.Shot)) { FrameworkElement shotControl = InvadersHelper.ShotControlFactory(e.Shot, Scale); _shots[e.Shot] = shotControl; _sprites.Add(shotControl); } else { FrameworkElement shotControl = _shots[e.Shot]; InvadersHelper.MoveElementOnCanvas(shotControl, e.Shot.Location.X * Scale, e.Shot.Location.Y * Scale); } } else { if (_shots.ContainsKey(e.Shot)) { FrameworkElement shotControl = _shots[e.Shot]; _sprites.Remove(shotControl); _shots.Remove(e.Shot); } } }
private void ShotMovedHandler(object sender, ShotMovedEventArgs e) { Shot shot = e.Shot; if (e.Removed) { AnimatedImage shotControl; if (_shots.ContainsKey(e.Shot)) { shotControl = _shots[e.Shot]; _sprites.Remove(shotControl); _shots.Remove(e.Shot); } } else { AnimatedImage shotControl; if (!e.IsBomb) { List <string> shotImages = new List <string>() { "Assets/shot1.png", "Assets/shot2.png", "Assets/shot3.png", "Assets/shot4.png", }; if (!_shots.ContainsKey(e.Shot)) { shotControl = InvadersHelper.ShotControlFactory(shot, shotImages, Scale) as AnimatedImage; _shots[e.Shot] = shotControl; //InvadersHelper.ResizeElement(shotControl, Shot.ShotSize.Width * Scale, Shot.ShotSize.Height * Scale); _sprites.Add(shotControl); } else { shotControl = _shots[e.Shot]; //InvadersHelper.ResizeElement(shotControl, Shot.ShotSize.Width * Scale, Shot.ShotSize.Height * Scale); InvadersHelper.MoveElementOnCanvas(shotControl, e.Shot.Location.X * Scale, e.Shot.Location.Y * Scale); } } else { List <string> bombImages = new List <string>() { "Assets/bomb1.png", "Assets/bomb2.png", "Assets/bomb3.png", "Assets/bomb4.png", }; if (!_shots.ContainsKey(e.Shot)) { shotControl = InvadersHelper.ShotControlFactory(shot, bombImages, Scale) as AnimatedImage; _shots[e.Shot] = shotControl; _sprites.Add(shotControl); } else { shotControl = _shots[e.Shot]; InvadersHelper.MoveElementOnCanvas(shotControl, e.Shot.Location.X * Scale, e.Shot.Location.Y * Scale); } } } }