本文整理汇总了C#中NetworkMessage类的典型用法代码示例。如果您正苦于以下问题:C# NetworkMessage类的具体用法?C# NetworkMessage怎么用?C# NetworkMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkMessage类属于命名空间,在下文中一共展示了NetworkMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToNetworkMessage
public override void ToNetworkMessage(NetworkMessage msg)
{
msg.AddByte((byte)Type);
msg.AddLocation(FromLocation);
msg.AddByte(FromStackPosition);
msg.AddLocation(ToLocation);
}
示例2: ToNetworkMessage
public override void ToNetworkMessage(NetworkMessage msg)
{
msg.AddByte((byte)Type);
msg.AddUInt32(CreatureId);
msg.AddByte(LightLevel);
msg.AddByte(LightColor);
}
示例3: AddMessageToSend
public void AddMessageToSend(NetworkMessage mes)
{
lock (messageQueue)
{
messageQueue.Enqueue(mes);
}
}
示例4: OnConnected
void OnConnected(NetworkMessage msg)
{
Debug.Log (string.Format("Connected to Server"));
connectionIdMessage connIdMsg = new connectionIdMessage ();
connIdMsg.setConnId (client.connection.connectionId);
client.Send(Message.GET_HAS_ROOM, connIdMsg);
}
示例5: OnSetupGameOver
public static void OnSetupGameOver(NetworkMessage netMsg)
{
var msg = netMsg.ReadMessage<PlayerMessage>();
var gameOver = msg.player.GetComponent<PlayerRespawn>();
gameOver.anim = GameObject.Find("HUDCanvas").GetComponent<Animator>();
}
示例6: ParseMessage
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
{
if (msg.GetByte() != (byte)OutgoingPacketType.AutoWalk)
return false;
Destination = destination;
Type = OutgoingPacketType.AutoWalk;
Directions = new List<Pokemon.Constants.Direction> { };
byte count = msg.GetByte();
for (int i = 0; i < count; i++)
{
Constants.Direction direction;
byte dir = msg.GetByte();
switch (dir)
{
case 1: direction = Pokemon.Constants.Direction.Right; break;
case 2: direction = Pokemon.Constants.Direction.UpRight; break;
case 3: direction = Pokemon.Constants.Direction.Up; break;
case 4: direction = Pokemon.Constants.Direction.UpLeft; break;
case 5: direction = Pokemon.Constants.Direction.Left; break;
case 6: direction = Pokemon.Constants.Direction.DownLeft; break;
case 7: direction = Pokemon.Constants.Direction.Down; break;
case 8: direction = Pokemon.Constants.Direction.DownRight; break;
default: continue;
}
Directions.Add(direction);
}
return true;
}
示例7: ParseMessage
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
{
int position = msg.Position;
if (msg.GetByte() != (byte)IncomingPacketType.ChannelOpen)
return false;
Destination = destination;
Type = IncomingPacketType.ChannelOpen;
ChannelId = (ChatChannel)msg.GetUInt16();
ChannelName = msg.GetString();
if (Client.VersionNumber >= 872)
{
NumberOfParticipants = msg.GetUInt16();
for (ushort p = 0; p < NumberOfParticipants; p++)
{
Participants[p] = msg.GetString();
}
NumberOfInvitees = msg.GetUInt16();
for (ushort i = 0; i < NumberOfInvitees; i++)
{
Invitees[i] = msg.GetString();
}
}
return true;
}
示例8: ParseMessage
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
{
int position = msg.Position;
if (msg.GetByte() != (byte)IncomingPacketType.ContainerOpen)
return false;
Destination = destination;
Type = IncomingPacketType.ContainerOpen;
Id = msg.GetByte();
ItemId = msg.GetUInt16();
Name = msg.GetString();
Capacity = msg.GetByte();
HasParent = msg.GetByte();
ItemCount = msg.GetByte();
Items = new List<Tibia.Objects.Item>(ItemCount);
for (int i = 0; i < ItemCount; i++)
{
Objects.Item item = msg.GetItem();
item.Location = Tibia.Objects.ItemLocation.FromContainer(Id, (byte)i);
Items.Add(item);
}
return true;
}
示例9: OnPlayerExperience
public static void OnPlayerExperience(NetworkMessage netMsg)
{
var msg = netMsg.ReadMessage<PlayerExperienceMessage>();
//Seems like the server is receiving the message as well
FloatingTextManager.PlayerXp(msg.amount, msg.position);
}
示例10: LogIn
void LogIn(NetworkMessage netMsg, InfoMessage msg)
{
bool loggedIn = false;
string query = "SELECT * FROM shogi.players WHERE players_email = \"" + msg.email + "\"";
if (con.State.ToString () != "Open")
con.Open ();
using (con) {
using (cmd = new MySqlCommand (query, con)) {
rdr = cmd.ExecuteReader();
if (rdr.HasRows) {
rdr.Read ();
if (msg.password == rdr["players_password"].ToString ()) {
incomeMessages.text += netMsg.conn.address + " logged in as " + msg.email + "\n";
loggedIn = true;
}
else
incomeMessages.text += netMsg.conn.address + " failed logging in for wrong password " + msg.password + "\n";
}
else
incomeMessages.text += netMsg.conn.address + " failed logging in for no entry " + msg.email + "\n";
rdr.Dispose ();
}
string queryIP = "UPDATE shogi.players SET players_ip = \"" + netMsg.conn.address + "\" WHERE players_email = \"" + msg.email + "\"";
if (loggedIn) {
using (cmd = new MySqlCommand (queryIP, con))
cmd.ExecuteNonQuery ();
msg.goal = "loggedin";
NetworkServer.SendToClient(netMsg.conn.connectionId, MyMsgType.Info, msg);
}
}
}
示例11: ParseMessage
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
{
int position = msg.Position;
if (msg.GetByte() != (byte)IncomingPacketType.PlayerStatus)
return false;
Destination = destination;
Type = IncomingPacketType.PlayerStatus;
Health = msg.GetUInt16();
MaxHealth = msg.GetUInt16();
PokemonsCount = msg.GetUInt32();
Experience = msg.GetUInt32();
Level = msg.GetUInt16();
LevelPercent = msg.GetByte();
Pokemons = msg.GetUInt16();
PokemonsMax = msg.GetUInt16();
MagicLevel = msg.GetByte();
MagicLevelPercent = msg.GetByte();
Soul = msg.GetByte();
Stamina = msg.GetUInt16();
return true;
}
示例12: ToNetworkMessage
public override void ToNetworkMessage(NetworkMessage msg)
{
msg.AddByte((byte)Type);
msg.AddUInt16(ChannelId);
msg.AddString(Name);
}
示例13: ToNetworkMessage
public override void ToNetworkMessage(NetworkMessage msg)
{
msg.AddByte((byte)Type);
msg.AddUInt32(PlayerId);
msg.AddString(PlayerName);
msg.AddByte(PlayerState);
}
示例14: ToNetworkMessage
public override void ToNetworkMessage(NetworkMessage msg)
{
msg.AddByte((byte)Type);
msg.AddUInt16(Health);
msg.AddUInt16(MaxHealth);
msg.AddUInt32(Capacity);
if (Client.VersionNumber >= 870)
{
msg.AddUInt64(Experience);
}
else
{
msg.AddUInt32((uint)Experience);
}
msg.AddUInt16(Level);
msg.AddByte(LevelPercent);
msg.AddUInt16(Mana);
msg.AddUInt16(MaxMana);
msg.AddByte(MagicLevel);
msg.AddByte(MagicLevelPercent);
msg.AddByte(Soul);
msg.AddUInt16(Stamina);
}
示例15: ParseMessage
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination)
{
int position = msg.Position;
if (msg.GetByte() != (byte)IncomingPacketType.OutfitWindow)
return false;
Destination = destination;
Type = IncomingPacketType.OutfitWindow;
Default = msg.GetOutfit();
byte count = msg.GetByte();
OutfitList = new List<AvalibleOutfit> { };
for (int i = 0; i < count; i++)
{
AvalibleOutfit outfit = new AvalibleOutfit();
outfit.Id = msg.GetUInt16();
outfit.Name = msg.GetString();
outfit.Addons = msg.GetByte();
OutfitList.Add(outfit);
}
return true;
}