// Update is called once per frame
    void Update()
    {
        if (thisPlayer == null && FindObjectOfType <NetworkedManager>().inRoomAndInitialized == true)
        {
            thisPlayer = GameObject.Find((string)PhotonNetwork.player.CustomProperties["UniqueId"]);
        }

        if (socialActions == null && PhotonNetwork.inRoom == true && FindObjectOfType <NetworkedManager>().inRoomAndInitialized == true)
        {
            socialActions = thisPlayer.GetComponent <NetworkedSocial>();
            client        = thisPlayer.GetComponent <NetworkedClient>();
        }

        if (client != null && client.FriendsStatus != null)
        {
            if (id.text == "Id" && name.text == "Name")
            {
                OnUpdateFriendsList();

                idInputField.text = (string)PhotonNetwork.player.CustomProperties["UniqueId"];
                name.text         = PhotonNetwork.player.NickName;
                room.text         = PhotonNetwork.room.Name;
            }
        }
    }
Beispiel #2
0
    // this happens after approval (96% sure :p)
    private void ML_OnClientConnected(ulong _clientId)
    {
        if (!NetworkingManager.Singleton.IsHost && !NetworkingManager.Singleton.IsServer)
        {
            return;
        }

        Debug.Log("Client " + _clientId + " connected");

        NetworkedClient client = NetworkingManager.Singleton.ConnectedClients[_clientId];
        Player          player = client.GetPlayer();



        player.ClientId.Value = _clientId;

        player.Name.Value = connectionDataCache[_clientId].playerName;

        connectionDataCache.Remove(_clientId);

        using (PooledBitStream stream = PooledBitStream.Get())
        {
            using (PooledBitWriter w = PooledBitWriter.Get(stream))
            {
                w.WriteUInt64(player.NetworkedObject.NetworkId);
                CustomMessagingManager.SendNamedMessage("ClientConnected", AllClientIDs(), stream);
            }
        }
    }
    public static Player GetPlayer(this NetworkedClient _client)
    {
        if (_client.PlayerObject != null)
        {
            return(_client.PlayerObject.GetComponent <Player>());
        }

        Debug.LogError("Client doesn't have a PlayerObject! This is not the character, it should exist very early on and should never be destroyed, something is wrong.");
        return(null);
    }
Beispiel #4
0
    public List <ulong> GetClientIdsListExcept(ulong clientId)
    {
        List <ulong> clients = new List <ulong>(NetworkingManager.Singleton.ConnectedClientsList.Count);

        for (int index = 0; index < NetworkingManager.Singleton.ConnectedClientsList.Count; ++index)
        {
            NetworkedClient client = NetworkingManager.Singleton.ConnectedClientsList[index];
            if (client.ClientId.CompareTo(clientId) != 0)
            {
                clients.Add(client.ClientId);
            }
        }
        return(clients);
    }
    public void InitSocial()
    {
        photonNetworkId   = (string)PhotonNetwork.player.CustomProperties["UniqueId"];
        photonNetworkName = PhotonNetwork.player.NickName;

        nameIsSet = photonNetworkName == photonNetworkId || photonNetworkName == "none" || photonNetworkName == "";

        _client = GetComponent <NetworkedClient>();

        Debug.Log(
            "InitSocial()\n" +
            "PhotonId:\t" + photonNetworkId +
            "\nPlayerName:\t" + photonNetworkName
            );
    }
Beispiel #6
0
    public void OnJoin(string inviteeId)
    {
        NetworkedClient client = GetComponent <NetworkedClient>();

        Debug.Log("name:\t" + this._name);
        Debug.Log("client:\t" + client);
        Debug.Log("joined:\t" + this._joined.Contains((string)PhotonNetwork.player.CustomProperties["UniqueId"]));
        Debug.Log("invited:\t" + _invited[0] + " :: " + inviteeId);

        if (
            this._name == null ||
            client == null ||
            !this._joined.Contains((string)PhotonNetwork.player.CustomProperties["UniqueId"])
            )
        {
            Debug.Log("There was an authentication issue while adding a player to the party");
            return;
        }

        string toJoined = "";

        foreach (string id in this._joined)
        {
            toJoined += id + "%";
        }
        toJoined = toJoined.Remove(toJoined.Length - 1);

        string toInvited = "";

        foreach (string id in this._invited)
        {
            toInvited += id + "%";
        }
        toInvited = toInvited.Remove(toInvited.Length - 1);

        Debug.Log("PARTY INVITE & JOIN UPDATE\n" + toJoined + "\n" + toInvited);

        object[] onJoinUpdate = new object[] { this._name, UserStatusCode.PartyJoinResponse, this._name, toInvited, toJoined, this._leaderId, this._room, this._isInviteOnly };
        client.chatClient.SendPrivateMessage(inviteeId, onJoinUpdate);
    }
Beispiel #7
0
    public void Invite(string inviteeId, NetworkedClient client)
    {
        if (
            string.IsNullOrEmpty(this._name) ||
            !_joined.Contains((string)PhotonNetwork.player.CustomProperties["UniqueId"]) ||
            client.Channels.Contains(_name) ||
            (this._isInviteOnly && (this._leaderId != (string)PhotonNetwork.player.CustomProperties["UniqueId"]))
            )
        {
            Debug.LogError("There was a problem while sending the party invitation");
            return;
        }

        object[] partyInvitation = new object[] { client.UserName, inviteeId, UserStatusCode.PartyInvitationRequest };

        // Send invite to inviteeId, and update channel invitedIds lists
        client.chatClient.SendPrivateMessage(inviteeId, partyInvitation);

        client.Subscribe(_name);
        client.Channels.Add(_name);

        client.chatClient.PublishMessage(_name, partyInvitation);
    }
Beispiel #8
0
    public void InitParty(List <string> joined, List <string> invited, string leaderId, string customName, bool inviteOnly, NetworkedClient client, bool doInvite, string room)
    {
        if (customName != null && doInvite == false)
        {
            this._name = customName;
        }

        if (doInvite == true)
        {
            this._name   = PhotonNetwork.playerName + "__" + customName + "__" + DataUtilities.GetUniqueId();
            this._joined = joined;

            foreach (string invitee in invited)
            {
                if (
                    invitee != PhotonNetwork.player.UserId &&
                    !_joined.Contains(invitee)
                    )
                {
                    this.Invite(invitee, client);
                }
            }
        }
        else
        {
            this._joined  = joined;
            this._invited = invited;
        }

        this._room         = room;
        this._leaderId     = leaderId;
        this._isInviteOnly = inviteOnly;
        this._client       = client;

        FindObjectOfType <InputHandler>().OnUpdatePartyList();
        FindObjectOfType <InputHandler>().OnUpdateInvitesList();
    }
 void Start()
 {
     nc = new NetworkedClient();
 }