コード例 #1
0
        public IEnumerable <SelectListItem> GetItems(ModelExplorer explorer)
        {
            if ((ItemsEnum != null) && (ItemsEnum.GetTypeInfo().IsEnum))
            {
                var          items     = new List <SelectListItem>();
                MemberInfo[] enumItems = ItemsEnum.GetTypeInfo().GetMembers(BindingFlags.Public | BindingFlags.Static);
                for (int i = 0; i < enumItems.Length; i++)
                {
                    items.Add(new SelectListItem()
                    {
                        Value = i.ToString(), Text = enumItems[i].Name
                    });
                }

                return(items);
            }
            else
            {
                var properties = explorer.Properties.Where(p => p.Metadata.PropertyName.Equals(ItemsProperty));
                if (properties.Count() == 1)
                {
                    return(properties.First().Model as IEnumerable <SelectListItem>);
                }
                return(new List <SelectListItem>());
            }
        }
コード例 #2
0
        void ResetLayout()
        {
            selectedItem = null;
            comboListStore.Clear();

            if (ItemsEnum == null)
            {
                return;
            }

            if (!ItemsEnum.IsEnum)
            {
                throw new NotSupportedException(string.Format("ItemsEnum only supports enum types, specified was {0}", ItemsEnum));
            }

            //Fill special fields
            if (ShowSpecialStateAll)
            {
                AppendEnumItem(typeof(SpecialComboState).GetField("All"));
            }
            if (ShowSpecialStateNot)
            {
                AppendEnumItem(typeof(SpecialComboState).GetField("Not"));
            }

            foreach (FieldInfo info in ItemsEnum.GetFields())
            {
                AppendEnumItem(info);
            }

            if (ShowSpecialStateAll || ShowSpecialStateNot || DefaultFirst)
            {
                Active = 0;
            }
        }
コード例 #3
0
 public void AddIntoContainer(PlayerItem item)
 {
     try
     {
         ItemsEnum  itemType = AnalyzeBaseRecord(item.baserecord);
         RarityEnum rarity   = RarityEnumHelpers.StringToRarityEnum(item.Rarity);
         containedItemTypes.Add(itemType);
         containedRarities.Add(rarity);
         if (!ItemsDict.ContainsKey(itemType))
         {
             ItemsDict.Add(itemType, new Dictionary <RarityEnum, List <PlayerItem> >());
         }
         if (!ItemsDict[itemType].ContainsKey(rarity))
         {
             ItemsDict[itemType].Add(rarity, new List <PlayerItem>()
             {
                 item
             });
         }
         else
         {
             ItemsDict[itemType][rarity].Add(item);
         }
     }
     catch (Exception ex)
     {
         log.Error("Error while adding item to dict:", ex);
     }
 }
コード例 #4
0
    // create an Item with the amount embedded in its alias
    public Item CreateItem(ItemsEnum item, int amount)
    {
        switch (item)
        {
        case ItemsEnum.Chocolate:
            return(CreateHealingItem(itemDetails.Chocolate, amount));

        case ItemsEnum.Hamburger:
            return(CreateHealingItem(itemDetails.Hamburger, amount));

        case ItemsEnum.Timbits:
            return(CreateHealingItem(itemDetails.Timbits, amount));

        case ItemsEnum.Pizza:
            return(CreateHealingItem(itemDetails.Pizza, amount));

        case ItemsEnum.Soda:
            return(CreateDestressingItem(itemDetails.Soda, amount));

        case ItemsEnum.Milkshake:
            return(CreateDestressingItem(itemDetails.Milkshake, amount));

        case ItemsEnum.Tea:
            return(CreateDestressingItem(itemDetails.Tea, amount));

        case ItemsEnum.Gatorade:
            return(CreateDestressingItem(itemDetails.Gatorade, amount));

        case ItemsEnum.FloppyDisk:
            return(CreateReviveItem(itemDetails.FloppyDisk, amount));

        default:
            return(CreateHealingItem(itemDetails.Chocolate, amount));
        }
    }
コード例 #5
0
    void UnacquireItem(ItemsEnum kind)
    {
        var obj = GetItemUI(kind).objUI;

        // obj.transform.SetAsLastSibling();
        obj.SetActive(false);
        SelectNextItem();
    }
コード例 #6
0
        /// <summary>
        /// Обновляет данные виджета
        /// </summary>
        private void ResetLayout()
        {
            if (Menu != null)
            {
                Menu.Destroy();
                Menu = null;
            }

            MenuItems = new Dictionary <ImageMenuItem, object>();

            if (ItemsEnum == null)
            {
                return;
            }

            if (ItemsEnum.IsEnum == false)
            {
                throw new NotSupportedException(string.Format("ItemsEnum only supports enum types, specified was {0}", ItemsEnum));
            }

            Menu = new Gtk.Menu();

            string hint;
            //Gdk.Pixbuf p;
            ImageMenuItem item;

            foreach (FieldInfo info in ItemsEnum.GetFields())
            {
                if (info.Name.Equals("value__"))
                {
                    continue;
                }
                item = new ImageMenuItem(info.GetEnumTitle());
                hint = info.GetFieldDescription();
                //p = (Gdk.Pixbuf) info.GetEnumIcon();
                //if (p != null)
                //	item.Image = new Gtk.Image (p);
                if (!String.IsNullOrWhiteSpace(hint))
                {
                    item.TooltipText = hint;
                }
                item.Activated += OnMenuItemActivated;
                if (sensitiveFalseItems.Contains(info.GetValue(null)))
                {
                    item.Sensitive = false;
                }
                if (invisibleItems.Contains(info.GetValue(null)))
                {
                    item.Visible = false;
                }
                MenuItems.Add(item, info.GetValue(null));
                Menu.Add(item);
            }
            Menu.ShowAll();
        }
コード例 #7
0
        public IItem this[ItemsEnum index]
        {
            get { return(Enum.IsDefined(typeof(ItemsEnum), index) ? ItemsObject[(int)index] : null); }

            set
            {
                if (Enum.IsDefined(typeof(ItemsEnum), index))
                {
                    ItemsObject[(int)index] = value;
                }
            }
        }
コード例 #8
0
    public void FillInventory(ItemsEnum armorToAdd, ItemsEnum weaponsToAdd, Sprite armorItemSprite = null, Sprite weaponItemSprite = null)
    {
        int tmpRngNum = Random.Range(0, 2);

        if (tmpRngNum == 0)
        {
            itemSharedInventory.AddItemToAvailableInventory(itemSharedInventory, armorToAdd, armorItemSprite);
        }
        else if (tmpRngNum == 1)
        {
            itemSharedInventory.AddItemToAvailableInventory(itemSharedInventory, weaponsToAdd, weaponItemSprite);
        }
    }
コード例 #9
0
 public void AddItemToAvailableInventory(Inventory inventoryToCheck, ItemsEnum itemToAdd, Sprite spriteToUse)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         if (Items[i] == ItemsEnum.Null_Item && InventoryItemsImages[i].sprite == null)
         {
             inventoryToCheck.Items[i] = itemToAdd;
             inventoryToCheck.InventoryItemsImages[i].sprite = spriteToUse;
             return;
         }
     }
     Debug.LogError("HAI FINITO GLI OGGETTI NELL'INVENTARIO! BASTA SPAMMARE!");
 }
コード例 #10
0
    public void AcquireItem(ItemsEnum kind)
    {
        var obj = GetItemUI(kind).objUI;

        obj.transform.SetAsLastSibling();
        obj.SetActive(true);

        if (currentItem.objUI == null)
        {
            obj.GetComponent <InventoryItemUI>().ToggleSelected(true);
            currentItem = GetItemUI(kind);
        }

        EasyAudio.Get().audio.PlayOneShot(this.selectItemClip, 0.05f);
    }
コード例 #11
0
    public void Change(ItemsEnum itemkind, int amount)
    {
        var itemUI = GetItemUI(itemkind).objUI.GetComponent <InventoryItemUI>();

        if (amount > 0)
        {
            EasyAudio.Get().audio.PlayOneShot(this.selectItemClip, 0.05f);
        }

        if (inventory[itemkind] == 0)
        {
            AcquireItem(itemkind);
        }
        if (inventory[itemkind] + amount == 0)
        {
            UnacquireItem(itemkind);
        }

        inventory[itemkind] += amount;
        itemUI.SetAmount(inventory[itemkind]);
    }
コード例 #12
0
 ItemUI GetItemUI(ItemsEnum kind)
 {
     return(items.Find((f) => f.itemKind == kind));
 }
コード例 #13
0
        private ItemsEnum AnalyzeBaseRecord(string baserecord)
        {
            if (String.IsNullOrWhiteSpace(baserecord))
            {
                return(ItemsEnum.Other);
            }
            string[]  splited = baserecord.Split('/');
            string    last    = splited.Last();
            string    group   = splited[splited.Length - 2];
            ItemsEnum result  = ItemsEnum.Other;

            switch (group)
            {
            case "necklaces":
                result = ItemsEnum.Necklace;
                break;

            case "rings":
                result = ItemsEnum.Ring;
                break;

            case "medals":
                result = ItemsEnum.Medal;
                break;

            case "waist":
                result = ItemsEnum.Belt;
                break;

            case "gearrelic":
                result = ItemsEnum.Relic;
                break;

            case "gearhead":
                result = ItemsEnum.Helm;
                break;

            case "gearshoulders":
                result = ItemsEnum.Shoulders;
                break;

            case "gearhands":
                result = ItemsEnum.Gloves;
                break;

            case "geartorso":
                result = ItemsEnum.Chest;
                break;

            case "gearlegs":
                result = ItemsEnum.Pants;
                break;

            case "gearfeet":
                result = ItemsEnum.Boots;
                break;

            case "swords1h":
                result = ItemsEnum.Sword1H;
                break;

            case "axe1h":
                result = ItemsEnum.Axe1H;
                break;

            case "blunt1h":
                result = ItemsEnum.Mace1H;
                break;

            case "guns1h":
                result = ItemsEnum.Ranged1H;
                break;

            case "guns2h":
                result = ItemsEnum.Ranged2H;
                break;

            case "shields":
                result = ItemsEnum.Shield;
                break;

            case "focus":
                result = ItemsEnum.Offhand;
                break;

            case "caster":
                if (last.Contains("dagger"))
                {
                    result = ItemsEnum.Dagger;
                }
                else if (last.Contains("scepter"))
                {
                    result = ItemsEnum.Scepter;
                }
                else
                {
                    result = ItemsEnum.Caster;
                }
                break;

            case "melee2h":
                if (last.Contains("axe2h"))
                {
                    result = ItemsEnum.Axe2H;
                }
                else if (last.Contains("sword2h"))
                {
                    result = ItemsEnum.Sword2H;
                }
                else if (last.Contains("blunt2h"))
                {
                    result = ItemsEnum.Mace2H;
                }
                else
                {
                    result = ItemsEnum.Melee2H;
                }
                break;

            default:
                result = ItemsEnum.Other;
                break;
            }
            return(result);
        }