/// <summary> /// 选择被吃的宝宝 /// </summary> /// <param name="item"></param> public void OnChooseMaterialClick(MaterialPartnerItemLogic item) { if (item.Choose) { m_ChoosePartnerGuid.Add(item.GetGuid()); m_ChoosePartnerExp += item.StarExp; } else { m_ChoosePartnerGuid.Remove(item.GetGuid()); m_ChoosePartnerExp -= item.StarExp; } ShowFellowDetail(item.m_fellow); int nTotalStarExp = m_ChoosePartnerExp + m_Fellow.StarExp; m_ChooseMaterialExpSprite.fillAmount = (float)nTotalStarExp / (float)m_Fellow.GetCurStarExpMax(); int addLevel = FellowTool.GetFellowAddStarLevel(m_Fellow.StarLevel, nTotalStarExp); if (addLevel > 0) { m_ChooseMaterialExpCount.gameObject.SetActive(true); m_ChooseMaterialExpCount.text = "x" + addLevel.ToString(); } else { m_ChooseMaterialExpCount.gameObject.SetActive(false); } if (PartnerFrameLogic.Instance().NewPlayerGuideFlag_Step == 17) { PartnerFrameLogic.Instance().NewPlayerGuide(18); } }
void UpdateFellowInfo_NextStar(Fellow fellow, int addExp) { int nNewStarExp = fellow.StarExp + addExp; // int nTotalStarExp = nNewStarExp; int addLevel = FellowTool.GetFellowAddStarLevel(fellow.StarLevel, nNewStarExp); // int nNewStarLevel = fellow.StarLevel + addLevel; if (fellow.GetCurStarExpMax() > 0) { //m_MaterialPartnerExpLabel.text = nNewStarExp.ToString() + "/" + fellow.GetCurStarExpMax(); m_MaterialPartnerExpSprite.fillAmount = (float)nNewStarExp / (float)fellow.GetCurStarExpMax(); } else { //m_MaterialPartnerExpLabel.text = ""; m_MaterialPartnerExpSprite.fillAmount = 0; } if (addLevel > 0) { m_MaterialPartnerExpCount.gameObject.SetActive(true); m_MaterialPartnerExpCount.text = "x" + addLevel.ToString(); } else { m_MaterialPartnerExpCount.gameObject.SetActive(false); } }
/// <summary> /// 自动筛选宠物 /// </summary> /// <param name="quality"></param> void InitMaterialPartnerGrid_Auto(int quality) { Utils.CleanGrid(m_ChooseMaterialGrid); m_ChoosePartnerGuid.Clear(); m_ChoosePartnerExp = 0; FellowContainer container = GameManager.gameManager.PlayerDataPool.FellowContainer; if (container == null) { return; } //遍历伙伴容器 List <Fellow> fellowList = FellowTool.FellowSort(container); bool gotFTEFellow = false; for (int i = 0; i < fellowList.Count; ++i) { //有效槽位 Fellow fellow = fellowList[i]; if (false == fellow.IsValid() || fellow.Guid == m_Fellow.Guid || fellow.Locked) { continue; } string objectName = string.Empty; if (!gotFTEFellow && PartnerFrameLogic.Instance().NewPlayerGuideFlag_Step == 16 && fellow.DataId == 41)// 宠物升星引导狗粮宠 { gotFTEFellow = true; objectName = "a" + fellow.DataId; } else { objectName = "b" + i; } GameObject fellowobject = Utils.BindObjToParent(m_MaterialPartnerItem, m_ChooseMaterialGrid, objectName); var logic = fellowobject.GetComponent <MaterialPartnerItemLogic>(); if (fellowobject == null || logic == null) { continue; } logic.Init(fellow); if (fellow.Quality < quality) { logic.Choose = true; m_ChoosePartnerGuid.Add(fellow.Guid); m_ChoosePartnerExp += logic.StarExp; } } if (fellowList.Count < FELLOW_PACK_DEFAULT_NUM) { for (int i = fellowList.Count; i <= FELLOW_PACK_DEFAULT_NUM; i++) { string objectName = "c" + i; Utils.BindObjToParent(m_MaterialPartnerItem, m_ChooseMaterialGrid, objectName); } } UIHexagonGrid grid = m_ChooseMaterialGrid.GetComponent <UIHexagonGrid>(); if (grid != null) { grid.sorted = true; grid.Reposition(); } int nTotalStarExp = m_ChoosePartnerExp + m_Fellow.StarExp; m_ChooseMaterialExpSprite.fillAmount = (float)nTotalStarExp / (float)m_Fellow.GetCurStarExpMax(); int addLevel = FellowTool.GetFellowAddStarLevel(m_Fellow.StarLevel, nTotalStarExp); if (addLevel > 0) { m_ChooseMaterialExpCount.gameObject.SetActive(true); m_ChooseMaterialExpCount.text = "x" + addLevel.ToString(); } else { m_ChooseMaterialExpCount.gameObject.SetActive(false); } }