public void Connect() { string playerName = GameObject.Find("Name Field").GetComponent <InputField>().text; connectToAddress = GameObject.Find("Address Field").GetComponent <InputField>().text; if (playerName == "") { Debug.LogWarning("You must have a name!"); playerName = PlayerName.GetName(); } PlayerName.SetName(playerName); NetworkTransport.Init(); ConnectionConfig cc = new ConnectionConfig(); reliableChannel = cc.AddChannel(QosType.Reliable); unreliableChannel = cc.AddChannel(QosType.Unreliable); HostTopology topo = new HostTopology(cc, MAX_CONNECTION); hostId = NetworkTransport.AddHost(topo, 0); connectionId = NetworkTransport.Connect(hostId, connectToAddress, port, 0, out error); connectionTime = Time.time; isConnected = true; packMan.ClearPacks(); Debug.Log("Started Client! : Error " + error + " : Port " + port); }
void CreateHostPlayer() { PlayerName.SetName(hostName); ServerClient c = new ServerClient(); c.connectionId = 0; c.playerName = PlayerName.GetName(); clients.Add(c); UpdateClientsList(); }
private void OnPlayerInfoChange(int playerNum) { if (playerNum == 1) { p1Name.SetName(playerController.GetPlayer(1).id); UpdateBankValues(playerController.GetPieceBank(1), p1Pieces); } else if (playerNum == 2) { p2Name.SetName(playerController.GetPlayer(2).id); UpdateBankValues(playerController.GetPieceBank(2), p2Pieces); } }