private void SetPetInfo() { SysPet pet = BaseDataMgr.instance.GetDataById <SysPet>(currentPPet.petId); NGUITools.FindInChild <UISprite>(gameObject, "info/gradeicn").spriteName = PetLogic.GetGradeIcn(currentPPet.grade); if (currentPPet != null) { NGUITools.FindInChild <UISprite>(gameObject, "info/typeicn").spriteName = PetLogic.GetTypeIcnName(pet.type); name.text = PetLogic.GetGradeDes(currentPPet.grade, pet.name); SetStars(currentPPet.star); NGUITools.FindInChild <UILabel>(gameObject, "info/levelvalue").text = currentPPet.lvl.ToString(); SysPetGrowUp petExp = BaseDataMgr.instance.GetDataById <SysPetGrowUp>(currentPPet.lvl); float exp = petExp.exp_upgrade; NGUITools.FindInChild <UISlider>(gameObject, "info/exp").value = currentPPet.exp / exp; NGUITools.FindInChild <UILabel>(gameObject, "info/exp/label").text = currentPPet.exp + "/" + exp; int stonenum = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)pet.stone_id); float need = 0f; if (currentPPet.star < 5) { need = PetLogic.GetNeedStone(currentPPet.star, true); NGUITools.FindInChild <UISlider>(gameObject, "info/stone/num").value = stonenum / need; } else { NGUITools.FindInChild <UISlider>(gameObject, "info/stone/num").value = 1; } NGUITools.FindInChild <UILabel>(gameObject, "info/stone/num/label").text = stonenum + "/" + need; //出战处理 if (currentPPet.state == 0) { FightButton.FindInChild <UILabel>("lk").text = "出战"; } else { FightButton.FindInChild <UILabel>("lk").text = "休息"; } SetPetSkill(currentPPet); SetPetEquips(currentPPet); SetPetProperty(currentPPet); } }
//设置宠物信息 private void SetPetInfo(SysPet pet, int num, bool own) { GameObject petobj; if (num > petsObj.Count) { petobj = GameObject.Instantiate(petsObj[0]) as GameObject; petsObj.Add(petobj); petobj.transform.parent = petsObj[0].transform.parent; petobj.transform.localScale = new Vector3(1, 1, 1); petobj.SetActive(false); petobj.GetComponent <UIWidgetContainer>().onClick = OnPetClick; petobj.name = pet.id.ToString(); } else { petobj = petsObj[num - 1]; petobj.name = pet.id.ToString(); } SetPetObjPos(petobj, num, own); NGUITools.FindInChild <UISprite>(petobj, "image").spriteName = pet.icon.ToString(); petobj.SetActive(true); NGUITools.FindChild(petobj, "tips").SetActive(false); //提示默认关闭 if (!own || PetLogic.CanOwn(pet)) { NGUITools.FindInChild <UILabel>(petobj, "name").text = pet.name; UIUtils.ChangeGrayShader(NGUITools.FindInChild <UISprite>(petobj, "image"), imageDepth - 1); NGUITools.FindChild(petobj, "equips").SetActive(false); NGUITools.FindChild(petobj, "level").SetActive(false); NGUITools.FindChild(petobj, "stars").SetActive(false); NGUITools.FindChild(petobj, "stone").SetActive(true); int stone = Singleton <GoodsMode> .Instance.GetCountByGoodsId((uint)pet.stone_id); int need = PetLogic.GetNeedStone((uint)pet.star, false); NGUITools.FindInChild <UISprite>(petobj, "gradeicn").spriteName = ""; NGUITools.FindInChild <UISlider>(petobj, "stone").value = stone / (float)need; NGUITools.FindInChild <UILabel>(petobj, "stone/num").text = stone + "/" + need; if (PetLogic.CanOwn(pet)) { NGUITools.FindChild(petobj, "active").SetActive(true); NGUITools.FindChild(petobj, "tips").SetActive(true); NGUITools.FindChild(petobj, "gradeicn").SetActive(false); } else { NGUITools.FindChild(petobj, "gradeicn").SetActive(false); NGUITools.FindChild(petobj, "active").SetActive(false); } } else { PPet ppet = Singleton <PetMode> .Instance.GetPetByPetId((uint)pet.id); NGUITools.FindChild(petobj, "gradeicn").SetActive(true); NGUITools.FindInChild <UISprite>(petobj, "gradeicn").spriteName = PetLogic.GetGradeIcn(ppet.grade); NGUITools.FindInChild <UILabel>(petobj, "name").text = PetLogic.GetGradeDes(ppet.grade, pet.name); UIUtils.ChangeNormalShader(NGUITools.FindInChild <UISprite>(petobj, "image"), imageDepth); NGUITools.FindChild(petobj, "equips").SetActive(true); NGUITools.FindChild(petobj, "level").SetActive(true); NGUITools.FindInChild <UILabel>(petobj, "level/label").text = ppet.lvl.ToString(); NGUITools.FindChild(petobj, "stars").SetActive(true); SetStar(petobj, ppet.star); SetEquipInfo(petobj, ppet.petId); NGUITools.FindChild(petobj, "stone").SetActive(false); NGUITools.FindChild(petobj, "active").SetActive(false); //检查是否可以升阶-升星 if (PetLogic.CanUpgrade(ppet) || PetLogic.CanEvolve(ppet)) { NGUITools.FindChild(petobj, "tips").SetActive(true); } } NGUITools.FindInChild <UISprite>(petobj, "typeicn").spriteName = PetLogic.GetTypeIcnName(pet.type); }