public void ClearSelectedItem() { Debug.Log("Clearing Shop Purchase Area"); SelectedShopSlot = null; PurchasingItemDisplay.sprite = null; PurchasingSection.SetActive(false); }
public void Open() { states = ShopStates.open; playerInv.ActivateInventory(); shop.SetActive(true); #region Logic foreach (ItemData items in shopInventory) { selectedItem = items; GameObject itemSlot = Instantiate(shopPrefab, shopSlotParent); Button itemButton = itemSlot.GetComponent <Button>(); selectedItem.button = itemButton; itemButton.onClick.AddListener(() => DisplayShopInventory(items)); ShopSlot shopSlot = itemSlot.GetComponent <ShopSlot>(); Image image = shopSlot.image; if (image != null) { image.sprite = items.Icon; } } #endregion }
private void Awake() { if (Singleton == null) { Singleton = this; } }
// Item hinzufiegen Funktion // WENN die maxSize vom item 1 ist, DANN Platziere das Item im Shop public bool AddItem(Item item) { if (item.maxSize == 1) { PlaceEmpty(item); return(true); } else { // ANSONSTEN gehe jeden Slot der Liste durch und ueberpruefe ihn foreach (GameObject slot in allSlots) { ShopSlot tmp = slot.GetComponent <ShopSlot>(); // Referenz auf das ShopSlotscript // WENN der Slot nicht leer ist dann ueberpruefe: if (!tmp.IsEmpty) { // OB das Item in dem Slot vom gleichen Item ist, wie das, was hinzugefuegt werden soll // UND ob der Slot zum Stacken verfuegbar ist // DANN fuege das Item hinzu if (tmp.CurrentItem.type == item.type && tmp.IsAvailable) { tmp.AddItem(item); return(true); } } } // WENN das Item nicht gestackt werden konnte // DANN soll das item einfach platziert werden, sofern es mindestens einen leeren Slot gibt if (emptySlot > 0) { PlaceEmpty(item); } } return(false); }
public void ShopSlotPurchased(ShopSlot slot, InventorySlot dropSlot) { if (onPurchase != null) { onPurchase(slot, dropSlot); } }
void ShopInventoryPurchase(ShopSlot slot, InventorySlot dropSlot) { if (shopInventory.BuyShopSlot(slot, partyInventory)) { partyInventory.DistributeFromShopItem(slot, dropSlot); } }
private void ShopSlotPurchased(ShopSlot slot, InventorySlot dropSlot) { if (EventPurchase != null) { EventPurchase(slot, dropSlot); } }
//回调函数 void OnUpSlot(PointerEventData eventData, ShopSlot slot) { //if (eventData.button == PointerEventData.InputButton.Left) // //gameObject.SetActive(!gameObject.activeSelf); // gameObject.SetActive(true); //if (tempSlot != null) // LoadText(tempSlot); }
private void Start() { foreach (Gear n in gear) { ShopSlot temp = Instantiate(shopSlotPrefab, layoutGroup.transform).GetComponent <ShopSlot>(); temp.EquipItem(n); } }
private void Refresh() { foreach (ConstructionItem i in inventory.items) { ShopSlot slot = ShopSlot.Instantiate(shopSlotPrefab, content); slot.Display(i, dragParent, slot.gameObject); } }
// 판매 아이템 목록에 아이템 추가. public void SellNewItem(Item item, int level = 0, params ItemCost[] itemCosts) { ShopSlot slot = Instantiate <ShopSlot>(slotPrefab); slot.transform.SetParent(slotRoot); slot.transform.localScale = Vector3.one; slot.SetItem(item, level, itemCosts); }
//回调函数 void OnEnterSlot(PointerEventData eventData, ShopSlot slot) { if (slot.CurrentItem == null) { return; } tempSlot = slot; LoadText(slot); }
public void ShopSlotLeftClicked(ShopSlot slot) { Item item = slot.Item(); if (item != null) { StartCoroutine(slotClickHelper.PurchaseItem(item)); } }
// Use this for initialization void Start() { if (!IsInited) { priceDic = new Dictionary <SkinType, Dictionary <string, int> >(); buyCheck = new Dictionary <SkinType, Dictionary <string, bool> >(); shoppingList = new Dictionary <SkinType, GameObject[]>(); for (int i = 1; i <= 5; i += 1) { var objs = Resources.LoadAll <GameObject>("Prefabs/Shop/" + ((SkinType)i).ToString() + "/"); shoppingList.Add((SkinType)i, objs); if ((SkinType)i != SkinType.Costume) { Dictionary <string, bool> checkDic = new Dictionary <string, bool>(); Dictionary <string, int> priceNameDic = new Dictionary <string, int>(); for (int j = 0; j < objs.Length; j += 1) { ShopSlot slot = objs[j].GetComponent <ShopSlot>(); slot.GetSpriteName(); // 세이브 기능 구현시 고쳐야 할 부분 checkDic.Add(slot.SpriteName, false); priceNameDic.Add(slot.SpriteName, slot.Price); } buyCheck.Add((SkinType)i, checkDic); priceDic.Add((SkinType)i, priceNameDic); } else { Dictionary <string, bool> checkDic = new Dictionary <string, bool>(); Dictionary <string, int> priceNameDic = new Dictionary <string, int>(); for (int j = 0; j < objs.Length; j += 1) { CostumeSlot slot = objs[j].GetComponent <CostumeSlot>(); // 세이브 기능 구현시 고쳐야 할 부분 checkDic.Add(slot.CostumeCode.ToString(), false); priceNameDic.Add(slot.CostumeCode.ToString(), slot.Price); } buyCheck.Add((SkinType)i, checkDic); priceDic.Add((SkinType)i, priceNameDic); } } effecters = FindObjectsOfType <ScaleEffecter>(); if (preShopPopup == null) { Debug.LogWarning("The Prefab NOT PREPARED"); } } }
// 다이아 소비 아이템 추가 private void AddItemSpendingDia() { GameObject tmp = Instantiate(SpendCashSlotPrefab, Shop3ScrollRect.transform); ShopSlot slot = tmp.GetComponent <ShopSlot>(); slot.nameTxt.text = "다이아 삭감"; slot.priceTxt.text = "다이아 1개"; slot.infoTxt.text = "다이아 1개 삭감"; slot.itemImage.color = new Color(0, 0, 0, 0); }
public static ShopSlot CreateComponent(GameObject where, ShopItem item) { where.SetActive(false); where.name = item.Name; ShopSlot myC = where.AddComponent <ShopSlot>(); myC.Item = item; where.SetActive(true); return(myC); }
private void SetupSlot(Item item, GameObject parentPanel, List <ShopSlot> slots) { GameObject newObject = Instantiate(itemTemplate.gameObject, parentPanel.transform); ShopSlot slot = newObject.GetComponent <ShopSlot>(); slot.shop = this; slots.Add(slot); slot.SetContents(item, 1); slot.descriptionPanel = descriptionPanel; }
// 현금 구매 아이템 추가 (다이아 추가 아이템) private void AddCashItem() { GameObject tmp = Instantiate(CashItemSlotPrefab, Shop3ScrollRect.transform); ShopSlot slot = tmp.GetComponent <ShopSlot>(); slot.nameTxt.text = "다이아10"; slot.priceTxt.text = "현금 : 1000원"; slot.infoTxt.text = "유료아이템을 구입하기 위한 다이아10개"; slot.itemImage.color = new Color(0, 0, 0, 0); }
private void Start() { CallbackHandler.instance.changeMenu += ChangeMenu; foreach (Ability n in ability) { ShopSlot temp = Instantiate(shopSlotPrefab, layoutGroup.transform).GetComponent <ShopSlot>(); temp.SetupAbility(n); } }
private void CreateShopSlot() { for (int i = 0; i < ShopInventory.Size; i++) { ShopSlot shopSlotClone = Instantiate(ShopSlotPrefab, ShopPanel); shopSlotClone.ClearSlot(); _shopSlots.Add(shopSlotClone); } }
void LoadText(ShopSlot slot) { title.text = slot.CurrentItem.Name; type.text = slot.CurrentItem.MainType + "-" + slot.CurrentItem.SubType; quality.text = slot.CurrentItem.Quality.ToString(); if (PlayerStateInfo.Instance.Level.Get() < slot.CurrentItem.ItemData.NeedLevel) { level.color = Color.red; } else { level.color = Color.white; } level.text = "需要等级:" + slot.CurrentItem.ItemData.NeedLevel; if (PlayerStateInfo.Instance.Gold.Get() < slot.CurrentItem.ItemData.Price) { price.color = Color.red; } else { price.color = Color.white; } price.text = slot.CurrentItem.ItemData.Price.ToString() + "金币"; //基础属性 if (GetBaseProperty(slot) == null) { baseProperty.text = ""; } else { baseProperty.text = GetBaseProperty(slot); } //附加属性 if (GetAdditionalProperty(slot) == null) { additionalProperty.text = ""; } else { additionalProperty.text = GetAdditionalProperty(slot); } //特殊属性 if (GetSpecialProperty(slot) == null) { specialProperty.text = ""; } else { specialProperty.text = GetSpecialProperty(slot); } description.text = slot.CurrentItem.ItemData.Descriptions; // Canvas.ForceUpdateCanvases(); }
private void AssignRarity(ShopSlot emptySlot, List <Ingredients_sObj> IngredList) { int shopIndex = UnityEngine.Random.Range(0, IngredList.Count); //INCLUSIVE random among IngredientList if (shopIndex == IngredList.Count) { shopIndex--; //cannot be EQUALS to COUNT, as COUNT13 cannot accept ingredient[13] } Debug.Log("random item is: " + shopIndex); emptySlot.SetIngredient(IngredList[shopIndex]); }
void OnClickSlot(PointerEventData eventData, ShopSlot slot) { if (isBuying) { CurSlot = slot; isBuying = false; CursorManager.Instance.SetNormal(); //显示数量选择框 SelectAmount.SetActive(true); SelectAmount.transform.position = Input.mousePosition; } }
void MakeShopSlots(InventoryItems itemName) { GameObject itemTemp = Instantiate(shopSlot, ShopBoard.transform.position, Quaternion.identity); itemTemp.transform.SetParent(ShopBoard.transform); ShopSlot newSlot = itemTemp.GetComponent <ShopSlot>(); if (newSlot) { newSlot.Setup(itemName, this); } }
public void PopulateShopItems() { foreach (ShopItem item in shopInventory) { GameObject newShopItem = Instantiate(shopItemPrefab, shopLayout.transform); ShopSlot shopSlot = newShopItem.GetComponent <ShopSlot>(); shopSlot.title.text = item.item.displayName; shopSlot.price.text = item.item.value.ToString(); shopSlot.purchaseButton.image.sprite = item.item.icon; item.shopSlot = shopSlot; } }
public bool BuyShopSlot(ShopSlot slot, IInventory inventory) { if (slot.Item.Amount <= 0 || !CheckPrice(slot) || !CheckInventorySpace(slot, inventory)) { return(false); } DarkestDungeonManager.Campaign.Estate.Currencies["gold"].amount -= slot.Cost; slot.Item.Amount--; slot.UpdateAmount(); currencyPanel.CurrencyDecreased("gold"); currencyPanel.UpdateCurrency(); return(true); }
public void PurchaseItem(ShopSlot slot) { //Take this away from the players gold //slot.price if (!slot.empty && PartyManager.instance.gold >= slot.price) { PartyManager.instance.gold -= slot.price; slot.HideStats(); InventoryManager.Instance.AddItem(slot.item); slot.RemoveItem(); } }
private void AddItem(int _id, GameObject ShopPanel) { Items_Info add_Item = item_Database.Search_For_Item(_id); GameObject tmp = Instantiate(SlotPrefab, ShopPanel.transform); //tmp.transform.SetParent(ShopPanel.transform); // 안드로이드폰에서 슬롯이 작아지는 문제가 생김 ShopSlot slot = tmp.GetComponent <ShopSlot>(); //Debug.Log(add_Item.name); slot.nameTxt.text = add_Item.name; // 이름 입력 slot.priceTxt.text = "가격 : " + add_Item.price.ToString(); // 가격 입력 slot.infoTxt.text = add_Item.description; // 설명 입력 slot.itemImage.sprite = add_Item.item_Img; // 이미지 입력 slot.id = _id; // ID 입력 }
public void CreateShop() { List <ShopSlot> Slots = new List <ShopSlot>(); foreach (var item in Items) { ShopSlot slot = Instantiate(ShopSlot, CardsContainer).GetComponent <ShopSlot>(); slot.Manager = this; slot.Fill(item); Slots.Add(slot); } Slots[0].Select(); UpperRightLbl.transform.parent.gameObject.SetActive(TopRightBar); }
//获得特殊属性 private string GetSpecialProperty(ShopSlot slot) { if (slot.CurrentItem.SpecialPropertys.Count == 0) { return(null); } StringBuilder description = new StringBuilder(); foreach (var i in slot.CurrentItem.SpecialPropertys) { description.Append(i.SpecialProperty.ToString() + "+" + i.Value + "\n"); } return(description.ToString()); }
public void ClearSelectedItem() { SelectedShopSlot = null; PurchaseItemDisplay.sprite = null; PurchasingSection.SetActive(false); }
public void SetShopSelectedItem(ShopSlot slot) { SelectedShopSlot = slot; PurchaseItemDisplay.sprite = slot.Item.Sprite; PurchasingSection.SetActive(true); }