public bool HasUsableItem() { return(this.Data.Items.Exists(itemId => { ItemDefinition item = DefinitionStore.Instance.GetItemDefinition(itemId); return item.IsUsable(); })); }
private void OnSelectedItem(int itemIndex) { //// Debug.Log("OnSelectedItem: " + itemIndex); if (!AllowSelection) { PickAtIndex(-1); } int itemId = creature.Data.Items[itemIndex]; ItemDefinition item = DefinitionStore.Instance.GetItemDefinition(itemId); if (showType == ShowType.SelectEquipItem && !item.IsEquipment()) { return; } if (showType == ShowType.SelectUseItem && !item.IsUsable()) { return; } if (itemIndex == lastSelectedIndex) { // Do selected action PickAtIndex(itemIndex); } if (lastSelectedIndex >= 0) { itemControlls[lastSelectedIndex].SetSelected(false); } itemControlls[itemIndex].SetSelected(true); lastSelectedIndex = itemIndex; }
void OnSelectClicked(int index) { if (!CanEdit) { return; } Debug.Log("Clicked on index: " + index); if (showType == ShowType.SelectAllItem) { OnCallback(index); } else if (showType == ShowType.SelectEquipItem) { int itemId = this.creature.Data.Items[index]; ItemDefinition item = DefinitionStore.Instance.GetItemDefinition(itemId); if (item.IsEquipment()) { OnCallback(index); } } else if (showType == ShowType.SelectUseItem) { int itemId = this.creature.Data.Items[index]; ItemDefinition item = DefinitionStore.Instance.GetItemDefinition(itemId); if (item.IsUsable()) { OnCallback(index); } } else if (showType == ShowType.SelectMagic) { int magicId = this.creature.Data.Magics[index]; MagicDefinition magic = DefinitionStore.Instance.GetMagicDefinition(magicId); OnCallback(index); } }