Exemple #1
0
 void AddShotControl()
 {
     if (_shotControlView != null) return;
     Dispatcher.CurrentDispatcher.Invoke((Action) (() => {
                                                       _shotControlView = new ShotControlView();
                                                       _shotControlView.DataContext = new ShotControlViewModel {
                                                                                                                   PlayersBall
                                                                                                                       =
                                                                                                                       GameEngine
                                                                                                                       .
                                                                                                                       PlayersBall,
                                                                                                                   Hit
                                                                                                                       =
                                                                                                                       new ActionCommand
                                                                                                                       (OnPlayerHit)
                                                                                                               };
                                                       SurfaceItems.Add(_shotControlView);
                                                   }));
 }
Exemple #2
0
 void OnPlayerHit2()
 {
     if (_shotControlView == null) return;
     var model = (ShotControlViewModel) _shotControlView.DataContext;
     SurfaceItems.Remove(_shotControlView);
     _shotControlView = null;
     GameEngine.PlayShot(400, 250);
 }