示例#1
0
    public static void UnserializeData(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
    {
        // While there is unread data in the stream
        while (_cStream.HasUnreadData)
        {
            // Save the first byte as the network action
            ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte();

            // Switch on the network action
            switch (eNetworkAction)
            {
            // New player message was sent
            case ENetworkAction.ActionSendPlayerMessage:
            {
                // Read out messages into output strings
                string strName    = _cStream.ReadString();
                string strMessage = _cStream.ReadString();

                // Find all players within 'hearing' range of the source player
                foreach (CNetworkPlayer Player in CheckPlayerDistances(_cNetworkPlayer))
                {
                    // Invoke RPC call to send the message to each player
                    Instance.InvokeRpc(Player.PlayerId, "ReceivePlayerMessage", strName, strMessage);
                }

                break;
            }
            }
        }
    }
示例#2
0
    public static void UnserializeData(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
    {
        ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte();

        switch (eNetworkAction)
        {
        case ENetworkAction.ActionSendPlayerName:
        {
            string sPlayerName = _cStream.ReadString();

            //Send all dictionary entries to new player
            foreach (KeyValuePair <ulong, string> entry in CGamePlayers.s_cInstance.m_mPlayersNames)
            {
                //Make sure you don't send RPC to yourself. Foreach loops will not let you modify the collections object (dictionary) you are operating on.
                if (_cNetworkPlayer.PlayerId != CNetwork.PlayerId)
                {
                    CGamePlayers.s_cInstance.InvokeRpc(_cNetworkPlayer.PlayerId, "RegisterPlayerName", entry.Key, entry.Value);
                }
            }

            // Send new player name to all other players
            CGamePlayers.s_cInstance.InvokeRpcAll("RegisterPlayerName", _cNetworkPlayer.PlayerId, sPlayerName);

            break;
        }
        }
    }
示例#3
0
文件: CGameChat.cs 项目: nulhax/VOID
    public static void UnserializeData(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
    {
        // While there is unread data in the stream
        while (_cStream.HasUnreadData)
        {
            // Save the first byte as the network action
            ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte();

            // Switch on the network action
            switch (eNetworkAction)
            {
                    // New player message was sent
                case ENetworkAction.ActionSendPlayerMessage:
                {
                    // Read out messages into output strings
                    string strName    = _cStream.ReadString();
                    string strMessage = _cStream.ReadString();

                    // Find all players within 'hearing' range of the source player
                    foreach (CNetworkPlayer Player in CheckPlayerDistances(_cNetworkPlayer))
                    {
                        // Invoke RPC call to send the message to each player
                        Instance.InvokeRpc(Player.PlayerId, "ReceivePlayerMessage", strName, strMessage);
                    }

                    break;
                }
            }
        }
    }
示例#4
0
	public static void UnserializeData(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
	{
		ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte();
		
		switch (eNetworkAction)
		{
			case ENetworkAction.ActionSendPlayerName:
			{
				string sPlayerName = _cStream.ReadString();

				//Send all dictionary entries to new player
				foreach (KeyValuePair<ulong, string> entry in CGamePlayers.s_cInstance.m_mPlayersNames) 
				{
					//Make sure you don't send RPC to yourself. Foreach loops will not let you modify the collections object (dictionary) you are operating on.
					if(_cNetworkPlayer.PlayerId != CNetwork.PlayerId)
					{
						CGamePlayers.s_cInstance.InvokeRpc(_cNetworkPlayer.PlayerId, "RegisterPlayerName", entry.Key, entry.Value);
					}
				}
						
				// Send new player name to all other players
				CGamePlayers.s_cInstance.InvokeRpcAll("RegisterPlayerName", _cNetworkPlayer.PlayerId, sPlayerName);
				
				break;
			}
		}
	}