本文整理汇总了C#中Packet.AddShort方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.AddShort方法的具体用法?C# Packet.AddShort怎么用?C# Packet.AddShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.AddShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleMessage
public static void HandleMessage(Packet packet, IClient client, bool fromQueue)
{
Packet reply = new Packet(PacketFamily.Welcome, PacketAction.Reply);
client.EnterGame();
client.Character.Map.Enter(client.Character, WarpAnimation.Admin);
reply.AddShort((short)WelcomeReply.WorldInfo);
reply.AddBreak();
for (int i = 0; i < 9; ++i)
{
reply.AddBreakString("A");
}
reply.AddChar(client.Character.Weight); // Weight
reply.AddChar(client.Character.MaxWeight); // Max Weight
// Inventory
foreach (ItemStack item in client.Character.Items)
{
reply.AddShort(item.Id);
reply.AddInt(item.Amount);
}
reply.AddBreak();
// Spells
reply.AddBreak();
IEnumerable<Character> characters = client.Character.GetInRange<Character>();
IEnumerable<NPC> npcs = client.Character.GetInRange<NPC>();
IEnumerable<MapItem> items = client.Character.GetInRange<MapItem>();
reply.AddChar((byte)characters.Count());
reply.AddBreak();
// Characters
// {
foreach (Character character in characters)
{
character.InfoBuilder(ref reply);
reply.AddBreak();
}
// }
// NPCs
foreach (NPC npc in npcs)
{
npc.InfoBuilder(ref reply);
}
reply.AddBreak();
// Items
foreach (MapItem item in items)
{
item.InfoBuilder(ref reply);
}
client.Send(reply);
}
示例2: AccountCreate
public bool AccountCreate(string uName, string pass, string realName, string location, string email, string HDDSerial, out AccountReply result)
{
result = AccountReply.THIS_IS_WRONG;
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet builder = new Packet(PacketFamily.Account, PacketAction.Create);
//eoserv doesn't care...
builder.AddShort(1337);
builder.AddByte(42);
builder.AddBreakString(uName);
builder.AddBreakString(pass);
builder.AddBreakString(realName);
builder.AddBreakString(location);
builder.AddBreakString(email);
builder.AddBreakString(System.Net.Dns.GetHostName());
builder.AddBreakString(HDDSerial);
if (!m_client.SendPacket(builder) || !m_account_responseEvent.WaitOne(Constants.ResponseTimeout))
return false;
result = m_account_reply;
return true;
}
示例3: _warpAccept
private void _warpAccept(short mapID)
{
if (!m_client.ConnectedAndInitialized) return;
Packet builder = new Packet(PacketFamily.Warp, PacketAction.Accept);
builder.AddShort(mapID);
m_client.SendPacket(builder);
}
示例4: ConfirmInit
/// <summary>
/// Confirms initialization with server
/// </summary>
/// <param name="SendMulti">Multiplier for send (encrypt multi)</param>
/// <param name="RecvMulti">Multiplier for recv (decrypt multi)</param>
/// <param name="clientID">Connection identifier</param>
/// <returns>True on successful send operation</returns>
public bool ConfirmInit(byte SendMulti, byte RecvMulti, short clientID)
{
if (!m_client.ConnectedAndInitialized)
return false;
Packet confirm = new Packet(PacketFamily.Connection, PacketAction.Accept);
confirm.AddShort(SendMulti);
confirm.AddShort(RecvMulti);
confirm.AddShort(clientID);
if (m_client.SendPacket(confirm))
{
Initialized = true;
return true;
}
return false;
}
示例5: RequestShop
public bool RequestShop(short npcIndex)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Shop, PacketAction.Open);
pkt.AddShort(npcIndex);
return m_client.SendPacket(pkt);
}
示例6: TradeRemoveItem
/// <summary>
/// Remove an item from a pending trade offer
/// </summary>
/// <param name="itemID">Item ID of the item to remove</param>
public bool TradeRemoveItem(short itemID)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Trade, PacketAction.Remove);
pkt.AddShort(itemID);
return m_client.SendPacket(pkt);
}
示例7: BankOpen
public bool BankOpen(short npcIndex)
{
if (!m_client.ConnectedAndInitialized || !Initialized || npcIndex < 0)
return false;
Packet pkt = new Packet(PacketFamily.Bank, PacketAction.Open);
pkt.AddShort(npcIndex);
return m_client.SendPacket(pkt);
}
示例8: TradeAcceptRequest
/// <summary>
/// Accept another players request for trade
/// </summary>
/// <param name="characterID">ID of the other player's character</param>
public bool TradeAcceptRequest(short characterID)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Trade, PacketAction.Accept);
pkt.AddChar(123); //?
pkt.AddShort(characterID);
return m_client.SendPacket(pkt);
}
示例9: BuyItem
/// <summary>
/// Buy an item from a shopkeeper
/// </summary>
public bool BuyItem(short ItemID, int amount)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Shop, PacketAction.Buy);
pkt.AddShort(ItemID);
pkt.AddInt(amount);
return m_client.SendPacket(pkt);
}
示例10: PrepareCastSpell
public bool PrepareCastSpell(short spellID)
{
if (spellID < 0) return false; //integer overflow resulted in negative number - server expects ushort
if (!Initialized || !m_client.ConnectedAndInitialized) return false;
Packet pkt = new Packet(PacketFamily.Spell, PacketAction.Request);
pkt.AddShort(spellID);
pkt.AddThree(DateTime.Now.ToEOTimeStamp());
return m_client.SendPacket(pkt);
}
示例11: LockerTakeItem
/// <summary>
/// Withdraw an item from your private locker
/// </summary>
public bool LockerTakeItem(byte x, byte y, short id)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Locker, PacketAction.Take);
pkt.AddChar(x);
pkt.AddChar(y);
pkt.AddShort(id);
return m_client.SendPacket(pkt);
}
示例12: ChestAddItem
public bool ChestAddItem(byte x, byte y, short itemID, int amount)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Chest, PacketAction.Add);
pkt.AddChar(x);
pkt.AddChar(y);
pkt.AddShort(itemID);
pkt.AddThree(amount);
return m_client.SendPacket(pkt);
}
示例13: HandleRequest
public static void HandleRequest(Packet packet, IClient client, bool fromQueue)
{
short count = (short)client.Server.Characters.Count;
// TODO: Don't list hidden admins
Packet reply = new Packet(PacketFamily.Init, PacketAction.Init);
reply.AddChar((byte)EO.InitReply.Players);
reply.AddShort(count);
reply.AddBreak();
foreach (Character character in client.Server.Characters)
{
reply.AddBreakString(character.Name);
reply.AddBreakString(character.Title ?? "");
reply.AddChar(0); // What's this?
reply.AddChar((byte)EO.PaperdollIcon.HGM);
reply.AddChar((byte)character.ClassId);
reply.AddString("TAG");
reply.AddBreak();
}
client.Send(reply);
}
示例14: PingServer
public bool PingServer()
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
if(requests == null)
requests = new Dictionary<short, DateTime>();
if(gen == null)
gen = new Random();
short nextReq;
do
{
nextReq = (short)gen.Next(ushort.MinValue, short.MaxValue - 1);
} while (requests.ContainsKey(nextReq));
Packet pkt = new Packet(PacketFamily.Message, PacketAction.Ping);
pkt.AddShort(nextReq);
requests.Add(nextReq, DateTime.Now);
return m_client.SendPacket(pkt);
}
示例15: GetItem
/// <summary>
/// Pick up the item with the specified UID
/// </summary>
public bool GetItem(short uid)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Item, PacketAction.Get);
pkt.AddShort(uid);
return m_client.SendPacket(pkt);
}