Exemplo n.º 1
0
 /// <summary>
 /// Disconnect from the server connected to.
 /// </summary>
 public static void disconnect()
 {
     if (ConnexionUtils.isConnected())
     {
         ConnexionUtils.peer.Disconnect(0);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Called at each update of the game. Used to check received messages
        /// </summary>
        public void FixedUpdate()
        {
            Debug.Log("On entre dans fixedUpdate de  chatWindow");

            string receiveMessage = ConnexionUtils.receiveChatMessage();

            if (!"".Equals(receiveMessage))
            {
                messages += '\n' + receiveMessage;
            }
        }
Exemplo n.º 3
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();
 }
Exemplo n.º 4
0
        /// <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();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="client.ConnexionWindow"/> class,
 /// in particular the window title.
 /// </summary>
 public ConnexionWindow() : base()
 {
     ConnexionUtils.disconnect();
     windowTitle = "Connexion au serveur";
 }