public virtual Background clone() { Background copy = new Background(data); copy.loadTextures(); return copy; }
protected override void Update(GameTime gameTime) { switch (_gameState) { case GameState.Initializing: Logger.log("Initializing in LoderGame.Update"); _gameState = GameState.Intro; handleArgs(); break; case GameState.Intro: Logger.log("In Intro game state in LoderGame.Update"); // TODO: Do some sort of intro, and then open the main menu Logger.log("Creating background object."); Background background = new Background(ResourceManager.getResource("main_menu_background")); Logger.log("Creating main menu screen."); _mainMenuScreen = new MainMenuScreen(this); Logger.log("Loading background textures."); background.loadTextures(); _menuBackgroundRenderer.background = background; Logger.log("Changing game state to MainMenu."); openMainMenu(true); _gameState = GameState.MainMenu; break; case GameState.MainMenu: _menuBackgroundScreenOffset += new Vector2(0.005f, 0f); _menuBackgroundRenderer.update(35f, _menuBackgroundScreenOffset); _systemManager.process(gameTime); break; case GameState.WorldMap: _systemManager.process(gameTime); break; case GameState.LoadingLevel: _systemManager.process(gameTime); if (!_levelSystem.isFinishedLoading) { _levelSystem.load(); } else if (_levelSystem.isFinishedLoading && !_levelSystem.finalized) { _levelSystem.relax(); _levelSystem.clean(); _levelSystem.callScripts(); _levelSystem.finalized = true; _levelSystem.switchToLevel(_levelSystem.lastLevelUidLoaded, _levelSystem.getPlayerSpawn(_levelSystem.lastLevelUidLoaded)); _loadingScreen.message = "Starting level!"; _screenSystem.addTransition(new ScreenFadeOutTransition(_loadingScreen, Color.Black, true, 0.05f, null, () => { _screenSystem.removeScreen(_loadingScreen); _gameState = GameState.Level; IsFixedTimeStep = true; _levelSystem.paused = false; _levelScreen = new LevelScreen(this, _systemManager, _entityManager); _screenSystem.addScreen(_levelScreen); _screenSystem.addTransition(new ScreenFadeInTransition(_levelScreen, Color.Black, true, 0.025f)); })); } break; case GameState.Level: _systemManager.process(gameTime); break; } base.Update(gameTime); }
// Set the background to render public void setBackground(Background background) { _backgroundRenderer.background = background; }
// Create background public void createBackgrounds() { foreach (XElement levelData in _levelsData.Values) { string backgroundUid; XElement backgroundData; Background background; backgroundUid = Loader.loadString(levelData.Attribute("background_uid"), "default_background"); backgroundData = ResourceManager.getResource(backgroundUid); background = new Background(backgroundData); background.loadTextures(); _backgrounds.Add(levelData.Attribute("name").Value, background); } }