private bool combineSuccess(MenuSlot releaseTo) { MenuSlotItem meTemp = this.getItem(); MenuSlotItem youTemp = releaseTo.getItem(); //If the two items should be merged if (this.getItem() != null && releaseTo.getItem() != null && meTemp.id == youTemp.id && meTemp.isFlower == youTemp.isFlower) { HomeBaseUIController hbuic = GetComponentInParent <HomeBaseUIController>(); if (releaseTo.type == SlotType.PlayerInventory)//if moving to inventory { hbuic.addHomeInventoryItem(releaseTo.getItem().id, -releaseTo.getItem().count, releaseTo.getItem().isFlower); } else if (this.type == SlotType.PlayerInventory)//if moving out of inventory { hbuic.addHomeInventoryItem(this.getItem().id, this.getItem().count, this.getItem().isFlower); } //Set the other item's count int oldCount = releaseTo.getItem().count; //Destroy the item in the other slot because the grabbed item will be stored GameObject.Destroy(releaseTo.getItem().gameObject); //Set the other slot to the grabbed item releaseTo.setItem(this.getItem()); releaseTo.setCount(oldCount + this.getItem().count); //Clear the item in the grabbed slot this.setItem(null); //It was successful so return true return(true); } return(false); }
private void sellDecoration(uint id, int count) { if (grabbedSlot == null) { int toSell = count; try { if (homeDecorationsBought[id] < toSell) { toSell = homeDecorationsBought[id]; } homeDecorationsBought[id] -= toSell; fpc.money += (int)(toSell * decorationValue[(uint)id] * 0.75f); } catch { } //todo decrease item's count by count MenuSlot sellSlot = GameObject.Find("sellFlowerSlot").GetComponent <MenuSlot>(); //Reduce flower count by "adding" a negative value addHomeInventoryItem(id, -count, false); sellSlot.setCount(sellSlot.getCount() - count);//this is neg for some reason updateMoneyText(); updateFlowerDisplaySlot(sellSlot.getItem()); } }
//Sell the flower the given number of times private void sellFlower(uint flowerID, int sellAmount) { if (grabbedSlot == null) { MenuSlot sellSlot = GameObject.Find("sellFlowerSlot").GetComponent <MenuSlot>(); //this was for multiple sells since processflowersell allways sells one //fpc.money += HomeBaseController.instance.getFlowerValue(flowerID) * (sellAmount-1); HomeBaseController.instance.processFlowerSell(flowerID); //Reduce flower count by "adding" a negative value addHomeInventoryItem(flowerID, -sellAmount, true); sellSlot.setCount(sellSlot.getCount() - sellAmount); updateMoneyText(); updateFlowerDisplaySlot(sellSlot.getItem()); } }
private void purchaseDecoration(uint id, MenuSlot item) { if (grabbedSlot == null) { if (fpc.money >= decorationValue[(uint)id]) { if (!homeDecorationsBought.ContainsKey(id)) { homeDecorationsBought.Add(id, 0); } homeDecorationsBought[id] += 1; fpc.money -= decorationValue[(uint)id]; updateMoneyText(); bool pushedToInventory = false; Transform playerInventoryPanel = GameObject.Find("playerInventoryPanel").transform; for (int i = 0; i < 10 && pushedToInventory == false; i++) { if (playerInventoryPanel.GetChild(i).childCount != 0) { MenuSlotItem msi = playerInventoryPanel.GetChild(i).GetChild(0).GetComponent <MenuSlotItem>(); if (msi.isFlower == false && msi.id == id) { msi.setCount(msi.count + 1); pushedToInventory = true; } } } if (!pushedToInventory) { item.setCount(item.getCount() + 1); addHomeInventoryItem(id, 1, false); } for (int i = 0; i < 10 && pushedToInventory == false; i++) { if (playerInventoryPanel.GetChild(i).childCount == 0) { item.releaseItem(playerInventoryPanel.GetChild(i).GetComponent <MenuSlot>()); pushedToInventory = true; } } } } }