本文整理汇总了C#中ByteBuffer.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.ReadByte方法的具体用法?C# ByteBuffer.ReadByte怎么用?C# ByteBuffer.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.ReadByte方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(ByteBuffer buff)
{
uint data = buff.ReadByte();
switch (data)
{
case 0x01://level
Level = buff.ReadUInt32();
break;
case 0x02://exp
XP = buff.ReadUInt64();
break;
case 0x03://str
buff.ReadUInt32();
break;
case 0x04://dex
buff.ReadUInt32();
break;
case 0x05://con
buff.ReadUInt32();
break;
case 0x06://int
buff.ReadUInt32();
break;
case 0x07://wit
buff.ReadUInt32();
break;
case 0x08://men
buff.ReadUInt32();
break;
case 0x09://cur hp
Cur_HP = buff.ReadUInt32();
break;
case 0x0A://max hp
Max_HP = buff.ReadUInt32();
break;
case 0x0B://cur mp
Cur_MP = buff.ReadUInt32();
break;
case 0x0C://max mp
Max_MP = buff.ReadUInt32();
break;
case 0x0D://sp
SP = buff.ReadUInt32();
break;
case 0x0E://cur load
Cur_Load = buff.ReadUInt32();
break;
case 0x0F://max load
Max_Load = buff.ReadUInt32();
break;
case 0x10://..
buff.ReadUInt32();
break;
case 0x11://patk
Patk = buff.ReadUInt32();
break;
case 0x12://atk spd
PatkSpeed = buff.ReadUInt32();
break;
case 0x13://pdef
PDef = buff.ReadUInt32();
break;
case 0x14://evasion
Evasion = buff.ReadUInt32();
break;
case 0x15://acc
Accuracy = buff.ReadUInt32();
break;
case 0x16://crit
Focus = buff.ReadUInt32();
break;
case 0x17://m atk
Matk = buff.ReadUInt32();
break;
case 0x18://cast spd
MatkSpeed = buff.ReadUInt32();
break;
case 0x19://mdef
MDef = buff.ReadUInt32();
break;
case 0x1A://pvp flag
PvPFlag = buff.ReadUInt32();
break;
case 0x1B://karma
Karma = buff.ReadInt32();
break;
case 0x1C://..
buff.ReadUInt32();
break;
case 0x1D://..
buff.ReadUInt32();
break;
case 0x1E://..
buff.ReadUInt32();
break;
case 0x1F://..
buff.ReadUInt32();
break;
case 0x20://..
//.........这里部分代码省略.........
示例2: Load_Pet
public void Load_Pet(ByteBuffer buff)
{
SummonType = buff.ReadUInt32(); //1 = summon, 2 = pet
ID = buff.ReadUInt32();
NPCID = buff.ReadUInt32();
isAttackAble = buff.ReadUInt32();//attackable = 0
X = buff.ReadUInt32();
Y = buff.ReadUInt32();
Z = buff.ReadUInt32();
Heading = buff.ReadInt32();
buff.ReadUInt32();//0x00
MatkSpeed = buff.ReadUInt32();
PatkSpeed = buff.ReadUInt32();
RunSpeed = buff.ReadUInt32();
WalkSpeed = buff.ReadUInt32();
SwimRunSpeed = buff.ReadUInt32();
SwimWalkSpeed = buff.ReadUInt32();
flRunSpeed = buff.ReadUInt32();
flWalkSpeed = buff.ReadUInt32();
if (Globals.gamedata.Chron >= Chronicle.CT1)
{
FlyRunSpeed = buff.ReadUInt32();
FlyWalkSpeed = buff.ReadUInt32();
}
MoveSpeedMult = System.Convert.ToSingle(buff.ReadDouble());
AttackSpeedMult = System.Convert.ToSingle(buff.ReadDouble());
CollisionRadius = System.Convert.ToSingle(buff.ReadDouble());
CollisionHeight = System.Convert.ToSingle(buff.ReadDouble());
LWeapon = buff.ReadUInt32();
Armor = buff.ReadUInt32();
RWeapon = buff.ReadUInt32();
HasOwner = buff.ReadByte(); //owneronline
isRunning = buff.ReadByte();
isInCombat = buff.ReadByte();
isAlikeDead = buff.ReadByte();
isSummoned = buff.ReadByte(); //isSummoned 0=teleported 1=default 2=summoned
if (Globals.gamedata.Chron >= Chronicle.CT3_0)
{
buff.ReadUInt32(); //FF FF FF FF
}
Name = buff.ReadString();
if (string.IsNullOrWhiteSpace(Name))
{
Name = Util.GetNPCName(NPCID);//"Unnamed Pet";
}
if (Globals.gamedata.Chron >= Chronicle.CT3_0)
{
buff.ReadUInt32(); //FF FF FF FF
}
Title = buff.ReadString(); //OwnerName
buff.ReadUInt32();//1
PvPFlag = buff.ReadUInt32();
Karma = buff.ReadInt32();
Cur_Fed = buff.ReadUInt32();
Max_Fed = buff.ReadUInt32();
Cur_HP = buff.ReadUInt32();
Max_HP = buff.ReadUInt32();
Cur_MP = buff.ReadUInt32();
Max_MP = buff.ReadUInt32();
SP = buff.ReadUInt32();
Level = buff.ReadUInt32();
XP = buff.ReadUInt64();
XP_ThisLevel = buff.ReadUInt64();
XP_NextLevel = buff.ReadUInt64();
Cur_Load = buff.ReadUInt32();
Max_Load = buff.ReadUInt32();
Patk = buff.ReadUInt32();
PDef = buff.ReadUInt32();
Accuracy = buff.ReadUInt32();// p
Evasion = buff.ReadUInt32();//p
Focus = buff.ReadUInt32();//p
Matk = buff.ReadUInt32();
MDef = buff.ReadUInt32();
buff.ReadUInt32();//m acu
buff.ReadUInt32();//m eva
buff.ReadUInt32();//m crit
buff.ReadUInt32();// speed
buff.ReadUInt32();//patak sped
buff.ReadUInt32();// cast
/*if (Globals.gamedata.Chron < Chronicle.CT3_0)
{
AbnormalEffects = buff.ReadUInt32(); //AbnormalEffect bleed=1; poison=2; poison & bleed=3; flame=4;
}
//.........这里部分代码省略.........
示例3: Character
void IClientPacket.ExecutePacket(AsyncConnection connection, ByteBuffer packet)
{
uint id = packet.ReadObjectIDRev();
int namelen = packet.ReadInt();
string name = "";
for (int i = 0; i < namelen; i++)
{
name += (char)packet.ReadByte();
}
packet.ReadInt(); packet.ReadInt();
packet.ReadInt();
uint CHARSPEC1 = packet.ReadUInt();
byte CHARSPEC2 = (byte)packet.ReadByte();
packet.ReadBytes(36);
uint CHARSPECAPP1 = packet.ReadUInt();
uint CHARSPECAPP2 = packet.ReadUInt();
uint CHARSPECAPP3 = packet.ReadUInt();
ushort CHARSPECAPP4 = packet.ReadUShort();
packet.ReadByte(); // separator
byte[] classBytes = packet.ReadBytes(8);
Array.Reverse(classBytes);
ulong classNodeRefId = BitConverter.ToUInt64(classBytes, 0);
Console.WriteLine("----- Creating Character -----");
Console.WriteLine("Name = " + name);
Console.WriteLine("Class ID = " + classNodeRefId);
Console.WriteLine("App1 = " + CHARSPECAPP1);
Console.WriteLine("App2 = " + CHARSPECAPP2);
Console.WriteLine("App3 = " + CHARSPECAPP3);
Console.WriteLine("App4 = " + CHARSPECAPP4);
/*byte[] known_offs = new byte[] { 84, 88, 91, 92, 95, 96, 100, 104, 107, 108, 112 };
long originalPositon = packet.Position;
byte[] thispkt = packet.ReadBytes((int)(packet.Length - packet.Position));
packet.Position = originalPositon;
if (lastpacket != null)
{
for (byte i = 0; i < thispkt.Length; i++)
{
if (lastpacket[i] != thispkt[i] && !known_offs.Contains<byte>(i))
Console.WriteLine("Data differs at " + i + " : " + lastpacket[i] + " => " + thispkt[i]);
}
}
lastpacket = thispkt;*/
Character c = new Character()
{
//APP1 = CHARSPECAPP1,
//APP2 = CHARSPECAPP2,
//APP3 = CHARSPECAPP3,
//APP4 = CHARSPECAPP4,
AreaSpec = TORBusiness.Data.MapAreas.PCShip_XSFreighter,
Class = (CharacterClass)classNodeRefId,
Level = 44,
Name = name,
spec2 = CHARSPEC1,
spec3 = CHARSPEC2,
};
packet.ReadBytes(78);
packet.ReadByte();
byte appDataCount = (byte)packet.ReadByte();
c.Appearance = new Tuple<byte, byte>[appDataCount];
packet.ReadByte();
Console.WriteLine("appearance entries: " + appDataCount);
for (int i = 0; i < appDataCount; i++)
{
byte[] data = packet.ReadBytes(4);
c.Appearance[i] = new Tuple<byte, byte>(data[0], data[3]);
Console.WriteLine("Appearance = " + data[3]);
}
Program.LastCreatedChar = c;
connection.SendPacket(new SMsg_CharacterCreateResponse(id, name, 0x07));
}
示例4: Main
static void Main(string[] args)
{
Console.Title = "Nexus Shard Server";
Console.WriteLine("Nexus Shard Server\n");
Utility.WriteLegal();
Console.WriteLine("");
AsyncServer server = new AsyncServer(IPAddress.Parse("0.0.0.0"), 20063);
server.Start();
server.ConnectionAccepted += new AsyncServer.ConnectionAcceptedHandler(connection =>
{
TORLog.Network("CnxAccept => " + connection.GetHashCode());
connection.DataReceived += new AsyncConnection.ConnectionDataReceivedHandler(data =>
{
if (connection.State == 1)
{
// rsa packet
connection.SetState(2);
connection.SendPacket(new SMsg_ClientSignatureRequest("OmegaServerProxyObjectName", 0x0174F5));
return;
}
ByteBuffer buffer = new ByteBuffer(ByteOrder.LittleEndian, data);
byte opcode = (byte)buffer.ReadByte();
byte[] len_data = buffer.ReadBytes(4);
byte chk = (byte)buffer.ReadByte();
uint packetid = buffer.ReadUInt();
if (chk != (byte)(opcode ^ len_data[0] ^ len_data[1] ^ len_data[2] ^ len_data[3]))
{
TORLog.Warn("Received packet with invalid checksum!");
}
if (opcode == 1) // Client Ping Packet
{
TORLog.Network("Ping from " + connection.GetHashCode() + " Seq = " + packetid);
ByteBuffer response = new ByteBuffer(ByteOrder.LittleEndian);
response.WriteByte(2); // Pong OPC = 2
response.WriteInt(0); // Pong Len
response.WriteByte(0); // Pong Chk
response.WriteUInt(packetid); // Pong
response.WriteInt(0);
response.WriteInt(1);
response.WriteByte(0);
connection.SendTORPacket(response);
return;
}
string packetname = OpcodeManager.Instance.GetPacketName(opcode, packetid);
if (packetname == "")
{
TORLog.Warn("Received unknown packet from SWTOR client\nOpcode = 0x" + opcode.ToString("X2") + " -- PacketID = 0x" + packetid.ToString("X8"));
TORLog.Warn("--- dump ---");
TORLog.Warn(Utility.HexDump(data));
}
else
{
try
{
IClientPacket pkt = Activator.CreateInstance(Type.GetType("ShardServer.Packets.Client." + packetname)) as IClientPacket;
TORLog.Network("PktRecv @ " + connection.GetHashCode() + " << " + packetname);
pkt.ExecutePacket(connection, buffer);
}
catch (Exception ex)
{
TORLog.Error("Exception occured while processing " + packetname, ex);
}
}
});
// Send HELLO packet
connection.SendClear(new byte[] { 0x03, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
// State is 1
connection.SetState(1);
connection.EngageReading();
});
TORLog.Info("SHARD Server running, press Enter to exit ...");
Console.ReadLine();
}
示例5:
void IClientPacket.ExecutePacket(AsyncConnection connection, ByteBuffer packet)
{
uint objid = packet.ReadObjectIDRev();
packet.ReadByte();
uint charid = packet.ReadUInt();
TORLog.Info("[email protected]" + objid + " - " + charid);
connection.SendPacket(new SMsg_CharacterSelectResponse(objid));
connection.SendPacket(new SMsg_CharacterCurrentMap(objid, "ord_main", "4611686019802843831"));
connection.SendPacket(new SMsg_CharacterAreaEnter(objid));
connection.SendPacket(new SMsg_CharacterAreaServerSpec(objid, "ord_main", "4611686019802843831"));
}