示例#1
0
    //아이템 버튼 클릭시 처리 : 첫번째 클릭-선택, 두번째 클릭 - 구매
    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));
            }
        }
    }
示例#2
0
 public bool hasItem(Constant.ItemDef item)
 {
     if (itemInventory_[(int)item] == 1)
     {
         return(true);
     }
     return(false);
 }
示例#3
0
 public bool isBoughtItem(Constant.ItemDef item)
 {
     if (itemInventory_[(int)item] != 0)
     {
         return(true);
     }
     return(false);
 }
示例#4
0
 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);
 }
示例#5
0
    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);
    }
示例#6
0
 public static Constant.ItemState GetItemState(Constant.ItemDef itemName)
 {
     return(itemInventory_[(int)itemName]);
 }
示例#7
0
 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;
 }