Exemplo n.º 1
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)
        {
            gameRef = this;
            if (bExited)
            {
                Exit();
            }

            if (bIsDebug && TestEnvironment.bDoTest && false)
            {
                TestEnvironment.Test();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.M) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                ToggleMouse();
            }

            //Console.WriteLine("Hello from Update");

            if (Keyboard.GetState().IsKeyDown(Keys.End) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                Console.WriteLine(Steamworks.SteamAPI.InitSafe());
            }

            SceneUtility.UpdateTransform();
            SceneUtility.Update(gameTime);
            SceneUtility.scenes = scenes;

            ResolutionUtility.bMouseIsVisible = this.IsMouseVisible;
            ResolutionUtility.mousePos.X      = Mouse.GetState().X;
            ResolutionUtility.mousePos.Y      = Mouse.GetState().Y;
            ResolutionUtility.KeyHandler(graphics, gameTime);
            //MouseMustStayWithinGame();
            buttonPressUtility.Update(gameTime);

            if (ResolutionUtility.stdScale != new Vector2(1))
            {
                this.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            }

            bIsActive = this.IsActive;
            //if (!bRunEditMode)
            //{
            //    MusicBGPlayer.Update(gameTime);
            //}

            //CursorUtility.update(gameTime);


            if (!bRunEditMode && !StartScreen.bIsRunning)
            {
                scenes[SceneUtility.currentScene].Update(gameTime, this);
            }
            else if (StartScreen.bIsRunning)
            {
                startScreen.Update(gameTime);
            }
            //else
            //{
            //    ScripTestingScene.Update(gameTime, this);
            //}

            if (SceneUtility.currentScene != (int)Screens.Editor)
            {
                buttonPressUtility.bPressed = true;
                Console.Out.WriteLine("You called the editor!");
                (scenes[(int)Screens.Editor] as Editor).preScreen = SceneUtility.prevScene;
                SceneUtility.ChangeScene((int)Screens.Editor);
                // SceneUtility.prevScene = SceneUtility.currentScene;
                //  SceneUtility.currentScene = (int)Screens.Editor;
                (scenes[(int)Screens.Editor] as Editor).scenes = scenes;
                (scenes[(int)Screens.Editor] as Editor).Start(this);
            }

            KeyboardMouseUtility.Update(this);

            //if (!bRunEditMode)
            //{

            //    if (SceneUtility.prevScene != SceneUtility.currentScene)
            //    {
            //        if (!scenes[SceneUtility.currentScene].bIsInitialized)
            //        {
            //            Console.Out.WriteLine("Called for: " + scenes[SceneUtility.currentScene]);
            //            scenes[SceneUtility.currentScene].Initialize(this);
            //        }
            //        else
            //        {
            //            scenes[SceneUtility.currentScene].Reload();
            //        }

            //    }

            //    if (SceneUtility.currentScene == (int)(Game1.Screens.ExitGame))
            //    {

            //        foreach (Scene scene in scenes)
            //        {
            //            scene.UnloadContent(this);
            //        }

            //        Exit();
            //    }

            //    if (buttonPressUtility.isPressedSub(EditorString) && !buttonPressUtility.bPressed && SceneUtility.currentScene != (int)Screens.Editor)
            //    {
            //        buttonPressUtility.bPressed = true;
            //        Console.Out.WriteLine("You called the editor!");
            //        (scenes[(int)Screens.Editor] as Editor).preScreen = SceneUtility.prevScene;
            //        SceneUtility.ChangeScene((int)Screens.Editor);
            //        // SceneUtility.prevScene = SceneUtility.currentScene;
            //        //  SceneUtility.currentScene = (int)Screens.Editor;
            //        (scenes[(int)Screens.Editor] as Editor).scenes = scenes;
            //        (scenes[(int)Screens.Editor] as Editor).Start(this);
            //    }
            //    else if (buttonPressUtility.isPressedSub(EditorString) && !buttonPressUtility.bPressed && SceneUtility.currentScene == (int)Screens.Editor)
            //    {
            //        buttonPressUtility.bPressed = true;
            //        Console.Out.WriteLine("You left the editor!");
            //        //TODO set the actual prevscreen before entering the editor
            //        SceneUtility.currentScene = SceneUtility.prevScene;
            //        SceneUtility.prevScene = (scenes[(int)Screens.Editor] as Editor).preScreen;
            //        (scenes[(int)Screens.Editor] as Editor).ResetBackToGame(this);
            //    }
            //}



            base.Update(gameTime);
        }