Equals() public method

Makes PhotonPlayer comparable
public Equals ( object p ) : bool
p object
return bool
コード例 #1
0
    public void AskForPickupItemSpawnTimes()
    {
        if (this.IsWaitingForPickupInit)
        {
            if (PhotonNetworkManager.playerList.Length < 2)
            {
                Debug.Log("Cant ask anyone else for PickupItem spawn times.");
                this.IsWaitingForPickupInit = false;
                return;
            }


            // find a another player (than the master, who likely is gone) to ask for the PickupItem spawn times
            PhotonPlayer nextPlayer = PhotonNetworkManager.masterClient.GetNext();
            if (nextPlayer == null || nextPlayer.Equals(PhotonNetworkManager.player))
            {
                nextPlayer = PhotonNetworkManager.player.GetNext();
                //Debug.Log("This player is the Master's next. Asking this client's 'next' player: " + ((nextPlayer != null) ? nextPlayer.ToStringFull() : ""));
            }

            if (nextPlayer != null && !nextPlayer.Equals(PhotonNetworkManager.player))
            {
                this.photonView.RPC("RequestForPickupItems", nextPlayer);

                // you could restart this invoke and try to find another player after 4 seconds. but after a while it doesnt make a difference anymore
                //this.Invoke("AskForPickupItemSpawnTimes", 2.0f);
            }
            else
            {
                Debug.Log("No player left to ask");
                this.IsWaitingForPickupInit = false;
            }
        }
    }
コード例 #2
0
 public void AskForPickupItemSpawnTimes()
 {
     if (this.IsWaitingForPickupInit)
     {
         if (PhotonNetwork.playerList.Length < 2)
         {
             Debug.Log("Cant ask anyone else for PickupItem spawn times.");
             this.IsWaitingForPickupInit = false;
             return;
         }
         PhotonPlayer next = PhotonNetwork.masterClient.GetNext();
         if (next == null || next.Equals(PhotonNetwork.player))
         {
             next = PhotonNetwork.player.GetNext();
         }
         if (next != null && !next.Equals(PhotonNetwork.player))
         {
             BasePV.RPC("RequestForPickupTimes", next, new object[0]);
         }
         else
         {
             Debug.Log("No player left to ask");
             this.IsWaitingForPickupInit = false;
         }
     }
 }
コード例 #3
0
 private void RequestEditorialAccess(PhotonPlayer requestor)
 {
     if (m_CurrentEditor == null || m_CurrentEditor.Equals(requestor))
     {
         m_CurrentEditor = requestor;
         m_PhotonView.RPC("GrantEditorialAccess", PhotonTargets.AllViaServer, m_CurrentEditor);
     }
 }
コード例 #4
0
    // 나 제외
    public void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer.Equals(null))
        {
            return;
        }
        GameObject otherPlayer;

        //로컬플레이어가 아니면 로컬플레이어가 속한 팀에따라 좌우를 나눔
        if (me.GetTeam() != photonPlayer.GetTeam())
        {
            otherPlayer = Instantiate(enemyTeamPlayerPrefab);
            otherPlayer.transform.SetParent(enemyTeamViewPort.transform, false);
        }
        else
        {
            otherPlayer = Instantiate(ourTeamPlayerPrefab);
            otherPlayer.transform.SetParent(ourTeamViewPort.transform, false);
        }

        SelectListing selectListing = otherPlayer.GetComponent <SelectListing>();

        selectListings.Add(selectListing);

        selectListing.PhotonPlayer = photonPlayer;
        selectListing.ApplyPhotonPlayer(photonPlayer);
    }
コード例 #5
0
    public static void RemovePlayerFromThirdPartyExperience(PhotonPlayer player)
    {
        if (!CurrentThirdPartyExperience)
        {
            return;
        }

        if (PlayersInExperience.ContainsKey(player))
        {
            PlayersInExperience.Remove(player);
        }

        //If the player who is leaving is the owner of the experience, set the owner to be the first player who is still in the experience, or the scene itself if there is no player left.
        if (player.Equals(CurrentThirdPartyExperience.photonView.owner))
        {
            if (PlayersInExperience != null && PlayersInExperience.Count > 0)
            {
                CurrentThirdPartyExperience.photonView.TransferOwnership(PlayersInExperience.Keys.First());
            }
            else
            {
                CurrentThirdPartyExperience.photonView.TransferOwnership(0);
            }
        }

        if (CurrentThirdPartyExperience)
        {
            CurrentThirdPartyExperience.PlayerLeft(player);
        }
    }
コード例 #6
0
    // 나 제외
    public void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer.Equals(null))
        {
            return;
        }
        GameObject SelectingPrefab;

        //로컬플레이어가 아니면 로컬플레이어가 속한 팀에따라 좌우를 나눔
        if (LocalPlayer.GetTeam() != photonPlayer.GetTeam())
        {
            SelectingPrefab = Instantiate(ChampSelectingPrefab_Enemy);
            SelectingPrefab.transform.SetParent(EnemyTeamViewPort.transform, false);
        }
        else
        {
            SelectingPrefab = Instantiate(ChampSelectingPrefab);
            SelectingPrefab.transform.SetParent(MyTeamViewPort.transform, false);
        }

        SelectListing selectListing = SelectingPrefab.GetComponent <SelectListing>();

        selectListings.Add(selectListing);

        selectListing.PhotonPlayer = photonPlayer;
        selectListing.ApplyPhotonPlayer(photonPlayer);
    }
コード例 #7
0
 public bool HasOwnership(PhotonPlayer player)
 {
     if (gameObject.GetComponent <PhotonView>() != null)
     {
         return(player.Equals(gameObject.GetComponent <PhotonView>().owner));
     }
     else
     {
         return(false);
     }
 }
コード例 #8
0
    public override void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
    {
        base.OnPhotonPlayerDisconnected(otherPlayer);

        if (PhotonNetwork.isMasterClient)
        {
            if (otherPlayer.Equals(m_CurrentEditor))
            {
                ReleaseEditorialAccess(otherPlayer);
            }
        }
    }
コード例 #9
0
 // 复写方法,当有玩家离开房间时
 public override void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
 {
     // 刷新房主
     master = PhotonNetwork.masterClient;
     // 更新所有UI
     begin.SetActive(true);
     if (me.Equals(master))
     {
         //ReIndex(otherPlayer);
         ReturnFlag(otherPlayer);
     }
 }
コード例 #10
0
        public override void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps)
        {
            //only react on property changes for this player
            PhotonPlayer player = playerAndUpdatedProps[0] as PhotonPlayer;

            if (player != null && !player.Equals(photonView.owner))
            {
                return;
            }

            //update values that could change any time for visualization to stay up to date
            uiScript.UpdateHealth(photonView.GetHealth());
            uiScript.UpdateShield(photonView.GetShield());
            uiScript.UpdateKillsText(photonView.GetKills());
        }
コード例 #11
0
    void OnSpawnPlayer(Vector3 pos, Quaternion rot, int photonViewId, PhotonPlayer photonPlayer)
    {
        var playerObject            = Instantiate(playerPrefab);
        var playerNetworkSyncObject = Instantiate(playerNetworkSyncPrefab);

        playerNetworkSyncObject.photonView.viewID = photonViewId;
        playerNetworkSyncObject.playerObject      = playerObject;

        if (photonPlayer.Equals(PhotonNetwork.player))
        {
            playerObject.GetComponent <MeshRenderer>().material.color = Color.blue;
            localPlayer = playerObject.AddComponent <PlayerManager>();
            localPlayer.playerNetworkSync = playerNetworkSyncObject;
            playerNetworkSyncObject.transform.SetParent(syncParent);
            playerNetworkSyncObject.onlySyncOutGoing = true;
        }

        syncObjectByPlayer[photonPlayer] = playerNetworkSyncObject;
    }
コード例 #12
0
    public void StartPlaying(PhotonPlayer A, PhotonPlayer B)
    {
        this.photonView.ClearRpcBufferAsMasterClient();    // We don't care about instructions in the buffer for previous games at this point
        this.photonView.RPC("ResetBoard", PhotonTargets.OthersBuffered);
        // this.PlayerTurn = false;
        this.SetLocalTurn(false);

        if (A.Equals(PhotonNetwork.player))
        {
            this.LocalSideB = false;
            this.RemotePlayer = B;
            this.LocalColour = ConnectFourSlot.Colour.Black;
            this.RemoteColour = ConnectFourSlot.Colour.Red;
            this.LocalSelectors = (ConnectFourSlot[])SelectorsA.Clone();
            this.RemoteSelectors = (ConnectFourSlot[])SelectorsB.Clone();
            if (this.SingleSided)
                { Array.Reverse(this.RemoteSelectors); }
            // this.PlayerTurn = true;
            this.SetLocalTurn(true);
        }
        else if (B.Equals(PhotonNetwork.player))
        {
            this.LocalSideB = true;
            this.RemotePlayer = A;
            this.LocalColour = ConnectFourSlot.Colour.Red;
            this.RemoteColour = ConnectFourSlot.Colour.Black;
            this.LocalSelectors = (ConnectFourSlot[])SelectorsB.Clone();
            this.RemoteSelectors = (ConnectFourSlot[])SelectorsA.Clone();
            if (this.SingleSided)
                { Array.Reverse(this.LocalSelectors); }
        }
        else    // This game is starting, but the local player isn't one of the players
        {
            return;
        }
        this.photonView.RPC("ResetBoardForPlay", this.RemotePlayer);
        this.ResetBoardForPlay(null);
        this.Playing = true;
        this.LocalSelectors[this.LocalSelectorIndex].Status = this.LocalColour;
    }
コード例 #13
0
    // 플레이어가 룸에 들어오면
    public void PlayerJoinedRoom(PhotonPlayer photonPlayer)
    {
        if (photonPlayer.Equals(null))
        {
            return;
        }

        //팀카운트에 따라 플레이어가 속한 뷰포트 및 팀 할당
        if (Team1_playerCount == Team2_playerCount)
        {
            RedTeamJoin(photonPlayer);
        }
        else if (Team1_playerCount > Team2_playerCount)
        {
            BlueTeamJoin(photonPlayer);
        }
        else if (Team1_playerCount < Team2_playerCount)
        {
            RedTeamJoin(photonPlayer);
        }

        // 참가버튼 재설정
        JoinButtonUpdate();
    }
コード例 #14
0
 public void UpdateView()
 {
     m_IsMaster.gameObject.SetActive((m_PhotonPlayer != null) && m_PhotonPlayer.Equals(PhotonNetwork.masterClient));
     m_SetMasterButton.gameObject.SetActive(PhotonNetwork.player.isMasterClient && (m_PhotonPlayer != null) && !m_PhotonPlayer.Equals(PhotonNetwork.masterClient));
 }
コード例 #15
0
    protected virtual void RemovePlayer(PhotonPlayer player, PhotonMessageInfo info)
    {
        // A recently disconnected player may still have a RemovePlayer RPC buffered for new joining players, in this case, the new joining player will be trying to remove a null player
        if (player == null)
            { return; }

        // Find the matching team
        MinigameTeam correspondingTeam = this.TeamContainers.Find(container => container.Team.Contains(player)).Team;

        if (correspondingTeam == null)
        {
            Debug.LogErrorFormat("Player with ID {0} was not found on any team to remove.", player);
            return;
        }

        // Remove the player from the team, if the player is the client, trigger the events associated with leaving the game
        bool successfullyRemoved = correspondingTeam.RemovePlayer(player);

        // Special handling if the player leaving is part of a game the local player is in
        if (this.LocalPlayerJoined && !player.Equals(PhotonNetwork.player) && successfullyRemoved)
            { this.HandleRemotePlayerLeaveDetails(correspondingTeam, player); }

        if (player.Equals(PhotonNetwork.player))
        {
            if (successfullyRemoved)
                { this.LocalPlayerLeave(); }
            else
                { this.DisplayLeavingError(); }
        }

        // The master client checks to see if the game is empty, if so, reset this game
        if (PhotonNetwork.isMasterClient)
        {
            int players = 0;
            foreach (MinigameTeamContainer container in this.TeamContainers)
                { players += container.Team.Size; }

            if (players == 0)
                { this.photonView.RPC("ResetGame", PhotonTargets.AllViaServer); }
        }

        // if (!this.ValidToStart())
        //     { this.InfoMenu.StartButton.interactable = false; }
    }
コード例 #16
0
    protected virtual void AddPlayerToTeam(PhotonPlayer player, MinigameTeam team, PhotonMessageInfo info)
    {
        // A recently disconnected player may still have an AddPlayer RPC buffered for new joining players, in this case, the new joining player will be trying to add a null player
        if (player == null)
            { return; }

        // Find the matching team
        MinigameTeam actualTeam = this.TeamContainers.Find(container => container.Team.Equals(team)).Team;

        // Add the player to the team, if the player is the client, trigger the events associated with joining a team
        bool successfullyAdded = actualTeam.AddPlayer(player);
        if (player.Equals(PhotonNetwork.player))
        {
            if (successfullyAdded)
                { this.LocalPlayerJoin(actualTeam); }
            else
                { this.DisplayJoiningError(); }
        }

        // if (this.LocalPlayerJoined && this.ValidToStart())
        //     { this.InfoMenu.StartButton.interactable = true; }
    }