Inheritance: HaxxitGameState
Esempio 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 (isExitButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    ServerOverworldState new_state = new ServerOverworldState();
                    Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                }
            }

            //buy/download button
            if (isBuyButtonClicked && mAvailSingleProgramSelectedIndex != -1 && mAvailSingleProgramSelectedIndex < mBuyablePrograms.Count())
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    //Buy Program:
                    //Check to see if Player has enough Silicoins to purchase Program
                    if (mBuyablePrograms[mAvailSingleProgramSelectedIndex].ProgramCost <= mPlayer1InShop.TotalSilicoins)
                    {
                        if (!mPlayer1InShop.OwnsProgrm(mBuyablePrograms[mAvailSingleProgramSelectedIndex]))
                        {
                            //if player does, deduct amount of program cost from player's silicoins
                            mPlayer1InShop.RemoveSilicoins((ushort)mBuyablePrograms[mAvailSingleProgramSelectedIndex].ProgramCost);

                            //Add program to Player's inventory
                            mPlayer1InShop.AddProgram(mBuyablePrograms[mAvailSingleProgramSelectedIndex]);
                        }
                        else
                        {
                            //if they do display to user they already have program
                            ShopStateDialogBox new_state = new ShopStateDialogBox(this, "You already have that program.");
                            Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                        }
                    }
                    else
                    {
                        //if not display to user they don't have enough silicoins
                        ShopStateDialogBox new_state = new ShopStateDialogBox(this, "You don't have enough silicoins.");
                        Mediator.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
                    }

                    //released button click state
                    isBuyButtonClicked = false;
                }
            }
            else
            {
                isBuyButtonClicked = false;
            }

            //update for player scroll up clicked
            if (isPlayerScrollUpButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    if (selectorMinPos - 1 >= 0)// mPlayer1InShop.GetPrograms().Count())
                    {
                        selectorMinPos--;
                    }

                    isPlayerScrollUpButtonClicked = false;
                }
            }

            //update for player scroll down clicked
            if (isPlayerScrollDownButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    if (selectorMinPos + 1 <= mPlayer1InShop.GetPrograms().Count() - 5)
                    {
                        selectorMinPos++;
                    }

                    isPlayerScrollDownButtonClicked = false;
                }
            }

            //update for available scroll up clicked
            if (isAvailScrollUpButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    if (selectorAvailMinPos - 1 >= 0)// mPlayer1InShop.GetPrograms().Count())
                    {
                        selectorAvailMinPos--;
                    }

                    isAvailScrollUpButtonClicked = false;
                }
            }

            //update for available scroll down clicked
            if (isAvailScrollDownButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    if (selectorAvailMinPos + 1 <= mBuyablePrograms.Count - 5)
                    {
                        selectorAvailMinPos++;
                    }

                    isAvailScrollDownButtonClicked = false;
                }
            }

            //update for scroll up
            if (mPlayerScrollUp.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isPlayerScrollUpButtonClicked = true;
            }
            // if hovering over rectangle
            else if (mPlayerScrollUp.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isPlayerScrollUpButtonClicked = false;
            }

            //update for scroll down
            if (mPlayerScrollDown.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isPlayerScrollDownButtonClicked = true;
            }
            // if hovering over rectangle
            else if (mPlayerScrollDown.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isPlayerScrollDownButtonClicked = false;
            }

            //update for scroll up
            if (mAvailScrollUp.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isAvailScrollUpButtonClicked = true;
            }
            // if hovering over rectangle
            else if (mAvailScrollUp.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isAvailScrollUpButtonClicked = false;
            }

            //update for scroll down
            if (mAvailScrollDown.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isAvailScrollDownButtonClicked = true;
            }
            // if hovering over rectangle
            else if (mAvailScrollDown.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isAvailScrollDownButtonClicked = false;
            }

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

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

            //figuring out what program player selected out of their inventory
            for (int i = 0; i < 5; i++) //mPlayersProgramsSelectable.Count(); i++)
            {
                // if clicking within rectangle within players programs
                if (mPlayersProgramsSelectable[i].Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
                {
                    //Update Program Info
                    //Program
                    mPlayerSingleProgramSelectedIndex = i + selectorMinPos;
                    mIsAPlayerProgramSelected = true;
                    return;
                }
                else // neither clicking nor hovering over rectangle
                {

                }
            }

            //figuring out what program player selected out of buyable programs
            for (int i = 0; i < 5; i++) //mBuyablePrograms.Count(); i++)
            {
                // if clicking within rectangle within players programs
                if (mAvailProgramsSelectable[i].Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
                {
                    //Update Program Info
                    //Program
                    mAvailSingleProgramSelectedIndex = i + selectorAvailMinPos;
                    mIsAnAvailProgramSelected = true;
                    return;
                }
                else // neither clicking nor hovering over rectangle
                {

                }
            }
        }
Esempio 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 (isContinueButtonClicked)
            {
                if (mouse_state.LeftButton == ButtonState.Released)
                {
                    ServerOverworldState new_state = new ServerOverworldState();
                    Mediator.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
                }
            }

            //Update for Continue Button
            if (ContinueButtonRect.Contains(mouse_position) && mouse_state.LeftButton == ButtonState.Pressed)
            {
                isContinueButtonClicked = true;
            }
            // if hovering over rectangle
            else if (ContinueButtonRect.Contains(mouse_position))
            {
            }
            else // neither clicking nor hovering over rectangle
            {
                isContinueButtonClicked = 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;
            }
        }