RequestOwnership() public method

Depending on the PhotonView's ownershipTransfer setting, any client can request to become owner of the PhotonView.
Requesting ownership can give you control over a PhotonView, if the ownershipTransfer setting allows that. The current owner might have to implement IPunCallbacks.OnOwnershipRequest to react to the ownership request. The owner/controller of a PhotonView is also the client which sends position updates of the GameObject.
public RequestOwnership ( ) : void
return void
Example #1
0
 /// <summary>
 ///
 /// </summary>
 void Start()
 {
     if (PhotonNetwork.isMasterClient && view.owner == null)
     {
         view.RequestOwnership();
     }
 }
    void UpdateOwner()
    {
        if (!pv.isMine)
        {
            int whose = pv.ownerId;

            if (whose == 2 && CanServerControl)
            {
                pv.RequestOwnership();
            }
            else if (whose == 1 && CanServerControl)
            {
                return;
            }
            else if (whose == 2 && CanClientControl)
            {
                return;
            }
            else if (whose == 1 && CanClientControl)
            {
                pv.RequestOwnership();
            }
        }
        else
        {
        }
    }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 private void Start()
 {
     m_Animator = GetComponent <Animator>();
     if (PhotonNetwork.isMasterClient && view.owner == null)
     {
         view.RequestOwnership();
         Debug.Log("Assign Master as owner");
     }
 }
Example #4
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.name == "Gem(Clone)")
     {
         if (!gem || gem != other.gameObject)
         {
             if (!view.IsMine)
             {
                 view.RequestOwnership();
                 Invoke("setanim", 0.5f);
                 gem = other.gameObject;
                 other.gameObject.GetComponent <SmallGem>().DestroyGem();
             }
             else
             {
                 if (anim.GetBool("b1") && anim.GetBool("b2"))
                 {
                     anim.SetBool("b3", true);
                     gem = other.gameObject;
                     other.gameObject.GetComponent <SmallGem>().DestroyGem();
                 }
                 else if (anim.GetBool("b1") && !anim.GetBool("b2"))
                 {
                     anim.SetBool("b2", true);
                     gem = other.gameObject;
                     other.gameObject.GetComponent <SmallGem>().DestroyGem();
                 }
                 else
                 {
                     anim.SetBool("b1", true);
                     gem = other.gameObject;
                     other.gameObject.GetComponent <SmallGem>().DestroyGem();
                 }
             }
         }
     }
     if (active)
     {
         if (other.gameObject.name == "Player2(Clone)")
         {
             if (other.gameObject.GetComponent <PhotonView>().IsMine)
             {
                 other.transform.parent = transform;
                 view.RPC("Parenting_RPC", RpcTarget.Others, other.gameObject.GetPhotonView().ViewID);
                 return;
             }
             Debug.Log("MovePlatform was parenting");
         }
     }
 }
Example #5
0
    void NewRound()
    {
        if (PhotonNetwork.isMasterClient)
        {
            round = round + 1;
            roomProp ["Round"] = round;
            room.SetCustomProperties(roomProp);


            PhotonView flag = GameObject.FindGameObjectWithTag("Flag").GetComponent <PhotonView> ();
            PhotonView fort = GameObject.FindGameObjectWithTag("Fort").GetComponent <PhotonView> ();
            if (!fort.isMine)
            {
                fort.RequestOwnership();
            }
            if (!flag.isMine)
            {
                flag.RequestOwnership();
            }
            PhotonNetwork.Destroy(flag);
            PhotonNetwork.Destroy(fort);
            Invoke("SpawnFlag", 0.5f);
        }
        updateHudInfo();
        complete   = false;
        scoreAdded = false;
    }
 public void TakeOwnershipOfView()
 {
     if (!photonView.IsMine)
     {
         photonView.RequestOwnership();
     }
 }
 public void IsInteractedOn()
 {
     if (photonView != null)
     {
         photonView.RequestOwnership();
     }
 }
Example #8
0
    IEnumerator NewRound()
    {
        yield return(new WaitForSeconds(2.5f));

        if (PhotonNetwork.isMasterClient)
        {
            round = round + 1;
            roomProp ["Round"] = round;
            room.SetCustomProperties(roomProp);

            photonView.RPC("DestroyFort", PhotonTargets.All);
            PhotonView flag = GameObject.FindGameObjectWithTag("Flag").GetComponent <PhotonView> ();

            if (!flag.isMine)
            {
                flag.RequestOwnership();
            }
            PhotonNetwork.Destroy(flag);
        }
        yield return(new WaitForSeconds(0.5f));

        if (PhotonNetwork.isMasterClient)
        {
            PhotonView fort = GameObject.FindGameObjectWithTag("Fort").GetComponent <PhotonView> ();
            if (!fort.isMine)
            {
                fort.RequestOwnership();
            }
            PhotonNetwork.Destroy(fort);
            Invoke("SpawnFlag", 0.5f);
        }
        updateHudInfo();
        complete   = false;
        scoreAdded = false;
    }
Example #9
0
        public bool Take()
        {
            PhotonView pv = gameObject.GetPhotonView();

            if (gameObject.GetPhotonView() != null)
            {
                bool owned = HasOwnership(PhotonNetwork.player);
                if (StoredInScene)
                {
                    pv.RequestOwnership();
                    pv.ownerId = PhotonNetwork.player.ID;
                }
                else if (CanTake() && !owned)
                {
                    pv.RPC("Grab", PhotonTargets.Others);
                }

                if (HasOwnership(PhotonNetwork.player))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
Example #10
0
 public void RequestOwnerChange()
 {
     if (!PV.IsMine)
     {
         PV.RequestOwnership();
     }
 }
Example #11
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.transform.root.gameObject == MultiplayerPlayer.LocalPlayer && !pView.AmOwner)
     {
         pView.RequestOwnership();
     }
 }
        private void Update()
        {
            if (PhotonScriptor.ConnectingScript.informConnected() == true)
            {
                if (addcallBacks == false)
                {
                    addcallBacks = true;
                    Debug.Log("add call back");
                    PhotonNetwork.AddCallbackTarget(this);
                }
            }

            if (_photonView.IsMine == true)
            {
                return;
            }

            if (TimeManager.BluePrint.BruePrintPhaze.InformBluePrintState() == true)
            {
                if (PN == ConnectingScript.informPlayerID())
                {
                    if (TakeOverOwnership == false)
                    {
                        Debug.Log("owmership requested");
                        _photonView.RequestOwnership();
                        TakeOverOwnership = true;
                    }
                }
            }
        }
Example #13
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <Rigidbody>())
     {
         ball  = other.GetComponent <Rigidbody>();
         pball = other.GetComponent <PhotonView>();
         pball.RequestOwnership();
     }
 }
Example #14
0
 /// <summary>
 /// After call PhotonView.RequestOwnership, wait until take ownership.
 /// </summary>
 public static async UniTask RequestOwnershipAsync(this PhotonView view, CancellationToken token = default)
 {
     if (view.IsMine)
     {
         return;
     }
     view.RequestOwnership();
     await view.IsMineAsyncEnumerable().FirstOrDefaultAsync(x => x, token);
 }
Example #15
0
    public void UsePost(GameObject player)
    {
        if (!postPlayer)
        {
            postPlayer = player;
            audioData.PlayOneShot(enter, 1);
            PV.RPC("OccupyPost", RpcTarget.Others);
            PhotonView playerPV = postPlayer.GetComponentInChildren <PhotonView> ();
            PhotonView postPV   = post.GetComponent <PhotonView> ();
            // PhotonView[] photonViews = post.GetComponents<PhotonView>();
            // foreach (PhotonView view in photonViews)
            // {
            //     print(view.ViewID);
            // }
            if (postPV)
            {
                postPV.RequestOwnership();
            }
            switch (type)
            {
            case postType.Canon:
                Canon tmpCanon = post.GetComponent <Canon> ();
                tmpCanon.enabled = true;
                break;

            case postType.Thruster:
                ThrusterControls tmp = post.GetComponent <ThrusterControls> ();
                tmp.enabled = true;
                break;

            case postType.Turret:
                Turret turret = post.GetComponent <Turret> ();
                turret.enabled = true;
                break;

            case postType.Rotate:
                RotateShip rotate = post.GetComponent <RotateShip> ();
                rotate.enabled = true;
                break;

            case postType.Shield:
                Shield shield = post.GetComponent <Shield> ();
                shield.enabled = true;
                break;

            case postType.MiniShip:
                postPlayer.transform.GetChild(1).gameObject.SetActive(false);
                MiniShip ship = post.GetComponent <MiniShip> ();
                ship.enabled = true;
                ship.ActivateShip();
                break;

            default:
                break;
            }
        }
    }
Example #16
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        var pos = Input.mousePosition;

        mouseDiff = transform.position - Camera.main.ScreenToWorldPoint(pos);
        transform.SetAsLastSibling();
        photonView.RequestOwnership();
        myGroup.blocksRaycasts = false;
        isDraging = true;
    }
Example #17
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("weapon"))
     {
         if (!pv.IsMine)
         {
             pv.RequestOwnership();
         }
     }
 }
    private void Start()
    {
        Debug.Log($"GunnerRole Start()    Is {(photonView.IsMine ? "": "NOT ")} mine. I am {Launcher.role}.");

        if (!photonView.IsMine && Launcher.role == Roles.Gunner)
        {
            //shipPhotonView.RequestOwnership();
            photonView.RequestOwnership();
            thisPhotonView.RequestOwnership();
        }
    }
Example #19
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Obstacle")
        {
            PhotonView view = other.gameObject.GetPhotonView();

            if (!view.IsMine)
            {
                view.RequestOwnership();
            }
        }
    }
Example #20
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("enemy"))
     {
         enemy = other.gameObject.GetComponent <Enemy>();
         pv    = other.gameObject.GetComponent <PhotonView>();
         if (!pv.IsMine)
         {
             pv.RequestOwnership();
         }
     }
 }
Example #21
0
 public override void GrabBegin(OVRGrabber hand, Collider grabPoint)
 {
     base.GrabBegin(hand, grabPoint);
     _ooi.IsBeingManipulated = true;
     if (_view)
     {
         if (!_view.IsMine)
         {
             _view.RequestOwnership();
         }
     }
 }
Example #22
0
 private void OnMouseDown()
 {
     Cursor.visible     = false;
     isFollowingParnt   = true;
     _isMouseOn         = true;
     _followPos         = transform.position;
     _mousePos          = Input.mousePosition;
     _rb.freezeRotation = true;
     _pv.RequestOwnership();
     _isfollowingPos = true;
     _pv.RPC("ConstrainRotation", RpcTarget.AllBuffered);
     _pv.RPC("UpdateIsFolloingPos", RpcTarget.AllBuffered, _isfollowingPos);
 }
Example #23
0
    protected override void OnSelectEnter(XRBaseInteractor interactor)
    {
        base.OnSelectEnter(interactor);

        canSelect                = true;
        isSelectExit             = false;
        selectRecognitionTimeVal = 0f;

        if (pv)
        {
            pv.RequestOwnership();
        }
    }
Example #24
0
 public void AttemptInteraction()
 {
     Debug.Log("isHeld = " + isHeld);
     if (photonView == null)
     {
         return;
     }
     if (isHeld == true)
     {
         return;
     }
     photonView.RequestOwnership();
 }
Example #25
0
 public void SetIsActive()
 {
     isActive = true;
     if (!view.IsMine)
     {
         view.RequestOwnership();
         Invoke("setanim", 0.5f);
     }
     else
     {
         anim.SetBool("On", isActive);
     }
 }
Example #26
0
        public void Take(GameObject taker)
        {
            this.name = originalName + " [" + taker.name + "]";

            if (!taker.GetComponent <PhotonView>().IsMine)
            {
                return;
            }

            PhotonView pv = this.GetComponent <PhotonView>();

            pv.RequestOwnership();
        }
 public void TransferOwnership()
 {
     if (PhotonView.Owner.IsLocal == false)
     {
         Debug.Log("Requesting Ownership");
         PhotonView.RequestOwnership();
         PhotonNetwork.Destroy(drink);
     }
     else
     {
         PhotonNetwork.Destroy(drink);
     }
 }
Example #28
0
    public override void OnJoinedRoom()
    {
        PhotonView[] PVs = localAvatar.GetPhotonViewsInChildren();

        for (int i = 0; i < PVs.Length; i++)
        {
            PVs[i].RequestOwnership();
        }

        PhotonView LYPV = localYoke.GetPhotonView();

        LYPV.RequestOwnership();
    }
Example #29
0
    void OnGameBegin()
    {
        Vector3 position = playerPrefab.transform.position;

        position.z = zPositionPlayer1;

        GameObject ball = PhotonNetwork.Instantiate(playerPrefab.name, position, transform.rotation, 0);
        PhotonView view = ball.GetComponent <PhotonView>();

        view.RequestOwnership();
        Debug.Assert(view.isMine);

        onGameBegin?.Invoke();
    }
Example #30
0
    public void gainFlag()
    {
        flag = GameObject.FindGameObjectWithTag("Flag");
        flag.GetComponent <Animator> ().SetBool("Wavin", true);
        Collider2D[] cols = flag.GetComponents <Collider2D> ();

        //deactivate rigidbody component
        Rigidbody2D rb = flag.GetComponent <Rigidbody2D> ();

        rb.gravityScale   = 0;
        rb.freezeRotation = false;
        rb.isKinematic    = true;

        flag.transform.parent = flagPos.transform;

        foreach (Collider2D coll in cols)
        {
            coll.enabled = false;
        }
        PhotonView flagPhotonView = flag.GetComponent <PhotonView> ();

        if (gameObject.GetPhotonView().isMine)
        {
            flagPhotonView.RequestOwnership();
        }
        flag.transform.localPosition = Vector3.zero;
        flag.transform.localRotation = Quaternion.Euler(Vector3.zero);

        if (PhotonNetwork.offlineMode)
        {
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject ply in players)
            {
                AILogic ailog = ply.GetComponent <AILogic> ();
                if (ailog)
                {
                    if (ply == this.gameObject)
                    {
                        ailog.StateChange(3);
                    }
                    else
                    {
                        ailog.StateChange(2);
                    }
                }
            }
        }
        isHandlingFlag = true;
        arrow.GetComponent <FixedRotation> ().isHandling = true;
    }