Exemplo n.º 1
0
        public Notification(ContentManager content, string whiteRectSprite, string text, int windowWidth, int windowHeight, SpriteFont font)
        {
            int height = (int)font.MeasureString(text).Y + SPACING;

            bgImg    = content.Load <Texture2D>(whiteRectSprite);
            bgRect   = new Rectangle(0, 0 - height, WIDTH, height);
            bgRect.X = windowWidth / 2 - (bgRect.Width / 2);

            hideButton = new MenuButton(new OnButtonClick(Hide), " X ", content, 0, 0, true, font);

            textPos = new Vector2();

            this.Text = text;
            this.font = font;

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

            timer = new Timer(3, TimerUnits.Seconds);
        }
Exemplo n.º 2
0
        public Tutorial(ContentManager content, List <string> tutorialAssetNames, string whiteRectAsset, int windowWidth,
                        int windowHeight, string leftArrowAsset, string rightArrowAsset)
        {
            // Initialize tutorial images
            foreach (string a in tutorialAssetNames)
            {
                tutorialImages.Add(content.Load <Texture2D>(a));
            }

            tutorialRect = new Rectangle(windowWidth / 2 - (IMG_WIDTH / 2), YSPACING, IMG_WIDTH, IMG_HEIGHT);

            nextPageButton   = new MenuButton(rightArrowAsset, new OnButtonClick(NextPage), content, 0, 0, true);
            nextPageButton.X = windowWidth - nextPageButton.Width - YSPACING;
            nextPageButton.Y = windowHeight - nextPageButton.Height - YSPACING;

            prevPageButton           = new MenuButton(leftArrowAsset, new OnButtonClick(PrevPage), content, XSPACING, nextPageButton.Y, true);
            prevPageButton.Width     = nextPageButton.Width;
            prevPageButton.ImgWidth  = nextPageButton.ImgWidth;
            prevPageButton.Height    = nextPageButton.Height;
            prevPageButton.ImgHeight = nextPageButton.ImgHeight;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
0
        public Popup(ContentManager content, SpriteFont smallFont, 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);

            font = smallFont;

            okButton = new MenuButton(new OnButtonClick(HidePopup), 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;
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
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);
 }