public void Init(UISelectServer uss, ServerInfo info, ServerButtonImage buttonImage, bool isCache = false) { uiSelectServer = uss; serverInfo = info; isCaheServer = isCache; serverIdLabel.text = serverInfo.id.ToString(); serverNameLabel.text = string.Format("{0}({1})", serverInfo.name, buttonImage.buttonLabelTxt); bool isEnable = buttonImage.State != ServerState.Unavailable; if (isEnable) { imageButton.label.color = buttonImage.labelColor; cubeButton.label.color = buttonImage.labelColor; } imageButton.isEnabled = isEnable; cubeButton.isEnabled = isEnable; }
void InitAllServer() { int index = 0; foreach (ServerInfo info in FCDownloadManager.Instance.GameServers) { ServerButtonImage buttonImage = GetServerButtonImageByState(info.state); GameObject obj = NGUITools.AddChild(allServerGrid.gameObject, cloneSingle.gameObject); obj.transform.localPosition = cloneSingle.transform.localPosition; UISingleServer singServer = obj.GetComponent <UISingleServer>(); singServer.Init(this, info, buttonImage); singServer.gameObject.SetActive(true); obj.name = string.Format("sort{0}", index.ToString("000")); ++index; } UIGrid uigrid = allServerGrid.GetComponent <UIGrid>(); uigrid.repositionNow = true; }
ServerButtonImage GetServerButtonImageByState(ServerState state) { ServerButtonImage buttonImage; Color color; switch (state) { case ServerState.Unavailable: color = new Color(246f / 255f, 246f / 255f, 246f / 255f); buttonImage = new ServerButtonImage(state, color, "IDS_NAME_SERVERSTATUS_UNAVAILABLE"); break; case ServerState.New: color = new Color(0f / 255f, 255f / 255f, 255f / 255f); buttonImage = new ServerButtonImage(state, color, "IDS_NAME_SERVERSTATUS_NEW"); break; case ServerState.Recommended: color = new Color(0f / 255f, 255f / 255f, 255f / 255f); buttonImage = new ServerButtonImage(state, color, "IDS_NAME_SERVERSTATUS_RECOMMAND"); break; case ServerState.Normal: color = new Color(40f / 255f, 220f / 255f, 0f / 255f); buttonImage = new ServerButtonImage(state, color, "IDS_NAME_SERVERSTATUS_NORMAL"); break; case ServerState.Hot: color = new Color(255f / 255f, 190f / 255f, 0f / 255f); buttonImage = new ServerButtonImage(state, color, "IDS_NAME_SERVERSTATUS_HOT"); break; default: buttonImage = null; break; } return(buttonImage); }
void InitThreeServer() { List <ServerInfo> serverList = FCDownloadManager.Instance.GameServers; serverList.Sort(ServerInfo.CompareServerFromMaxToMin); //paixu const int Count = 3; List <ServerInfo> threeServerList = new List <ServerInfo>(); ServerInfo serverInfo = GetServerInfoFromCache(PrefsKey.ServerCacheOne); if (null != serverInfo) { threeServerList.Add(serverInfo); } serverInfo = GetServerInfoFromCache(PrefsKey.ServerCacheTwo); if (null != serverInfo) { threeServerList.Add(serverInfo); } if (threeServerList.Count >= 1) { foreach (ServerInfo info in serverList) { if (threeServerList.Count >= Count) { break; } if (!threeServerList.Contains(info)) { threeServerList.Add(info); } } } else { List <ServerInfo> recommendedList = serverList.FindAll( delegate(ServerInfo info) { return(info.state == ServerState.Recommended); }); foreach (ServerInfo info in recommendedList) { if (threeServerList.Count >= Count) { break; } if (!threeServerList.Contains(info)) { threeServerList.Add(info); } } if (threeServerList.Count < Count) { foreach (ServerInfo info in serverList) { if (threeServerList.Count >= Count) { break; } if (!threeServerList.Contains(info)) { threeServerList.Add(info); } } } } int index = 0; foreach (ServerInfo info in threeServerList) { ServerButtonImage buttonImage = GetServerButtonImageByState(info.state); GameObject obj = NGUITools.AddChild(cacheGrid.gameObject, cloneSingle.gameObject); UISingleServer singServer = obj.GetComponent <UISingleServer>(); singServer.Init(this, info, buttonImage, true); singServer.gameObject.SetActive(true); singServer.name = string.Format("sort{0}", index.ToString("000")); ++index; } UIGrid uigrid = cacheGrid.GetComponent <UIGrid>(); uigrid.repositionNow = true; }