protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); baseFont = this.Content.Load <SpriteFont>(Consts.SF_BaseFont); baseFontBig = this.Content.Load <SpriteFont>(Consts.SF_BaseFontBig); mainMenu.LoadButtonList(this); pauseMenu.LoadButtonList(this); tutorialMenu.LoadButtonList(this); aboutMenu.LoadButtonList(this); player.Load(this); backBackground.Load(this); foreBackground.Load(this); walkPlace.Load(this); barriers.Load(this); moneys.Load(this); modifiers.Load(this); collosion.Load(this); }
protected override void Update(GameTime gameTime) { switch (gameState) { //NOTE: LOAD LEVEL case GameState.LoadLevel: if (firstEntry) { player.RePosition(); firstEntry = false; Thread loadThread = new Thread(() => { foreach (PlayerBackground item in backgroundList) { item.RePosition(); } string level = LevelHelper.SelectLevel(); barriers = new Barriers(level, 4); barriers.Load(this); moneys = new Moneys(level, 4); moneys.Load(this); modifiers = new Modifiers(level, 4); modifiers.Load(this); collosion = new Collosion(barriers, player, moneys, modifiers, backgroundList); collosion.Load(this); gameState = GameState.Gaming; //Transitions.ChangeGameState(ref firstEntry); }); loadThread.Start(); } player.Update(this, ref firstEntry); backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); break; //NOTE: GAMING case GameState.Gaming: if (firstEntry) { firstEntry = false; } else { if (LevelHelper.IsLevelEnd(moneys)) { player.isEnd = true; if (player.Position.X >= Consts.PhoneWidth) { Transitions.ChangeGameState(ref firstEntry); gameState = GameState.InEndGameMenu; } } player.Update(this, ref firstEntry); backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); barriers.Scroll(this); moneys.Scroll(this); modifiers.Scroll(this); collosion.Update(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { gameState = GameState.InPauseMenu; firstEntry = true; } } break; //NOTE: MAIN MENU case GameState.InMainMenu: if (firstEntry) { player.Score.LoadTotalScore(); player.Score.LoadHighScore(); mainMenu = new Menu(mainButtons); player.isDead = false; player.isEatMoney = false; player.isEatModifier = false; backBackground.RePosition(); foreBackground.RePosition(); walkPlace.RePosition(); collosion.Reset(); firstEntry = false; } backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); gameState = mainMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } break; //NOTE: PAUSE MENU case GameState.InPauseMenu: if (firstEntry) { pauseMenu = new Menu(pauseButtons); firstEntry = false; } gameState = pauseMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Transitions.ChangeGameState(ref firstEntry); player.Score.GameScore = 0; gameState = GameState.InMainMenu; } break; //NOTE: TUTORIAL case GameState.InTutorial: backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); gameState = tutorialMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Transitions.ChangeGameState(ref firstEntry); gameState = GameState.InMainMenu; } break; //NOTE: ABOUT case GameState.About: backBackground.Scroll(this); foreBackground.Scroll(this); walkPlace.Scroll(this); gameState = aboutMenu.IsTouched(this, TouchPanel.GetState(), gameState, ref firstEntry); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Transitions.ChangeGameState(ref firstEntry); gameState = GameState.InMainMenu; } break; //NOTE: ENDGAME MENU case GameState.InEndGameMenu: player.Score.SaveTotalScore(); player.Score.SaveHighScore(); gameState = GameState.InMainMenu; break; default: break; } base.Update(gameTime); }