void UpdateHeroItem(int index, RectTransform cell) { HeroItemData objHero = heroDatas[index]; UI_HeroListItem uiIt = cell.gameObject.GetComponent <UI_HeroListItem>(); if (uiIt == null) { uiIt = cell.gameObject.AddComponent <UI_HeroListItem>(); heroList.Add(uiIt); } // 有一个空 if (ObjectSelf.GetInstance().HeroContainerBag.GetHeroList().Count % 2 != 0 && index == ObjectSelf.GetInstance().HeroContainerBag.GetHeroList().Count) { uiIt.index = index; uiIt.m_id = index; uiIt.Initialize(objHero, ItemType.Empty); } else { uiIt.index = index; uiIt.m_id = index; uiIt.Initialize(objHero); } // // if (index < ObjectSelf.GetInstance ().HeroContainerBag.GetHeroList ().Count) { // uiIt.index = index; // uiIt.m_id = index; // uiIt.Initialize (objHero); // } // //else if(index == // else // { // uiIt.index = index; // uiIt.m_id = index; // uiIt.Initialize(objHero); // } // if (index == noGetHeros.Count && (noGetHeros.Count % 2 != 0)) //当显示未获取的英雄时 需要空出一个空格 // { // uiIt.index = index; // uiIt.m_id = index; // uiIt.Initialize(objHero, ItemType.Empty); // } // else // { // uiIt.index = index; // uiIt.m_id = index; // uiIt.Initialize(objHero); // } }
// 加载一个英雄 GameObject LoadCurHero(int index) { GameObject cell = null; int count = _heroList.Count; if (index < count) { HeroTemplate heroData = new HeroTemplate(); heroData = ( HeroTemplate )_heroList [index].GetHeroRow(); cell = Instantiate(Resources.Load("UI/Prefabs/UI_Home/UI_HeroItem")) as GameObject; cell.AddComponent <Button> (); ObjectCard objHero = _heroList [index]; UI_HeroListItem uiIt = cell.AddComponent <UI_HeroListItem> (); _curHeroListItem.Add(uiIt); uiIt.m_id = index; uiIt.tableId = objHero.GetHeroData().TableID; uiIt.AddSelectBtnSoul(); uiIt.ShowInfo(); // 是否正在探险中 if (ObjectSelf.GetInstance().IsInExploring(objHero.GetHeroData().GUID)) { uiIt.SetExplore(true); uiIt.specialValue = -1; } else { uiIt.SetExplore(false); uiIt.specialValue = GetSpecialValue(objHero, index); // 是否已上阵 if (isUpFront(objHero)) { uiIt.ShowUpFront(); } } } else { string url = "UI/Prefabs/UI_Home/UI_HeroItemK2"; //空框修正值 cell = Instantiate(Resources.Load(url)) as GameObject; cell.transform.FindChild("UI_HeroItemK").GetComponent <RectTransform> ().anchoredPosition = new Vector2(cell.transform.FindChild("UI_HeroItemK").GetComponent <RectTransform> ().anchoredPosition.x, 41); } return(cell); }
List <HeroTemplate> noGetHeros = new List <HeroTemplate>(); //未获取的英雄 public void SetCurHeroListItem(UI_HeroListItem item) { curHLItem = item; }