本文整理汇总了C#中Packet.ReadObject方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadObject方法的具体用法?C# Packet.ReadObject怎么用?C# Packet.ReadObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onPlayerDisconnected
private void onPlayerDisconnected(Packet<IScenePeer> packet)
{
Player fakeAlly = packet.ReadObject<Player>();
for (int i = 0; i < m_allies.Length; i++)
if (m_allies[i] != null && m_allies[i].ID == fakeAlly.ID)
m_allies[i] = null;
}
示例2: OnChat
public void OnChat(Packet<IScenePeer> packet)
{
ChatMessageDTO dto;
dto = packet.ReadObject<ChatMessageDTO>();
if (dto.UserInfo.User == "")
{
dto.UserInfo.User = "annonymous" + dto.UserInfo.ClientId;
}
string message = dto.UserInfo.User + ": " + dto.Message + "\b";
ReceiverPump.Enqueue(message);
messageReceived = true;
}
示例3: onUpdatePos
private void onUpdatePos(Packet<IScenePeer> packet)
{
Player ally = packet.ReadObject<Player>();
if (player.ID == ally.ID)
{
player.Pos = ally.Pos;
return;
}
for (int i = 0; i < m_allies.Length; i++)
if (m_allies[i] != null && m_allies[i].ID == ally.ID)
{
m_allies[i].Pos = ally.Pos;
return;
}
for (int i = 0; i < m_allies.Length; i++)
if (m_allies[i] == null)
m_allies[i] = ally;
}
示例4: OnRemoveObject
public void OnRemoveObject(Packet<IScenePeerClient> packet)
{
_log.Debug("replicator", "removing object");
var dto = packet.ReadObject<ReplicatorDTO>();
_scene.Broadcast<ReplicatorDTO>("DestroyObject", dto);
}
示例5: OnPlayerDisconnect
public void OnPlayerDisconnect(Packet<IScenePeer> packet)
{
var clientId = packet.ReadObject<long>();
int i = 0;
foreach(StormancerNetworkIdentity ni in SlaveObjects.Values)
{
if (ni.MasterId == clientId)
{
i++;
StormancerNetworkIdentity trash;
SlaveObjects.TryRemove(ni.Id, out trash);
MainThread.Post(() =>
{
Destroy(trash.gameObject);
});
}
}
Debug.Log("a player disconnected. Removed " + i + " objects");
}
示例6: onCreateGame
public void onCreateGame(Packet<IScenePeerClient> packet)
{
GameInfos game = packet.ReadObject<GameInfos>();
game.IDOwner = packet.Connection.Id;
game.IDPlayers[packet.Connection.Id] = m_players[packet.Connection];
m_log.Debug("Lobby", "Client (id : " + packet.Connection.Id + ") with player name : \"" + m_players[packet.Connection].Name + "\" created game.");
m_games.Add(game);
}
示例7: onQuitGame
private void onQuitGame(Packet<IScenePeerClient> packet)
{
GameInfos game = packet.ReadObject<GameInfos>();
game = m_games.Find(npc => { return (npc.IDOwner == game.IDOwner); });
game.IDPlayers.Remove(packet.Connection.Id);
foreach (IScenePeerClient client in m_scene.RemotePeers)
if (game.IDPlayers.ContainsKey(client.Id))
client.Send("UpdateGame", game);
}
示例8: Error
internal void Error(Packet<IScenePeer> p)
{
var rq = GetPendingRequest(p);
if (rq != null)
{
rq.Observer.OnError(new ClientException(p.ReadObject<string>()));
}
}
示例9: onUpdateGame
private void onUpdateGame(Packet<IScenePeer> packet)
{
GameInfos infos = packet.ReadObject<GameInfos>();
if (actualGame.IDOwner == infos.IDOwner)
{
actualGame = infos;
affPlayersGame();
}
else
onRefresh();
}
示例10: onGetGameInfos
private void onGetGameInfos(Packet<IScenePeerClient> packet)
{
m_game = packet.ReadObject<GameInfos>();
m_log.Debug("Game", "Setting name to " + m_game.SceneName);
m_log.Debug("Game", "Setting max players to " + m_game.MaxPlayer.ToString());
m_game.IDPlayers.Clear();
if (m_game.MaxPlayer == m_nbPlayer)
{
m_started = true;
m_log.Debug("Game", "Game " + m_game.SceneName + " is running.");
}
}
示例11: onFire
private void onFire(Packet<IScenePeerClient> packet)
{
Pos pos = packet.ReadObject<Pos>();
Entity fire = new Entity(TypeEntity.FIREALLY, findNextIDEntity());
fire.Position = pos;
m_scene.Broadcast("CreateEntity", fire);
}
示例12: OnDestroyObject
private void OnDestroyObject(Packet<IScenePeer> packet)
{
var dto = packet.ReadObject<ReplicatorDTO>();
StormancerNetworkIdentity DestroyedGO;
Debug.Log("destroying object");
if (SlaveObjects.TryRemove(dto.Id, out DestroyedGO))
{
MainThread.Post(() =>
{
Destroy(DestroyedGO.gameObject);
});
}
}
示例13: OnCreateObject
private void OnCreateObject(Packet<IScenePeer> packet)
{
var dto = packet.ReadObject<ReplicatorDTO>();
Debug.Log("creating object");
if (dto.PrefabId < Prefabs.Count && SlaveObjects.ContainsKey(dto.Id) == false && MastersObjects.ContainsKey(dto.Id) == false)
{
MainThread.Post(() =>
{
var SynchedGO = Instantiate(Prefabs[dto.PrefabId]);
var ni = SynchedGO.GetComponent<StormancerNetworkIdentity>();
ni.Id = dto.Id;
ni.PrefabId = dto.PrefabId;
ni.MasterId = dto.ClientId;
SlaveObjects.TryAdd(dto.Id, ni);
});
}
}
示例14: OnMessageReceived
void OnMessageReceived(Packet<IScenePeerClient> packet)
{
var dto = new ChatMessageDTO();
ChatUserInfo temp;
if (_UsersInfos.TryGetValue(packet.Connection.Id, out temp) == false)
{
temp = new ChatUserInfo();
temp.ClientId = packet.Connection.Id;
temp.User = "";
}
dto.UserInfo = temp;
dto.Message = packet.ReadObject<string>();
dto.TimeStamp = _env.Clock;
AddMessageToCache(dto);
_scene.Broadcast("chat", dto, PacketPriority.MEDIUM_PRIORITY, PacketReliability.RELIABLE);
}
示例15: onGetCollision
private void onGetCollision(Packet<IScenePeerClient> packet)
{
Collision collision = packet.ReadObject<Collision>();
if (collision.ObjectCollidedOne == TypeEntity.PLAYER)
{
}
}