private ServerMsgStruct DefaulatAnalyzeZones(object obj) { ServerMsgStructZone msgStruct = new ServerMsgStructZone(); msgStruct.analyzeData(obj); return(msgStruct); }
void OnPropertyChanged(int objectID, int eventType, IPropertyObject obj, object eventObj) { if (eventType == (int)Login.ENPropertyChanged.enServerListUpdate) { ServerMsgStructZone msg = (ServerMsgStructZone)eventObj; UpdateList(msg); } }
public void OnMsgGetZone(int respond, Dictionary <string, ServerMsgStruct> msgList) { ServerMsgStruct msgStruct; if (msgList.TryGetValue(ServerMessageKeyWords.KEYWORD_ZONES, out msgStruct) == false) { return; } ServerMsgStructZone msg = (ServerMsgStructZone)msgStruct; // foreach (ZoneInfo info in msg.zoneInfoList) // { //Debug.Log(info.zoneName + info.zoneUrl); // } // UIServerList.GetInstance().UpdateList(msg); Login.Singleton.OnGetZone(msg); }
// 获取服务器列表 public void OnGetZone(ServerMsgStructZone msg) { NotifyChanged((int)ENPropertyChanged.enServerListUpdate, msg); }
public void UpdateList(ServerMsgStructZone msg) { // 暂时以列表不空 时不做处理 需修改 如果 要强制更新的时候 要跳过此判断 做额外处理 todo if (m_serverList.Count != 0 && m_serverList.Count != 0) { return; } // 显示推荐服务器 UIImageButton btn = FindChildComponent <UIImageButton>("Server"); if (msg.zoneInfoList.Count >= 1) { btn.transform.Find("ServerTxt").name = "Txt" + 0; // 设置位置 btn.transform.localPosition = Vector3.zero; FindChildComponent <UILabel>("Txt" + 0).text = msg.zoneInfoList[0].zoneName; btn.name = "" + 0; AddChildMouseClickEvent(btn.name, OnClickServer); m_serverList.Add(btn.name, msg.zoneInfoList[0]); //Debug.Log("1UpdateList:" + msg.zoneInfoList[0].zoneName); } if (msg.zoneInfoList.Count <= 1) { return; } // 显示全部服务器 for (int i = 0; i < msg.zoneInfoList.Count; i++) { UIImageButton btn1 = GameObject.Instantiate(btn) as UIImageButton; // 设置 父物体 btn1.transform.parent = FindChildComponent <UIPanel>("AllServers").transform; // 设置位置 btn1.transform.localPosition = new Vector3(0, i * (-25), 0); // 设置大小 btn1.transform.localScale = btn.transform.localScale; // 修改按钮名称 btn1.name = "all" + i; // 修改名称 btn1.transform.Find("Txt0").name = "Txt" + i; FindChildComponent <UILabel>("Txt" + i).text = msg.zoneInfoList[i].zoneName; // 关联事件 AddChildMouseClickEvent(btn1.name, OnClickServer2); if (false == m_allServerList.ContainsKey(btn1.name)) { m_allServerList.Add(btn1.name, msg.zoneInfoList[i]); } //Debug.Log("2UpdateList: i =" + i + "," + msg.zoneInfoList[i].zoneName + ",label.text:" + FindChildComponent<UILabel>("Txt" + i).text + ",btn1.name:" + btn1.name); } }