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); })); }
void OnPlayerHit2() { if (_shotControlView == null) return; var model = (ShotControlViewModel) _shotControlView.DataContext; SurfaceItems.Remove(_shotControlView); _shotControlView = null; GameEngine.PlayShot(400, 250); }