private void OnGetMatch(GetMatchResult result) { //storing the players IDs on the PlayersIDSaver two join them string p1 = result.Members[0].Attributes.DataObject.ToString(); string p2 = result.Members[1].Attributes.DataObject.ToString(); Debug.Log("..." + p1); Debug.Log("..." + p2); string p1ID = ""; string p2ID = ""; //reading the id of the two players for (int i = 7; i < p1.Length - 2; i++) { p1ID += p1[i]; } for (int i = 7; i < p2.Length - 2; i++) { p2ID += p2[i]; } Debug.Log(p1ID); Debug.Log(p2ID); idSaver.ManageIDs(p1ID, p2ID); //sending my selected level data to the other player EftClient.Send(Application.persistentDataPath + "/Multiplayer Levels/" + PlayerPrefs.GetString("selectedLevelName") + ".level", ID_Generator.ID_to_IP(PlayerPrefs.GetString("otherPlayerID")), 9999); matchmakingObjects.SetActive(false); gameplayObjects.SetActive(true); }
public void Join() { //trying to connect to the target player host try { networkAddress = ID_Generator.ID_to_IP(id); StartClient(); Debug.Log("Client Started"); } catch (Exception e) { Debug.Log(e); } }
private void Start() { //generating the player ID once he open this scene string hostName = Dns.GetHostName(); string ip = Dns.GetHostByName(hostName).AddressList[0].ToString(); playerID = ID_Generator.IP_to_ID(ip); // reciving the other player level data EftServer server = new EftServer(Application.persistentDataPath + "/", 9999); System.Threading.Thread thread = new System.Threading.Thread(server.StartServer); thread.Start(); }
public void Join() { //trying to connect to the target player host try { networkAddress = ID_Generator.ID_to_IP(enterPlayerID.text); StartClient(); Debug.Log("Client Started"); }catch (Exception e) { oneVoneVarManager.OneVoneVarManager.errorPanel.SetActive(true); oneVoneVarManager.OneVoneVarManager.errorContent.text = e.ToString(); } }
public void ManageIDs(string player1ID, string player2ID) { if (player1ID == myID) { isHost = true; otherPlayerID = player2ID; otherPlayerIP = ID_Generator.ID_to_IP(otherPlayerID); PlayerPrefs.SetInt("isHost", 1); PlayerPrefs.SetString("otherPlayerID", otherPlayerID); } else { isHost = false; otherPlayerID = player1ID; otherPlayerIP = ID_Generator.ID_to_IP(otherPlayerID); PlayerPrefs.SetInt("isHost", 0); PlayerPrefs.SetString("otherPlayerID", otherPlayerID); } }
public ID_Generator() { instance = this; }