public void SetSlotWithoutNotifyingInventory(ItemSaveFile newItem) { if (newItem != null && newItem.ID != ItemID.Empty) { //Status currentItem = ItemDirectory.GetItem(newItem.ID); itemHasCooldown = currentItem.HasCooldown; hasValidItem = true; //Description descriptionText.text = currentItem.description; itemNameText.text = currentItem.itemName; //Set icon image.sprite = currentItem.icon; countText.text = (currentItem.IsStackable && newItem.stacks > 1) ? newItem.stacks.ToString() : string.Empty; //Set reference this.itemFile = newItem; } else { ClearSlotWithoutNotifyingInventory(); } }
protected override void OnItemSlotted(int slotIndex) { if (startedSelling) { //Item sold, give player money player.AddMoney((int)(ItemDirectory.GetItem(itemList[slotIndex].ID).price * 0.5f)); } }
public void DragAndDraop_DropItemOnGroundAndNotifyInventory() { if (HasFile) { ItemDirectory.SpawnItemAtPlayerPosition(itemFile); inventory.SlotRequest_ClearSlot(slotIndex); } }
void Awake() { Instance = this; foreach (var item in items) { lookup.Add(item.ID, item); } }
public bool SlotRequest_TryStackItem(ItemSaveFile newFile, int slotIndex) { if (itemList[slotIndex].ID == newFile.ID && ItemDirectory.GetItem(newFile.ID).IsStackable) { itemList[slotIndex].stacks += newFile.stacks; InvokeEvent_SlotChange(slotIndex); return(true); } return(false); }
public void StartDrag(UIItemSlot uiSlot, ItemSaveFile itemFile) { if (itemFile != null && itemFile.ID != ItemID.Empty) { IsDragging = true; startingSlot = uiSlot; startingFile = itemFile; image.sprite = ItemDirectory.GetItem(itemFile.ID).icon; image.enabled = true; } }
public void UpdateQuest(Quest quest) { //Go through all the reward icon and fill them on screen for (int i = 0; i < rewardIcons.Count; i++) { if (i < quest.ItemRewards.Length) { rewardIcons[i].sprite = ItemDirectory.GetItem(quest.ItemRewards[i]).icon; rewardIcons[i].enabled = true; } else { rewardIcons[i].enabled = false; } } }
bool TryGetItem(out Item item) { item = null; ItemSaveFile itemSaveFile = inventory.ItemList[slotIndex]; if (itemSaveFile != null) { ItemID id = itemSaveFile.ID; if (id != ItemID.Empty) { item = ItemDirectory.GetItem(itemSaveFile.ID); return(true); } } return(false); }
public void CollectedRewards() { npc.Quest.CollectedRewards(); //Hide all the reward images! for (int i = 0; i < rewardImages.Length; i++) { rewardImages[i].enabled = false; } OnlyRevealNecessaryButtons(); //Go through the rewards, and give the player the reward if they have inventory space, otherwise drop the reward on the ground foreach (var itemID in npc.Quest.ItemRewards) { if (!player.Inventory.TryPickUpItem(ItemDirectory.GetItem(itemID))) { ItemDirectory.GetItem(itemID).SpawnItem(player.transform.position); } } }
//NPC tells this script, the QuestInterfaceController, to reveal the quest page by the NPC public void Initialize(NPC npc) { this.npc = npc; nameText.text = npc.Quest.QuestName; descriptionText.text = npc.Quest.Description; //Display the reward images for (int i = 0; i < rewardImages.Length; i++) { if (i < npc.Quest.ItemRewards.Length) { rewardImages[i].enabled = true; rewardImages[i].sprite = ItemDirectory.GetItem(npc.Quest.ItemRewards[i]).icon; } else { rewardImages[i].enabled = false; } } //Display and hide buttons based on status OnlyRevealNecessaryButtons(); }
protected Item GetItemFromID(ItemID ID) => ItemDirectory.GetItem(ID);