Exemplo n.º 1
0
 private void _on_TextureRect_gui_input(InputEvent @event)
 {
     if (@event is InputEventMouseButton button && button.Pressed && button.ButtonIndex == 1 && orphanage.GetChildCount() > 0)
     {
         LblError.Text = "";
         InventoryItem orphanItem = (InventoryItem)orphanage.GetChild(0);
         if (ItemTypes.Contains(orphanItem.Item.Type))
         {
             if (!orphanage.PreviousSlot.Merchant && !Merchant && CheckItemLevel(orphanItem) && CheckItemClasses(orphanItem))
             {
                 PutItemInSlot(orphanItem);                                                                                       // if not buying nor selling, and is a valid slot
             }
             else if (orphanage.PreviousSlot.Merchant && !Merchant && CheckItemLevel(orphanItem) && CheckItemClasses(orphanItem)) // if purchasing and can afford it
             {
                 if (GameState.CurrentHero.PurchaseItem(orphanItem.Item))                                                         // if purchasing and can afford it
                 {
                     PutItemInSlot(orphanItem);
                 }
                 else
                 {
                     LblError.Text = "You cannot afford that item.";
                 }
             }
             else if (!orphanage.PreviousSlot.Merchant && Merchant) // if selling
             {
                 if (orphanItem.Item.CanSell)
                 {
                     GameState.CurrentHero.SellItem(orphanItem.Item);
                     PutItemInSlot(orphanItem);
                 }
                 else
                 {
                     LblError.Text = "This item cannot be sold.";
                 }
             }
             else if (orphanage.PreviousSlot.Merchant && Merchant) // if moving Merchant item to different Merchant slot
             {
                 PutItemInSlot(orphanItem);
             }
             else if (!CheckItemLevel(orphanItem))
             {
                 LblError.Text = "You are not high enough level to equip this item.";
             }
             else if (!CheckItemClasses(orphanItem))
             {
                 LblError.Text = "You are unable to equip this item because you are not the correct class.";
             }
         }
         else
         {
             LblError.Text = "That is not a valid slot for this item.";
         }
     }
 }
Exemplo n.º 2
0
 private void _on_TextureRect_gui_input(InputEvent @event)
 {
     if (@event is InputEventMouseButton button && button.Pressed && button.ButtonIndex == 1)
     {
         if (orphanage.GetChildCount() > 0)
         {
             QuincyItem item = (QuincyItem)orphanage.GetChild(0);
             if (ItemTypes.Contains(item.Item.Type))
             {
                 item.Drag = false;
                 item.RectGlobalPosition = Vector2.Zero;
                 orphanage.RemoveChild(item);
                 AddChild(item);
                 TextureRect rect = (TextureRect)GetChild(1).GetChild(0);
                 rect.MouseFilter = MouseFilterEnum.Pass;
             }
         }
     }
 }
Exemplo n.º 3
0
 protected override bool MeetsCondition(Player player, object value) => (value == null ? false : ItemTypes.Contains((value as Item).itemType));
Exemplo n.º 4
0
        /// <summary>
        /// Method that updates the information displayed each time the page is called
        /// </summary>
        /// <param name="MinCalories">Minimum calories for the search functionality</param>
        /// <param name="MaxCalories">Maximum calories for the search functionality</param>
        /// <param name="MinPrice">Minimum price for the search functionality</param>
        /// <param name="MaxPrice">Maximum price for the search functionality</param>
        public void OnGet(int?MinCalories, int?MaxCalories, double?MinPrice, double?MaxPrice)
        {
            this.MinCalories = MinCalories;
            this.MaxCalories = MaxCalories;
            this.MinPrice    = MinPrice;
            this.MaxPrice    = MaxPrice;
            SearchTerms      = Request.Query["SearchTerms"];
            ItemTypes        = Request.Query["ItemTypes"];

            //Search through items by SearchTerms
            if (SearchTerms != null)
            {
                items = Menu.CompleteMenu.Where(item =>
                                                item.ToString().Contains(SearchTerms, StringComparison.InvariantCultureIgnoreCase)
                                                );
            }
            //Search through items by ItemTypes
            if (ItemTypes != null && ItemTypes.Length != 0)
            {
                items = Items.Where(item =>
                                    item.GetType().BaseType.Name != null &&
                                    ItemTypes.Contains(item.GetType().BaseType.Name)
                                    );
            }
            //Search through items by Max and MinCalories
            if (!(MinCalories == null && MaxCalories == null))
            {
                if (MinCalories == null && MaxCalories != null)
                {
                    items = Items.Where(item =>
                                        item.Calories <= MaxCalories
                                        );
                }
                else if (MinCalories != null && MaxCalories == null)
                {
                    items = Items.Where(item =>
                                        item.Calories >= MinCalories
                                        );
                }
                else
                {
                    items = Items.Where(item =>
                                        item.Calories >= MinCalories &&
                                        item.Calories <= MaxCalories
                                        );
                }
            }
            //Search through items by Min and MaxPrice
            if (!(MinPrice == null && MaxPrice == null))
            {
                if (MinPrice == null && MaxPrice != null)
                {
                    items = Items.Where(item =>
                                        item.Price <= MaxPrice
                                        );
                }
                else if (MinPrice != null && MaxPrice == null)
                {
                    items = Items.Where(item =>
                                        item.Price >= MinPrice
                                        );
                }
                else
                {
                    items = Items.Where(item =>
                                        item.Price >= MinPrice &&
                                        item.Price <= MaxPrice
                                        );
                }
            }
        }