Exemplo n.º 1
0
 public GuiButton(Rectangle position, Color backColor, Color backColorHover, Color backColorPressed, GuiLabel label)
 {
     Rectangle = position;
     this.backColor = backColor;
     this.backColorHover = backColorHover;
     this.backColorPressed = backColorPressed;
     if (label != null)
     {
         this.label = label;
         Point textPosition = CalculateTextPosition();
         this.label.Parent = this;
         this.label.SetRelativePosition(textPosition);
     }
     state = GuiElementState.Normal;
 }
Exemplo n.º 2
0
        internal void SwapWith(Cell cell, bool unswap)
        {
            int swapSpeed = unswap ? SPEED_UNSWAP : SPEED_SWAP;

            State = GuiElementState.Normal;
            cell.State = GuiElementState.Normal;

            Vector2 tempLocation = location;
            location = cell.location;
            cell.location = tempLocation;

            cell.moveDestination = location;
            moveDestination = cell.location;

            Shape tempShape = Shape;
            Shape = cell.Shape;
            cell.Shape = tempShape;

            Bonus tempBonus = Bonus;
            Bonus = cell.Bonus;
            cell.Bonus = tempBonus;

            speed = swapSpeed;
            cell.speed = swapSpeed;
            opacity = 0.5f;
            cell.opacity = 0.5f;
            Animation = Animation.Swap;
            cell.Animation = Animation.Swap;
        }
Exemplo n.º 3
0
 internal void Spawn(Shape shape)
 {
     State = GuiElementState.Normal;
     Shape = shape;
     opacity = 0f;
     Animation = Animation.FadeIn;
 }
Exemplo n.º 4
0
 internal void Destroy()
 {
     if (Shape != Shape.Empty && Animation != Animation.FadeOut)
     {
         State = GuiElementState.Normal;
         Animation = Animation.FadeOut;
         parent.AddDestroyer(Row, Column, Bonus);
     }
 }
Exemplo n.º 5
0
 internal override void Update(GameTime gameTime)
 {
     MouseState mouseState = Mouse.GetState();
     if (Rectangle.Contains(mouseState.Position))
     {
         if (state == GuiElementState.Pressed && mouseState.LeftButton == ButtonState.Released)
         {
             state = GuiElementState.Hover;
             OnClick?.Invoke(this, null);
         }
         else
         {
             state = mouseState.LeftButton == ButtonState.Pressed ? GuiElementState.Pressed : GuiElementState.Hover;
         }
     }
     else
     {
         state = GuiElementState.Normal;
     }
 }