void SortHeroWithQuailty(ref List <HerorecruitTemplate> heroList) { for (int i = 0; i < heroList.Count - 1; ++i) { HerorecruitTemplate item = heroList[i]; for (int j = i; j < heroList.Count; ++j) { HeroTemplate hero1 = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(heroList[i].GetID()); int quality1 = hero1.getQuality(); HeroTemplate hero2 = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(heroList[j].GetID()); int quality2 = hero2.getQuality(); if (quality2 > quality1) { item = heroList[j]; heroList[j] = heroList[i]; heroList[i] = item; } else if (quality2 == quality1) { if (hero2.GetID() > hero1.GetID()) { item = heroList[j]; heroList[j] = heroList[i]; heroList[i] = item; } } } } }
/// <summary> /// 初始化数据 /// </summary> /// <param name="heroId">英雄id</param> public void InitData(int heroId) { HeroTemplate hero = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(heroId); if (hero == null) { Debug.LogError("找不到英雄数据 id:" + heroId); return; } m_HeroName.text = GameUtils.getString(hero.getTitleID()); InterfaceControler.GetInst().ShowTypeIcon(hero, m_Type, m_TypeText); m_FragmentCount.text = string.Format("碎片数量:<color=#FF0000>{0}</color>/{1}", ObjectSelf.GetInstance().CommonItemContainer.GetFragmentCount(hero.GetID()), hero.getSyntheticCount()); ArtresourceTemplate _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(hero.getArtresources()); m_HeroIcon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + _Artresourcedata.getHeadiconresource()); m_Zizhi.sprite = InterfaceControler.GetInst().GetHeroAptImg(hero); m_Desc.text = GameUtils.getString(hero.getTedian()); SetTextColorByQuilt(hero.getQuality()); }
void OnRecruit() { UI_HeroListManager._instance.m_SelectRecruitTableId = this.objHeroItemData.heroTableID; ItemFragment item = (ItemFragment)ObjectSelf.GetInstance().CommonItemContainer.GetFragmentBaseItem(_HeroItem.GetID()); if (item != null) { item.OnUseItem(1); } }
/// <summary> /// 填充数据 需要标识一下是哪个界面的item /// </summary> /// <param name="objHero">英雄卡牌信息</param> public void Initialize(HeroItemData objHero, ItemType type = ItemType.None) { if (type == ItemType.Empty) { parent.gameObject.SetActive(false); return; } else { parent.gameObject.SetActive(true); } this.objHero = objHero.objcet; objHeroItemData = objHero; if (objHero.objcet != null) //获取item { m_GetTran.gameObject.SetActive(true); m_NoGetTran.gameObject.SetActive(false); m_HeroLevelTran.gameObject.SetActive(true); //设置 _HeroItem = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(objHero.objcet.GetHeroData().TableID); //卡牌图标 _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(objHero.objcet.GetHeroData().GetHeroViewID()); //等级显示 m_heroLevel = objHero.objcet.GetHeroData().Level; m_HeroLevelText.text = m_heroLevel.ToString(); //设置是否上阵 int mid = -1; m_ShangZhen.gameObject.SetActive(ObjectSelf.GetInstance().Teams.IsHeroInTeam(objHero.objcet.GetGuid(), ref mid)); //设置战斗力 m_FigthVigor.text = objHero.objcet.GetHeroData().FightVigor.ToString(); //星级 m_heroStar = this.objHero.GetHeroData().StarLevel; int maxStar = _HeroItem.getMaxQuality(); for (int i = 0; i < 6; i++) { Image temp = selfTransform.FindChild("Parent/new/touxiang/Star_Image").GetChild(i).GetComponent <Image>(); if (i < m_heroStar) { temp.gameObject.SetActive(true); } else { temp.gameObject.SetActive(false); } } //m_StarsHui.gameObject.SetActive(true); m_StarsHui.gameObject.SetActive(false); } else if (objHero.objcet == null) //未获取 { m_GetTran.gameObject.SetActive(false); m_NoGetTran.gameObject.SetActive(true); m_HeroLevelTran.gameObject.SetActive(false); m_ShangZhen.gameObject.SetActive(false); m_StarsHui.gameObject.SetActive(false); for (int i = 0; i < 6; i++) { selfTransform.FindChild("Parent/new/touxiang/Star_Image").GetChild(i).gameObject.SetActive(false); } //设置 _HeroItem = (HeroTemplate)DataTemplate.GetInstance().m_HeroTable.getTableData(objHero.heroTableID); //卡牌图标 _Artresourcedata = (ArtresourceTemplate)DataTemplate.GetInstance().m_ArtresourceTable.getTableData(_HeroItem.getArtresources()); //碎片合成进度 int fragmentCount = ObjectSelf.GetInstance().CommonItemContainer.GetFragmentCount(_HeroItem.GetID()); int needCount = _HeroItem.getSyntheticCount(); //Debug.LogError("process:" + fragmentCount + "max:" + needCount); if (fragmentCount >= needCount) { m_GetHeroBt.gameObject.SetActive(false); m_RecruitBt.gameObject.SetActive(true); } else { m_GetHeroBt.gameObject.SetActive(true); m_RecruitBt.gameObject.SetActive(false); } m_CompoundText.text = fragmentCount + "/" + needCount; float _baifenbi = ((float)fragmentCount / needCount); m_RectFill.sizeDelta = new Vector2((_baifenbi > 1 ? 1 :_baifenbi) * m_FillInitWidth, m_RectFill.sizeDelta.y); } m_HeroIcon.sprite = UIResourceMgr.LoadSprite(url + _Artresourcedata.getHeadiconresource()); //类型 InterfaceControler.GetInst().ShowTypeIcon(_HeroItem, m_HeroTypeIcon, m_HeroTypeText); //品质 if (objHeroItemData.objcet == null) { m_Qulit.sprite = InterfaceControler.GetInst().ReturnHeroQuailty(_HeroItem.getQuality()); } else { m_Qulit.sprite = InterfaceControler.GetInst().ReturnHeroQuailty(this.objHero.GetHeroData().QualityLev); } //Debug.Log(m_heroLevel); //名称 ChsTextTemplate chs = new ChsTextTemplate(); chs = (ChsTextTemplate)DataTemplate.GetInstance().m_ChsTextTable.getTableData(_HeroItem.getTitleID()); m_heroName = chs.languageMap["Chinese"]; HeroName.text = m_heroName; if (objHeroItemData.objcet == null) { SetTextColorByQuilt(_HeroItem.getQuality()); } else { SetTextColorByQuilt(this.objHero.GetHeroData().QualityLev); } }