Inheritance: HaxxitGameState
Exemplo n.º 1
0
        public override void Update()
        {
            MouseState mouse_state = Mouse.GetState(); // Gets the mouse state object
            Point mouse_position = new Point(mouse_state.X, mouse_state.Y); // creates a point for the mouse's position

            if (isBackButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    MainMenuGameState new_state = new MainMenuGameState();
                    Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                }
            }

            //Update for Start Button
            if (backRect.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isBackButtonClicked = true;
            }
            // if hovering over rectangle
            else if (backRect.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isBackButtonClicked = false;
            }

            //check to start new time capture
            if (!trackingTime)
            {
                timeElasped = GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds;
                trackingTime = true;
            }

            //position to next char in string array if certain amount of time has expired
            if (GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds - timeElasped >= MAX_TIME_BEFORE_NEXT_CHAR)
            {
                if (nextCharInString + 1 <= storyString.Count())
                {
                    nextCharInString++;
                }

                trackingTime = false;
            }

            //track blinking icon
            if (!trackBlink)
            {
                blinkingTimer = GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds;
                trackBlink = true;
            }

            //switch whether icon is shown or not based on amount of time that has passed
            if (GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds - blinkingTimer >= MAX_BLINK)
            {
                blinkIconIsShown = !blinkIconIsShown;
                trackBlink = false;
            }
        }
Exemplo n.º 2
0
        public override void Update()
        {
            MouseState mouse_state = Mouse.GetState(); // Gets the mouse state object
            Point mouse_position = new Point(mouse_state.X, mouse_state.Y); // creates a point for the mouse's position

            if (userWantsToSkip)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    MainMenuGameState new_state = new MainMenuGameState();
                    Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                }
            }

            //User clicks anywhere within window
            if (backgroundRect.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                userWantsToSkip = true;
            }

            //check to start new time capture
            if (!trackingTime)
            {
                timeElasped = GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds;
                trackingTime = true;
            }

            //check to start logo animation
            if (GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds - timeElasped >= STAY_ON_SCREEN)
            {
                startFadeIn = true;
                trackingTime = false;
            }

            //check to fade in, keep on screen or fade out
            if (startFadeIn)
            {
                if (fadeIn && alphaValue >= 1f)
                {
                    if (GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds - timeElasped >= STAY_ON_SCREEN)
                    {
                        fadeIn = false;
                    }
                }
                else if (fadeIn)
                {
                    if (GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds - timeElasped >= MAX_TIME_BEFORE_CHANGE)
                    {
                        alphaValue += .008f;
                        trackingTime = false;
                    }
                }
                else if (!fadeIn && alphaValue >= 0)
                {
                    if (GlobalAccessors.mGameTime.TotalGameTime.TotalMilliseconds - timeElasped >= MAX_TIME_BEFORE_CHANGE)
                    {
                        alphaValue -= .008f;
                        trackingTime = false;
                    }
                }
                else
                {
                    MainMenuGameState new_state = new MainMenuGameState();
                    Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                }
            }
        }