Beispiel #1
0
        private void ModelShotMovedEventHandler(object sender, Model.Event_Arguments.ShotMovedEventArgs e)
        {
            if (!e.Disappeared)
            {
                if (!_shots.ContainsKey(e.Shot))
                {
                    Rectangle shot = InvadersHelper.ShotFactory(new Rect(e.Shot.Location, e.Shot.ShotSize), e.PlayerShot);
                    _shots.Add(e.Shot, shot);
                    _sprites.Add(shot);
                    InvadersHelper.ResizeElement(shot, shot.Width * Scale, shot.Height * Scale);
                    InvadersHelper.RepositionElement(shot, e.Shot.Location.X * Scale, e.Shot.Location.Y * Scale);
                }
                else
                {
                    InvadersHelper.ResizeElement(_shots[e.Shot], e.Shot.ShotSize.Width * Scale, e.Shot.ShotSize.Height * Scale);
                    InvadersHelper.RepositionElement(_shots[e.Shot], e.Shot.Location.X * Scale, e.Shot.Location.Y * Scale);
                }
            }

            else
            {
                if (_shots.ContainsKey(e.Shot))
                {
                    _sprites.Remove(_shots[e.Shot]);
                    _shots.Remove(e.Shot);
                }
            }
        }