本文整理汇总了C#中Packet.readUShort方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.readUShort方法的具体用法?C# Packet.readUShort怎么用?C# Packet.readUShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.readUShort方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handleExamineNPC
private void handleExamineNPC(Player player, Packet packet)
{
int npcId = packet.readUShort();
if (npcId < 0 || npcId > NpcData.getTotalNpcDefinitions() || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
return;
player.getPackets().sendMessage(NpcData.forId(npcId).getExamine());
}
示例2: handleDropItem
private void handleDropItem(Player player, Packet packet)
{
int item = packet.readShortA();
int slot = packet.readShortA();
int interfaceId = packet.readLEShort();
int childId = packet.readUShort();
if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
SkillHandler.resetAllSkills(player);
if (player.getInventory().getItemInSlot(slot) == item) {
player.getPackets().closeInterfaces();
if (ItemData.isPlayerBound(player.getInventory().getItemInSlot(slot))) {
Item[] items = {new Item(player.getInventory().getItemInSlot(slot), 1)};
//player.getPackets().sendItems(94, 0, 93, items);
player.getPackets().modifyText("Are you sure you want to destroy this item?", 94, 3); // Title
//player.getPackets().modifyText("Yes", 94, 4); // Yes
//player.getPackets().modifyText("No", 94, 5); // No
player.getPackets().modifyText("", 94, 10); // Line 1
player.getPackets().modifyText("If you wish to get another Fire cape, you must", 94, 11); // Line 2
player.getPackets().modifyText("complete the Fight cave minigame again.", 94, 12); // Line 3
player.getPackets().modifyText("Fire Cape", 94, 13); // Item name
player.getPackets().sendChatboxInterface(94);
return;
}
int id = player.getInventory().getItemInSlot(slot);
int amt = player.getInventory().getAmountInSlot(slot);
GroundItem i = new GroundItem(id, amt, new Location(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()), player);
if (player.getInventory().deleteItem(id, slot, amt)) {
if (!Server.getGroundItems().addToStack(id, amt, player.getLocation(), player)) {
Server.getGroundItems().newEntityDrop(i);
}
}
}
}
示例3: handleSwapSlot2
private void handleSwapSlot2(Player player, Packet packet)
{
int interfaceId = packet.readLEShort();
int child = packet.readUShort();
int newSlot = packet.readLEShort();
int interface2 = packet.readUShort();
int child2 = packet.readUShort();
int oldSlot = packet.readLEShort();
int oldItem = player.getInventory().getItemInSlot(oldSlot);
int oldAmount = player.getInventory().getAmountInSlot(oldSlot);
int newItem = player.getInventory().getItemInSlot(newSlot);
int newAmount = player.getInventory().getAmountInSlot(newSlot);
if (oldSlot > 28 || oldSlot < 0 || newSlot > 28 || oldSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
switch (interfaceId) {
case 621: // Shop.
case 763: // Bank.
case 336: // Duel
player.getInventory().getSlot(oldSlot).setItemId(newItem);
player.getInventory().getSlot(oldSlot).setItemAmount(newAmount);
player.getInventory().getSlot(newSlot).setItemId(oldItem);
player.getInventory().getSlot(newSlot).setItemAmount(oldAmount);
break;
default:
misc.WriteError("UNHANDLED ITEM SWAP 2 : interface = " + interfaceId);
break;
}
//No need to update the screen since the client does it for us!
player.getPackets().refreshInventory();
}
示例4: handleSwapSlot
private void handleSwapSlot(Player player, Packet packet)
{
int oldSlot = packet.readUShort();
int childId = packet.readLEShort();
int interfaceId = packet.readLEShort();
int newSlot = packet.readShortA();
int swapType = packet.readByteS();
int oldItem = player.getInventory().getItemInSlot(oldSlot);
int oldAmount = player.getInventory().getAmountInSlot(oldSlot);
int newItem = player.getInventory().getItemInSlot(newSlot);
int newAmount = player.getInventory().getAmountInSlot(newSlot);
if (oldSlot > 28 || oldSlot < 0 || newSlot > 28 || oldSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
switch (interfaceId) {
case 149:
if (swapType == 0 && childId == 0) {
player.getInventory().getSlot(oldSlot).setItemId(newItem);
player.getInventory().getSlot(oldSlot).setItemAmount(newAmount);
player.getInventory().getSlot(newSlot).setItemId(oldItem);
player.getInventory().getSlot(newSlot).setItemAmount(oldAmount);
}
break;
default:
misc.WriteError("UNHANDLED ITEM SWAP 1 : interface = " + interfaceId);
break;
}
//No need to update the screen since the client does it for us!
}
示例5: handlePickupItem
private void handlePickupItem(Player player, Packet packet)
{
int x = packet.readLEShort();
int id = packet.readUShort();
int y = packet.readLEShortA();
Location l = new Location(x, y, player.getLocation().getZ());
SkillHandler.resetAllSkills(player);
if (x < 1000 || y < 1000 | id < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
player.getPackets().closeInterfaces();
if(player.getLocation().Equals(l)) {
Server.getGroundItems().pickupItem(player, id, player.getLocation());
return;
}
CoordinateEvent pickupItemCoordinateEvent = new CoordinateEvent(player, l);
pickupItemCoordinateEvent.setAction(() => {
Server.getGroundItems().pickupItem(player, id, player.getLocation());
});
Server.registerCoordinateEvent(pickupItemCoordinateEvent);
}
示例6: handleItemOnObject
private void handleItemOnObject(Player player, Packet packet)
{
int objectX = packet.readShortA();
int item = packet.readUShort();
int objectY = packet.readLEShort();
int slot = packet.readUShort();
int interfaceId = packet.readLEShort();
int child = packet.readUShort();
int objectId = packet.readShortA();
if (slot > 28 || slot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
Console.WriteLine("Item on object = " + objectId + " " + objectX + " " + objectY);
SkillHandler.resetAllSkills(player);
player.getPackets().closeInterfaces();
player.setFaceLocation(new Location(objectX, objectY, player.getLocation().getZ()));
if (player.getInventory().getItemInSlot(slot) == item) {
if (Crafting.wantsToCraftOnObject(player, player.getInventory().getItemInSlot(slot), objectId)) {
return;
} else if (Farming.interactWithPatch(player, objectId, objectX, objectY, player.getInventory().getItemInSlot(slot))) {
return;
} else if (WarriorGuild.useAnimator(player, player.getInventory().getItemInSlot(slot), objectId, objectX, objectY)) {
return;
}
if (player.getInventory().getItemInSlot(slot) == 7936) {
if (RuneCraft.wantToRunecraft(player, objectId, objectX, objectY)) {
return;
}
if (RuneCraft.useTalisman(player, objectId, objectX, objectY)) {
return;
}
}
switch(objectId) {
case 6: // Cannon:
DwarfCannon cannon = player.getCannon();
Location l = new Location(objectX, objectY, player.getLocation().getZ());
if (cannon == null || (cannon != null & !l.withinDistance(cannon.getLocation(), 2))) {
player.getPackets().sendMessage("This isn't your cannon!");
break;
}
cannon.loadCannon();
break;
case 36781: // Lumbridge fountain.
case 24214: // Fountain in east Varrock.
case 24265: // Varrock main fountain.
case 11661: // Falador waterpump.
case 11759: // Falador south fountain.
case 879: // Camelot fountains.
case 29529: // Sink.
case 874: // Sink.
if (FillVial.fillingVial(player, new Location(objectX, objectY, player.getLocation().getZ())) && player.getInventory().getItemInSlot(slot) == 229) {
break;
}
break;
case 2728: // Range in Catherby
if (Cooking.isCooking(player, player.getInventory().getItemInSlot(slot), false, -1, -1)) {
break;
}
break;
case 2732: // Fire
if (Cooking.isCooking(player, player.getInventory().getItemInSlot(slot), true, objectX, objectY)) {
break;
}
break;
case 36956: // Lumbridge furnace
case 11666: // Falador furnace
if (Smelting.wantToSmelt(player, player.getInventory().getItemInSlot(slot))) {
break;
} else if (Crafting.wantsToCraftOnObject(player, player.getInventory().getItemInSlot(slot), objectId)) {
break;
}
break;
case 2783: // Anvil
if (Smithing.wantToSmithOnAnvil(player, player.getInventory().getItemInSlot(slot), new Location(objectX, objectY, player.getLocation().getZ()))) {
break;
}
break;
default:
player.getPackets().sendMessage("Nothing interesting happens.");
break;
}
}
}
示例7: handleItemOnItem
private void handleItemOnItem(Player player, Packet packet)
{
int itemSlot = packet.readUShort();
int unused = packet.readInt();
int withSlot = packet.readLEShort();
int unused2 = packet.readInt();
int itemUsed = packet.readLEShortA();
int usedWith = packet.readLEShortA();
if (itemSlot > 28 || itemSlot < 0 || withSlot > 28 || withSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
SkillHandler.resetAllSkills(player);
player.getPackets().closeInterfaces();
if (player.getInventory().getSlot(itemSlot).getItemId() == itemUsed && player.getInventory().getSlot(withSlot).getItemId() == usedWith) {
if (Fletching.isFletching(player, itemUsed, usedWith)) {
return;
} else if (Herblore.doingHerblore(player, itemUsed, usedWith)) {
return;
} else if (Herblore.mixDoses(player, itemUsed, usedWith, itemSlot, withSlot)) {
return;
} else if (Crafting.wantsToCraft(player, itemUsed, usedWith)) {
return;
} else if (Firemaking.isFiremaking(player, itemUsed, usedWith, itemSlot, withSlot)) {
return;
} else if (Farming.plantSapling(player, itemUsed, usedWith)) {
return;
} else {
player.getPackets().sendMessage("Nothing interesting happens.");
}
}
}
示例8: handleItemOnGroundItem
private void handleItemOnGroundItem(Player player, Packet packet)
{
int objectX = packet.readLEShortA();
int itemSlot = packet.readLEShort();
int itemIdInInventory = packet.readLEShort();
int itemIdOnGround = packet.readLEShort();
int objectY = packet.readLEShortA();
int interfaceId = packet.readLEShort();
int child = packet.readUShort();
if (itemSlot > 28 || itemSlot < 0 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null)
return;
if (Firemaking.isFiremaking(player, itemIdInInventory, itemIdOnGround, itemSlot, -1))
return;
else
player.getPackets().sendMessage("Nothing interesting happens.");
}
示例9: handleFourthClickNPC
private void handleFourthClickNPC(Player player, Packet packet)
{
int npcIndex = packet.readUShort();
if (npcIndex < 0 || npcIndex > Constants.MAX_NPCS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
return;
}
Npc npc = Server.getNpcList()[npcIndex];
if (npc == null || npc.isDestroyed()) {
return;
}
Console.WriteLine("Fourth click NPC " + npc.getId());
SkillHandler.resetAllSkills(player);
if (Slayer.openSlayerShop(player, npc)) {
return;
}
switch(npc.getId()) {
case 553: // Aubury
HomeArea.interactWithAubury(player, npc, 3);
break;
}
}