Beispiel #1
0
        public Popup(ContentManager content, OnButtonClick whenOkButtonClicked, string checkboxSprite, string checkSprite,
                     SpriteFont font, string transAsset, int windowWidth, int windowHeight, bool hasCancelButton, SpriteFont bigFont)
        {
            this.hasCancelButton = hasCancelButton;

            backgroundImage = content.Load <Texture2D>(transAsset);
            drawRectangle   = new Rectangle(0, 0, BACKGROUND_WIDTH, BACKGROUND_HEIGHT);

            whenCancelButtonClicked  = new OnButtonClick(HidePopup);
            this.whenOkButtonClicked = whenOkButtonClicked;

            queryCheckbox = new Checkbox(LanguageTranslator.Translate("Do not show again"), content, font, checkboxSprite, checkSprite);

            this.font = font;

            okButton = new MenuButton(new OnButtonClick(OnButtonClick), BUTTON1, content, 0, 0, true, bigFont);
            if (hasCancelButton)
            {
                cancelButton = new MenuButton(whenCancelButtonClicked, BUTTON2, content, 0, 0, true, bigFont);
            }

            textPosition = new Vector2(0, 0);

            transImg     = content.Load <Texture2D>(transAsset);
            transRect    = new Rectangle(0, 0, windowWidth, windowHeight);
            transColor   = Color.Black;
            transColor.A = ALPHA;
        }
Beispiel #2
0
        public ShopItemInterface(ContentManager content, string whiteRectAsset, Skin itemSkin, SpriteFont smallFont, SkinAction buyClicked,
                                 int cost, int x, int y, int itemWidth, int itemHeight, string tongueAsset)
        {
            // Initialize image objects
            bgImg      = content.Load <Texture2D>(whiteRectAsset);
            costString = cost.ToString() + "c";
            name       = itemSkin.Name;

            this.skinBought = buyClicked;
            this.ItemSkin   = itemSkin;
            this.Cost       = cost;
            this.font       = smallFont;

            bgColor.R = 124;
            bgColor.G = 216;
            bgColor.B = 247;

            // Initialize positioning objects
            bgRect  = new Rectangle(x, y, BG_WIDTH, BG_HEIGHT);
            namePos = new Vector2(bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(name).X / 2)), bgRect.Y + SPACING);

            buyButton   = new MenuButton(new OnButtonClick(SkinClicked), LanguageTranslator.Translate("Buy") + " (" + cost + "c)", content, 0, 0, true, font);
            buyButton.X = bgRect.X + (bgRect.Width / 2 - (buyButton.Width / 2));
            buyButton.Y = bgRect.Bottom - buyButton.Height - SPACING;

            costPos = new Vector2(bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(costString).X / 2)),
                                  buyButton.Y - SPACING - (int)(font.MeasureString(costString).Y));

            snake   = new Snake(itemSkin, 0, 0, content, tongueAsset);
            snake.X = bgRect.X + (bgRect.Width / 2 - (snake.Width / 2));
            snake.Y = (int)costPos.Y - snake.Height - SPACING;

            itemType = ShopItemType.Skin;
        }
Beispiel #3
0
        public void Update(bool isBuyButtonActive)
        {
            // Update Values
            buyButton.Text = LanguageTranslator.Translate("Buy") + " (" + Cost + "c)";
            name           = LanguageTranslator.Translate(name);
            costString     = Cost + "c";
            if (Cost == 0)
            {
                buyButton.Text = LanguageTranslator.Translate("Buy") + " (" + LanguageTranslator.Translate("Free") + ")";
            }

            namePos.X = bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(name).X / 2));
            namePos.Y = bgRect.Y + SPACING;
            if (itemType == ShopItemType.Powerup)
            {
                costPos.Y  = buyButton.Y - SPACING - (int)(font.MeasureString(costString).Y);
                itemRect.X = bgRect.X + (bgRect.Width / 2 - (itemRect.Width / 2));
                itemRect.Y = (int)costPos.Y - itemRect.Height - SPACING;
            }
            else
            {
                costPos.Y = buyButton.Y - SPACING - (int)(font.MeasureString(costString).Y);
                snake.X   = bgRect.X + (bgRect.Width / 2 - (snake.Width / 2));
                snake.Y   = (int)costPos.Y - snake.Height - SPACING;
            }

            costPos.X   = bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(costString).X / 2));
            buyButton.X = bgRect.X + (bgRect.Width / 2 - (buyButton.Width / 2));
            buyButton.Y = bgRect.Bottom - buyButton.Height - SPACING;

            buyButton.Active = isBuyButtonActive;

            // Update Objects
            buyButton.Update();
        }
Beispiel #4
0
        public void Collect(int windowWidth, int windowHeight)
        {
            this.windowWidth  = windowWidth;
            this.windowHeight = windowHeight;

            if (!IsPickedUp)
            {
                IsPickedUp     = true;
                ShowingDisplay = true;
                switch (this.Type)
                {
                case PowerupType.Speed:
                    display = LanguageTranslator.Translate("Speed");
                    break;

                case PowerupType.Teleport:
                case PowerupType.Restart:
                    display = LanguageTranslator.Translate("Teleport");
                    break;

                case PowerupType.WallBreaker:
                    display = LanguageTranslator.Translate("Electric");
                    break;

                case PowerupType.Jackpot:
                    display = LanguageTranslator.Translate("Jackpot");
                    break;

                case PowerupType.Frozen:
                    display = LanguageTranslator.Translate("Frozen");
                    break;

                case PowerupType.Forcefield:
                    display = LanguageTranslator.Translate("Forcefield");
                    break;
                }
                displayPos.X = drawRectangle.X;
                displayPos.Y = drawRectangle.Y;
                if (displayPos.X + font.MeasureString(display).X > windowWidth)
                {
                    // The display text doesn't fit on the screen (right side)
                    displayPos.X = windowWidth - font.MeasureString(display).X;
                }
                else if (displayPos.X < 0)
                {
                    // The display text doesn't fit on the screen (left side)
                    displayPos.X = 0;
                }
                if (displayPos.Y + font.MeasureString(display).Y > windowHeight)
                {
                    // The display text doesn't fit on the screen (bottom)
                    displayPos.Y = windowHeight - font.MeasureString(display).Y;
                }
                else if (displayPos.Y < 0)
                {
                    // The display text doesn't fit on the screen (top)
                    displayPos.Y = 0;
                }
            }
        }
Beispiel #5
0
        public SkinInterface(Skin skin, SkinAction whenSelectClicked, ContentManager content, string bgAsset, SpriteFont font, string tongueAsset,
                             int x, int y)
        {
            this.Skin         = skin;
            this.font         = font;
            this.skinSelected = whenSelectClicked;

            color   = Color.White;
            color.R = 124;
            color.G = 216;
            color.B = 247;

            bgRect = new Rectangle(x, y, WIDTH, HEIGHT);

            skinName    = skin.Name;
            skinNamePos = new Vector2(bgRect.X + (bgRect.Width / 2 - ((int)font.MeasureString(skinName).X / 2)), bgRect.Y + SPACING);

            selectButton = new MenuButton(new OnButtonClick(SelectClicked), LanguageTranslator.Translate("Select"), content, 0, 0,
                                          true, font);
            selectButton.X = bgRect.X + (bgRect.Width / 2 - (selectButton.Width / 2));
            selectButton.Y = bgRect.Bottom - selectButton.Height - SPACING;

            snake   = new Snake(skin, 0, 0, content, tongueAsset);
            snake.X = bgRect.X + (bgRect.Width / 2 - (snake.Width / 2));
            snake.Y = selectButton.Y - snake.Rectangle.Height - SPACING;

            bgImg = content.Load <Texture2D>(bgAsset);
        }
Beispiel #6
0
        public void Update()
        {
            okButton.Text = LanguageTranslator.Translate("Okay");
            if (hasCancelButton)
            {
                cancelButton.Text = LanguageTranslator.Translate("Cancel");
            }
            if (active && hasCheckbox)
            {
                queryCheckbox.Text = LanguageTranslator.Translate("Do not show again.");
            }

            if (active)
            {
                okButton.Update();
                if (hasCancelButton)
                {
                    cancelButton.Update();
                }
                if (hasCheckbox)
                {
                    queryCheckbox.Update();
                }
            }

            // set button positions so they are correctly aligned with the popup background
            if (hasCancelButton)
            {
                okButton.X     = drawRectangle.X + SPACING_X;
                okButton.Y     = drawRectangle.Y + drawRectangle.Height - SPACING_Y;
                cancelButton.X = drawRectangle.Right - (SPACING_X + cancelButton.Width);
                cancelButton.Y = drawRectangle.Y + drawRectangle.Height - SPACING_Y;
            }
            else
            {
                // No cancel button, center Ok Button
                okButton.X = drawRectangle.X + (drawRectangle.Width / 2 - (okButton.Width / 2));
                okButton.Y = drawRectangle.Y + drawRectangle.Height - SPACING_Y;
            }

            // set the checkbox and text positions so they are correctly aligned with the popup background
            if (hasCheckbox)
            {
                queryCheckbox.X = okButton.DrawRectangle.Left;
                queryCheckbox.Y = okButton.DrawRectangle.Top - SPACING_Y;
            }
            textPosition.X = drawRectangle.X + SPACING_X;
            textPosition.Y = (float)drawRectangle.Y + SPACING_Y;
        }
Beispiel #7
0
        public void Update()
        {
            // Update Positioning  Vars
            skinNamePos.X  = bgRect.X + (bgRect.Width / 2 - ((int)font.MeasureString(skinName).X / 2));
            skinNamePos.Y  = bgRect.Y + SPACING;
            selectButton.X = bgRect.X + (bgRect.Width / 2 - (selectButton.Width / 2));
            selectButton.Y = bgRect.Bottom - selectButton.Height - SPACING;
            snake.X        = bgRect.X + (bgRect.Width / 2 - (snake.Width / 2));
            snake.Y        = selectButton.Y - snake.Rectangle.Height - SPACING;

            // Update Objects
            skinName = LanguageTranslator.Translate(skinName);

            selectButton.Update();
        }
Beispiel #8
0
        public ShopItemInterface(ContentManager content, string whiteRectAsset, string itemAsset, SpriteFont smallFont, OnButtonClick buyClicked,
                                 string itemName, int cost, int x, int y, int itemWidth, int itemHeight, ItemType powerupType)
        {
            // Initialize image objects
            bgImg      = content.Load <Texture2D>(whiteRectAsset);
            itemImg    = content.Load <Texture2D>(itemAsset);
            costString = cost.ToString() + "c";
            name       = itemName;

            this.Cost = cost;
            this.font = smallFont;

            bgColor.R = 124;
            bgColor.G = 216;
            bgColor.B = 247;

            // Initialize positioning objects
            bgRect  = new Rectangle(x, y, BG_WIDTH, BG_HEIGHT);
            namePos = new Vector2(bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(name).X / 2)), bgRect.Y + SPACING);

            buyButton   = new MenuButton(buyClicked, LanguageTranslator.Translate("Buy") + " (" + cost + "c)", content, 0, 0, true, font);
            buyButton.X = bgRect.X + (bgRect.Width / 2 - (buyButton.Width / 2));
            buyButton.Y = bgRect.Bottom - buyButton.Height - SPACING;
            if (cost == 0)
            {
                buyButton.Text = LanguageTranslator.Translate("Buy") + " (" + LanguageTranslator.Translate("Free") + ")";
            }

            costPos = new Vector2(bgRect.X + (bgRect.Width / 2 - (int)(font.MeasureString(costString).X / 2)),
                                  buyButton.Y - SPACING - (int)(font.MeasureString(costString).Y));

            itemRect   = new Rectangle(bgRect.X + (bgRect.Width / 2 - (itemWidth / 2)), 0, itemWidth, itemHeight);
            itemRect.Y = (int)costPos.Y - itemRect.Height - SPACING;

            this.PowerupType = powerupType;
            itemType         = ShopItemType.Powerup;
        }
Beispiel #9
0
 private void FrozenBought()
 {
     itemsToAdd.Add(new InventoryItem(LanguageTranslator.Translate("Frozen Powerup"), ItemType.FrozenPowerup));
     coinsToRemove += frozenCost;
     onItemPurchase();
 }
Beispiel #10
0
 private void ForcefieldBought()
 {
     itemsToAdd.Add(new InventoryItem(LanguageTranslator.Translate("Forcefield Powerup"), ItemType.ForcefieldPowerup));
     coinsToRemove += forcefieldCost;
     onItemPurchase();
 }
Beispiel #11
0
 private void WallBreakerBought()
 {
     itemsToAdd.Add(new InventoryItem(LanguageTranslator.Translate("Electric Powerup"), ItemType.WallBreakPowerup));
     coinsToRemove += wallBreakCost;
     onItemPurchase();
 }
Beispiel #12
0
 private void TeleportBought()
 {
     itemsToAdd.Add(new InventoryItem(LanguageTranslator.Translate("Teleport Powerup"), ItemType.TeleportPowerup));
     coinsToRemove += teleportCost;
     onItemPurchase();
 }
Beispiel #13
0
 private void SpeedBought()
 {
     itemsToAdd.Add(new InventoryItem(LanguageTranslator.Translate("Speed Powerup"), ItemType.SpeedPowerup));
     coinsToRemove += speedCost;
     onItemPurchase();
 }
Beispiel #14
0
        public void Update(ref User user, GameTime gameTime)
        {
            pwButton.Active   = state != ShopState.Powerups;
            skinButton.Active = state != ShopState.Skins;
            skinButton.Text   = LanguageTranslator.Translate("Snakes");
            pwButton.Text     = LanguageTranslator.Translate("Powerups");
            skinButton.Width  = pwButton.Width;
            pwButton.X        = windowWidth / 2 - (SPACING / 2 + pwButton.Width);
            skinButton.X      = windowWidth / 2 + SPACING / 2;

            pwButton.Update();
            skinButton.Update();

            if (skinPage < 0)
            {
                skinPage = 0;
            }
            if (skinPages.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
                nextPageButton.Active = false;
                prevPageButton.Active = false;
                // Since there is only one page, we have to set the page integer to 0
                skinPage = 0;
            }
            else if (skinPage == 0)
            {
                // There is another page, but we are on the first. Therefore, we cannot go backwards, so we'll disable the backwards button
                nextPageButton.Active = true;
                prevPageButton.Active = false;
            }
            else if (skinPage + 1 == skinPages.Count)
            {
                // We are on the last page, so the forward button must be disabled
                nextPageButton.Active = false;
                prevPageButton.Active = true;
            }
            else
            {
                // We must be somewhere in the middle, so both buttons should be enabled
                nextPageButton.Active = true;
                prevPageButton.Active = true;
            }

            this.user = user;

            int row   = 0;
            int lastX = 0;
            int lastY = 0;
            int interfacesInCurrentRow = 0;

            switch (state)
            {
                #region Powerups

            case ShopState.Powerups:

                row   = 0;
                lastX = X_OFFSET;
                lastY = Y_OFFSET;
                interfacesInCurrentRow = 0;
                if (pwInterfaces.Count > 0)
                {
                    foreach (ShopItemInterface si in pwInterfaces)
                    {
                        si.X   = lastX;
                        lastX += si.Width + SPACING;
                        if (interfacesInCurrentRow >= ITEMS_PER_ROW)
                        {
                            row++;
                            si.X   = lastX = X_OFFSET;
                            lastX += si.Width + SPACING;
                            interfacesInCurrentRow = 0;
                        }
                        if (row == 0)
                        {
                            si.Y = lastY;
                        }
                        else if (row == 1)
                        {
                            si.Y = lastY + SPACING + si.Height;
                        }
                        interfacesInCurrentRow++;
                    }
                }

                foreach (ShopItemInterface si in pwInterfaces)
                {
                    si.Update(user.Coins >= si.Cost);
                }

                break;

                #endregion

                #region Skins

            case ShopState.Skins:

                // Update ShopItemInterface values
                row   = 0;
                lastX = X_OFFSET;
                lastY = Y_OFFSET;
                interfacesInCurrentRow = 0;
                if (skinPage <= skinPages.Count - 1)
                {
                    foreach (ShopItemInterface si in skinPages[skinPage])
                    {
                        si.X   = lastX;
                        lastX += si.Width + SPACING;
                        if (interfacesInCurrentRow >= ITEMS_PER_ROW)
                        {
                            row++;
                            si.X   = lastX = X_OFFSET;
                            lastX += si.Width + SPACING;
                            interfacesInCurrentRow = 0;
                        }
                        if (row == 0)
                        {
                            si.Y = lastY;
                        }
                        else if (row == 1)
                        {
                            si.Y = lastY + SPACING + si.Height;
                        }
                        interfacesInCurrentRow++;
                    }
                }

                bool skinNotOwned = true;
                foreach (ShopItemInterface si in skinPages[skinPage])
                {
                    foreach (Skin s in user.Skins)
                    {
                        if (!(si.ItemSkin.MemberEquals(s)))
                        {
                            // If true, the current ShopItemInterface's skin is owned by the signed-in user
                            skinNotOwned = true;
                        }
                        else
                        {
                            skinNotOwned = false;
                            break;
                            // We have found the skin in the user's inventory. Continued running of this loop may result in this value incorrectly
                            // being set to true
                        }
                    }
                    bool isBuyButtonActive = (user.Coins >= si.Cost) && skinNotOwned;
                    si.Update(isBuyButtonActive);
                }

                break;

                #endregion
            }

            // We need to do it this way, because the delegates for when items are bought won't work,
            // as no parameters can be passed in to an OnButtonClick delegate
            foreach (InventoryItem item in itemsToAdd)
            {
                user.Inventory.Add(item);
            }
            itemsToAdd.Clear();

            foreach (Skin skin in skinsToAdd)
            {
                user.Skins.Add(skin);
            }
            skinsToAdd.Clear();

            nextPageButton.Update();
            prevPageButton.Update();

            user.Coins   -= coinsToRemove;
            coinsToRemove = 0;
        }
Beispiel #15
0
 public static string Translate(string text)
 {
     return(LanguageTranslator.TranslateInto(GameInfo.Language, text));
 }
Beispiel #16
0
        public void Update(GameTime gameTime, EnterDirection enterDir)
        {
            // Update Location
            if (viewButton != null)
            {
                viewButton.Text = LanguageTranslator.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();
            }

            hideButton.Update();

            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;
                    }
                }
                else
                {
                    if (bgRect.Y < windowHeight)
                    {
                        bgRect.Y += 2;
                    }
                    else
                    {
                        leaving = false;
                        showing = false;
                    }
                }
            }

            #endregion
        }
Beispiel #17
0
        public Shop(ContentManager content, string speedAsset, string teleportAsset, string wallBreakAsset,
                    string whiteRectSprite, SpriteFont smallFont, string mazeAsset, Dictionary <ItemType, InventoryAction> itemActions,
                    List <Skin> skins, string tongueAsset, SkinAction skinBought, string leftArrowAsset, string rightArrowAsset,
                    int windowWidth, int windowHeight, Action onItemPurchase, SpriteFont bigFont, string textboxAsset,
                    SpriteFont mediumFont, string forcefieldAsset, string frozenAsset)
        {
            this.onItemPurchase = onItemPurchase;

            this.bigFont = bigFont;

            this.content = content;

            this.speedAsset     = speedAsset;
            this.teleportAsset  = teleportAsset;
            this.wallBreakAsset = wallBreakAsset;
            this.instaFinAsset  = mazeAsset;

            this.windowWidth  = windowWidth;
            this.windowHeight = windowHeight;

            this.skinBought  = skinBought;
            this.itemActions = itemActions;

            skinButton       = new MenuButton(new OnButtonClick(MakeStateSkins), LanguageTranslator.Translate("Snakes"), content, 0, 0, true, bigFont);
            skinButton.Y     = windowHeight - (skinButton.Height * 2) - SPACING;
            pwButton         = new MenuButton(new OnButtonClick(MakeStatePowerups), LanguageTranslator.Translate("Powerups"), content, 0, 0, true, bigFont);
            pwButton.Y       = skinButton.Y;
            skinButton.Width = pwButton.Width;
            pwButton.X       = windowWidth / 2 - (SPACING / 2 + pwButton.Width);
            skinButton.X     = windowWidth / 2 + SPACING / 2;

            nextPageButton = new MenuButton(rightArrowAsset, new OnButtonClick(NextPage), content, 0, 0, true);

            prevPageButton   = new MenuButton(leftArrowAsset, new OnButtonClick(PrevPage), content, 0, 0, true);
            prevPageButton.Y = windowHeight - (prevPageButton.Height + SPACING);
            prevPageButton.X = SPACING * 2;

            nextPageButton.ImgWidth  = prevPageButton.ImgWidth;
            nextPageButton.ImgHeight = prevPageButton.ImgHeight;
            nextPageButton.Width     = prevPageButton.Width;
            nextPageButton.Height    = prevPageButton.Height;

            nextPageButton.Y = windowHeight - (nextPageButton.Height + SPACING);
            nextPageButton.X = windowWidth - (SPACING + nextPageButton.Width);

            pwInterfaces = new List <ShopItemInterface>()
            {
                new ShopItemInterface(content, whiteRectSprite, speedAsset, smallFont, new OnButtonClick(SpeedBought),
                                      LanguageTranslator.Translate("Speed Powerup"), speedCost, 0, 0, powerupWidth, powerupHeight, ItemType.SpeedPowerup),
                new ShopItemInterface(content, whiteRectSprite, teleportAsset, smallFont, new OnButtonClick(TeleportBought),
                                      LanguageTranslator.Translate("Teleport Powerup"), teleportCost, 0, 0, powerupWidth, powerupHeight,
                                      ItemType.TeleportPowerup),
                new ShopItemInterface(content, whiteRectSprite, wallBreakAsset, smallFont, new OnButtonClick(WallBreakerBought),
                                      LanguageTranslator.Translate("Electric Powerup"), wallBreakCost, 0, 0, powerupWidth, powerupHeight,
                                      ItemType.WallBreakPowerup),
                new ShopItemInterface(content, whiteRectSprite, forcefieldAsset, smallFont, new OnButtonClick(ForcefieldBought),
                                      LanguageTranslator.Translate("Forcefield Powerup"), forcefieldCost, 0, 0, powerupWidth, powerupHeight,
                                      ItemType.ForcefieldPowerup),
                new ShopItemInterface(content, whiteRectSprite, frozenAsset, smallFont, new OnButtonClick(FrozenBought),
                                      LanguageTranslator.Translate("Frozen Powerup"), frozenCost, 0, 0, powerupWidth, powerupHeight,
                                      ItemType.FrozenPowerup),
                //new ShopItemInterface(content, whiteRectSprite, mazeAsset, smallFont, new OnButtonClick(FinishBought),
                //    LanguageTranslator.Translate("Finish"), 50, 0, 0, powerupWidth, powerupHeight, ItemType.Finish),
            };

            for (int i = 0; i <= skins.Count - 1; i++)
            {
                // Iterates through the skins collection, making sure that all skins make it into the game
                // The old code was inefficient and filled with bugs
                skinInterfaces.Add(new ShopItemInterface(content, whiteRectSprite, skins[i], smallFont, new SkinAction(SkinBought), Costs.SkinCosts[skins[i].Type],
                                                         0, 0, Snake.REG_WIDTH, Snake.REG_HEIGHT, tongueAsset));
            }
            UpdateSkinPagesToInterfaces();
        }
        private void CheckPowerupClicks(GameMode gameMode)
        {
            MouseState mouse = Mouse.GetState();

            if (speedRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)))
            {
                // This item has the mouse hovering over it
                label = LanguageTranslator.Translate("Speed") + "\nAlt+S";
            }
            if ((((speedRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)) && mouse.LeftButton == ButtonState.Pressed &&
                   !clickStarted) || (IsAlt(Keys.S) && !altStarted))) && speedCount > 0)
            {
                // We have used the speed powerup
                itemActions[ItemType.SpeedPowerup]();
                clickStarted = true;
                altStarted   = true;
            }

            if (teleportRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)))
            {
                // This item has the mouse hovering over it
                label = LanguageTranslator.Translate("Teleport") + "\nAlt+T";
            }
            if ((((teleportRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)) && mouse.LeftButton == ButtonState.Pressed &&
                   !clickStarted) || (IsAlt(Keys.T) && !altStarted))) && teleportCount > 0)
            {
                // We have used the speed powerup
                itemActions[ItemType.TeleportPowerup]();
                clickStarted = true;
                altStarted   = true;
            }

            if (wallBreakRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)))
            {
                // This item has the mouse hovering over it
                label = LanguageTranslator.Translate("Electric") + "\nAlt+W";
            }
            if ((((wallBreakRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)) && mouse.LeftButton == ButtonState.Pressed &&
                   !clickStarted) || (IsAlt(Keys.W) && !altStarted))) && wallBreakCount > 0)
            {
                // We have used the speed powerup
                itemActions[ItemType.WallBreakPowerup]();
                clickStarted = true;
                altStarted   = true;
            }

            if (forcefieldRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)))
            {
                // This item has the mouse hovering over it
                label = LanguageTranslator.Translate("Forcefield") + "\nAlt+F";
            }
            if ((((forcefieldRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)) && mouse.LeftButton == ButtonState.Pressed &&
                   !clickStarted) || (IsAlt(Keys.F) && !altStarted))) && forcefieldCount > 0 &&
                !(gameMode == GameMode.Freeplay || gameMode == GameMode.Star))
            {
                // We have used the speed powerup
                itemActions[ItemType.ForcefieldPowerup]();
                clickStarted = true;
                altStarted   = true;
            }

            if (iceRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)))
            {
                // This item has the mouse hovering over it
                label = LanguageTranslator.Translate("Frozen") + "\nAlt+R";
            }
            if ((((iceRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)) && mouse.LeftButton == ButtonState.Pressed &&
                   !clickStarted) || (IsAlt(Keys.R) && !altStarted))) && iceCount > 0 && gameMode != GameMode.Freeplay)
            {
                // We have used the speed powerup
                itemActions[ItemType.FrozenPowerup]();
                clickStarted = true;
                altStarted   = true;
            }

            //if (finRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)))
            //{
            //    // This item has the mouse hovering over it
            //    label = LanguageTranslator.Translate("Finish") + "\nAlt+F";
            //}
            //if ((((finRect.Intersects(new Rectangle(mouse.X, mouse.Y, 1, 1)) && mouse.LeftButton == ButtonState.Pressed &&
            //    !clickStarted) || (IsAlt(Keys.F) && !altStarted))) && finCount > 0)
            //{
            //    // We have used the speed powerup
            //    itemActions[ItemType.Finish]();
            //    clickStarted = true;
            //    altStarted = true;
            //}
        }
Beispiel #19
0
 public Notification(ContentManager content, string whiteRectSprite, string text, int windowWidth, int windowHeight, SpriteFont font,
                     OnButtonClick whenViewButtonClicked)
     : this(content, whiteRectSprite, text, windowWidth, windowHeight, font)
 {
     viewButton = new MenuButton(whenViewButtonClicked, LanguageTranslator.Translate("View"), content, 0, 0, true, font);
 }