示例#1
0
    private GameObject GetItem(PetInfo petinfo, Pet dataPet, bool isSelected)
    {
        GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab(WidgetName.PetChooseItem);

        instantiate2Prefab.set_name("Item_" + petinfo.petId);
        PetID component = instantiate2Prefab.GetComponent <PetID>();

        component.petInfo = petinfo;
        instantiate2Prefab.SetActive(true);
        instantiate2Prefab.get_transform().SetParent(this.GridChoosePet.get_transform());
        instantiate2Prefab.GetComponent <RectTransform>().set_localScale(Vector3.get_one());
        instantiate2Prefab.GetComponent <ButtonCustom>().onClickCustom = new ButtonCustom.VoidDelegateObj(this.OnClickPetChoose);
        component.SetItem(dataPet, petinfo);
        component.ShowLimit(PetManager.Instance.IsFormationFromInstance && PetManagerBase.IsPetLimit(petinfo.petId));
        component.ShowSelect(isSelected);
        if (this.mMode != PetSelectUI.Mode.PetTask)
        {
            component.SetRecommend(false);
        }
        else
        {
            component.SetRecommend(PetTaskFormationUIView.Instance.IsRecommend((int)dataPet.id));
        }
        return(instantiate2Prefab);
    }
    private void ResetChoosePetUI()
    {
        if (this.mPetInfos == null)
        {
            return;
        }
        this.petSelectedInfo    = null;
        this.petSelectedGameObj = null;
        for (int i = 0; i < this.listPetsGameObject.get_Count(); i++)
        {
            GameObject gameObject = this.listPetsGameObject.get_Item(i);
            Object.Destroy(gameObject);
        }
        this.listPetsGameObject.Clear();
        bool flag = false;

        for (int j = 0; j < this.mPetInfos.get_Count(); j++)
        {
            PetInfo petinfo = this.mPetInfos.get_Item(j);
            if (ElementInstanceManager.Instance.m_elementCopyLoginPush.minePetInfos.Find((MinePetInfo a) => a.petId == petinfo.id) == null)
            {
                flag = true;
                Pet dataPet = DataReader <Pet> .Get(petinfo.petId);

                GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab(WidgetName.PetChooseItem);
                instantiate2Prefab.set_name("PetChooseItem_" + j);
                PetID component = instantiate2Prefab.GetComponent <PetID>();
                component.petInfo = petinfo;
                instantiate2Prefab.SetActive(true);
                instantiate2Prefab.get_transform().SetParent(this.GridChoosePet.get_transform());
                instantiate2Prefab.GetComponent <ButtonCustom>().onClickCustom = new ButtonCustom.VoidDelegateObj(this.OnClickPetChoose);
                component.SetItem(dataPet, petinfo);
                this.listPetsGameObject.Add(instantiate2Prefab);
            }
        }
        if (flag)
        {
            this.NoPets.get_gameObject().SetActive(false);
        }
        else
        {
            this.NoPets.get_gameObject().SetActive(true);
        }
    }