Exemple #1
0
        protected override void Initialize()
        {
            this.Window.Title = "Ariyana : Defence of the Keep!";

            splashScreen = new SplashScreen();
            gameBoard    = new GameBoard();

            Configuration singleton = Configuration.Instance;

            gameBoardManager = new GameBoardManager();
            singleton.Initialize(graphics);
            newTitleScreen = new TitleScreen();
            introScreen    = new Cinematic();
            newsound       = new Sound();

            GameBoardManager.Initilize();
            HUDManager.Initilize();

            gameBoard.ClearBoard();
            stopWatch.Start();

            gameState = GameStates.SplashScreen;

            base.Initialize();
        }
Exemple #2
0
        protected override void Update(GameTime gameTime)
        {
            switch (gameState)
            {
            case GameStates.SplashScreen:

                if (!splashScreen.getVideoPlaying())
                {
                    splashScreen.playVideo();
                    newsound.stopSong();
                }
                splashScreen.Update();
                break;

            case GameStates.Playing:
                if (!restartGame)
                {
                    if (!GameBoardManager.gameStarted)
                    {
                        GameBoardManager.gameStarted = true;
                        stopWatch.Restart();
                    }
                    if (!paused)
                    {
                        GameBoardManager.updateGameBoard();
                        HUDManager.updateHUDScreen(gameTime);
                    }

                    if (!(newsound.getSongPlaying()) && audioEnabled)
                    {
                        newsound.playSong();
                    }

                    if (!stopWatch.IsRunning)
                    {
                        stopWatch.Start();
                    }
                }
                else
                {
                    restartGame = false;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.Escape) || (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed))
                {
                    gameState   = GameStates.TitleScreen;
                    titleState  = TitleStates.Start;
                    restartGame = true;
                    paused      = true;
                    stopWatch.Stop();
                }
                break;

            case GameStates.TitleScreen:
                if (TitleScreen.timeSinceStart == 0)
                {
                    TitleScreen.timeSinceStart = (int)stopWatch.ElapsedMilliseconds / 1000;
                }
                newTitleScreen.Update();

                if (!(newsound.getSongPlaying()) && audioEnabled)
                {
                    newsound.playSong();
                }

                if (intro.getVideoPlaying())
                {
                    intro.stopVideo();
                }

                if (newTitleScreen.exitGame)
                {
                    Exit();
                }
                break;

            case GameStates.GameOver:
                if (Keyboard.GetState().IsKeyDown(Keys.Escape) || (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed))
                {
                    gameState = GameStates.TitleScreen;
                    GameBoardManager.resetGameBoard();
                    HUDManager.Initilize();
                    restartGame = true;
                    paused      = false;
                    titleState  = TitleStates.Start;

                    if (replayGame == true)
                    {
                        newsound.stopSong();
                        Initialize();
                        LoadContent();
                        gameState = GameStates.TitleScreen;
                        GameStats.resetStats();
                    }
                }
                else
                {
                    GameBoardManager.updateGameBoard();
                    HUDManager.updateHUDScreen(gameTime);
                }
                break;

            case GameStates.Intro:
                if (!intro.getVideoPlaying())
                {
                    intro.playVideo();
                    newsound.stopSong();
                }
                intro.Update();
                break;
            }

            base.Update(gameTime);
        }