protected override void Update(GameTime gameTime) { if (gameScreen != null) { if (loadingThread == null) { } else if (loadingThread!=null) { nextScreen = gameScreen; toBeRemoved.Add(loadingScreen); } } input.KeyStateAfter = Keyboard.GetState(); input.GamePadAfter = GamePad.GetState(input.MainIndex); if (nextScreen != null) { activeScreens.Add(nextScreen); nextScreen = null; } foreach (Screen screen in toBeRemoved) { if (activeScreens.Contains(screen)) activeScreens.Remove(screen); } toBeRemoved.Clear(); foreach (Screen screen in activeScreens) screen.Update(gameTime); base.Update(gameTime); input.KeyStateBefore = Keyboard.GetState(); input.GamePadBefore = GamePad.GetState(input.MainIndex); }
private void MenuEventHandler(Screen s,MenuEventType et) { if (s is MenuScreen) { if (et == MenuEventType.Exit) Exit(); else if (et == MenuEventType.Continue) { nextScreen = gameScreen; toBeRemoved.Add(s); } else if (et == MenuEventType.MainMenu) { nextScreen = titleScreen; toBeRemoved.Add(s); } else if (et == MenuEventType.Start) { gameScreen = new WindowsGame1.Game1(); gameScreen.Initialize(Services); gameScreen.LoadContent(); gameScreen.Event += new Game1.EventHandler(MenuEventHandler); nextScreen = gameScreen; toBeRemoved.Add(s); } Console.Out.WriteLine("Title!" + et); } else if (s == gameScreen) { if(et == MenuEventType.Load){ loadingScreen = new LoadingScreen(); loadingScreen.Initialize(Services); loadingScreen.LoadContent(); nextScreen = loadingScreen; toBeRemoved.Add(s); } if (et == MenuEventType.Pause) { pauseScreen = new PauseScreen(); pauseScreen.Initialize(Services); pauseScreen.LoadContent(); pauseScreen.Event += new PauseScreen.EventHandler(MenuEventHandler); nextScreen = pauseScreen; toBeRemoved.Add(s); } else if (et == MenuEventType.Exit) { gameScreen = null; nextScreen = titleScreen; toBeRemoved.Add(s); } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here gameScreen = new GameScreen(this); base.Initialize(); }