コード例 #1
0
    private void ChooseIsInstance(GameObject sender)
    {
        if (this.mMode != PetSelectUI.Mode.Instance)
        {
            return;
        }
        PetID component = sender.GetComponent <PetID>();

        if (component == null)
        {
            return;
        }
        string[]   array       = sender.get_name().Split("_".ToCharArray());
        int        num         = int.Parse(array[1]);
        GameObject gameObject  = sender.get_transform().FindChild("ImageSelect").get_gameObject();
        PetInfo    petInfoById = PetManager.Instance.GetPetInfoById(num);

        if (petInfoById == null)
        {
            Debug.LogError("宠物不存在, petId = " + num);
            return;
        }
        Pet pet = DataReader <Pet> .Get(num);

        if (pet.fightRoleLv > EntityWorld.Instance.EntSelf.Lv)
        {
            string text = GameDataUtils.GetChineseContent(510112, false);
            text = text.Replace("{s1}", pet.fightRoleLv.ToString());
            UIManagerControl.Instance.ShowToastText(text);
            return;
        }
        if (gameObject.get_activeSelf())
        {
            component.ShowSelect(false);
            component.ShowLimit(PetManager.Instance.IsFormationFromInstance && PetManagerBase.IsPetLimit(petInfoById.petId));
            for (int i = 0; i < this.listPetsSelected.get_Count(); i++)
            {
                if (this.listPetsSelected.get_Item(i) == petInfoById.id)
                {
                    this.listPetsSelected.RemoveAt(i);
                    break;
                }
            }
        }
        else
        {
            if (this.listPetsSelected.get_Count() == this.m_maxPetsCount)
            {
                UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(505132, false));
                return;
            }
            if (PetManager.Instance.IsFormationFromInstance && PetManagerBase.IsPetLimit(petInfoById.petId))
            {
                InstanceManagerUI.ShowLimitMessage();
                return;
            }
            component.ShowSelect(true);
            this.listPetsSelected.Add(petInfoById.id);
        }
    }
コード例 #2
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);
    }