public void OnClickConfirm(GameObject obj, object[] args) { GameConf conf = new GameConf(); conf.Name = UIOnline.s_roomName; conf.MapType = (MapType)m_mapOption.value; conf.MemCount = m_memCountOption.value + 2; conf.ForceKill = m_forceToggle.isOn; Globals.Instance.GameConf = conf; Globals.Instance.UIManager.RemoveUI(this); if (Globals.Instance.IsOnline) { BroadCastServer.Start(conf); Globals.Instance.StartServer(); Globals.Instance.UIManager.CreateUI <UIEnterRoom>(); // 自己作为第一个玩家 Globals.Instance.ConnectGame(Globals.GetPrivateIP(), 4050, conf); } else { Globals.Instance.ToGame(); } }
public void OnGetRoomConf(object[] args) { string address = args[0].ToString(); int port = (int)args[1]; GameConf conf = args[2] as GameConf; if (conf == null) { return; } if (m_gameConfs.ContainsKey(address)) { if (m_gameConfs[address].ContainsKey(port)) { return; } } else { m_gameConfs.Add(address, new Dictionary <int, GameConf>()); } m_gameConfs[address].Add(port, conf); CreateItem(address, port, conf); }
public void SetRoomConfig() { GameConf conf = Globals.Instance.GameConf; m_confText.text = string.Format( "地图: {0}\n人数: {1}\n必须砸落: {2}", UIConstants.s_mapName[conf.MapType], conf.MemCount, conf.ForceKill ? "是" : "否"); }
private void CreateItem(string address, int port, GameConf conf) { GameObject new_item = GameObject.Instantiate(m_roomItemTpl, m_roomListRoot); new_item.transform.Find("name").GetComponent <Text>().text = conf.Name; new_item.transform.Find("map").GetComponent <Text>().text = conf.MapType.ToString(); new_item.transform.Find("mem").GetComponent <Text>().text = conf.MemCount.ToString(); new_item.transform.Find("force").GetComponent <Text>().text = conf.ForceKill.ToString(); AddClickEvent(new_item.transform.Find("joinBtn").gameObject, OnClickJoin, address, port, conf); new_item.SetActive(true); }
public void ConnectGame(string address, int port, GameConf conf) { GameClient = new GameClient(address, port); }