예제 #1
0
 public void ClearPlayerLobbyList()
 {
     App.Current.Dispatcher.Invoke((Action) delegate
     {
         Clientlist.Clear();
     });
 }
예제 #2
0
    IEnumerator GetClientsWebApi()
    {
        // Se crea la petición a la web api
        using (UnityWebRequest www = UnityWebRequest.Get(Uri.EscapeUriString(String.Format(GameManager.WEP_API_GET_CLIENTS, GameManager.ipAddress))))
        {
            // Hacemos la petición y esperamos que responda
            yield return(www.SendWebRequest());

            // Acción a realizar si la petición se ha ejecutado sin error
            if (!www.isNetworkError)
            {
                // Se recupera la lista de clientes
                Clientlist clientList = JsonUtility.FromJson <Clientlist>(www.downloadHandler.text);
                for (int i = 0; i < clientList.clients.Length; i++)
                {
                    // Creamos el objeto para un cliente
                    GameObject clientItem = Instantiate(client);
                    // Se asigna el texto que debe mostrar
                    clientItem.GetComponentInChildren <Text>().text = clientList.clients[i].dni + " - " + clientList.clients[i].name;
                    // Se establece su padre que esté en la escena
                    clientItem.transform.SetParent(information.transform);
                    clientItem.GetComponent <RectTransform>().localPosition = new Vector3(0, -0.13f * (i + 1), 0);
                }
            }
        }
    }
예제 #3
0
 private void HandleClientLoginEvent(string username)
 {
     App.Current.Dispatcher.Invoke((Action) delegate
     {
         Clientlist.Add(username);
         OnPropertyChanged("Clientlist");
     });
 }
예제 #4
0
 /// <summary>
 /// Der Client erhaelt vom Server eine Liste aller Clients, die online sind. Diese werden in der Clientlist gespeichert.
 /// </summary>
 /// <param name="clientList"></param>
 private void HandleClientsOnlineEvent(string[] clientList)
 {
     foreach (string username in clientList)
     {
         if (username != "")
         {
             App.Current.Dispatcher.Invoke((Action) delegate
             {
                 Clientlist.Add(username);
                 OnPropertyChanged("Clientlist");
             });
         }
     }
 }
예제 #5
0
        /// <summary>
        /// Anzeige aller Clients, die der Gamelobby beigetreten sind
        /// </summary>
        /// <param name="userList"></param>
        private void HandleClientsInGame(string[] userList)
        {
            bool inList = false;

            foreach (string username in userList)
            {
                if (username != "")
                {
                    foreach (PlayerReadyData client in Clientlist)
                    {
                        if (client.Name == username)
                        {
                            inList = true;
                        }
                    }
                    if (!inList)
                    {
                        App.Current.Dispatcher.Invoke((Action) delegate
                        {
                            PlayerReadyData pd = new PlayerReadyData(username);
                            Clientlist.Add(pd);
                        });
                    }
                    inList = false;
                }
            }

            //loeschen von Clients aus der Clientlist, die die Lobby verlassen haben
            List <PlayerReadyData> helperList = new List <PlayerReadyData>();

            foreach (PlayerReadyData client in Clientlist)
            {
                if (!userList.Contains(client.Name))
                {
                    helperList.Add(client);
                }
            }
            foreach (PlayerReadyData clientToRemove in helperList)
            {
                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    Clientlist.Remove(clientToRemove);
                });
            }
        }