本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ReadUInt16方法的具体用法?C# NetIncomingMessage.ReadUInt16怎么用?C# NetIncomingMessage.ReadUInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetIncomingMessage
的用法示例。
在下文中一共展示了NetIncomingMessage.ReadUInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
protected override void Read(NetIncomingMessage message)
{
x = message.ReadFloat();
y = message.ReadFloat();
rotation = message.ReadUInt16().FromNetworkRotation() * (180f / (float)Math.PI);
type = message.ReadByte();
}
示例2: Read
public override void Read(NetIncomingMessage msg)
{
Id = msg.ReadUInt16();
int count = msg.ReadInt32();
for(int i = 0; i < count; ++i)
Cards.Add(msg.ReadString());
}
示例3: readBytes
public static void readBytes(NetIncomingMessage data, ClientSprite cs)
{
data.ReadByte();
cs.ID = data.ReadUInt32();
cs.SpriteID = (SpriteIDs)data.ReadUInt16();
cs.Position = new Microsoft.Xna.Framework.Vector2(data.ReadFloat(),data.ReadFloat());
cs.Rotation = data.ReadFloat();
}
示例4: Read
protected override void Read(NetIncomingMessage message)
{
Name = message.ReadString();
X = message.ReadFloat();
Y = message.ReadFloat();
rotation = message.ReadUInt16().FromNetworkRotation() * (180f / (float)Math.PI);
Health = message.ReadByte() / (float)byte.MaxValue;
}
示例5: Read
protected override void Read(NetIncomingMessage message)
{
var length = message.ReadUInt16();
Program = new short[length];
for (var i = 0; i < length; i++)
{
Program[i] = message.ReadInt16();
}
}
示例6: Read
protected override void Read(NetIncomingMessage message)
{
Items.Clear();
var count = message.ReadUInt16();
for (var i = 0; i < count; i++)
{
Items.Add(NetObject.ReadFromMessage(message));
}
}
示例7: HandleEntityComponentNetworkMessage
/// <summary>
/// Handles an incoming entity component message
/// </summary>
/// <param name="message">Raw network message</param>
/// <returns>An IncomingEntityComponentMessage object</returns>
public IncomingEntityComponentMessage HandleEntityComponentNetworkMessage(NetIncomingMessage message)
{
var componentFamily = (ComponentFamily) message.ReadByte();
var messageParams = new List<object>();
while (message.Position < message.LengthBits)
{
switch ((NetworkDataType) message.ReadByte())
{
case NetworkDataType.d_enum:
messageParams.Add(message.ReadInt32());
break;
case NetworkDataType.d_bool:
messageParams.Add(message.ReadBoolean());
break;
case NetworkDataType.d_byte:
messageParams.Add(message.ReadByte());
break;
case NetworkDataType.d_sbyte:
messageParams.Add(message.ReadSByte());
break;
case NetworkDataType.d_ushort:
messageParams.Add(message.ReadUInt16());
break;
case NetworkDataType.d_short:
messageParams.Add(message.ReadInt16());
break;
case NetworkDataType.d_int:
messageParams.Add(message.ReadInt32());
break;
case NetworkDataType.d_uint:
messageParams.Add(message.ReadUInt32());
break;
case NetworkDataType.d_ulong:
messageParams.Add(message.ReadUInt64());
break;
case NetworkDataType.d_long:
messageParams.Add(message.ReadInt64());
break;
case NetworkDataType.d_float:
messageParams.Add(message.ReadFloat());
break;
case NetworkDataType.d_double:
messageParams.Add(message.ReadDouble());
break;
case NetworkDataType.d_string:
messageParams.Add(message.ReadString());
break;
case NetworkDataType.d_byteArray:
int length = message.ReadInt32();
messageParams.Add(message.ReadBytes(length));
break;
}
}
return new IncomingEntityComponentMessage(componentFamily, messageParams);
}
示例8: OnAdvancedNetworkMessage
public override void OnAdvancedNetworkMessage(NetIncomingMessage msg)
{
if (msg.ReadByte() == 0)
{
this.lxLoot = new List<PreSeededLoot>();
byte byCount = msg.ReadByte();
for (int i = 0; i < (int)byCount; i++)
{
this.lxLoot.Add(new PreSeededLoot(msg.ReadUInt16(), (ItemCodex.ItemTypes)msg.ReadInt32(), new Vector2(msg.ReadFloat(), msg.ReadFloat())));
}
}
}
示例9: Read
public override void Read(NetIncomingMessage msg)
{
int count = msg.ReadInt32();
for(int i = 0; i < count; ++i)
{
ushort uid = msg.ReadUInt16();
List<string> cards = new List<string>();
int cardCount = msg.ReadInt32();
for(int j = 0; j < cardCount; ++j)
cards.Add(msg.ReadString());
Options.Add(new Tuple<ushort, List<string>>(uid, cards));
}
}
示例10: Get
public static Packet Get(NetIncomingMessage message)
{
var packetId = message.ReadUInt16();
var pdata = PacketFactory.GetPacketType(packetId);
var newPacket = (Packet)Activator
.CreateInstance(pdata.PacketType);
if (newPacket != null)
{
Bitstream stream = new Bitstream(message);
newPacket.Deserialize(stream);
return newPacket;
}
//TODO
return null;
}
示例11: HandleData
public override void HandleData(NetIncomingMessage msg)
{
NetEntityType Type;
ushort ID;
Vector3 Position;
Vector3 Velocity;
Quaternion Orientation;
NetMsgType datatype = (NetMsgType)msg.ReadByte();
switch (datatype)
{
case NetMsgType.Chat:
Console.WriteLine(msg.ReadString());
break;
case NetMsgType.CreateOnClient:
#region CreateOnClient
Type = (NetEntityType)msg.ReadByte();
ID = msg.ReadUInt16();
Position = new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat());
Orientation = new Quaternion(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat());
ushort Resource;
long OwnerID;
//DEBUG
if (Type == NetEntityType.Ship)
{
int[] shipWeapons = null;
var shipNose = msg.ReadInt32();
var shipCore = msg.ReadInt32();
var shipTail = msg.ReadInt32();
int weaponLength = msg.ReadInt32();
if (weaponLength > 0)
{
shipWeapons = new int[weaponLength];
for (int i = 0; i < weaponLength; i++)
shipWeapons[i] = msg.ReadInt32();
}
Resource = 0;
OwnerID = msg.ReadInt64();
var shipData = new ShipData(shipNose, shipCore, shipTail);
WeaponsFromData(shipData, shipWeapons);
var ship = new ShipObj(MobileFortressClient.Game, Position, Orientation, shipData);
ship.ID = ID;
if (OwnerID == Network.Client.UniqueIdentifier)
{
Network.JoinedGame = true;
Camera.Setup(MobileFortressClient.Game, ship, new Vector3(0, 2f, 6f));
var HUD = new ShipHUD();
if (shipWeapons != null)
{
for (int i = 0; i < shipWeapons.Length; i++)
{
HUD.MakeAmmoIndicator(shipWeapons[i]);
}
}
MenuManager.Menu = HUD;
}
}
else
{
Resource = msg.ReadUInt16();
if (Type == NetEntityType.Building)
{
new Building(Position, Resource);
}
else if (Type == NetEntityType.Missile)
{
var obj = new Rocket(MobileFortressClient.Game, Resource, Position, Orientation);
obj.ID = ID;
}
else
{
var obj = new PhysicsObj(MobileFortressClient.Game, Position, Orientation, Resource);
obj.ID = ID;
}
}
#endregion
break;
case NetMsgType.MapLoading:
#region MapLoading
if (msg.ReadByte() == 0)
{
var Seed = msg.ReadInt32();
var Power = msg.ReadInt32();
var Roughness = msg.ReadFloat();
Sector.Redria.Terrain.Terrain = new Heightmap(Seed, Power, Roughness);
}
else
{
var terrain = Sector.Redria.Terrain.Terrain;
int alterations = msg.ReadInt32();
Console.WriteLine(alterations + " Recieved Alterations.");
for (int i = 0; i < alterations; i++)
{
Rectangle flattenedArea = new Rectangle(msg.ReadInt32(),
msg.ReadInt32(), msg.ReadInt32(), msg.ReadInt32());
terrain.FlattenArea(flattenedArea);
}
terrain.Graphics.ResetVertexBuffer();
//.........这里部分代码省略.........
示例12: OnAdvancedNetworkMessage
public override void OnAdvancedNetworkMessage(NetIncomingMessage msg)
{
if (msg.ReadByte() == 0)
{
FlagCodex.FlagID enFlag = (FlagCodex.FlagID)msg.ReadUInt16();
this.HandleFlagTrigger(enFlag);
}
}
示例13: Read
public virtual NetworkMessage Read(NetIncomingMessage msgIn)
{
type = (NetworkMessageType)msgIn.ReadUInt16();
return this;
}
示例14: HandleRegisterHost
private void HandleRegisterHost(NetIncomingMessage inc)
{
var id = inc.ReadInt64();
var name = inc.ReadString();
var population = inc.ReadUInt16();
var maxPopulation = inc.ReadUInt16();
var guid = inc.ReadString();
var endpoint = inc.ReadIPEndpoint();
var game = inc.ReadInt32();
//if (manager.Register(id, new Guid(guid)))
{
registeredHosts[id] = new Object[]
{
endpoint,
inc.SenderEndpoint,
name,
population,
maxPopulation,
NetTime.Now,
game
};
}
}
示例15: HandleDataMessage
private void HandleDataMessage(NetIncomingMessage incomingMessage)
{
if (IsAuthenticated)
{
//incomingMessage.Decrypt(cryptoAlgorithm);
}
var p = incomingMessage.ReadProtocol();
ushort messageType = incomingMessage.ReadUInt16();
//Trace.WriteLine("Received " + ((CustomMessageType)messageType).ToString() + ".");
var protocol = Protocols.Where(x => x.Equals(p)).First();
var mHandlers = GetHandlers(protocol, messageType);
var message = protocol.Create(messageType);
message.ReadPayload(incomingMessage);
if (OnMessageReceived != null)
OnMessageReceived(null, new MessageEventArgs(this, message));
if (mHandlers != null)
{
for (int n = 0; n < mHandlers.Count; ++n)
mHandlers[n](new MessageEventArgs(this, message));
}
}