public bool OnServerList(NFIDataList valueList) { ArrayList serverList = NFCLoginLogic.Instance().mGameServerList; Debug.Log("OnServerList" + serverList.Count); ArrayList lst = new ArrayList(); foreach (Transform child in mContentList.transform) { lst.Add(child); Debug.Log(child.gameObject.name); } foreach (Transform child in lst) { Destroy(child.gameObject); } foreach (NFMsg.ServerInfo info in serverList) { GameObject item = Instantiate(mItemModle); item.transform.SetParent(mContentList); item.transform.localScale = UnityEngine.Vector3.one; item.GetComponentInChildren <Text>().text = System.Text.Encoding.Default.GetString(info.name); item.GetComponent <Button>().onClick.AddListener(() => { OnGameServerClick(info); }); } return(true); }
// Use this for initialization void Start() { mContentList = transform.Find("Panel/ListView/Mask/Content"); mItemModle = mContentList.Find("Item").gameObject; mItemModle.transform.SetParent(null); NFCLoginLogic.Instance().RegisterCallback((int)NFCLoginLogic.Event.WorldList, OnWorldList); NFCLoginLogic.Instance().RegisterCallback((int)NFCLoginLogic.Event.ServerList, OnServerList); NFCLoginLogic.Instance().RegisterCallback((int)NFCLoginLogic.Event.SelectServerSuccess, OnSelectServer); NFCLoginLogic.Instance().RequireWorldList(); }
// Use this for initialization void Start() { mAccount = transform.Find("Panel/Account").GetComponent <InputField>(); mPassword = transform.Find("Panel/Password").GetComponent <InputField>(); mLogin = transform.Find("Panel/Login").GetComponent <Button>(); mLogin.onClick.AddListener(onLoginClick); //NFCNetLogic.Instance().ConnectServer("104.160.35.67", 14001); NFCNetLogic.Instance().ConnectServer("127.0.0.1", 14001); NFCLoginLogic.Instance().RegisterCallback((int)NFCLoginLogic.Event.LoginSuccess, OnLoginSuccess); }
// UI Event private void onLoginClick() { NFCLoginLogic.Instance().LoginPB(mAccount.text, mPassword.text, ""); }
private void OnGameServerClick(NFMsg.ServerInfo info) { NFCLoginLogic.Instance().RequireSelectServer(info.server_id); }
// UI Event private void OnWorldServerClick(NFMsg.ServerInfo info) { NFCLoginLogic.Instance().RequireConnectWorld(info.server_id); }