public MainPage() { InitializeComponent(); SoundPlayer.FillDictionary(App.Current.Resources.MergedDictionaries[0]); SoundPlayer.BackgroundMusic.FillBgDictionary(App.Current.Resources.MergedDictionaries[1]); TextHandler.FillDictionary(App.Current.Resources.MergedDictionaries[2]); this.GotFocus += MainPageGotFocus; this.LostFocus += MainPageLostFocus; _keyHandler = new KeyHandler(this); _menuEngine = new MenuEngine(this.gameSurface); _menuEngine.Updated += MenuEngineUpdated; _levelEngine = new LevelEngine(new Canvas()); _levelEngine.Renewed += LevelEngineRenewed; _hudEngine = new HudEngine(new Canvas()); _scoreEngine = new ScoreEngine(new Canvas(), 10); Level.Player = Player = new Player(); _renderNotifier = new RenderNotifier(this); _renderNotifier.AddObservedChild(this.gameSurface); _renderNotifier.RenderComplete += RenderNotifierRenderComplete; _mainLoop = new CompositionTargetGameLoop(); _mainLoop.Update += MainLoopUpdate; }
public LevelHolder(LevelEngine levelEngine, HudEngine hudEngine, ScoreEngine scoreEngine) : base(_menu) { if (levelEngine == null) { throw new ArgumentNullException("No LevelEngine defined!"); } _levelEngine = levelEngine; _levelEngine.Started += LevelEngineStarted; _levelEngine.BeforeNextLevel += LevelEngineBeforeNextLevel; _levelEngine.Finished += LevelEngineFinished; if (hudEngine == null) { throw new ArgumentNullException("No HudEngine defined!"); } _hudEngine = hudEngine; _hudEngine.TimesUp += TimesUp; if (scoreEngine == null) { throw new ArgumentNullException("No ScoreEngine defined!"); } _scoreEngine = scoreEngine; ConnectPlayer(); _levelSurface = _menu.FindName("levelSurface") as Canvas; if (_levelSurface == null) { throw new NotImplementedException("levelSurface canvas not implemented"); } _levelSurface.Children.Add(_levelEngine.Container); _hudSurface = _menu.FindName("hudSurface") as Canvas; if (_hudSurface == null) { throw new NotImplementedException("hudSurface canvas not implemented"); } _hudSurface.Children.Add(_hudEngine.Container); this.Shown += LevelHolderShown; }