本文整理汇总了C#中UnityEngine.NetworkPlayer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkPlayer.ToString方法的具体用法?C# NetworkPlayer.ToString怎么用?C# NetworkPlayer.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.NetworkPlayer
的用法示例。
在下文中一共展示了NetworkPlayer.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: client_authenticate_switch_handler
public static void client_authenticate_switch_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Authentication Switch received: #" + np.ToString());
if(np.ToString() == Constants.SERVER_ID_STRING && Network.isServer) return;
_PMClient.Authentication authObject = PurpleSerializer.StringToObjectConverter<_PMClient.Authentication> (dataObject);
bool validationResult = false;
string newToken = string.Empty;
// TODO...
}
示例2: client_authenticate_handler
public static void client_authenticate_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Authentication received: #" + np.ToString());
if(np.ToString() == Constants.SERVER_ID_STRING && Network.isServer) return;
_PMClient.Authentication authObject = PurpleSerializer.StringToObjectConverter<_PMClient.Authentication> (dataObject);
bool validationResult = false;
string newToken = string.Empty;
if(string.IsNullOrEmpty(authObject.ClientPassword))
{
validationResult = AccountHelper.ValidateAuthentication (authObject.ClientName, authObject.ClientToken);
if(validationResult)
newToken = AccountHelper.GenerateToken(authObject.ClientName, authObject.ClientToken, np);
}
else
{
validationResult = AccountHelper.Login (authObject.ClientName, authObject.ClientPassword, np, out newToken);
}
authObject.validate = validationResult;
authObject.timestamp = DateTime.Now;
// save 2 spaces if monitoring is allowed otherwise just one for Admin/Mod/GM
int maxAllowedConnections = PurpleServer.CurrentConfig.ServerMaxClients;
maxAllowedConnections -= (PurpleServer.CurrentConfig.ServerAllowMonitoring) ? 2 : 1;
authObject.ClientPassword = String.Empty;
authObject.ClientToken = String.Empty;
authObject.ClientAuthenticated = false;
if(validationResult && PurpleServer.UserList.Count <= maxAllowedConnections)
{
authObject.ClientToken = newToken;
authObject.ClientAuthenticated = true;
}
else if(validationResult)
{
PurpleNetworkUser playerReference = get_network_player_reference(np);
if (playerReference.UserType != UserTypes.User)
{
authObject.ClientToken = newToken;
authObject.ClientAuthenticated = true;
}
}
AccountHelper.AddLog(get_network_player_reference(np).UserName, "client_authenticate_handler "
+ authObject.ClientName + " - "+ authObject.ClientAuthenticated);
PurpleDebug.Log("Authentication result: " + authObject.ClientName + ": " + authObject.ClientAuthenticated);
PurpleNetwork.ToPlayer(np, "server_authenticate_result", authObject);
}
示例3: getDebugName
public static string getDebugName(NetworkPlayer player)
{
string address = formatAddress(player.ipAddress, player.port);
string externalAddress = "(Ext:" + formatAddress(player.externalIP, player.externalPort) + ")";
string guid = "[" + player.guid + "]";
return string.Join(" ", new string[] {address, externalAddress, guid, player.ToString()});
}
示例4: AddNewPlayer
/// <summary>
/// Called by UserManagementObjectController on the server whenever a new player has successfully connected.
/// </summary>
/// <param name="player">Newly connected player</param>
/// <param name="isClient">True if Client connected</param>
public void AddNewPlayer(NetworkPlayer player,bool isClient)
{
if (!networkPlayerMap.ContainsKey(player))
{
int playerCounter = 1;
while (networkPlayerMap.ContainsValue("player" + System.Convert.ToString(playerCounter)))
{
playerCounter++;
}
Debug.Log("UserManager Unity player " + player.ToString() + "added as UserManager player" + System.Convert.ToString(playerCounter));
networkPlayerMap.Add(player,"player" + System.Convert.ToString(playerCounter));
if(isClient)
{
Debug.Log("RPC Call setname sent to player"+System.Convert.ToString(playerCounter));
GameObject.Find("GUIObj").networkView.RPC("setName", player, "player" + System.Convert.ToString(playerCounter));
}
else
{
Debug.Log("Server setname sent to player"+System.Convert.ToString(playerCounter));
GameObject.Find("GUIObj").GetComponent<MobileNetworkGUI>().setName("player" + System.Convert.ToString(playerCounter));
}
}
}
示例5: client_validate_username_handler
// HANDLER /////////////////////////
// ACCOUNT /////////////////////////
public static void client_validate_username_handler(string dataObject, NetworkPlayer np)
{
PurpleDebug.Log("Username validation received: #" + np.ToString());
_PMBasic.Data basicData = PurpleSerializer.StringToObjectConverter<_PMBasic.Data> (dataObject);
basicData.validate = AccountHelper.IsUniqueUsername (basicData.data);
PurpleNetwork.ToPlayer (np, "server_validate_username_result", basicData);
}
示例6: OnPlayerConnected
void OnPlayerConnected(NetworkPlayer player)
{
Debug.Log ("Client connected: " + player.ToString());
OccludedPlayer newOplayer = new OccludedPlayer(player);
_players.Add(newOplayer);
}
示例7: DisconnectPlayer
void DisconnectPlayer(NetworkPlayer player)
{
if(Network.isClient)
{
Debug.Log("Player Disconnected: " + player.ToString());
}
// now we have to do the reverse lookup from
// the NetworkPlayer --> GameObject
// this is easy with the Hashtable
if(players.ContainsKey(player))
{
// we check to see if the gameobject exists
// or not first just as a safety measure
// trying to destory a gameObject that
// doesn't exist causes a runtime error
if((GameObject)players[player]) {
Destroy((GameObject)players[player]);
}
// we also have to remove the Hashtable entry
players.Remove(player);
}
}
示例8: PlayerLeft
void PlayerLeft(NetworkPlayer player)
{
string key = player.ToString();
if(PlayerNamesScript.names.ContainsKey (key))
PlayerNamesScript.names.Remove(key);
else
Debug.Log ("Player we didn't know about left the game!?");
}
示例9: ServerPlaceBlock
public void ServerPlaceBlock( NetworkPlayer sender, int x, int y, int z, int chunkx, int chunky, int chunkz, int data )
{
if (EnableDebugLog) Debug.Log ("UniblocksServer: Received PlaceBlock from player " + sender.ToString());
// You can check whether the change sent by the client is valid here
// if (true) {
DistributeChange (sender, x,y,z, chunkx, chunky,chunkz, data, false);
// }
}
示例10: SpawnPlayer
void SpawnPlayer(NetworkPlayer player)
{
string tempPlayerString = player.ToString ();
int playerNumber = Convert.ToInt32(tempPlayerString);
Transform newPlayerTransform = (Transform)Network.Instantiate (playerPrefab, transform.position, transform.rotation, playerNumber);
playerScripts.Add (newPlayerTransform.GetComponent ("CubeScriptAuthoritative"));//that's the authoritative movement script
NetworkView theNetworkView = newPlayerTransform.networkView;
theNetworkView.RPC ("SetPlayer", RPCMode.AllBuffered, player);
}
示例11: SyncMyPosition
void SyncMyPosition(NetworkPlayer np, Vector3 position)
{
foreach(NetworkPlayer npp in Network.connections){
if(npp.ToString() == np.ToString()){
transform.position = position;
break;
}
}
}
示例12: AddPlayerToList
void AddPlayerToList(NetworkPlayer nPlayer)
{
//Create a new entry in the PlayerList and supply the players Network ID as the first entry
PlayerDataClass capture = new PlayerDataClass();
capture.networkPlayer = int.Parse(nPlayer.ToString());
PlayerList.Add (capture);
}
示例13: EditPlayerListWithScore
void EditPlayerListWithScore(NetworkPlayer nPlayer, int pScore)
{
for(int i = 0; i < PlayerList.Count; i++)
{
if(PlayerList[i].networkPlayer == int.Parse (nPlayer.ToString ()))
{
PlayerList[i].playerScore = pScore;
}
}
}
示例14: AddPlayerNameToList
void AddPlayerNameToList(NetworkPlayer rpcNetPlayer)//takes the onplayerconncted(netplayer.tostring) ID.
{
for(int i = 0; i<OBplayer.Count; i++)
{
if(OBplayer[i].PlayerIndex == int.Parse (rpcNetPlayer.ToString()))
{
OBplayer[i].PlayerName = setPlayerName; //this setPlayerName was set globally from menumanager RPC also nameset = true so it fires
}
}
}
示例15: RemovePlayerFromList
void RemovePlayerFromList(NetworkPlayer rpcNetPlayer)
{
for(int i = 0; i<OBplayer.Count; i++)
{
if(OBplayer[i].PlayerIndex == int.Parse (rpcNetPlayer.ToString()))
{
OBplayer.RemoveAt(i);
}
}
}