Beispiel #1
0
        public void Update(GameTime gameTime)
        {
            selectButton.Update(gameTime);

            keyboard = Keyboard.GetState();
            if (Selected)
            {
                if (keyboard.GetPressedKeys().Count() > 0)
                {
                    prevKey = Key;
                    Key     = keyboard.GetPressedKeys()[0];
                    Controls.SetControlFor(Control, Key);
                    keyChanged?.Invoke(Control);
                }
            }
        }
        public void Update(CannonSettings settings, User user, GameTime gameTime)
        {
            bool atMax = user.CannonSettings.GetValueOfStat(stat) == GameInfo.MaxStats[stat];

            upgradeButton.Active = (user.Coins >= cost) && !atMax;
            upgradeButton.Text   = atMax ? Language.Translate("Max Level") :
                                   Language.Translate("Upgrade") + " " + valueString;
            upgradeButton.Update(gameTime);
            currentValue = settings.GetValueOfStat(stat);

            cost       = GameInfo.GetCostOfStat(stat, settings.GetValueOfStat(stat));
            costString = atMax ? Language.Translate("Max Level") : Language.Translate("Cost") + ": " + cost;
            costPos.X  = bgRect.X + (bgRect.Width / 2 - (font.MeasureString(costString).X / 2));

            Rectangle mouseRect = new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 1, 1);

            HoveringOnItem = mouseRect.Intersects(iconRect);
        }
Beispiel #3
0
        public void Update(GameTime gameTime)
        {
            switch (state)
            {
            case SettingsState.Profile:

                usernameBox.Update(gameTime);
                rSlider.Update();
                gSlider.Update();
                bSlider.Update();

                nextProj.Update(gameTime);
                prevProj.Update(gameTime);

                break;

            case SettingsState.Graphics:

                brightnessSlider.Update();

                break;

            case SettingsState.Sound:

                systemSlider.Update();
                musicSlider.Update();
                sfxSlider.Update();
                muteToggle.Update(gameTime);
                dirXInstallButton.Update(gameTime);

                break;
            }

            replayTutorial.Update(gameTime);
            submit.Update(gameTime);

            profileButton.Active  = state != SettingsState.Profile;
            graphicsButton.Active = state != SettingsState.Graphics;
            soundButton.Active    = state != SettingsState.Sound;
            profileButton.Update(gameTime);
            graphicsButton.Update(gameTime);
            soundButton.Update(gameTime);
        }
        public void Update(Menu menu, GameTime gameTime)
        {
            currentKeyboard = Keyboard.GetState();

            if (currentKeyboard.IsKeyDown(Keys.Space) && !prevKeyboard.IsKeyDown(Keys.Space) && alienLoaded && !waitingForAction)
            {
                if (stage + 1 < TutorialStages.Instructions.Count)
                {
                    stage++;
                    PrepForStage(stage, menu);
                }
                else
                {
                    Playing = false;
                    onComplete?.Invoke();
                }
            }
            //else if (currentKeyboard.IsKeyDown(Keys.Left) && !prevKeyboard.IsKeyDown(Keys.Left) && alienLoaded)
            //{
            //    if (stage - 1 >= 0)
            //    {
            //        stage--;
            //        PrepForStage(stage, menu);
            //    }
            //}

            skipTutorialButton.Active = (stage == 0);
            if (stage == 0)
            {
                // Allow the user to skip
                skipTutorialButton.Update(gameTime);
            }

            if (alienTravelingTo.X > 0 && alienTravelingTo.Y > 0)
            {
                UpdateAlienLocation(gameTime);
            }

            prevKeyboard = currentKeyboard;
        }
Beispiel #5
0
        public void Update(GameTime gameTime)
        {
            if (cursorBlinkTimer.QueryWaitTime(gameTime))
            {
                showCursor = !showCursor;
            }

            cursorRectangle.Y = DrawRectangle.Y + CURSOR_SPACING;

            cursorBlinkTimer.Update(gameTime);

            textPos.X = DrawRectangle.X + TEXT_EDGE_SPACING_X;
            textPos.Y = DrawRectangle.Y + TEXT_EDGE_SPACING_Y;
            if (checkForClickButton != null)
            {
                checkForClickButton.X = this.X;
                checkForClickButton.Y = this.Y;
                checkForClickButton.Update(gameTime);
            }

            if (Active)
            {
                keyboard    = Keyboard.GetState();
                pressedKeys = keyboard.GetPressedKeys();
                key         = Microsoft.Xna.Framework.Input.Keys.None;
                if (pressedKeys.Count() > 0)
                {
                    var keys = pressedKeys.Where(x => x != Microsoft.Xna.Framework.Input.Keys.LeftShift &&
                                                 x != Microsoft.Xna.Framework.Input.Keys.RightShift &&
                                                 x != Microsoft.Xna.Framework.Input.Keys.LeftControl &&
                                                 x != Microsoft.Xna.Framework.Input.Keys.RightControl && !lastKeys.Contains(x)).ToList();
                    if (keys.Count > 0)
                    {
                        key = keys[0];
                    }
                    else if (pressedKeys.Contains(lastKey))
                    {
                        // Only allow key spamming if there is only one character key pressed
                        key = lastKey;
                    }
                }
                keyName = key.ToString();
                if (key != Microsoft.Xna.Framework.Input.Keys.None)
                {
                    // We know at this point that we are typing a key, like Enter or Backspace or a letter, number, or symbol
                    if (!spammingKey)
                    {
                        // We must first check to see if we have been pressing the key before
                        if (lastKeys.Contains(key))
                        {
                            // We have to check the long timer
                            typeTimerLong.Update(gameTime);
                            if (typeTimerLong.QueryWaitTime(gameTime))
                            {
                                spammingKey = true;
                                HandleKey(key);
                            }
                        }
                        else
                        {
                            typeTimerLong.Reset();
                            HandleKey(key);
                        }
                    }
                    else
                    {
                        if (lastKeys.Contains(key))
                        {
                            typeTimerShort.Update(gameTime);
                            if (typeTimerShort.QueryWaitTime(gameTime))
                            {
                                // We are pressing & holding a key and can now "spam" it
                                HandleKey(key);
                            }
                        }
                        else
                        {
                            spammingKey = false;
                        }
                    }
                }
                lastKey = key;

                #region Handle Caret Moving

                if (keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) && !arrowKeyPrevDown)
                {
                    arrowKeyPrevDown = true;
                    if (cursorPosition > 0)
                    {
                        cursorRectangle.X -= (int)font.MeasureString(text[cursorPosition - 1].ToString()).X + cursorRectangle.Width;
                        cursorPosition--;
                    }
                }
                else if (keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) && !arrowKeyPrevDown)
                {
                    arrowKeyPrevDown = true;
                    if (cursorPosition < text.Length)
                    {
                        cursorRectangle.X += (int)font.MeasureString(text[cursorPosition].ToString()).X + cursorRectangle.Width;
                        cursorPosition++;
                    }
                }
                else if (!(keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) || keyboard.IsKeyDown
                               (Microsoft.Xna.Framework.Input.Keys.Right)))
                {
                    arrowKeyPrevDown = false;
                }

                if (keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Home))
                {
                    cursorPosition    = 0;
                    cursorRectangle.X = DrawRectangle.X + TEXT_EDGE_SPACING_X;
                }
                else if (keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.End))
                {
                    cursorPosition    = text.Length;
                    cursorRectangle.X = DrawRectangle.X + ((int)font.MeasureString(text).X + cursorRectangle.Width);
                }

                #endregion

                #region Paste Support

                if ((keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl) || keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl)) &&
                    keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V) && !shortcutPreviouslyPressed)
                {
                    string clipboardText = Clipboard.GetText();
                    if (!(font.MeasureString(text + clipboardText).X > DrawRectangle.Width))
                    {
                        // The clipboard text is short enough, and will not extend past the textbox's length
                        text += clipboardText;
                    }
                    shortcutPreviouslyPressed = true;
                }
                else if (!((keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl) || keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl)) &&
                           keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.V)))
                {
                    shortcutPreviouslyPressed = false;
                }

                #endregion

                MouseState mouse     = Mouse.GetState();
                Rectangle  mouseRect = new Rectangle(mouse.X, mouse.Y, 1, 1);
                if (!(DrawRectangle.Intersects(mouseRect)) && mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                {
                    Active = false;
                }

                lastKeys = pressedKeys;
            }
        }
        public void Update(User user, GameTime gameTime)
        {
            bool changed = false;

            for (int i = 0; i < user.AchievementsCompleted.Count; i++)
            {
                for (int j = 0; j < displays.Count; j++)
                {
                    if (user.AchievementsCompleted[i].Id == displays[j].Achievement.Id && !displays[j].Completed)
                    {
                        displays[j].SetCompletion(true);
                        changed = true;
                        break;
                        // We break here because we found a display that matches the completed achievement
                        // Now we can move on to a new achievement without wasting processing power
                    }
                }
            }
            if (changed)
            {
                UpdatePagesToDisplays();
            }

            if (slideOffset + X_OFFSET >= windowWidth || slideOffset + (X_OFFSET * -1) <= windowWidth * -1)
            {
                slideOffset = 0;
                slidingOver = false;
                page        = transitionPage;
            }

            if (page <= pages.Count - 1)
            {
                if (slidingOver)
                {
                    int offset = 0;
                    if (slideSpd < 0)
                    {
                        offset = displays[0].Width + X_OFFSET;
                    }
                    else
                    {
                        offset = (displays[0].Width + X_OFFSET) * -1;
                    }
                    UpdatePositions(transitionPage, offset);
                }

                UpdatePositions(page, 0);
            }

            for (int i = 0; i <= pages.Count - 1; i++)
            {
                if (pages[i].Count <= 0)
                {
                    pages.RemoveAt(i);
                }
            }

            if (pages.Count <= 1)
            {
                // Both buttons should be disabled, as there is only 1 page
                // This must be tested for first, otherwise, since the page always starts equal to 0, the below criteria will be met
                // and the game will act like there are 2 pages when there is only 1
                nextButton.Active = false;
                prevButton.Active = false;
                // Since there is only one page, we have to set the page integer to 0
                page = 0;
            }
            else if (page == 0)
            {
                // There is another page, but we are on the first. Therefore, we cannot go backwards, so we'll disable the backwards button
                nextButton.Active = true;
                prevButton.Active = false;
            }
            else if (page + 1 == pages.Count)
            {
                // We are on the last page, so the forward button must be disabled
                nextButton.Active = false;
                prevButton.Active = true;
            }
            else
            {
                // We must be somewhere in the middle, so both buttons should be enabled
                nextButton.Active = true;
                prevButton.Active = true;
            }

            if (slidingOver)
            {
                slideOffset += slideSpd;
            }

            nextButton.Update(gameTime);
            prevButton.Update(gameTime);
        }
Beispiel #7
0
        public void Update(GameTime gameTime)
        {
            if (Active)
            {
                mouse = Mouse.GetState();

                fireworkTimer.Update(gameTime);
                if (fireworkTimer.QueryWaitTime(gameTime))
                {
                    Sound.PlaySound(Sounds.Firework);
                    fireworkTimer.WaitTime = Utilities.Rand.Next(FIREWORK_MILLISECS_MIN, FIREWORK_MILLISECS_MAX);
                }

                UpdateParticles();
                claimButton.Active = done;
                claimButton.Update(gameTime);
                if (done)
                {
                    itemRect.Width = itemRect.Height = ITEM_SIZE;
                    itemRect.Y     = bgRect.Y + SPACING + (int)font.MeasureString("A").Y;
                    itemRect.X     = bgRect.X + bgRect.Width / 2 - itemRect.Width / 2;
                }
                else
                {
                    if (waitingForItemToHide)
                    {
                        itemTimer.Update(gameTime);
                        if (itemTimer.QueryWaitTime(gameTime))
                        {
                            HideAndShowNextItem();
                        }
                    }
                    else if (growingItem)
                    {
                        GrowItemRect();
                        if (itemRect.Width >= ITEM_SIZE)
                        {
                            AfterGrow();
                        }
                    }
                    else if (risingItem)
                    {
                        RiseItemRect();
                        if (itemRect.Y <= bgRect.Y + ITEM_SIZE - ITEM_SIZE_SMALL + SPACING + font.MeasureString("A").Y)
                        {
                            itemRect.Y  = bgRect.Y + ITEM_SIZE - ITEM_SIZE_SMALL + SPACING + (int)font.MeasureString("A").Y;
                            risingItem  = false;
                            growingItem = true;
                        }
                    }

                    if (mouse.LeftButton == ButtonState.Pressed &&
                        prevMouse.LeftButton != ButtonState.Pressed)
                    {
                        if (waitingForItemToHide)
                        {
                            HideAndShowNextItem();
                        }
                        else if (growingItem || risingItem)
                        {
                            AfterGrow();
                        }
                    }

                    prevMouse = mouse;
                }
            }
        }
Beispiel #8
0
 public void Update(GameTime gameTime)
 {
     openButton.Update(gameTime);
 }
Beispiel #9
0
        public void Update(GameTime gameTime, User user)
        {
            // Update displaying time until next free gift
            TimeSpan timeUntil = user.LastReceivedGift.AddHours(GameInfo.HOURS_UNTIL_NEXT_GIFT) - DateTime.Now;

            nextGiftIn = Language.Translate("Next free gift in") + ": " +
                         string.Format("{0:00}:{1:00}:{2:00}", timeUntil.Hours, timeUntil.Minutes, timeUntil.Seconds);
            nextGiftInPos.X = windowWidth / 2 - font.MeasureString(nextGiftIn).X / 2;

            if (!(giftP?.Active == true))
            {
                if (slideOffset + X_OFFSET >= windowWidth || slideOffset + (X_OFFSET * -1) <= windowWidth * -1)
                {
                    slideOffset = 0;
                    slidingOver = false;
                    page        = transitionPage;
                }

                if (page <= pages.Count - 1)
                {
                    if (slidingOver)
                    {
                        int offset = 0;
                        if (slideSpd < 0)
                        {
                            offset = (interfaces[0].Width + SPACING) * 5 + X_OFFSET;
                        }
                        else
                        {
                            offset = ((interfaces[0].Width + SPACING) * 5 + X_OFFSET) * -1;
                        }
                        Reposition(transitionPage, offset, true, gameTime);
                    }

                    Reposition(page, 0, true, gameTime);
                }

                if (pages.Count <= 1)
                {
                    // Both buttons should be disabled, as there is only 1 page
                    // This must be tested for first, otherwise, since the page always starts equal to 0, the below criteria will be met
                    // and the game will act like there are 2 pages when there is only 1
                    nextButton.Active = false;
                    prevButton.Active = false;
                    // Since there is only one page, we have to set the page integer to 0
                    page = 0;
                }
                else if (page == 0)
                {
                    // There is another page, but we are on the first. Therefore, we cannot go backwards, so we'll disable the backwards button
                    nextButton.Active = true;
                    prevButton.Active = false;
                }
                else if (page + 1 == pages.Count)
                {
                    // We are on the last page, so the forward button must be disabled
                    nextButton.Active = false;
                    prevButton.Active = true;
                }
                else
                {
                    // We must be somewhere in the middle, so both buttons should be enabled
                    nextButton.Active = true;
                    prevButton.Active = true;
                }

                nextButton.Update(gameTime);
                prevButton.Update(gameTime);

                if (slidingOver)
                {
                    slideOffset += slideSpd;
                }
            }

            if (giftP?.Active == true)
            {
                giftP.Update(gameTime);
            }
        }
Beispiel #10
0
        public void Update(User user, bool?onlyBuyStone, GameTime gameTime)
        {
            // If onlyBuyStone == null, don't update anything
            if (onlyBuyStone == true)
            {
                ShopMaterialInterface s = materialInterfaces.Find(x => x.Item == Material.Stone);
                s.Update(user, true, gameTime);
                List <ShopMaterialInterface> woutStone = materialInterfaces.Except(new List <ShopMaterialInterface> {
                    s
                }).ToList();
                for (int i = 0; i < woutStone.Count; i++)
                {
                    woutStone[i].DisableAllButtons();
                }
            }
            else if (onlyBuyStone == false)
            {
                materialButton.Update(gameTime);
                cannonButton.Update(gameTime);
                giftsButton.Update(gameTime);

                switch (state)
                {
                case ShopState.Materials:
                    #region Materials

                    if (slideOffset + X_OFFSET >= windowWidth || slideOffset + (X_OFFSET * -1) <= windowWidth * -1)
                    {
                        slideOffset = 0;
                        slidingOver = false;
                        page        = transitionPage;
                    }

                    if (page <= materialPages.Count - 1)
                    {
                        if (slidingOver)
                        {
                            int offset = 0;
                            if (slideSpd < 0)
                            {
                                offset = (materialInterfaces[0].Width + SPACING) * 5 + X_OFFSET;
                            }
                            else
                            {
                                offset = ((materialInterfaces[0].Width + SPACING) * 5 + X_OFFSET) * -1;
                            }
                            UpdateMaterialPositions(transitionPage, user, offset, true, gameTime);
                        }

                        UpdateMaterialPositions(page, user, 0, true, gameTime);
                    }

                    bool mActive = false;
                    for (int i = 0; i < materialPages[page].Count; i++)
                    {
                        if (materialPages[page][i].HoveringOnItem)
                        {
                            mInfoHover.ResetMaterial(materialPages[page][i].Item);
                            mActive = true;
                            mInfoHover.Update();
                            break;
                        }
                    }
                    mInfoHover.Active = mActive;

                    for (int i = 0; i <= materialPages.Count - 1; i++)
                    {
                        if (materialPages[i].Count <= 0)
                        {
                            materialPages.RemoveAt(i);
                        }
                    }

                    //if (pages.Count <= 1)
                    //{
                    //    // Both buttons should be disabled, as there is only 1 page
                    //    // This must be tested for first, otherwise, since the page always starts equal to 0,
                    //the below criteria will be met
                    //    // and the game will act like there are 2 pages when there is only 1
                    //    nextButton.Active = false;
                    //    prevButton.Active = false;
                    //    // Since there is only one page, we have to set the page integer to 0
                    //    page = 0;
                    //}
                    //else if (page == 0)
                    //{
                    //    // There is another page, but we are on the first. Therefore, we cannot go backwards, so we'll disable the backwards button
                    //    nextButton.Active = true;
                    //    prevButton.Active = false;
                    //}
                    //else if (page + 1 == pages.Count)
                    //{
                    //    // We are on the last page, so the forward button must be disabled
                    //    nextButton.Active = false;
                    //    prevButton.Active = true;
                    //}
                    //else
                    //{
                    //    // We must be somewhere in the middle, so both buttons should be enabled
                    //    nextButton.Active = true;
                    //    prevButton.Active = true;
                    //}

                    //nextButton.Update();
                    //prevButton.Update();

                    if (slidingOver)
                    {
                        slideOffset += slideSpd;
                    }
                    break;
                    #endregion

                case ShopState.Cannons:
                    #region Cannons
                    for (int i = 0; i < cannonInterfaces.Count; i++)
                    {
                        cannonInterfaces[i].Update(user, gameTime);
                    }

                    bool cActive = false;
                    for (int i = 0; i < cannonInterfaces.Count; i++)
                    {
                        if (cannonInterfaces[i].HoveringOnItem)
                        {
                            if (user.Cannons.Where(x => x.CannonType == cannonInterfaces[i].Cannon.CannonType).Count() > 0)
                            {
                                cInfoHover.ResetCannon(user.Cannons.Where(x => x.CannonType == cannonInterfaces[i].Cannon.CannonType).First());
                            }
                            else
                            {
                                cInfoHover.ResetCannon(CannonSettings.SettingsForType(cannonInterfaces[i].Cannon.CannonType));
                            }
                            cActive = true;
                            cInfoHover.Update();
                            break;
                        }
                    }
                    cInfoHover.Active = cActive;

                    break;
                    #endregion

                case ShopState.Gifts:
                    #region Gifts
                    for (int i = 0; i < giftInterfaces.Count; i++)
                    {
                        giftInterfaces[i].Update(user, gameTime);
                    }
                    break;
                    #endregion
                }
            }
        }
Beispiel #11
0
        public void Update(GameTime gameTime, EnterDirection enterDir)
        {
            // Update Location
            if (viewButton != null)
            {
                viewButton.Text = Language.Translate("View");
            }

            if (enterDir == EnterDirection.Top && bgRect.Y == windowHeight)
            {
                bgRect.Y = 0 - bgRect.Height;
            }
            if (enterDir == EnterDirection.Bottom && bgRect.Y == 0 - bgRect.Height)
            {
                bgRect.Y = windowHeight;
            }

            hideButton.X = (bgRect.Width + bgRect.X) - (SPACING + hideButton.Width);
            hideButton.Y = bgRect.Y + (bgRect.Height / 2 - (hideButton.Height / 2));
            if (viewButton != null)
            {
                viewButton.X = hideButton.X - (viewButton.Width + SPACING);
                viewButton.Y = hideButton.Y;
            }

            textPos.X = bgRect.X + SPACING;
            textPos.Y = bgRect.Y + SPACING;

            // Update Objects
            if (viewButton != null && showing)
            {
                viewButton.Update(gameTime);
            }

            hideButton.Update(gameTime);

            if (showing)
            {
                timer.Update(gameTime);
            }

            if (timer.QueryWaitTime(gameTime))
            {
                leaving = true;
            }

            #region Entering and Leaving Animation

            if (entering)
            {
                currentDir = enterDir;
                if (enterDir == EnterDirection.Top)
                {
                    if (bgRect.Y < SPACING)
                    {
                        bgRect.Y += 2;
                    }
                    else
                    {
                        entering = false;
                    }
                }
                else if (enterDir == EnterDirection.Bottom)
                {
                    if (bgRect.Y > windowHeight - bgRect.Height - SPACING)
                    {
                        bgRect.Y -= 2;
                    }
                    else
                    {
                        entering = false;
                    }
                }
            }
            else if (leaving)
            {
                if (bgRect.Y < windowHeight / 2)
                {
                    if (bgRect.Y >= 0 - bgRect.Height)
                    {
                        bgRect.Y -= 2;
                    }
                    else
                    {
                        leaving = false;
                        showing = false;
                        Active  = false;
                    }
                }
                else
                {
                    if (bgRect.Y < windowHeight)
                    {
                        bgRect.Y += 2;
                    }
                    else
                    {
                        leaving = false;
                        showing = false;
                        Active  = false;
                    }
                }
            }

            #endregion
        }
        public void Update(ref List <Item> items, ref User user, List <Projectile> projectiles, bool needSweep,
                           bool restrictActions, GameTime gameTime)
        {
            keyState = Keyboard.GetState();

            List <ProjectileType> currentHotbar = user.Hotbar;

            for (int i = 0; i <= currentHotbar.Count - 1; i++)
            {
                if (GameInfo.CountOf(GameInfo.ProjListToTypesWithoutFlying(projectiles), currentHotbar[i]) == 0)
                {
                    // Resets the hotbar if there are no available projectiles of a certain type
                    List <ProjectileType> availableTypes = GameInfo.ProjListToTypesWithoutFlying(projectiles);
                    // Make sure that we can't include any projectiles that are already on our "hotbar"
                    availableTypes   = availableTypes.Except(availableTypes).ToList();
                    currentHotbar[i] = GameInfo.GetRandomProjType(availableTypes);
                }
                projAmountStrings[i] = "x" + AmountOf(currentHotbar[i], projectiles).ToString();
                projAmounts[i]       = AmountOf(currentHotbar[i], projectiles);

                projImgs[i] = Utilities.GetIconOf(currentHotbar[i]);
            }
            if (user.Hotbar != currentHotbar)
            {
                user.SetHotbar(currentHotbar);
            }

            projs = user.Hotbar;

            if (!restrictActions)
            {
                Rectangle mouseRect = new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 1, 1);
                for (int i = 0; i <= projRects.Count - 1; i++)
                {
                    if (((mouseRect.Intersects(projRects[i]) && Mouse.GetState().LeftButton == ButtonState.Pressed) ||
                         (keyState.IsKeyDown(KeyForHotbarSlot(i + 1)) && prevKeyState.IsKeyUp(KeyForHotbarSlot(i + 1)))) &&
                        projAmounts[i] > 0)
                    {
                        PrimaryProj = user.Hotbar[i];
                        SetHighlightSquare(PrimaryProj);
                    }
                }
                if (mouseRect.Intersects(rapidFireButton.Button.DrawRectangle))
                {
                    toolTip     = Language.Translate(MACH_TOOLTIP);
                    toolTipRect = new Rectangle(mouseRect.X - (int)mediumFont.MeasureString(toolTip).X,
                                                mouseRect.Y, (int)mediumFont.MeasureString(toolTip).X + SPACING,
                                                (int)mediumFont.MeasureString(toolTip).Y + SPACING);
                    toolTipLoc     = new Vector2(toolTipRect.X + SPACING / 2, toolTipRect.Y + SPACING / 2);
                    showingToolTip = true;
                }
                else if (mouseRect.Intersects(sweeperButton.DrawRectangle))
                {
                    toolTip     = Language.Translate(SWEEP_TOOLTIP);
                    toolTipRect = new Rectangle(mouseRect.X - (int)mediumFont.MeasureString(toolTip).X,
                                                mouseRect.Y, (int)mediumFont.MeasureString(toolTip).X + SPACING,
                                                (int)mediumFont.MeasureString(toolTip).Y + SPACING);
                    toolTipLoc     = new Vector2(toolTipRect.X + SPACING / 2, toolTipRect.Y + SPACING / 2);
                    showingToolTip = true;
                }
                else
                {
                    showingToolTip = false;
                }

                if (keyState.IsKeyDown(Controls.ToggleRapidFireKey) && prevKeyState.IsKeyUp(Controls.ToggleRapidFireKey))
                {
                    rapidFireButton.ClickWithSound();
                }
                rapidFireButton.Update(gameTime);
            }

            if (needSweep || !restrictActions)
            {
                if (keyState.IsKeyDown(Controls.SweepKey) && prevKeyState.IsKeyUp(Controls.SweepKey) && !Controls.CtrlPressed())
                {
                    sweeper.Sweep();
                }
                sweeperButton.Update(gameTime);
                sweeper.Update(ref items);
            }

            prevKeyState = keyState;
        }
Beispiel #13
0
 public void Update(GameTime gameTime)
 {
     toggleButton.Update(gameTime);
 }
 public void Update(GameTime gameTime)
 {
     closeButton.Update(gameTime);
     skipButton.Update(gameTime);
 }
Beispiel #15
0
 public void Update(GameTime gameTime)
 {
     proceedButton.Update(gameTime);
     cancelButton.Update(gameTime);
 }
        public void Update(User user, List <Projectile> projectiles, GameTime gameTime)
        {
            if (slideOffset + X_OFFSET >= windowWidth || slideOffset + (X_OFFSET * -1) <= windowWidth * -1)
            {
                slideOffset = 0;
                slidingOver = false;
                page        = transitionPage;
            }

            bool active = false;

            for (int i = 0; i < pages[page].Count; i++)
            {
                if (pages[page][i].HoveringOnItem && pages[page][i].Visible)
                {
                    active = true;
                    infoHover.ResetProjectile(pages[page][i].Output.Type);
                    infoHover.Update();
                }
            }
            infoHover.Active = active;

            if (page <= pages.Count - 1)
            {
                if (slidingOver)
                {
                    int offset = 0;
                    if (slideSpeed < 0)
                    {
                        offset = interfaces[0].Width + X_OFFSET;
                    }
                    else
                    {
                        offset = (interfaces[0].Width + X_OFFSET) * -1;
                    }
                    UpdatePositions(transitionPage, user, offset, projectiles, gameTime);
                }

                UpdatePositions(page, user, 0, projectiles, gameTime);
            }

            for (int i = 0; i <= pages.Count - 1; i++)
            {
                if (pages[i].Count <= 0)
                {
                    pages.RemoveAt(i);
                }
            }

            if (pages.Count <= 1)
            {
                // Both buttons should be disabled, as there is only 1 page
                // This must be tested for first, otherwise, since the page always starts equal to 0, the below criteria will be met
                // and the game will act like there are 2 pages when there is only 1
                nextButton.Active = false;
                prevButton.Active = false;
                // Since there is only one page, we have to set the page integer to 0
                page = 0;
            }
            else if (page == 0)
            {
                // There is another page, but we are on the first. Therefore, we cannot go backwards, so we'll disable the backwards button
                nextButton.Active = true;
                prevButton.Active = false;
            }
            else if (page + 1 == pages.Count)
            {
                // We are on the last page, so the forward button must be disabled
                nextButton.Active = false;
                prevButton.Active = true;
            }
            else
            {
                // We must be somewhere in the middle, so both buttons should be enabled
                nextButton.Active = true;
                prevButton.Active = true;
            }

            if (pages.Count > page + 1)
            {
                // If the next page doesn't contain any unlocked projectiles
                if (!pages[page + 1].Exists(x => x.Visible))
                {
                    nextButton.Active = false;
                }
            }

            if (slidingOver)
            {
                slideOffset += slideSpeed;
            }

            nextButton.Update(gameTime);
            prevButton.Update(gameTime);
        }
Beispiel #17
0
 public void Update(User user, GameTime gameTime)
 {
     buyButton.Active = user.Coins >= cost;
     buyButton.Update(gameTime);
 }