public ScreenManager() { Dimensions = new Vector2(640, 480); currentScreen = new SplashScreen(); xmlGameScreenManager = new XmlManager<GameScreen>(); xmlGameScreenManager.Type = currentScreen.Type; currentScreen = xmlGameScreenManager.Load("Load/SplashScreen.xml"); }
/// <summary> /// Used to change screens ingame. Saves the map screen so that it shouldn't have to be reloaded every time a player wins a battle or exits the menu. /// </summary> /// <param name="screenName"></param> public void ChangeIngameScreens(string screenName) { newScreen = (GameScreen)Activator.CreateInstance(Type.GetType("SecondAttempt." + screenName)); if (currentScreen is MapScreen) { overworldScreen = currentScreen; currentScreen = newScreen; currentScreen.LoadContent(); } else if (newScreen is TitleScreen) { currentScreen.UnloadContent(); GameplayScreen.Player.UnloadContent(); currentScreen = newScreen; newScreen.LoadContent(); } else { currentScreen.UnloadContent(); currentScreen = overworldScreen; ((MapScreen)currentScreen).ReloadMusic(); } }
/// <summary> /// Enables the trasition fade effect between initial game screens. /// </summary> /// <param name="gameTime"></param> void Transition(GameTime gameTime) { if(IsTransitioning) { Image.Update(gameTime); if(Image.Alpha == 1.0f) { currentScreen.UnloadContent(); currentScreen = newScreen; xmlGameScreenManager.Type = currentScreen.Type; if (File.Exists(currentScreen.XmlPath)) currentScreen = xmlGameScreenManager.Load(currentScreen.XmlPath); currentScreen.LoadContent(); } else if (Image.Alpha == 0.0f) { Image.IsActive = false; IsTransitioning = false; } } }
/// <summary> /// Uses the generated enemies to start a new battle. /// </summary> /// <param name="enemies"></param> public void ChangeToBattleScreen(List<Enemy> enemies) { newScreen = (GameScreen)new BattleScreen(enemies); overworldScreen = currentScreen; currentScreen = newScreen; currentScreen.LoadContent(); }