本文整理汇总了C#中PlayerData.deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerData.deserialize方法的具体用法?C# PlayerData.deserialize怎么用?C# PlayerData.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerData
的用法示例。
在下文中一共展示了PlayerData.deserialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readPlayerData
/// <summary>
/// Reads in a packet containing all player-related data, and parses it
/// into a PlayerData object
/// </summary>
private void readPlayerData(NetIncomingMessage inMsg)
{
PlayerData newPlayer = new PlayerData();
newPlayer.deserialize(inMsg);
clientWorld.addPlayer(newPlayer);
dwLog.info("Received player data for " + newPlayer.name);
}
示例2: setupNewPlayer
//===================================
//Server processing/outgoing messages
//===================================
private void setupNewPlayer(NetIncomingMessage connectionMsg)
{
NetOutgoingMessage outMsg;
//Create new player data
PlayerData newPlayer = new PlayerData();
newPlayer.deserialize(connectionMsg);
//Update netServer player list
serverWorld.addPlayer(newPlayer);
//Tell all players in this game about the new player
outMsg = netServer.CreateMessage();
outMsg.Write((byte)NetDataType.PlayerConnect);
newPlayer.serialize(outMsg);
netServer.SendToAll(outMsg, connectionMsg.SenderConnection, NetDeliveryMethod.ReliableOrdered, 0);
//Assign an index to the new player
for (int i = 0; i < dwWorldConstants.GAME_MAX_PLAYERS; i++)
{
if (serverWorld.getPlayer(i) == null)
{
//Update the server world
serverWorld.assignPlayerIndex(newPlayer.uid, i);
//Send a message to all clients
outMsg = getPlayerIndexUpdate(newPlayer.uid, i);
netServer.SendToAll(outMsg, NetDeliveryMethod.ReliableOrdered);
break;
}
}
//Tell the new player about all the players in this game
for (int i = 0; i < dwWorldConstants.GAME_MAX_PLAYERS; i++)
{
PlayerData player = serverWorld.getPlayer(i);
if (player == null)
continue;
if (player.Equals(newPlayer))
continue;
//Send player data
outMsg = netServer.CreateMessage();
outMsg.Write((byte)NetDataType.PlayerConnect);
player.serialize(outMsg);
netServer.SendMessage(outMsg, connectionMsg.SenderConnection, NetDeliveryMethod.ReliableOrdered);
//Send a player index update (because this is not part of serialization)
outMsg = getPlayerIndexUpdate(player.uid, player.index);
netServer.SendMessage(outMsg, connectionMsg.SenderConnection, NetDeliveryMethod.ReliableOrdered);
}
}