Beispiel #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            try
            {
                GraphicsDevice.BlendState = BlendState.AlphaBlend;
                GraphicsDevice.Clear(new Color(0, 0, 00));

                if (contentLoadingState == ContentLoadingState.SPLASH_CONTENT_LOADED)
                {
                    contentLoadingState = ContentLoadingState.SPLASH_CONTENT_SHOWN;
                    spriteBatch.Begin();
                    spriteBatch.Draw(splashScreen, new Rectangle(0, 0, ScreenUtils.ScreenWidth, ScreenUtils.ScreenHeight), Color.White);
                    spriteBatch.End();
                }
                else if (contentLoadingState == ContentLoadingState.CONTENT_LOADED)
                {
                    core2d.CoreAnimation.Instance.Update(gameTime.TotalGameTime.TotalSeconds);
                    GameScreenManager.Instance.Draw();
                }
                base.Draw(gameTime);
            }
            catch (Exception e)
            {
                Debug.WriteLine("An exception in draw caught: " + e + " " + e.Message + " " + e.StackTrace);
            }
        }
Beispiel #2
0
        /// <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)
        {
            if (contentLoadingState == ContentLoadingState.SPLASH_CONTENT_SHOWN)
            {
                contentLoadingState = ContentLoadingState.LOADING_CONTENT;
                LoadContent();
            }
            else if (contentLoadingState != ContentLoadingState.CONTENT_LOADED)
            {
                base.Update(gameTime);
                return;
            }

            try
            {
                World.Instance.OnTimeUpdate(gameTime);
                ProcessTouchEvents();

                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    GameState.Instance.Save();

                    if (GameScreenManager.Instance.GetActiveScreenID().Equals(MenuScreen.ID))
                    {
                        this.Exit();
                    }
                    else if (GameScreenManager.Instance.GetActiveScreenID().Equals(GameOverScreen.ID))
                    {
                        GameScreenManager.Instance.MoveToScreen(MenuScreen.ID);
                    }
                    else if (GameScreenManager.Instance.GetActiveScreenID().Equals(BattleScreen.ID))
                    {
                        GameScreenManager.Instance.MoveToScreen(MenuScreen.ID);
                    }
                }
            }
            catch (Exception e)
            {
                // NOP
            }

//            AdGameComponent.Current.Update(gameTime);

            try
            {
                base.Update(gameTime);
            }
            catch (Exception e)
            {
                Debug.WriteLine("An exception in update caught: " + e + " " + e.Message + " " + e.StackTrace);
            }
        }
Beispiel #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            if (contentLoadingState == ContentLoadingState.FIRST_RUN)
            {
                splashScreen        = Content.Load <Texture2D>("SplashScreenImage");
                contentLoadingState = ContentLoadingState.SPLASH_CONTENT_LOADED;
                return;
            }

            ScreenUtils.OnLoadContent(GraphicsDevice, Content);
            GameScreenManager.Instance.OnLoadContent(new GameScreenManager.LoadContentEventArgs(Content));

            GameScreenManager.Instance.MoveToScreen(MenuScreen.ID);
            // Create a new SpriteBatch, which can be used to draw textures.

            contentLoadingState = ContentLoadingState.CONTENT_LOADED;
        }