예제 #1
0
 public void LoadAvailablePrerequisiteItemCost(string token, Character character)
 {
     foreach (Item item in AllItems)
     {
         item.Cost = 0.0f;
         foreach (var li in item.LocationInfo)
         {
             if (li.Source == ItemSource.Vendor)
             {
                 VendorItem vendor = li as VendorItem;
                 int        count;
                 if (vendor.TokenMap.TryGetValue(token, out count))
                 {
                     // determine if the other prerequisites are available
                     bool valid = true;
                     foreach (var t in vendor.TokenMap)
                     {
                         if (t.Key != token)
                         {
                             // we have the name of the lower level item
                             // find this item
                             var pitem = AllItems.Find(i => i.Name == t.Key && i.ItemLevel < item.ItemLevel);
                             if (pitem != null)
                             {
                                 // is it available
                                 if (character.GetItemAvailability(new ItemInstance(pitem, 0, null, null, null, null, null, null)) == ItemAvailability.NotAvailable)
                                 {
                                     valid = false;
                                     break;
                                 }
                             }
                         }
                     }
                     if (valid)
                     {
                         item.Cost = count;
                     }
                 }
             }
         }
     }
     // don't need to invalidate relevant caches, but still trigger event to refresh graphs etc.
     if (ItemsChanged != null)
     {
         ItemsChanged(null, null);
     }
 }
예제 #2
0
        override public bool UpdateCapture(InputEvent e)
        {
            GameObject hitGO = FindHitGO(e.ray);

            // find item we want to higlight
            MenuItem highlightItem = (hitGO == null) ? null : AllItems.Find((x) => x.GO == hitGO);

            // update visual higlight
            foreach (MenuItem item in AllItems)
            {
                if (item == highlightItem)
                {
                    MaterialUtil.SetMaterial(item.GO, highlightMaterial);
                }
                else
                {
                    MaterialUtil.SetMaterial(item.GO, itemMaterial);
                }
            }

            // TODO cannot automatically hide when we miss, or we never expand the submenu.
            if (highlightItem == null)
            {
                return(true);
            }

            if (ActiveMenuItem == highlightItem)
            {
                return(true);
            }

            if (ActiveMenuItem != null)
            {
                hide_child_menus(ActiveMenuItem);
                hide_sub_menu(ActiveMenuItem);
                ActiveMenuItem = null;
            }

            if (highlightItem != null)
            {
                show_parent_menus(highlightItem);
                show_sub_menu(highlightItem);
                ActiveMenuItem = highlightItem;
            }

            return(true);
        }
예제 #3
0
 public void Scan(string sku)
 {
     try
     {
         Items item = AllItems.Find(x => x.Sku == sku);
         //if shoppingbasket already has the item then increase quantity by 1, else add the item to the basket
         if (ShoppingBasket.ContainsKey(item))
         {
             ShoppingBasket[item] += 1;
         }
         else
         {
             ShoppingBasket.Add(item, 1);
         }
     }
     catch (ArgumentNullException e)
     {
         Console.WriteLine("{0} Exception caught. Invalid item scanned", e);
     }
 }