public void UpdateRankContent() { if (WindObj == null || !WindObj.activeSelf) { return; } if (PlayerRole.Instance.RankManager.GetRankInfo() == null || PlayerRole.Instance.RelationManager.GetFriendMap() == null) { return; } m_RankList.Clear(); ClearGird(); if (PlayerRole.Instance.RankManager.GetRankInfo().ContainsKey((byte)m_RankType) == false) { return; } m_ScrollTrans.localPosition = new Vector3(64, 104, 0); m_UIPanel.clipOffset = new Vector2(55.27f, -150); m_UIScrollView.ResetPosition(); foreach (KeyValuePair <uint, tagRankInfo> map in PlayerRole.Instance.RankManager.GetRankInfo()[(byte)m_RankType].RankMap) { RankItemUI rank = new RankItemUI(m_RankType, map.Value); rank.Init(m_BaseChild); m_RankList.Add(rank); } m_RankList.Sort(CompareItemByIndex); for (byte i = 0; i < m_RankList.Count; ++i) { m_Grid.AddChild(m_RankList[i].m_BaseTrans, false); m_RankList[i].ResetScale(); } }
static int CompareItemByIndex(RankItemUI item1, RankItemUI item2) { if (item1.RankInfo.bIndex > item2.RankInfo.bIndex) { return(1); } else { return(-1); } }
public static RankItemUI CreateNew(Transform _parent) { GameObject go = null; UnityEngine.Object prefab = exResources.GetResource(ResourceType.GUI, "Ranking/RankingItem"); go = Instantiate(prefab) as GameObject; go.transform.parent = _parent; go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; go.SetActive(true); prefab = null; RankItemUI applyItem = go.GetComponent <RankItemUI>(); if (applyItem == null) { applyItem = go.AddComponent <RankItemUI>(); } return(applyItem); }
void ShowRank() { List <guild_guard_rank> rankList = GameCenter.activityMng.ProtectActivityRankList; for (int i = 0, max = rankList.Count; i < max; i++) { RankItemUI item = null; if (!allItemList.TryGetValue(i, out item)) { item = RankItemUI.CreateNew(rankPanel.transform); allItemList[i] = item; } item = allItemList[i]; if (item != null) { item.SetData(rankList[i], i); } } if (rankPanel != null) { rankPanel.repositionNow = true; } }