本文整理汇总了C#中Lidgren.Network.NetBuffer.ReadFloat方法的典型用法代码示例。如果您正苦于以下问题:C# NetBuffer.ReadFloat方法的具体用法?C# NetBuffer.ReadFloat怎么用?C# NetBuffer.ReadFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetBuffer
的用法示例。
在下文中一共展示了NetBuffer.ReadFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: MSG_ReadDeltaEntity
/*
==================
MSG_ReadDeltaEntity
The entity number has already been read from the message, which
is how the from state is identified.
If the delta removes the entity, entityState_t->number will be set to MAX_GENTITIES-1
Can go from either a baseline or a previous packet_entity
==================
*/
public void MSG_ReadDeltaEntity(NetBuffer msg, ref Common.entityState_t from, ref Common.entityState_t to, int number)
{
int startBit = msg.Position-32;
if (number < 0 || number >= 1024)
{
Common.Instance.Error("ReadDeltaEntity: number < 0 || number >= 1024");
}
// Check for remove
if (msg.ReadBoolean())
{
to = new Common.entityState_t();
to.number = 1023;
Common.Instance.WriteLine("Removed entity: {0}", number);
return;
}
// Check for no delta
if (!msg.ReadBoolean())
{
to = from;
to.number = number;
return;
}
to.number = number;
int dataStart = msg.Position;
to.eType = msg.ReadBoolean() ? msg.ReadInt32() : from.eType;
to.eFlags = msg.ReadBoolean() ? (Common.EntityFlags)msg.ReadInt32() : from.eFlags;
int middle = msg.Position;
to.pos.trBase.X = msg.ReadBoolean() ? msg.ReadFloat() : from.pos.trBase.X;
to.pos.trBase.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.pos.trBase.Y;
to.pos.trBase.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.pos.trBase.Z;
to.pos.trDelta.X = msg.ReadBoolean() ? msg.ReadFloat() : from.pos.trDelta.X;
to.pos.trDelta.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.pos.trDelta.Y;
to.pos.trDelta.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.pos.trDelta.Z;
to.pos.trDuration = msg.ReadBoolean() ? msg.ReadInt32() : from.pos.trDuration;
to.pos.trTime = msg.ReadBoolean() ? msg.ReadInt32() : from.pos.trTime;
to.pos.trType = msg.ReadBoolean() ? (Common.trType_t)msg.ReadInt32() : from.pos.trType;
to.apos.trBase.X = msg.ReadBoolean() ? msg.ReadFloat() : from.apos.trBase.X;
to.apos.trBase.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.apos.trBase.Y;
to.apos.trBase.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.apos.trBase.Z;
to.apos.trDelta.X = msg.ReadBoolean() ? msg.ReadFloat() : from.apos.trDelta.X;
to.apos.trDelta.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.apos.trDelta.Y;
to.apos.trDelta.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.apos.trDelta.Z;
to.apos.trDuration = msg.ReadBoolean() ? msg.ReadInt32() : from.apos.trDuration;
to.apos.trTime = msg.ReadBoolean() ? msg.ReadInt32() : from.apos.trTime;
to.apos.trType = msg.ReadBoolean() ? (Common.trType_t)msg.ReadInt32() : from.apos.trType;
to.time = msg.ReadBoolean() ? msg.ReadInt32() : from.time;
to.time2 = msg.ReadBoolean() ? msg.ReadInt32() : from.time2;
to.origin.X = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.X;
to.origin.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.Y;
to.origin.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.Z;
to.origin2.X = msg.ReadBoolean() ? msg.ReadFloat() : from.origin2.X;
to.origin2.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.origin2.Y;
to.origin2.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.origin2.Z;
to.angles.X = msg.ReadBoolean() ? msg.ReadFloat() : from.angles.X;
to.angles.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.angles.Y;
to.angles.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.angles.Z;
to.angles2.X = msg.ReadBoolean() ? msg.ReadFloat() : from.angles2.X;
to.angles2.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.angles2.Y;
to.angles2.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.angles2.Z;
to.otherEntityNum = msg.ReadBoolean() ? msg.ReadInt32() : from.otherEntityNum;
to.otherEntityNum2 = msg.ReadBoolean() ? msg.ReadInt32() : from.otherEntityNum2;
to.groundEntityNum = msg.ReadBoolean() ? msg.ReadInt32() : from.groundEntityNum;
to.modelindex = msg.ReadBoolean() ? msg.ReadInt32() : from.modelindex;
to.clientNum = msg.ReadBoolean() ? msg.ReadInt32() : from.clientNum;
to.frame = msg.ReadBoolean() ? msg.ReadInt32() : from.frame;
to.solid = msg.ReadBoolean() ? msg.ReadInt32() : from.solid;
to.generic1 = msg.ReadBoolean() ? msg.ReadInt32() : from.generic1;
int lenghtBits = msg.ReadInt32();
dataStart = msg.Position - dataStart;
lenghtBits -= dataStart;
for (int i = 0; i < lenghtBits; i++)
{
msg.ReadBoolean();
}
middle = msg.Position - middle;
//Common.Instance.WriteLine("MSG_ReadDeltaEntity: Read {0} bits", msg.Position - startBit);
}
示例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();
}
示例4: ReadDeltaPlayerstate
public static void ReadDeltaPlayerstate(NetBuffer msg, Common.PlayerState from, Common.PlayerState to)
{
int startoffset = msg.Position;
if (from == null)
from = new Common.PlayerState();
to.commandTime = msg.ReadBoolean() ? msg.ReadInt32() : from.commandTime;
to.pm_type = msg.ReadBoolean() ? (Common.PMType)msg.ReadInt32() : from.pm_type;
to.pm_flags = msg.ReadBoolean() ? (client.PMFlags)msg.ReadInt32() : from.pm_flags;
to.pm_time = msg.ReadBoolean() ? msg.ReadInt32() : from.pm_time;
to.origin.X = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.X;
to.origin.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.Y;
to.origin.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.Z;
to.velocity.X = msg.ReadBoolean() ? msg.ReadFloat() : from.velocity.X;
to.velocity.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.velocity.Y;
to.velocity.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.velocity.Z;
to.weaponTime = msg.ReadBoolean() ? msg.ReadInt32() : from.weaponTime;
to.gravity = msg.ReadBoolean() ? msg.ReadInt32() : from.gravity;
to.delta_angles[0] = msg.ReadBoolean() ? msg.ReadInt32() : from.delta_angles[0];
to.delta_angles[1] = msg.ReadBoolean() ? msg.ReadInt32() : from.delta_angles[1];
to.delta_angles[2] = msg.ReadBoolean() ? msg.ReadInt32() : from.delta_angles[2];
to.groundEntityNum = msg.ReadBoolean() ? msg.ReadInt32() : from.groundEntityNum;
to.movementDir = msg.ReadBoolean() ? msg.ReadInt32() : from.movementDir;
to.ladderNormal.X = msg.ReadBoolean() ? msg.ReadFloat() : from.ladderNormal.X;
to.ladderNormal.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.ladderNormal.Y;
to.ladderNormal.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.ladderNormal.Z;
to.speed = msg.ReadBoolean() ? msg.ReadInt32() : from.speed;
to.eFlags = msg.ReadBoolean() ? (Common.EntityFlags)Enum.Parse(typeof(Common.EntityFlags), ""+msg.ReadInt32()) : from.eFlags;
to.eventSequence = msg.ReadBoolean() ? msg.ReadInt32() : from.eventSequence;
to.events[0] = msg.ReadBoolean() ? msg.ReadInt32() : from.events[0];
to.events[1] = msg.ReadBoolean() ? msg.ReadInt32() : from.events[1];
to.eventParms[0] = msg.ReadBoolean() ? msg.ReadInt32() : from.eventParms[0];
to.eventParms[1] = msg.ReadBoolean() ? msg.ReadInt32() : from.eventParms[1];
to.externalEvent = msg.ReadBoolean() ? msg.ReadInt32() : from.externalEvent;
to.externalEventParm = msg.ReadBoolean() ? msg.ReadInt32() : from.externalEventParm;
to.externalEventTime = msg.ReadBoolean() ? msg.ReadInt32() : from.externalEventTime;
to.clientNum = msg.ReadBoolean() ? msg.ReadInt32() : from.clientNum;
to.viewangles.X = msg.ReadBoolean() ? msg.ReadFloat() : from.viewangles.X;
to.viewangles.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.viewangles.Y;
to.viewangles.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.viewangles.Z;
to.viewheight = msg.ReadBoolean() ? msg.ReadInt32() : from.viewheight;
//if (to.viewheight == 16)
//{
// int test = 2;
//}
to.generic1 = msg.ReadBoolean() ? msg.ReadInt32() : from.generic1;
to.bobCycle = msg.ReadBoolean() ? msg.ReadInt32() : from.bobCycle;
to.Ducked = msg.ReadBoolean() ? msg.ReadBoolean() : from.Ducked;
to.Ducking = msg.ReadBoolean() ? msg.ReadBoolean() : from.Ducking;
to.DuckTime = msg.ReadBoolean() ? msg.ReadInt32() : from.DuckTime;
to.OldButtons = msg.ReadBoolean() ? msg.ReadInt32() : from.OldButtons;
// Got diff arrays
int msgMiddle = 99999;
if (msg.ReadBoolean())
{
if (msg.ReadBoolean())
{
// stat
int statbits = msg.ReadInt32();
for (int i = 0; i < 16; i++)
{
if ((statbits & (1 << i)) == (1 << i))
{
to.stats[i] = msg.ReadInt16();
}
else
to.stats[i] = from.stats[i];
}
}
else
to.stats = from.stats;
msgMiddle = msg.Position;
if (msg.ReadBoolean())
{
// pers
int persbits = msg.ReadInt32();
for (int i = 0; i < 16; i++)
{
if ((persbits & (1 << i)) == (1 << i))
{
to.persistant[i] = msg.ReadInt16();
}
else
to.persistant[i] = from.persistant[i];
}
}
else
to.persistant = from.persistant;
}
else
{
to.stats = from.stats;
to.persistant = from.persistant;
}
//System.Console.WriteLine("Read {0}bits snapshot, {1} middle", msg.Position - startoffset, msgMiddle - startoffset);
}