Пример #1
0
    void ShowPet(PetItemShowType type)
    {
        InitControl();

        if (type == PetItemShowType.Normal)
        {
            petIconBtn.gameObject.SetActive(true);
            petLockBtn.gameObject.SetActive(false);
            addPetBtn.gameObject.SetActive(false);
        }
        else if (type == PetItemShowType.Lock)
        {
            petIconBtn.gameObject.SetActive(false);
            petLockBtn.gameObject.SetActive(true);
            addPetBtn.gameObject.SetActive(false);
        }
        else if (type == PetItemShowType.Add)
        {
            petIconBtn.gameObject.SetActive(false);
            petLockBtn.gameObject.SetActive(false);
            addPetBtn.gameObject.SetActive(true);
        }
    }
Пример #2
0
 public void UpdatePetItemData(IPet data, PetItemShowType type = PetItemShowType.Normal)
 {
     selectPet = data;
     ShowPet(type);
     if (data != null)
     {
         table.PetDataBase petdb = petDataManager.GetPetDataBase(data.PetBaseID);
         if (petdb != null)
         {
             petNameLabel.text = petDataManager.GetPetName(data);
             if (selectPet != null)
             {
                 m_levelLabel.text = petDataManager.GetPetLvelStr(selectPet.GetID());
             }
             if (petIconBtn != null)
             {
                 //UIButton spr = petIconBtn.GetComponent<UIButton>();
                 //if (spr != null)
                 {
                     UITexture petspr = petIconBtn.GetComponent <UITexture>();
                     if (petspr)
                     {
                         //  DataManager.Manager<UIManager>().SetSpriteDynamicIcon(petspr, petdb.icon);
                         UIManager.GetTextureAsyn(petdb.icon, ref m_curIconAsynSeed, () =>
                         {
                             if (null != petspr)
                             {
                                 petspr.mainTexture = null;
                             }
                         }, petspr, false);
                         Transform bgTrans = petspr.transform.Find("Pingzhi_bg");
                         if (bgTrans)
                         {
                             UISprite bgSpr = bgTrans.GetComponent <UISprite>();
                             if (bgSpr)
                             {
                                 string bgName = ItemDefine.GetItemFangBorderIconByItemID(petdb.ItemID);
                                 UIManager.GetAtlasAsyn(bgName, ref m_curQualityAsynSeed, () =>
                                 {
                                     if (null != bgSpr)
                                     {
                                         bgSpr.atlas = null;
                                     }
                                 }, bgSpr);
                             }
                         }
                     }
                     // spr.normalSprite = petdb.icon;
                 }
             }
         }
         if (petDataManager.CurFightingPet == selectPet.GetID())
         {
             fightFlag.gameObject.SetActive(true);
         }
         else
         {
             fightFlag.gameObject.SetActive(false);
         }
     }
     else
     {
         if (fightFlag == null)
         {
             return;
         }
         fightFlag.gameObject.SetActive(false);
         m_levelLabel.text = "";
         if (type == PetItemShowType.Add)
         {
             UISprite spr = addPetBtn.Find("iconspr").GetComponent <UISprite>();
             if (spr != null)
             {
                 spr.gameObject.SetActive(false);
             }
             petNameLabel.text = "";
         }
         else if (type == PetItemShowType.Lock)
         {
             petNameLabel.color = Color.white;
             petNameLabel.text  = ColorManager.GetColorString(0, 144, 255, 255, "[u]" + CommonData.GetLocalString("增加珍兽上限") + "[/u]");
         }
         Transform gaoliangSpr = transform.Find("Sprite");
         if (gaoliangSpr != null)
         {
             if (selectPet == null)
             {
                 gaoliangSpr.gameObject.SetActive(false);
                 return;
             }
             if (petDataManager.CurPetThisID == selectPet.GetID())
             {
                 gaoliangSpr.gameObject.SetActive(true);
             }
             else
             {
                 gaoliangSpr.gameObject.SetActive(false);
             }
         }
     }
 }