/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); Font = Content.Load <SpriteFont>("font"); drawAdapter = new MonoGameDrawManager(_spriteBatch); _drawVisitor = new DrawVisitor(drawAdapter); _updateVisitor = new UpdateVisitor(drawAdapter); mainScreenElements = screenFactory.CreateHomeCollectionScreen(); labelScreenElements = screenFactory.CreateLabelCollectionScreen(); inputScreenElements = screenFactory.CreateInputCollectionScreen(); collection = screenFactory.CreateHomeCollectionScreen(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic here switch (CurrentScreen) { case ScreenManager.MainWindow: collection = mainScreenElements; break; case ScreenManager.InputWindow: collection = inputScreenElements; break; case ScreenManager.LabelWindow: collection = labelScreenElements; break; case ScreenManager.Exit: Exit(); break; } IIterator iterator = collection.Iterator(); while (iterator.HasNext()) { var guiElement = iterator.Next(); guiElement.Accept(_updateVisitor); } base.Update(gameTime); }