Exemple #1
0
    public void RefreshUI(int pos, int currentSlot)
    {
        this.CurrentPos  = pos;
        this.CurrentSlot = currentSlot;
        this.cellTransList.Clear();
        List <Goods> canEnchantmentGoods = EquipGlobal.GetCanEnchantmentGoods(this.CurrentPos, this.CurrentSlot);

        if (canEnchantmentGoods.get_Count() <= 0)
        {
            this.NoEnchantMentTrans.get_gameObject().SetActive(true);
            this.HaveEnchantMentTrans.get_gameObject().SetActive(false);
        }
        else
        {
            this.NoEnchantMentTrans.get_gameObject().SetActive(false);
            this.HaveEnchantMentTrans.get_gameObject().SetActive(true);
            for (int i = 0; i < this.scrollLayout.get_transform().get_childCount(); i++)
            {
                Transform child = this.scrollLayout.get_transform().GetChild(i);
                Object.Destroy(child.get_gameObject());
            }
            for (int j = 0; j < canEnchantmentGoods.get_Count(); j++)
            {
                Goods      goods = canEnchantmentGoods.get_Item(j);
                GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab(WidgetName.PetChooseItem);
                instantiate2Prefab.set_name("Enchantment_" + goods.GetItemId());
                PetID component = instantiate2Prefab.GetComponent <PetID>();
                instantiate2Prefab.SetActive(true);
                instantiate2Prefab.get_transform().SetParent(this.scrollLayout.get_transform());
                instantiate2Prefab.GetComponent <RectTransform>().set_localScale(new Vector3(1f, 1f, 1f));
                instantiate2Prefab.GetComponent <ButtonCustom>().onClickCustom = new ButtonCustom.VoidDelegateObj(this.OnClickSelectEnchantmentItem);
                component.SetItemData(goods.GetItemId());
                this.cellTransList.Add(instantiate2Prefab.get_transform());
            }
            if (this.CurrentSelectID < 0 && this.cellTransList.get_Count() > 0)
            {
                this.CurrentSelectID = this.cellTransList.get_Item(0).GetComponent <PetID>().ItemID;
                this.cellTransList.get_Item(0).GetComponent <PetID>().Selected = true;
                this.SetEnchantmentGoodInfo();
            }
            else if (this.CurrentSelectID > 0)
            {
                int num = this.cellTransList.FindIndex((Transform a) => a.GetComponent <PetID>().ItemID == this.CurrentSelectID);
                if (num >= 0)
                {
                    this.cellTransList.get_Item(num).GetComponent <PetID>().Selected = true;
                }
            }
        }
    }