コード例 #1
0
ファイル: CreateShopItem.cs プロジェクト: BushoRyu/-
    public Action <int> Init()
    {
        Action <int> onChangeCoin = (coin) => { };

        foreach (int id in itemIds)
        {
            var item = (Instantiate(Resources.Load("Prefabs/ItemButton")) as GameObject).transform;
            item.SetParent(shopContent, false);
            item.GetComponent <ShowItemData> ().SetItemData(id);

            Button button = item.Find("Button").GetComponent <Button> ();
            Button panel  = item.GetComponent <Button> ();

            int key = id;

            button.onClick.AddListener(() => {
                OpenYesNoWindow(key);
            });

            panel.onClick.AddListener(() => {
                ChangeItemText(key);
            });

            onChangeCoin += (coin) => {
                bool canBuy = coin >= ItemMasterData.GetValue(key).prise;
                button.interactable = canBuy;
                panel.interactable  = canBuy;
            };
        }

        ItemTextInit();

        return(onChangeCoin);
    }
コード例 #2
0
 public void SetItemData(int id)
 {
     itemData      = ItemMasterData.GetValue(id);
     image.sprite  = itemData.sprite;
     itemName.text = itemData.name;
     price.text    = itemData.prise.ToString();
 }
コード例 #3
0
ファイル: CreateShopItem.cs プロジェクト: BushoRyu/-
 private void ItemTextInit()
 {
     if (ItemMasterData.GetLength() > 0 && itemIds.Length > 0)
     {
         itemText.text = ItemMasterData.GetValue(itemIds [0]).text;
     }
     else
     {
         itemText.text = "品切れです";
     }
 }
コード例 #4
0
ファイル: CreateShopItem.cs プロジェクト: BushoRyu/-
 private void ChangeItemText(int id)
 {
     itemText.text = ItemMasterData.GetValue(id).text;
 }