Ejemplo n.º 1
0
 private void DrawButtonTT(Button[] buttons)
 {
     Rectangle tooltip;
     String label; // tooltip's text
     int width, height; // width & height of the tooltip rectangle
     float scale = 0.4f;
     foreach (Button b in buttons)
     {
         if (b.Show && mouseR.Intersects(b.Area))
         {
             label = b.Tooltip;
             width = (int)(font.MeasureString(label).X * scale);
             height = (int)(font.MeasureString(label).Y * scale);
             tooltip = new Rectangle(mouse.X, mouse.Y - 15, width, height);
             spriteBatch.Draw(texBlank, tooltip, new Color(50, 50, 50, 128));
             spriteBatch.DrawString(font, label, new Vector2(tooltip.X, tooltip.Y),
                 Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
         }
     }
 }
Ejemplo n.º 2
0
        // Sets up every button
        private void SetupButtons()
        {
            #region Panel Buttons
            bTowers = new Button ("Towers", font, new Rectangle (bPanelTop.X, bPanelTop.Y + 3, bWidth, bHeight), texButtonUp,
                texButtonDown, true, "Build different towers");
            buttonsPanel = new Button[] { bTowers };
            #endregion

            #region Tower Type Buttons
            bDirect = new Button ("Direct", font, new Rectangle (bPanelTowersL.X + pPad, bPanelTowersL.Y + pPad, bWidth, bHeight),
                texButtonUp, texButtonDown, true, "Towers that apply damage to a single target");
            bSplash = new Button ("Splash", font, new Rectangle (bDirect.Area.X, bDirect.Area.Y + bHeight + bPad, bWidth,
                bHeight), texButtonUp, texButtonDown, false, "Towers that apply damage to multiple targets");
            bUtility = new Button ("Utility", font, new Rectangle (bSplash.Area.X, bSplash.Area.Y + bHeight + bPad, bWidth,
                bHeight), texButtonUp, texButtonDown, false, "Towers that perform support roles");
            buttonsBuild = new Button[] { bDirect, bSplash, bUtility };
            #endregion

            #region Direct DMG Tower Buttons
            buttonsDirect = new Button[] {
                new Button ("Rifle", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + pPad,
                bWidth, bHeight), texButtonUp, texButtonDown, false, "Cheap tower that fires single shots"),
                new Button ("MG", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + bHeight + pPad,
                bWidth, bHeight), texButtonUp, texButtonDown, false, "Covers an area with bullets"),
                new Button ("Pulse", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + bHeight * 2 + pPad,
                bWidth, bHeight), texButtonUp, texButtonDown, false, "Fires accurate pulses of energy"),
                new Button ("Gamma", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + bHeight * 3 + pPad,
                bWidth, bHeight), texButtonUp, texButtonDown, false, "Continuously damages its target"),
            };
            #endregion

            #region Splash DMG Tower Buttons
            buttonsSplash = new Button[] {
                new Button ("Rocket", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + pPad, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Fires rockets"),
                new Button ("Artillery", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + pPad + bHeight, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Fires long range shells"),
                new Button ("Flame", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + pPad + bHeight * 2, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Shoots fire")
            };
            #endregion

            #region Utility Tower Buttons
            buttonsUtility = new Button[] {
                new Button ("Command", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + pPad, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Enhances nearby towers' attributes"),
                new Button ("Concussion", font, new Rectangle (bPanelTowersR.X + pPad, bPanelTowersR.Y + pPad + bHeight, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Slows Nearby Enemies")
            };
            #endregion

            #region Menu Buttons
            buttonsMenu = new Button[] {
                new Button ("Controls", font, new Rectangle (menu.X + (menu.Width - bWidth) / 2, menu.Y + 80, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Display controls"),
                new Button ("Quit", font, new Rectangle (menu.X + (menu.Width - bWidth) / 2, menu.Y + 120, bWidth, bHeight),
                    texButtonUp, texButtonDown, false, "Exits the game"),
                new Button ("Restart", font, new Rectangle (menu.X + (menu.Width - bWidth) / 2, menu.Y + 160, bWidth, bHeight),
                texButtonUp, texButtonDown, false, "Restarts the game"),
            };
            #endregion

            #region Other Buttons
            bUpgrade = new Button ("Upgrade", font, new Rectangle (bPanelSelect.X - pPad * 2 - bWidth,
                bPanelSelect.Bottom - bHeight - pPad, bWidth, bHeight), texButtonUp, texButtonDown, false,
                "Improves this tower");
            bUpgrade.Show = true;
            #endregion

            foreach (Button b in buttonsDirect) {
                b.Show = true;
            }
        }
Ejemplo n.º 3
0
        // Draws each button and its label from a set of buttons
        private void DrawButtons(Button[] buttons)
        {
            Color lColor;
            Color bColor;

            foreach (Button b in buttons)
            {
                if (b.IsDown)
                {
                    bColor = Color.White;
                    lColor = Color.White;
                }
                else
                {
                    bColor = new Color(230, 230, 250, 255);
                    lColor = new Color(255, 255, 255, 200);
                }

                spriteBatch.Draw(b.Texture, b.Area, bColor);
                spriteBatch.DrawString(font, b.Label, b.LabelPosition, lColor, 0,
                    Vector2.Zero, b.LabelScale, SpriteEffects.None, 0);
            }
        }