private void SyncMars(List <GowDataForMsg> marslist) { try { if (marslist != null) { int mlcount = marslist.Count; int glcount = golist.Count; UnityEngine.GameObject item = UIManager.Instance.GetWindowGoByName("Ranking"); UnityEngine.Transform tfr = item.transform.Find("ScrollView2/Grid"); if (tfr == null) { return; } for (int i = 0; i < mlcount; ++i) { if (i < glcount) { UnityEngine.GameObject go = golist[i]; if (go != null) { GowDataForMsg gdfm = marslist[i]; if (gdfm != null) { SetMarsCellInfo(go, gdfm, i); } } } else { UnityEngine.GameObject go = CrossObjectHelper.TryCastObject <UnityEngine.GameObject>(ArkCrossEngine.ResourceSystem.GetSharedResource("UI/Mars/MarsCell")); if (go != null) { go = NGUITools.AddChild(tfr.gameObject, go); if (go != null) { golist.Add(go); GowDataForMsg gdfm = marslist[i]; if (gdfm != null) { SetMarsCellInfo(go, gdfm, i); } } } } } if (glcount > mlcount) { for (int j = mlcount; j < glcount; ++j) { UnityEngine.GameObject go = golist[j]; if (go != null) { NGUITools.DestroyImmediate(go); } } golist.RemoveRange(mlcount, glcount - mlcount); } UIGrid ug = tfr.gameObject.GetComponent <UIGrid>(); if (ug != null) { ug.repositionNow = true; } } } catch (Exception ex) { ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
private void SetMarsCellInfo(UnityEngine.GameObject go, GowDataForMsg gdfm, int order) { if (go != null && gdfm != null) { UnityEngine.Transform tf = go.transform.Find("Label4/Sprite"); if (tf != null) { UISprite us = tf.gameObject.GetComponent <UISprite>(); if (us != null) { us.spriteName = "no" + (order + 1); } } tf = go.transform.Find("Head"); if (tf != null) { UISprite us = tf.gameObject.GetComponent <UISprite>(); if (us != null) { Data_PlayerConfig cg = PlayerConfigProvider.Instance.GetPlayerConfigById(gdfm.m_Heroid); us.spriteName = cg.m_PortraitForCell; } } tf = go.transform.Find("Label0"); if (tf != null) { UILabel ul = tf.gameObject.GetComponent <UILabel>(); if (ul != null) { ul.text = "Lv." + gdfm.m_Level; } } tf = go.transform.Find("Label1"); if (tf != null) { UILabel ul = tf.gameObject.GetComponent <UILabel>(); if (ul != null) { ul.text = gdfm.m_FightingScore.ToString(); } } tf = go.transform.Find("Label2"); if (tf != null) { UILabel ul = tf.gameObject.GetComponent <UILabel>(); if (ul != null) { ul.text = gdfm.m_GowElo.ToString(); } } tf = go.transform.Find("Label3"); if (tf != null) { UILabel ul = tf.gameObject.GetComponent <UILabel>(); if (ul != null) { ul.text = gdfm.m_Nick; } } tf = go.transform.Find("Label4"); if (tf != null) { UILabel ul = tf.gameObject.GetComponent <UILabel>(); if (ul != null) { if (order + 1 < 4) { ul.text = "NOD" + (char)('A' + order); } else { ul.text = (order + 1).ToString() + "ETH"; } } } } }