本文整理汇总了C#中Lidgren.Network.NetBuffer.ReadUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# NetBuffer.ReadUInt64方法的具体用法?C# NetBuffer.ReadUInt64怎么用?C# NetBuffer.ReadUInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetBuffer
的用法示例。
在下文中一共展示了NetBuffer.ReadUInt64方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StateUpdateEventArgs
public StateUpdateEventArgs(NetBuffer msg) : base(msg)
{
EntitiesUpdatedState = new List<StateUpdateData>();
RemarkableEvents = new List<RemarkableEventData>();
LastAcknowledgedActionID = msg.ReadUInt64();
Time = msg.ReadDouble();
Vec2 velocity = new Vec2(msg.ReadFloat(), msg.ReadFloat());
byte nbClients = msg.ReadByte();
for (byte i = 0; i < nbClients; ++i) {
ulong id = msg.ReadUInt64();
Vec2 pos = new Vec2(msg.ReadFloat(), msg.ReadFloat());
ChampionAnimation anim = (ChampionAnimation)msg.ReadByte();
bool facingLeft = msg.ReadBoolean();
EntitiesUpdatedState.Add(new StateUpdateData(id, pos, velocity, anim, facingLeft));
}
while (msg.Position != msg.LengthBits) {
ServerCommand cmd = (ServerCommand)msg.ReadByte();
RemarkableEventData data = null;
switch (cmd) {
case ServerCommand.SpellCast:
data = new SpellCastEventData(
msg.ReadUInt64(),
msg.ReadUInt64(),
(SpellTypes)msg.ReadByte(),
msg.ReadFloat(),
new Vec2(msg.ReadFloat(), msg.ReadFloat()),
new Vec2(msg.ReadFloat(), msg.ReadFloat()),
TimeSpan.FromSeconds(msg.ReadFloat()),
msg.ReadFloat(),
msg.ReadFloat());
break;
case ServerCommand.SpellDisappear:
data = new SpellDisappearEventData(msg.ReadUInt64());
break;
case ServerCommand.StatsChanged:
data = new StatsChangedEventData(msg.ReadUInt64(), msg.ReadFloat());
break;
case ServerCommand.ChampionDied:
data = new ChampionDiedEventData(msg.ReadUInt64(),
msg.ReadUInt64(),
msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(), msg.ReadUInt32(),
TimeSpan.FromSeconds(msg.ReadUInt16()));
break;
case ServerCommand.StructureStatsChanged:
data = new StructureStatsChangedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
(StructureTypes)msg.ReadByte(),
msg.ReadFloat());
break;
case ServerCommand.StructureDestroyed:
data = new StructureDestroyedEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
(StructureTypes)msg.ReadByte());
break;
case ServerCommand.EndOfGame:
data = new EndOfGameEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right);
break;
case ServerCommand.TowerPreparingToShoot:
data = new TowerPreparingToShootEventData(msg.ReadBoolean() ? Teams.Left : Teams.Right,
(StructureTypes)msg.ReadByte());
break;
default:
Debug.Fail("Unknown server command when updating (unknown remarkable event)");
break;
}
if (data != null) {
RemarkableEvents.Add(data);
}
}
}
示例2: Main
//.........这里部分代码省略.........
throw new Exception("Ack thphth 6");
if (msg.ReadSingle() != 8.111f)
throw new Exception("Ack thphth 7");
if (msg.ReadString() != "again")
throw new Exception("Ack thphth 8");
byte[] rrr = msg.ReadBytes(4);
if (rrr[0] != arr[0] || rrr[1] != arr[1] || rrr[2] != arr[2] || rrr[3] != arr[3])
throw new Exception("Ack thphth 9");
if (msg.ReadByte(7) != 7)
throw new Exception("Ack thphth 10");
if (msg.ReadInt32() != Int32.MinValue)
throw new Exception("Ack thphth 11");
if (msg.ReadUInt32() != UInt32.MaxValue)
throw new Exception("Ack thphth 12");
float v = msg.ReadRangedSingle(-10, 50, 12);
// v should be close to, but not necessarily exactly, 21.0f
if ((float)Math.Abs(21.0f - v) > 0.1f)
throw new Exception("Ack thphth *RangedSingle() failed");
if (msg.ReadInt32(5) != 15)
throw new Exception("Ack thphth ReadInt32 1");
if (msg.ReadInt32(5) != 2)
throw new Exception("Ack thphth ReadInt32 2");
if (msg.ReadInt32(5) != 0)
throw new Exception("Ack thphth ReadInt32 3");
if (msg.ReadInt32(5) != -1)
throw new Exception("Ack thphth ReadInt32 4");
if (msg.ReadInt32(5) != -2)
throw new Exception("Ack thphth ReadInt32 5");
if (msg.ReadInt32(5) != -15)
throw new Exception("Ack thphth ReadInt32 6");
UInt64 longVal = msg.ReadUInt64();
if (longVal != UInt64.MaxValue)
throw new Exception("Ack thphth UInt64");
if (msg.ReadInt64() != Int64.MaxValue)
throw new Exception("Ack thphth Int64");
if (msg.ReadInt64() != Int64.MinValue)
throw new Exception("Ack thphth Int64");
if (msg.ReadInt32() != 42)
throw new Exception("Ack thphth end");
msg.SkipPadBits();
if (msg.ReadRangedInteger(0, 10) != 5)
throw new Exception("Ack thphth ranged integer");
}
// test writevariableuint64
NetBuffer largeBuffer = new NetBuffer(100 * 8);
UInt64[] largeNumbers = new ulong[100];
for (int i = 0; i < 100; i++)
{
largeNumbers[i] = ((ulong)NetRandom.Instance.NextUInt() << 32) | (ulong)NetRandom.Instance.NextUInt();
largeBuffer.WriteVariableUInt64(largeNumbers[i]);
}
largeBuffer.Position = 0;
for (int i = 0; i < 100; i++)
{
UInt64 ln = largeBuffer.ReadVariableUInt64();
if (ln != largeNumbers[i])
throw new Exception("large fail");
}
示例3: PlayerData
public PlayerData(NetBuffer msg) : this()
{
ID = msg.ReadUInt64();
Position = new Vec2(msg.ReadFloat(), msg.ReadFloat());
Type = (ChampionTypes)msg.ReadByte();
Team = msg.ReadBoolean() ? Teams.Left : Teams.Right;
MaxHealth = msg.ReadFloat();
Health = msg.ReadFloat();
}