void TryToBuy(StoredItem s) { InventoryList merchantInventory = currentMerchant.baseInventory; Item item = s.item; bool hasMoney = item.cost <= GlobalController.inventory.CheckMoney(); if (hasMoney) { // copy StoredItem toAdd = new StoredItem(merchantInventory.GetItem(item).item); TakeMoney(item.cost); if (merchantInventory.GetItem(item).item.stackable) { if (merchantInventory.GetItem(s).count > 1) { merchantInventory.GetItem(s).count -= 1; } else { merchantInventory.RemoveItem(s); } } else { merchantInventory.RemoveItem(s); } AddItem(toAdd, false); inventoryUI.merchantLine.text = currentMerchant.GetThanksDialogue(item); itemBuy.PlayOneShot(itemBuy.clip); UpdateMoneyUI(); currentMerchant.ReactToBuy(); } else { inventoryUI.merchantLine.text = currentMerchant.notEnoughMoneyDialogue; } inventoryUI.PopulateItems(currentMerchant.baseInventory); }
override public void ActivateSwitch(bool b) { if (b) { InventoryList playerInventory = GlobalController.inventory.items; if (playerInventory.HasItem(plasma)) { StoredItem playerPlasma = playerInventory.GetItem(plasma); int plasmaCount = playerPlasma.count; playerInventory.RemoveItem(playerPlasma); GlobalController.BoostStat(StatType.HEALTH, plasmaCount * healthPerPlasma); } } }
void TryToBuy(InventoryItem item) { InventoryList merchantInventory = currentMerchant.baseInventory; bool hasMoney = item.cost <= GlobalController.inventory.CheckMoney(); if (hasMoney) { InventoryItem toAdd = merchantInventory.GetItem(item).Clone(); TakeMoney(item.cost); if (merchantInventory.GetItem(item).stackable) { if (merchantInventory.GetItem(item).count > 1) { merchantInventory.GetItem(item).count -= 1; } else { merchantInventory.RemoveItem(item); } } else { merchantInventory.RemoveItem(item); } toAdd.count = 1; AddItem(toAdd); inventoryUI.merchantLine.text = currentMerchant.thanksDialogue; itemBuy.PlayOneShot(itemBuy.clip); UpdateMoneyUI(); currentMerchant.ReactToBuy(); } else { inventoryUI.merchantLine.text = currentMerchant.notEnoughMoneyDialogue; } inventoryUI.PopulateItems(currentMerchant.baseInventory); }
public void OnDrop(PointerEventData eventData) { RectTransform invPanel = transform as RectTransform; if (!RectTransformUtility.RectangleContainsScreenPoint(invPanel, Input.mousePosition)) { InventoryItemBase item = eventData.pointerDrag.gameObject.GetComponent <ItemDragHandler>().Item; if (item != null) { Debug.Log(item + " isn't null from dropHandler"); m_Inventory.RemoveItem(item); item.OnDrop(); } Debug.Log(item + " is null from drop handler"); } }
void DropCurrentItem() { GameObject itemToDrop = mItemIAmHolding.gameObject; if (itemToDrop != null) { inventory.RemoveItem(mItemIAmHolding); //StartCoroutine(DropItem(itemToDrop)); Rigidbody rbItem = itemToDrop.AddComponent <Rigidbody>(); if (rbItem != null) { animator.SetTrigger(DROP_ITEM); StartCoroutine(DropItem(rbItem)); } } }
public void RemoveObjectOne() { Inventory.RemoveItem(ObjectOne); }
//click (collider) only on buttonup void OnClick() { if (this.ID == 0) { return; } InventoryList temp = InventoryList._instance; PlayerState ps = PlayerState.instance; if (Input.GetMouseButtonUp(0)) { temp.clickItem = this; temp.desLabel.text = it.desc; //uiSprite.spriteName = "选中框"; } if (Input.GetMouseButtonUp(1)) { if (ps.level >= it.level) { switch (it.infoType) { case InfoType.drug: if (isStartColding != true) { PlayerState.instance.UpdateDateUp(it.plusHP, it.plusMP); temp.RemoveItem(this, 1); //player state update together if (this.count <= 0) { Clear(); temp.desLabel.text = ""; } else if (this.count == 1) { this.countLabel.text = ""; //cd isUse = true; } else { isUse = true; } } break; case InfoType.equip: if (ps.sexType != it.sexType && it.sexType != SexType.common) { MessageBox._instance.ShowMessageBox("装備できません", TipsCode.wrong); } else { EquipAndStatus.instance.SetEquipUI(it.dressType, ID); temp.RemoveItem(this, 1); //player state update together } break; case InfoType.weapon: EquipAndStatus.instance.SetEquipUI(it.dressType, ID); WeaponManager.instance.ShowWeapon(it.icon_name); temp.RemoveItem(this, 1); break; } } else { MessageBox._instance.ShowMessageBox("レベルが足りない", TipsCode.wrong); } } }