public CraftingInterface(CraftingRecipe recipe, Projectile output, SpriteFont font, int x, int y,
                                 int width, int height, OnCraft onCraft, GraphicsDevice graphics)
        {
            Output        = output;
            this.font     = font;
            this.onCraft  = onCraft;
            this.graphics = graphics;

            bgImg  = new Texture2D(graphics, width, height);
            bgImg  = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray);
            bgRect = new Rectangle(x, y, width, height);

            Output.X = bgRect.X + (bgRect.Width / 2 - (output.Width / 2));
            Output.Y = bgRect.Y + SPACING;
            if (Output.Height > Utilities.LightningHeight * 2)
            {
                Output.Height = Utilities.LightningHeight * 2;
            }

            materials      = recipe.Materials;
            materialCounts = recipe.MaterialAmounts;

            int lastXMaterials = bgRect.X + SPACING;

            for (int i = 0; i < recipe.Materials.Count; i++)
            {
                materialImgs.Add(Utilities.GetImgOfMaterial(recipe.Materials[i]));
                materialRects.Add(new Rectangle(lastXMaterials, output.Y + output.Height + SPACING,
                                                MATERIAL_SIZE, MATERIAL_SIZE));
                materialCountLocations.Add(new Vector2(materialRects[i].Right - SPACING,
                                                       materialRects[i].Bottom - SPACING));
                lastXMaterials += materialRects[i].Width + (SPACING * 3);
            }

            craftButton         = new MenuButton(Craft, Language.Translate("Craft"), 0, 0, true, font, graphics);
            craftButton.CanHold = true;
            Reposition();

            youHave    = Language.Translate("You Have") + ": 0";
            youHavePos = new Vector2(bgRect.X + (bgRect.Width / 2 - (font.MeasureString(youHave).X / 2)),
                                     craftButton.Y - (font.MeasureString(youHave).Y));
        }
        public AchievementMenu(ContentManager content, int windowWidth, int windowHeight, SpriteFont smallFont,
                               SpriteFont bigFont, GraphicsDevice graphics, Texture2D arrowImg, Texture2D checkImg)
        {
            this.windowWidth  = windowWidth;
            this.windowHeight = windowHeight;

            nextButton   = new MenuButton(NextPage, 0, 0, true, graphics, arrowImg);
            nextButton.X = windowWidth - nextButton.Width - SPACING;
            nextButton.Y = windowHeight - nextButton.Height - SPACING;
            prevButton   = new MenuButton(PrevPage, SPACING, nextButton.Y, true, graphics, arrowImg);

            foreach (Achievement a in Achievements.AchievementsList)
            {
                displays.Add(new AchievementDisplay(a, bigFont, smallFont, content, 0, 0, ACH_WIDTH, ACH_HEIGHT,
                                                    graphics, checkImg));
            }
            UpdatePagesToDisplays();

            X_OFFSET = windowWidth / 2 - (displays[0].Width / 2);
        }
Exemple #3
0
        public GiftInterface(GiftType giftType, GraphicsDevice graphics, int x, int y, int width, int height,
                             SpriteFont font)
        {
            this.font = font;

            bgImg  = new Texture2D(graphics, width, height);
            bgImg  = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray);
            bgRect = new Rectangle(x, y, width, height);

            openButton   = new MenuButton(new System.Action(() => open?.Invoke(Gift)), Language.Translate("Open"), 0, 0, true, font, graphics);
            openButton.X = bgRect.X + bgRect.Width / 2 - openButton.Width / 2;
            openButton.Y = bgRect.Bottom - openButton.Height - SPACING;

            Gift      = giftType;
            giftImg   = Utilities.GiftImg;
            giftRect  = new Rectangle(bgRect.X + bgRect.Width / 2 - GIFT_SIZE / 2, bgRect.Y + SPACING, GIFT_SIZE, GIFT_SIZE);
            giftColor = OneCannonOneArmy.Gift.GetColor(giftType);

            name    = Language.Translate(giftType.ToString()) + " " + Language.Translate("Gift");
            namePos = new Vector2(bgRect.X + bgRect.Width / 2 - font.MeasureString(name).X / 2, giftRect.Y + SPACING);
        }
        public CannonUpgradeMenu(int windowWidth, int windowHeight, GraphicsDevice graphics, Texture2D arrowImg,
                                 List <CannonStats> stats, UpgradeCannon upgrade, List <Texture2D> statIcons, SpriteFont font)
        {
            this.windowWidth  = windowWidth;
            this.windowHeight = windowHeight;

            for (int i = 0; i < stats.Count; i++)
            {
                interfaces.Add(new CannonUpgradeInterface(upgrade, statIcons[i], stats[i].ToString().AddSpaces(),
                                                          graphics, 0, 0, INT_WIDTH, INT_HEIGHT, font, stats[i]));
            }
            UpdatePagesToInterfaces();

            nextButton   = new MenuButton(NextPage, 0, 0, true, graphics, arrowImg);
            nextButton.X = windowWidth - SPACING - nextButton.Width;
            nextButton.Y = windowHeight - SPACING - nextButton.Height;
            prevButton   = new MenuButton(PrevPage, SPACING, nextButton.Y, true, graphics, arrowImg);

            X_OFFSET = (windowWidth - (interfaces[0].Width * ITEMS_PER_ROW + SPACING * ITEMS_PER_ROW)) / 2;

            statInfoHover = new StatInfoHover(CannonStats.Accuracy, font, graphics, windowWidth);
        }
Exemple #5
0
        public NotificationInstance(GraphicsDevice graphics, string text, int windowWidth, int windowHeight,
                                    SpriteFont font)
        {
            hideButton = new MenuButton(new System.Action(Hide), " X ", 0, 0, true, font, graphics);

            int height1 = (int)font.MeasureString(text).Y + HEIGHT_SPACING;
            int height2 = hideButton.Height + HEIGHT_SPACING * 2;
            int height  = height1 > height2 ? height1 : height2;

            bgImg    = new Texture2D(graphics, WIDTH, height);
            bgImg    = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray);
            bgRect   = new Rectangle(0, 0 - height, WIDTH, height);
            bgRect.X = windowWidth / 2 - (bgRect.Width / 2);

            textPos = new Vector2();

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

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

            timer = new Timer(3, TimerUnits.Seconds);
        }
        public ShopMaterialInterface(BuyItem buy, int x, int y, int width, int height, SpriteFont font, int cost,
                                     GraphicsDevice graphics, Material item, int windowWidth)
        {
            this.font = font;
            this.buy  = buy;

            Cost = cost;

            Item = item;

            bgImg  = new Texture2D(graphics, width, height);
            bgImg  = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray);
            bgRect = new Rectangle(x, y, width, height);

            name    = Language.Translate(Item.ToString().AddSpaces());
            namePos = new Vector2(x + (width / 2 - (font.MeasureString(name).X / 2)), y + SPACING);

            itemImg    = Utilities.GetImgOfMaterial(Item);
            itemRect   = new Rectangle(0, 0, MATERIAL_SIZE, MATERIAL_SIZE);
            itemRect.X = x + (width / 2 - (itemRect.Width / 2));
            itemRect.Y = (int)(namePos.Y + SPACING + font.MeasureString("A").Y);

            buyOnceButton = new MenuButton(Buy, Language.Translate("Buy") + " (" + cost.ToString() + "c)", 0,
                                           0, true, font, graphics);
            buyOnceButton.X = x + (width / 2 - (buyOnceButton.Width / 2));

            buyTenButton = new MenuButton(() => Buy(10), Language.Translate("Buy") + " 10 (" + (cost * 10).ToString() + "c)", 0,
                                          0, true, font, graphics);
            buyTenButton.X = x + (width / 2 - (buyTenButton.Width / 2));

            buyFiftyButton = new MenuButton(() => Buy(50), Language.Translate("Buy") + " 50 (" + (cost * 50).ToString() + "c)", 0,
                                            bgRect.Bottom - buyOnceButton.Height - EDGE_SPACING, true, font, graphics);

            buyTenButton.Y  = buyFiftyButton.Y - buyTenButton.Height - SPACING;
            buyOnceButton.Y = buyTenButton.Y - buyOnceButton.Height - SPACING;
        }
Exemple #7
0
        public SettingsMenu(int windowWidth, int windowHeight, GraphicsDevice graphics, int usernameWidth, int usernameHeight,
                            SpriteFont bigFont, SpriteFont mediumFont, SpriteFont smallFont, int sliderWidth, int sliderHeight,
                            List <Texture2D> projImgs, Texture2D arrowImg, Texture2D graphicsImg, Texture2D profileImg, Texture2D soundImg,
                            Texture2D crossImg)
        {
            this.bigFont  = bigFont;
            this.projImgs = projImgs;

            state = SettingsState.Profile;

            usernameBox = new Textbox(windowWidth / 2 - usernameWidth / 2, Utilities.MENU_Y_OFFSET, usernameWidth, usernameHeight,
                                      bigFont, false, graphics);
            usernameBox.Drawn = true;

            alienImg    = Utilities.AlienImg;
            alienEyeImg = Utilities.AlienEyeImg;
            alienRect   = new Rectangle(windowWidth / 2 - ALIEN_WIDTH / 2, usernameBox.Y + usernameBox.Height + SPACING,
                                        ALIEN_WIDTH, ALIEN_HEIGHT);
            alienEyeRect   = new Rectangle(0, alienRect.Y + (EYE_SPACING * 4), EYE_SPACING * 5, EYE_SPACING);
            alienEyeRect.X = alienRect.X + (alienRect.Width / 2 - (alienEyeRect.Width / 2));

            rSlider = new ValueSlider(0, Utilities.RectImage, windowWidth / 2 - sliderWidth / 2, alienRect.Bottom + SPACING,
                                      sliderWidth, sliderHeight, smallFont, Language.Translate("Red"), 255.0f);
            rSlider.AddValueChangedHandler(ColorChanged);
            gSlider = new ValueSlider(0, Utilities.RectImage, rSlider.X, rSlider.Y + rSlider.Height + SPACING,
                                      sliderWidth, sliderHeight, smallFont, Language.Translate("Green"), 255.0f);
            gSlider.AddValueChangedHandler(ColorChanged);
            bSlider = new ValueSlider(0, Utilities.RectImage, gSlider.X, gSlider.Y + gSlider.Height + SPACING,
                                      sliderWidth, sliderHeight, smallFont, Language.Translate("Blue"), 255.0f);
            bSlider.AddValueChangedHandler(ColorChanged);

            projRect = new Rectangle(windowWidth / 2 - PROJ_SIZE / 2,
                                     bSlider.Y + bSlider.Height + SPACING, PROJ_SIZE, PROJ_SIZE);
            prevProj = new MenuButton(PrevProj, 0, 0,
                                      true, graphics, arrowImg);
            prevProj.X = projRect.X - prevProj.Width - SPACING;
            prevProj.Y = projRect.Y + projRect.Height / 2 - prevProj.Height / 2;
            nextProj   = new MenuButton(NextProj, projRect.Right + SPACING, prevProj.Y, true, graphics, arrowImg);

            replayTutorial   = new MenuButton(ReplayTutorial, Language.Translate("Replay Tutorial"), 0, 0, true, mediumFont, graphics);
            replayTutorial.X = windowWidth - replayTutorial.Width - SPACING;
            replayTutorial.Y = windowHeight - replayTutorial.Height - SPACING;

            submit = new MenuButton(new System.Action(() => submitInfo(usernameBox.Content, rSlider.Value, gSlider.Value, bSlider.Value,
                                                                       projImgs[projIndex].Name, new GraphicsSettings(brightnessSlider.Value / 100.0f),
                                                                       new VolumeSettings(systemSlider.Value, musicSlider.Value, sfxSlider.Value, muteToggle.Toggled))),
                                    Language.Translate("Submit"), 0, 0, true, bigFont, graphics);
            submit.X = windowWidth / 2 - submit.Width / 2;
            submit.Y = windowHeight - submit.Height - SPACING;

            usernamePrePos.X = usernameBox.X - bigFont.MeasureString(usernamePre).X;
            usernamePrePos.Y = usernameBox.Y;

            graphicsButton = new MenuButton(new System.Action(() => state = SettingsState.Graphics), BUTTON_SPACING * 2, 0, true, graphics, graphicsImg);

            profileButton = new MenuButton(new System.Action(() => state = SettingsState.Profile), graphicsButton.X, 0, true, graphics, profileImg);

            soundButton = new MenuButton(new System.Action(() => state = SettingsState.Sound), graphicsButton.X, 0, true, graphics, soundImg);

            graphicsButton.ImgWidth  = graphicsButton.ImgHeight = profileButton.ImgWidth = profileButton.ImgHeight =
                soundButton.ImgWidth = soundButton.ImgHeight = BUTTON_IMG_SIZE;
            graphicsButton.Width     = graphicsButton.Height = profileButton.Width = profileButton.Height =
                soundButton.Width    = soundButton.Height = BUTTON_SIZE;

            graphicsButton.Y = windowHeight / 2 - graphicsButton.Height / 2;
            profileButton.Y  = graphicsButton.Y - profileButton.Height - BUTTON_SPACING;
            soundButton.Y    = graphicsButton.Y + graphicsButton.Height + BUTTON_SPACING;

            brightnessSlider = new ValueSlider(0, Utilities.RectImage, rSlider.X, rSlider.Y,
                                               rSlider.Width, rSlider.Height, smallFont, Language.Translate("Brightness"));

            systemSlider = new ValueSlider(0, Utilities.RectImage, rSlider.X, rSlider.Y, rSlider.Width, rSlider.Height,
                                           smallFont, Language.Translate("System"));
            musicSlider = new ValueSlider(0, Utilities.RectImage, gSlider.X, gSlider.Y, gSlider.Width, gSlider.Height,
                                          smallFont, Language.Translate("Music"));
            sfxSlider = new ValueSlider(0, Utilities.RectImage, bSlider.X, bSlider.Y, bSlider.Width, bSlider.Height,
                                        smallFont, Language.Translate("Sound Effects"));
            muteToggle = new ToggleButton(soundImg, crossImg, graphics, sfxSlider.X, sfxSlider.Y + sfxSlider.Height + SPACING * 2,
                                          MUTE_TOGGLE_SIZE, MUTE_TOGGLE_SIZE);

            dirXInstallButton = new MenuButton(DirectXInstallClick, Language.Translate("Sound Issues?"),
                                               muteToggle.X, muteToggle.Y + muteToggle.Height + SPACING, true, bigFont, graphics);
        }
Exemple #8
0
 public NotificationInstance(GraphicsDevice graphics, string text, int windowWidth, int windowHeight,
                             SpriteFont font, System.Action whenViewButtonClicked)
     : this(graphics, text, windowWidth, windowHeight, font)
 {
     viewButton = new MenuButton(whenViewButtonClicked, "View", 0, 0, true, font, graphics);
 }