Esempio n. 1
0
 private static void CreateMaxPlayer(int maxPlayer)
 {
     for (int i = 0; i < maxPlayer; i++)
     {
         GameObject go = Instantiate(playerPrefabRef);
         go.transform.parent = refGameObject.transform;
         UDPPlayer player = go.GetComponent <UDPPlayer>();
         freePlayerManagers.Add(player);
         go.SetActive(false);
     }
 }
Esempio n. 2
0
 public static void DeactivatePlayer(string id)
 {
     if (playerById.ContainsKey(id))
     {
         UDPPlayer player = playerById[id];
         player.SetPlayerId(0);
         freePlayerManagers.Add(player);
         playerById.Remove(id);
         playersID.Remove(id.ToString());
         player.gameObject.SetActive(false);
     }
 }
Esempio n. 3
0
        public static void ActivatePlayer(string id)
        {
            if (!playerCreated)
            {
                CreateMaxPlayer(UDPConnectionManager.GetMaxPlayerCount());
                playerCreated = true;
            }

            if (freePlayerManagers.Count > 0 && !playersID.Contains(id))
            {
                Debug.Log("Activated user: " + id);
                UDPPlayer player   = freePlayerManagers[0];
                int       playerId = int.Parse(id);
                player.SetPlayerId(playerId);
                player.ActivatePlayerReceivers();
                player.ActivateSender();
                playerById.Add(id, player);
                freePlayerManagers.Remove(player);
                playersID.Add(id);
                player.gameObject.transform.position = UDPConnectionManager.singleton.transform.position;
                player.gameObject.SetActive(true);
            }
        }