/// <summary> /// Disconnect from the server connected to. /// </summary> public static void disconnect() { if (ConnexionUtils.isConnected()) { ConnexionUtils.peer.Disconnect(0); } }
/// <summary> /// Draws the content of the window. /// </summary> /// <param name="windowID">Window I.</param> protected override void DrawContent(int windowID) { GUILayout.BeginVertical(); { GUILayout.Label(messages); GUILayout.Label("Message to sent: "); message = GUILayout.TextArea(message); if (GUILayout.Button("Envoyer", buttonStyles, GUILayout.ExpandWidth(true))) //GUILayout.Button is "true" when clicked { if (ConnexionUtils.isConnected() && message != null && !"".Equals(message)) { ConnexionUtils.sendChatMessage(message); message = ""; } } } GUILayout.EndVertical(); }
/// <summary> /// Draws the content of the window. /// </summary> /// <param name="windowID">Window I.</param> protected override void DrawContent(int windowID) { GUILayout.BeginVertical(); { // The server name region GUILayout.BeginHorizontal(); { GUILayout.Label("Server Address: "); server = GUILayout.TextField(server); } GUILayout.EndHorizontal(); // the user name region GUILayout.BeginHorizontal(); { GUILayout.Label("Surname: "); surnom = GUILayout.TextField(surnom); } GUILayout.EndHorizontal(); // the buttons region GUILayout.BeginHorizontal(); { if (GUILayout.Button("Save", buttonStyles, GUILayout.ExpandWidth(true))) //GUILayout.Button is "true" when clicked { Debug.Log("On a cliqué sur le bouton save: " + server); savedServersList.Add(server); } if (GUILayout.Button("Connect", buttonStyles, GUILayout.ExpandWidth(true))) //GUILayout.Button is "true" when clicked { Debug.Log("On a cliqué sur le bouton connect: " + server + " avec le surnom: " + surnom); if (server != null && !"".Equals(server) && surnom != null && !"".Equals(surnom)) { Debug.Log("Initializing client..."); ConnexionUtils.connectTo(server, surnom); if (ConnexionUtils.isConnected()) { Debug.Log("on charge le jeu"); Game game = GamePersistence.LoadGame("KeronMultiGame", "../GameData/Keron", true, false); game.Load(); game.Start(); } } } if (GUILayout.Button("Erase", buttonStyles, GUILayout.ExpandWidth(true))) //GUILayout.Button is "true" when clicked { Debug.Log("On a cliqué sur le bouton erase"); server = ""; } } GUILayout.EndHorizontal(); // the saved server region savedServersList.ForEach( s => { if (GUILayout.Button(s, serverListStyles, GUILayout.ExpandWidth(true))) //GUILayout.Button is "true" when clicked { UnityEngine.Debug.Log("On a cliqué sur le bouton : " + s); server = s; } } ); } GUILayout.EndVertical(); }