예제 #1
0
        public SceneManager(Game game)
            : base(game)
        {
            this.game = game;

            floorEffect = Game.Content.Load <Effect>("effects");
            player      = Game.Content.Load <PlayerData>("Configuration/PlayerData");
            tankmode    = Game.Content.Load <Mode[]>(@"Configuration/TankMode");
            world       = Game.Content.Load <WorldMatrix>("Configuration/WorldData");
            tankStatus  = new TankStatusMode(tankmode[0]);


            city             = new City();
            background       = new BackGround(game);
            inputHandler     = new InputHandler();
            textHandler      = new TextHandler();
            levelHander      = new GameLevelHandler(Game.Content);
            explosionHandler = new ExplosionHandler(game);
            gameMenu         = new GameMenuScreen(game, levelHander);
            worldData        = new GameWorldData(world);
            camera           = new FirstPersonCamera(game);
            background.InitializeModel(floorEffect);

            camera.prepareCamera();
            camera.setWeapon(Game.Content.Load <Model>(@"Models\weapon"));
        }
예제 #2
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            float         time       = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;
            MouseState    mouseState = Mouse.GetState();
            KeyboardState keyState   = Keyboard.GetState();

            //Console.WriteLine(levelHander.GetGameState.ToString());

            if (levelHander.GetGameState == GameLevelHandler.GameState.INITIALIZE)
            {
                playerHealth = player.hp;
                playerScore  = player.score;
                octreeWorld  = new Octree(game, this, worldData);
                LoadWorldModels();
                octreeWorld.Initialize(levelHander.GetEmemyData, tankStatus, gameTime, player);
                Game.Components.Remove(gameMenu);
                Game.Components.Add(camera);
                music = new Music(game);
                game.IsMouseVisible = false;
                textHandler.UpdateText(this);
                city.SetUpCity(Game.GraphicsDevice, sceneryTexture);
                music.BackGroundPlay();
                levelHander.SetGameState = GameLevelHandler.GameState.PLAY;
            }
            else if (levelHander.GetGameState == GameLevelHandler.GameState.PLAY)
            {
                levelHander.UpdateGameStatus(playerScore, playerHealth);
                textHandler.UpdateText(this);
                inputHandler.UpdateWorld(gameTime, camera, this, music);
                octreeWorld.Update(gameTime, camera, levelHander.GetEmemyData);
                explosionHandler.Update(gameTime);
            }
            else if (levelHander.GetGameState == GameLevelHandler.GameState.FINISHING)
            {
                Game.Components.Remove(camera);

                music.BackgroundStop();
                game.IsMouseVisible = true;
                levelHander         = new GameLevelHandler(Game.Content);
                gameMenu            = new GameMenuScreen(game, levelHander);
                Game.Components.Add(gameMenu);
                levelHander.SetFinalScore(playerScore);
                levelHander.SetGameState = GameLevelHandler.GameState.END;
            }
        }