Example #1
0
 public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
 {
     if (CheckButton)
     {
         foreach (Component component in Components)
         {
             if (component is Button)
             {
                 Button button = (Button)component;
                 if (button.Contains(PositionCheck))
                 {
                     if (button.GetType() == typeof(ItemsButtons))
                     {
                         DisplayValues((ItemsButtons)button);
                         selectedItem = (ItemsButtons)button;
                     }
                     else if (button.GetType() == typeof(RecipeButtons))
                     {
                         selectedItem = (RecipeButtons)button;
                         button.delegatedMethod();
                     }
                     else
                     {
                         button.delegatedMethod();
                     }
                     CheckButton = false;
                     break;
                 }
             }
         }
     }
     base.Draw(gameTime, spriteBatch);
 }
Example #2
0
        public virtual Button AddButton(IItem item, float price, Vector2 position)
        {
            item.Price = price;
            ItemsButtons itemButton = new ItemsButtons(Game, item);

            itemButton.CreateButton(item.Name, position, Color.Magenta, Color.Black);
            this.Components.Add(itemButton);
            return(itemButton);
        }
Example #3
0
        public virtual void DisplayValues(ItemsButtons button)
        {
            List <Component> temp = Components.Where(x => x.GetType() == typeof(Text)).ToList();

            foreach (var item in temp)
            {
                Components.Remove(item);
            }
            temp.Clear();
            selectedItem = button;
            AddText($"Name: {button.item.Name}", new Vector2(this.GraphicsDevice.Viewport.Width / 4, Components.Where(x => x.GetType() == typeof(Text)).Count() * 20 + 20), Color.Black);
            AddText($"Price: {button.item.Price}", new Vector2(this.GraphicsDevice.Viewport.Width / 4, Components.Where(x => x.GetType() == typeof(Text)).Count() * 20 + 20), Color.Black);
        }
Example #4
0
        public override void DisplayValues(ItemsButtons button)
        {
            foreach (var item in DisplayableComponents)
            {
                Components.Remove(item);
            }
            selectedItem = button;
            Component component;

            component = AddText($"Name: {button.item.Name}", new Vector2(this.GraphicsDevice.Viewport.Width / 4, Components.Where(x => x.GetType() == typeof(Text)).Count() * 20 + 20), Color.Black);
            DisplayableComponents.Add(component);
            component = AddText($"Price: {button.item.Price}", new Vector2(this.GraphicsDevice.Viewport.Width / 4, Components.Where(x => x.GetType() == typeof(Text)).Count() * 20 + 20), Color.Black);
            DisplayableComponents.Add(component);
            component = AddButton("Purchase", new Vector2(this.GraphicsDevice.Viewport.Width / 4, Components.Where(x => x.GetType() == typeof(Text)).Count() * 20 + 20), CanPurchase, Color.White);
            DisplayableComponents.Add(component);
        }