/// <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); // TODO: use this.Content to load your game content here //sc = new SceneBattle(Content, GraphicsDevice); sc = new SceneTitle(Content); //sc = new SceneChessBoard(Content, GraphicsDevice); //sc = new SceneLoading(Content, @"Images/UI/progressBar"); DataSystem.fontDavida = Content.Load<SpriteFont>(@"Fonts/UTM-Davida"); DataSystem.fontArial = Content.Load<SpriteFont>(@"Fonts/Arial"); DataSystem.fontAvo = Content.Load<SpriteFont>(@"Fonts/UTM-Avo"); DataSystem.fontCourierNew = Content.Load<SpriteFont>(@"Fonts/CourierNew"); DataSystem.fontCourierNewSmall = Content.Load<SpriteFont>(@"Fonts/CourierNew-small"); }
void loadScene(GameScene scene) { sc = new SceneLoading(Content, @"Images/UI/progressBar"); curScene = GameScene.SceneLoading; tmpScene = scene; Thread loadSceneThread = new Thread(new ThreadStart(loadTempScene)); loadSceneThread.Start(); }
void loadTempScene() { switch (tmpScene) { case GameScene.SceneMenu: tmp = SceneMenu.getInstance(Content); break; case GameScene.SceneChessBoard: tmp = new SceneChessBoard(Content, GraphicsDevice); break; case GameScene.SceneOpening: tmp = new SceneOpening(Content, @"Video\Opening"); break; case GameScene.SceneResult: tmp = new SceneResult(Content, paramTmp); break; case GameScene.SceneBattle: tmp = new SceneBattle(Content, GraphicsDevice); break; } }
/// <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) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // TODO: Add your update logic here if (tmp != null) // Đã hoàn thành loadscene { sc = tmp; curScene = tmpScene; tmp = null; } int t = sc.Update(gameTime); if (t != 0) { switch (curScene) { case GameScene.SceneAbout: sc = SceneMenu.getInstance(Content); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); curScene = GameScene.SceneMenu; break; case GameScene.SceneTitle: sc = new SceneOpening(Content, @"Video\Opening"); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); curScene = GameScene.SceneOpening; break; case GameScene.SceneOpening: loadScene(GameScene.SceneMenu); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); break; case GameScene.SceneMenu: switch (t) { case 1: loadScene(GameScene.SceneChessBoard); sc.Update(gameTime); break; case 2: // Options sc = new SceneOption(Content); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); curScene = GameScene.SceneOption; break; case 3: // About sc = new SceneAbout(Content); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); curScene = GameScene.SceneAbout; break; case 4: // Quit this.Exit(); break; } break; case GameScene.SceneLoading: break; case GameScene.SceneChessBoard: switch (t) { case 4: // Chuyển sang SceneBattle DataSystem.keepScene = sc; loadScene(GameScene.SceneBattle); break; case 5: DataSystem.keepScene = sc; sc = new ScenePromote(Content); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; curScene = GameScene.ScenePromote; break; case 6: loadScene(GameScene.SceneMenu); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); break; default: paramTmp = t; loadScene(GameScene.SceneResult); break; } sc.Update(gameTime); break; case GameScene.SceneBattle: sc = DataSystem.keepScene; DataSystem.keepScene = null; sc.changeParam(t - 1); curScene = GameScene.SceneChessBoard; //sc.Update(gameTime); break; case GameScene.SceneResult: loadScene(GameScene.SceneMenu); sc.Update(gameTime); break; case GameScene.SceneOption: sc = SceneMenu.getInstance(Content); DataSystem.firstTime = (int)gameTime.TotalGameTime.TotalSeconds; sc.Update(gameTime); curScene = GameScene.SceneMenu; break; case GameScene.ScenePromote: sc = DataSystem.keepScene; DataSystem.keepScene = null; DataSystem.promote = t; sc.changeParam(2); curScene = GameScene.SceneChessBoard; //sc.Update(gameTime); break; } } //sceneOpening.Update(gameTime); base.Update(gameTime); }