//아이템 버튼 클릭시 처리 : 첫번째 클릭-선택, 두번째 클릭 - 구매 public void OnClickItemBtn(int itemNumber) { string buttonName = getItemButtonName(itemNumber); GameObject itemBtn = shopUI_.transform.Find(buttonName).gameObject; if (itemBtn != null) { if (currentClickedItem_ == itemBtn) { Constant.ItemDef item = (Constant.ItemDef)itemNumber; if (gameManagerScript_.BuyItem(item, calcItemPrice(item)) == true) { ChangeItemBtnState(itemNumber, false); currentClickedItem_ = null; selectRect_.SetActive(false); } } else { Debug.Log("Select : " + buttonName + itemBtn.GetComponent <RectTransform>().localPosition); selectRect_.SetActive(true); currentClickedItem_ = itemBtn; selectRect_.GetComponent <RectTransform>().localPosition = currentClickedItem_.GetComponent <RectTransform>().localPosition; //selectRect_.GetComponent<RectTransform>(). //currentClickedItem_.transform.localScale.Scale(new Vector3(1.1f, 1.1f, 1.0f)); } } }
public bool hasItem(Constant.ItemDef item) { if (itemInventory_[(int)item] == 1) { return(true); } return(false); }
public bool isBoughtItem(Constant.ItemDef item) { if (itemInventory_[(int)item] != 0) { return(true); } return(false); }
public bool BuyItem(Constant.ItemDef item, int price) { if (fishCount_ >= price && itemInventory_[(int)item] == 0) { fishCount_ -= price; itemInventory_[(int)item] = 1; string inventoryName = "Inventory_" + ((int)item).ToString(); GameObject itemIcon = GameObject.Find("UI").transform.Find(inventoryName).gameObject; itemIcon.SetActive(true); return(true); } return(false); }
public int calcItemPrice(Constant.ItemDef item) { switch (shopType_) { case Constant.MapObjects.SHOP_NORMAL: return(Constant.itemPrice_[(int)item]); case Constant.MapObjects.SHOP_EXPENSIVE: return(Constant.itemPrice_[(int)item] * 2); case Constant.MapObjects.SHOP_SANTA: return(0); } return(0); }
public static Constant.ItemState GetItemState(Constant.ItemDef itemName) { return(itemInventory_[(int)itemName]); }
public static Constant.ItemState[] itemInventory_; //0 : none, 1: buy, 2: buy and used public static void SetItemState(Constant.ItemDef itemName, Constant.ItemState state) { itemInventory_[(int)itemName] = state; }