Exemplo n.º 1
0
    public static void assignObjectToPlayer(NetworkIdentity netIdObject, NetworkIdentity playerId, float delay)
    {
        if (delay >= 0)
        {
            GameObject goNetworkUtils          = new GameObject("NetworkUtilsDelayInstance");
            NetworkUtilsDelayInstance instance = goNetworkUtils.AddComponent <NetworkUtilsDelayInstance> ();
            instance.init(true, netIdObject, playerId, delay);
        }
        else if (null != netIdObject)
        {
            netIdObject.localPlayerAuthority = true;
            NetworkConnection otherOwner = netIdObject.clientAuthorityOwner;

            if (otherOwner == playerId.connectionToClient)
            {
                return;
            }
            else if (otherOwner != null)
            {
                netIdObject.RemoveClientAuthority(otherOwner);
            }

            netIdObject.AssignClientAuthority(playerId.connectionToClient);
        }
    }
Exemplo n.º 2
0
 public static void unassignObjectFromPlayer(NetworkIdentity netIdObject, NetworkIdentity playerId, float delay)
 {
     if (delay >= 0)
     {
         GameObject goNetworkUtils          = new GameObject("NetworkUtilsDelayInstance");
         NetworkUtilsDelayInstance instance = goNetworkUtils.AddComponent <NetworkUtilsDelayInstance> ();
         instance.init(false, netIdObject, playerId, delay);
     }
     else if (null != netIdObject)
     {
         //TODO verifier si necessaire exception envoyer sinon
         //netIdObject.localPlayerAuthority = false;
         netIdObject.RemoveClientAuthority(playerId.connectionToClient);
     }
 }