Example #1
0
    void CmdRemoveObjectAuthorityFromClient(NetworkIdentity netID)
    {
        //Debug.Log("in CmdRemoveObjectAuthorityFromClient for shared object netid=" + netID);
        //netID.GetComponent<AuthorityManager>().RemoveClientAuthority(this.connectionToClient);
        ParametersAuthorityManager parametersAuthorityManager = netID.GetComponent <ParametersAuthorityManager>();
        ViveParamsAuthorityManager viveParamsAuthorityManager = netID.GetComponent <ViveParamsAuthorityManager>();

        if (parametersAuthorityManager != null)
        {
            //Debug.Log("...for parametersAuthorityManager");
            parametersAuthorityManager.RemoveClientAuthority(this.connectionToClient);
            return;
        }
        else if (viveParamsAuthorityManager != null)
        {
            //Debug.Log("...for viveParamsAuthorityManager");
            viveParamsAuthorityManager.RemoveClientAuthority(this.connectionToClient);
        }
    }
Example #2
0
    void CmdAssignObjectAuthorityToClient(NetworkIdentity netID)
    {
        //Debug.Log("in CmdAssignObjectAuthorityToClient for shared object netid=" + netID);

        AuthorityManager           authorityManager           = netID.GetComponent <AuthorityManager>();
        ParametersAuthorityManager parametersAuthorityManager = netID.GetComponent <ParametersAuthorityManager>();
        ViveParamsAuthorityManager viveParamsAuthorityManager = netID.GetComponent <ViveParamsAuthorityManager>();

        if (authorityManager != null)
        {
            //Debug.Log("...for shared objects");
            authorityManager.AssignClientAuthority(this.connectionToClient);
        }
        else if (parametersAuthorityManager != null)
        {
            //Debug.Log("...for parametersAuthorityManager");
            parametersAuthorityManager.AssignClientAuthority(this.connectionToClient);
        }
        else if (viveParamsAuthorityManager != null)
        {
            //Debug.Log("...for viveParamsAuthorityManager");
            viveParamsAuthorityManager.AssignClientAuthority(this.connectionToClient);
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        if (isServer || isLocalPlayer)
        {
            if (isLocalPlayer)
            {
                // Inform the local player about his new character
                LocalPlayerController.Singleton.SetActor(this);
                CmdInitialize(prefabNameHand);
                CmdInitialize(prefabNameFoot);
                if (GameObject.Find("ArdManager") != null)
                {
                    ardManager = FindObjectOfType <ArdManager>();
                    if (ardManager != null)
                    {
                        coroutine  = SendPositionToArduino();
                        cameraVive = GameObject.FindGameObjectWithTag("cameraVive");
                        StartCoroutine(coroutine);
                    }
                }
            }


            //this part is for object sharing
            //*******************************
            if (isServer)
            {
                // find objects that can be manipulated
                // TIPP : you can use a specific tag for all GO's that can be manipulated by players
                foreach (GameObject go in GameObject.FindGameObjectsWithTag("shared"))
                {
                    sharedObjects.Add(go.GetComponent <NetworkIdentity>());
                }
            }
            if (isLocalPlayer)
            {
                // find objects that can be manipulated
                // assign this Actor to the localActor field of the AuthorityManager component of each shared object
                foreach (GameObject go in GameObject.FindGameObjectsWithTag("shared"))
                {
                    sharedObjects.Add(go.GetComponent <NetworkIdentity>());

                    ParametersAuthorityManager paramAuthority = go.GetComponent <ParametersAuthorityManager>();
                    if (paramAuthority != null)
                    {
                        paramAuthority.AssignActor(this);
                    }

                    ViveParamsAuthorityManager viveParamAuthority = go.GetComponent <ViveParamsAuthorityManager>();
                    if (viveParamAuthority != null)
                    {
                        viveParamAuthority.AssignActor(this);
                    }
                }
            }
        }
        else
        {
            // Initialize on startup
            InitializeHands(prefabNameHand);
            InitializeFoot(prefabNameFoot);
        }
    }