Пример #1
0
        public MenuScreen(Screen parentScreen, ContentManager m, string title, Vector2i pos, bool centeredX, bool centeredY, bool bordered, bool hasBackground, Color backgroundColor)
        {
            this.ParentScreen = parentScreen;

            this.ButtonColor = Color.Black;
            this.BackGroudColor = backgroundColor;
            this.TitleFont = m.Media.loadFont("Content/fonts/sweetness.ttf");
            this.ButtonFont = m.Media.loadFont("Content/fonts/sweetness.ttf");
            this.TitleSize = 90;
            this.ButtonSize = 55;
            this.buttons = new List<MenuButton>();

            this.Title = new Text(title, TitleFont, TitleSize);
            Title.Origin = new Vector2f(Title.GetLocalBounds().Left, Title.GetLocalBounds().Top);
            this.bounds = new Rectangle(pos.X, pos.Y, 0,0);

            this.isBordered = bordered;
            this.isCenteredX = centeredX;
            this.isCenteredY = centeredY;
            this.IsDrawn = true;
            this.IsUpdated = true;

            this.hasBackground = hasBackground;
            this.BackGroudColor = backgroundColor;

            setButtons();
        }
Пример #2
0
 public static bool checkMouseCollision(int x, int y, Rectangle rect)
 {
     if (x > rect.x && x < rect.x + rect.width)
     {
         if (y > rect.y && y < rect.y + rect.height)
             return true;
     }
     return false;
 }
Пример #3
0
        public SelectorButton(SelectorPannel parent, Types type, Vector2f offset, Vector2f dimensions, string name, Color c, Texture t = null)
        {
            this.parent = parent;
            this.Type = type;
            this.offset = offset;
            this.positionBox = new Rectangle(parent.PositionBox.x + offset.X, parent.PositionBox.y + offset.Y, dimensions.X, dimensions.Y);
            updateBlockParamers();
            this.text = new Text(name, Game1.plainFont);
            text.Color = Color.Black;
            text.CharacterSize = 24;
            text.Origin = new Vector2f(text.GetLocalBounds().Left, text.GetLocalBounds().Top);
            setTextPosition();

            this.outlineLight = new Color(255, 255, 255, 0);
            this.outlineDark = new Color(parent.Color.R, parent.Color.G, parent.Color.B, 220);
            this.currentOutline = outlineDark;
            this.drawColor = c;
            if (t != null)
                sprite = new Sprite(t);
        }
Пример #4
0
 private void updateBlockParamers()
 {
     blockPositionBox = new Rectangle(positionBox.x + 13, positionBox.y +25, positionBox.width -25, positionBox.height - 25);
 }
Пример #5
0
        public void update(Vector2i mPos)
        {
            if(IsActive)
            {
                Vector2i gridPos = new Vector2i(mPos.X - (mPos.X % 32) + 16, mPos.Y - (mPos.Y % 32) + 16);

                int lowX,  lowY,  highX,  highY;

                if(gridPos.Y < blockStart.Y)
                {
                    highY = blockStart.Y + 16;
                    lowY = gridPos.Y - 16;
                }
                else
                {
                    lowY = blockStart.Y - 16;
                    highY = gridPos.Y + 16;
                }

                if (gridPos.X < blockStart.X)
                {
                    highX = blockStart.X + 16;
                    lowX = gridPos.X - 16;
                }
                else
                {
                    lowX = blockStart.X - 16;
                    highX = gridPos.X + 16;
                }

                this.blockOutline = new Rectangle(lowX, lowY, highX - lowX, highY - lowY);
            }
        }
Пример #6
0
 public void newOutline(Vector2i startPos)
 {
     this.blockOutline = new Rectangle(startPos.X, startPos.Y, 32, 32);
     this.blockStart = new Vector2i(startPos.X + 16, startPos.Y + 16);
 }
Пример #7
0
 public void setPosition(Vector2f pos)
 {
     Text.Position = pos;
     float size = Text.CharacterSize / 5;
     TextBox = new Rectangle(pos.X - size, pos.Y - size, Text.GetGlobalBounds().Width + 2 * size, Text.GetGlobalBounds().Height + 2 * size);
 }