当前位置: 首页>>代码示例>>C#>>正文


C# Player.getInventory方法代码示例

本文整理汇总了C#中WorldServer.player.Player.getInventory方法的典型用法代码示例。如果您正苦于以下问题:C# Player.getInventory方法的具体用法?C# Player.getInventory怎么用?C# Player.getInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorldServer.player.Player的用法示例。


在下文中一共展示了Player.getInventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getProtectedItem1

 public static int[] getProtectedItem1(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     for (int i = 0; i < 28; i++) {
         if(p.getInventory().getSlot(i).itemId == -1) continue;
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if ((price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice()))
         {
             protectedItem[0] = p.getInventory().getSlot(i).getItemId();
             protectedItem[1] = INVENTORY;
         }
     }
     foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
         if (equip == ItemData.EQUIP.NOTHING) continue;
         if (p.getEquipment().getSlot(equip).itemId == -1) continue;
         int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
             protectedItem[1] = EQUIPMENT;
         }
     }
     return protectedItem;
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:25,代码来源:ProtectedItems.cs

示例2: getProtectedItem2

 public static int[] getProtectedItem2(Player p)
 {
     int[] protectedItem = new int[2];
     protectedItem[0] = -1;
     int[] protectedItem1 = getProtectedItem1(p);
     bool save;
     for (int i = 0; i < 28; i++) {
         if (p.getInventory().getSlot(i).itemId == -1) continue;
         int amt = p.getInventory().getItemAmount(p.getInventory().getItemInSlot(i));
         int price = p.getInventory().getSlot(i).getDefinition().getPrice().getMaximumPrice();
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             save = true;
             if (protectedItem1[1] == INVENTORY) {
                 if (protectedItem1[0] == p.getInventory().getItemInSlot(i)) {
                     if (amt < 2) {
                         save = false;
                     }
                 }
             }
             if (save) {
                 protectedItem[0] = p.getInventory().getSlot(i).getItemId();
                 protectedItem[1] = INVENTORY;
             }
         }
     }
        foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
        if (equip == ItemData.EQUIP.NOTHING) continue;
        if (p.getEquipment().getSlot(equip).itemId == -1) continue;
        int price = p.getEquipment().getSlot(equip).getDefinition().getPrice().getMaximumPrice();
        int amt = p.getEquipment().getAmountInSlot(equip);
         if (price > ItemData.forId(protectedItem[0]).getPrice().getMaximumPrice())
         {
             save = true;
             if (protectedItem1[1] == EQUIPMENT) {
                 if (protectedItem1[0] == p.getEquipment().getItemInSlot(equip))
                 {
                     if (amt < 2) {
                         save = false;
                     }
                 }
             }
             if (save) {
                 protectedItem[0] = p.getEquipment().getSlot(equip).getItemId();
                 protectedItem[1] = EQUIPMENT;
             }
         }
     }
     return protectedItem;
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:50,代码来源:ProtectedItems.cs

示例3: 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!
        }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:30,代码来源:ItemInteract.cs

示例4: handleRightClickTwo

        private void handleRightClickTwo(Player player, Packet packet)
        {
            int childId = packet.readLEShort();
            int interfaceId = packet.readLEShort();
            int slot = packet.readLEShort();
            int item = packet.readLEShort();
            if (slot < 0 || slot > 28 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
                return;
            }
            SkillHandler.resetAllSkills(player);
            if (player.getInventory().getItemInSlot(slot) == item) {
                player.getPackets().closeInterfaces();
                switch(player.getInventory().getItemInSlot(slot)) {
                    case 5509: // Small pouch.
                        player.getPackets().sendMessage("There is " + player.getSmallPouchAmount() + " Pure essence in your small pouch. (holds 3).");
                        break;

                    case 5510: // Medium pouch.
                        player.getPackets().sendMessage("There is " + player.getMediumPouchAmount() + " Pure essence in your medium pouch. (holds 6).");
                            break;

                        case 5512: // Large pouch.
                            player.getPackets().sendMessage("There is " + player.getLargePouchAmount() + " Pure essence in your large pouch. (holds 9).");
                            break;

                        case 5514: // Giant pouch.
                            player.getPackets().sendMessage("There is " + player.getGiantPouchAmount() + " Pure essence in your giant pouch. (holds 12).");
                            break;
                }
            }
        }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:31,代码来源:ItemInteract.cs

示例5: handleRightClickOne

 private void handleRightClickOne(Player player, Packet packet)
 {
     int childId = packet.readLEShort();
     int interfaceId = packet.readLEShort();
     int item = packet.readLEShortA();
     int slot = packet.readLEShortA();
     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 (interfaceId == 149 && childId == 0) {
             if (Herblore.emptyPotion(player, player.getInventory().getItemInSlot(slot), slot)) {
                 return;
             } else if (JewelleryTeleport.useJewellery(player, player.getInventory().getItemInSlot(slot), slot, false)) {
                 return;
             }
         }
     }
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:21,代码来源:ItemInteract.cs

示例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;
                }
            }
        }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:89,代码来源:ItemInteract.cs

示例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.");
         }
     }
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:31,代码来源:ItemInteract.cs

示例8: handleInvenClickItem

        private void handleInvenClickItem(Player player, Packet packet)
        {
            int slot = packet.readLEShortA();
            int item = packet.readShortA();
            int childId = packet.readLEShort();
            int interfaceId = packet.readLEShort();
            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 (Consumables.isEating(player, player.getInventory().getItemInSlot(slot), slot))
                    return;
                else if (Herblore.idHerb(player, player.getInventory().getItemInSlot(slot)))
                    return;
                else if (RuneCraft.fillPouch(player, (RuneCraftData.POUCHES)player.getInventory().getItemInSlot(slot)))
                    return;
                else if (Prayer.wantToBury(player,  player.getInventory().getItemInSlot(slot), slot))
                    return;
                else if (Teleport.useTeletab(player, player.getInventory().getItemInSlot(slot), slot))
                    return;
                else if (FarmingAmulet.showOptions(player, player.getInventory().getItemInSlot(slot)))
                    return;

                switch(item) {
                    case 4155: // Slayer gem
                        Slayer.doDialogue(player, 1051);
                        break;

                    case 6: // Dwarf multicannon
                        if (player.getCannon() != null) {
                            player.getPackets().sendMessage("You already have a cannon set up!");
                            break;
                        }
                        player.setCannon(new DwarfCannon(player));
                        break;

                    case 5073: // Nest with seeds.
                    case 5074: // Nest with jewellery.
                        Woodcutting.randomNestItem(player, item);
                        break;

                    case 952: // Spade
                        player.setLastAnimation(new Animation(830));
                        if (Barrows.enterCrypt(player)) {
                            player.getPackets().sendMessage("You've broken into a crypt!");
                            break;
                        }
                        player.getPackets().sendMessage("You find nothing.");
                        break;
                }
            }
        }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:54,代码来源:ItemInteract.cs

示例9: savePlayer

        public bool savePlayer(Player p)
        {
            if (p == null) return false;
            try
            {
                string username = p.getLoginDetails().getUsername().ToLower();

                /* Character saving code goes here */
                XmlTextWriter writer = new XmlTextWriter(misc.getServerPath() + @"\accounts\" + username + ".xml", null);
                writer.Formatting = Formatting.Indented;
                writer.WriteStartElement("Player");
                    writer.WriteStartElement("Login");
                        writer.WriteElementString("Password", p.getLoginDetails().getPassword());
                        writer.WriteElementString("Rights", p.getRights().ToString());
                        writer.WriteElementString("BankPin", p.getBank().getBankPin());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Position");
                        writer.WriteElementString("X", p.getLocation().getX().ToString());
                        writer.WriteElementString("Y", p.getLocation().getY().ToString());
                        writer.WriteElementString("Z", p.getLocation().getZ().ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Settings");
                        writer.WriteElementString("RunEnergy", p.getRunEnergy().ToString());
                        writer.WriteStartElement("PrivacySettings");
                            writer.WriteElementString("Public", p.getFriends().getPrivacyOption(0).ToString());
                            writer.WriteElementString("Private", p.getFriends().getPrivacyOption(1).ToString());
                            writer.WriteElementString("Trade", p.getFriends().getPrivacyOption(2).ToString());
                        writer.WriteEndElement();
                    writer.WriteEndElement();

                    writer.WriteStartElement("Friends");
                        foreach(long friend in p.getFriends().getFriendsList())
                            writer.WriteElementString("Friend", friend.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Ignores");
                        foreach (long ignore in p.getFriends().getIgnoresList())
                            writer.WriteElementString("Ignore", ignore.ToString());
                    writer.WriteEndElement();

                    writer.WriteStartElement("Stats");
                        foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL))) {
                             writer.WriteStartElement(skill.ToString()); //skill name.
                                writer.WriteElementString("CurrentLevel", p.getSkills().getCurLevel(skill).ToString());
                                writer.WriteElementString("XP", p.getSkills().getXp(skill).ToString());
                            writer.WriteEndElement();
                        }
                    writer.WriteEndElement();

                    Item item;
                    writer.WriteStartElement("EquipmentItems");
                    foreach (ItemData.EQUIP equip in Enum.GetValues(typeof(ItemData.EQUIP))) {
                        if (equip == ItemData.EQUIP.NOTHING) continue;
                        item = p.getEquipment().getSlot(equip);
                        if (item.getItemId() == -1) continue; //empty slot.

                        writer.WriteStartElement(equip.ToString());
                            writer.WriteElementString("Id", item.getItemId().ToString());
                            writer.WriteElementString("Amount", item.getItemAmount().ToString());
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();

                    writer.WriteStartElement("InventoryItems");
                        for (int i = 0; i < Inventory.MAX_INVENTORY_SLOTS; i++) {
                            item = p.getInventory().getSlot(i);
                            if (item.getItemId() == -1) continue; //empty slot.

                            writer.WriteStartElement("Item");
                                writer.WriteElementString("Slot", i.ToString());
                                writer.WriteElementString("Id", item.getItemId().ToString());
                                writer.WriteElementString("Amount", item.getItemAmount().ToString());
                            writer.WriteEndElement();
                        }
                    writer.WriteEndElement();

                    writer.WriteStartElement("BankItems");
                    for (int i = 0; i < Bank.MAX_BANK_SLOTS; i++)
                    {
                        item = p.getBank().getSlot(i);
                        if (item.getItemId() == -1) continue; //empty slot.

                        writer.WriteStartElement("Item");
                            writer.WriteElementString("Slot", i.ToString());
                            writer.WriteElementString("Id", item.getItemId().ToString());
                            writer.WriteElementString("Amount", item.getItemAmount().ToString());
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                writer.WriteEndElement();
                //Write the XML to file and close the writer
                writer.Close();
            }
            catch (Exception)
            {
                return false;
            }

//.........这里部分代码省略.........
开发者ID:Krill156,项目名称:SharpEMU,代码行数:101,代码来源:LoginHandler.cs

示例10: handleItemOnNPC

 private void handleItemOnNPC(Player player, Packet packet)
 {
     int interfaceId = packet.readInt();
     int slot = packet.readLEShort();
     int npcIndex = packet.readLEShort();
     int item = packet.readLEShortA();
     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;
     }
     SkillHandler.resetAllSkills(player);
     player.getPackets().closeInterfaces();
     Console.WriteLine("Item on NPC " + npc.getId());
     if (player.getInventory().getItemInSlot(slot) == item) {
         switch(npc.getId()) {
             case 519: // Bob
                 BrokenBarrows.talkToBob(player, npc, player.getInventory().getItemInSlot(slot), 0);
                 break;
         }
     }
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:24,代码来源:NPCInteract.cs

示例11: getBarrowReward

 protected static void getBarrowReward(Player p)
 {
     int barrowChance = misc.random(BARROWS_CHANCE);
     int killCount = p.getBarrowKillCount();
     if (barrowChance == 0) {
         int reward = BARROW_REWARDS[misc.random(BARROW_REWARDS.Length - 1)];
         p.getInventory().addItemOrGround(reward);
     }
     if (misc.random(20) == 0) {
         p.getInventory().addItemOrGround(1149); // Dragon med helm.
     } else if (misc.random(15) == 0) {
         int halfKey = misc.random(1) == 0 ? 985 : 987;
         p.getInventory().addItemOrGround(halfKey); // Half key.
     }
     if (misc.random(3) == 0 || p.getBarrowTunnel() == KARIL) { // Bolt racks.
         int amount = getAmountOfReward(4740, killCount);
         p.getInventory().addItemOrGround(4740, amount);
     }
     if (misc.random(3) == 0) { // Blood runes
         int amount = getAmountOfReward(565, killCount);
         p.getInventory().addItemOrGround(565, amount);
     }
     if (misc.random(2) == 0) { // Death runes
         int amount = getAmountOfReward(560, killCount);
         p.getInventory().addItemOrGround(560, amount);
     }
     if (misc.random(1) == 0) { // Chaos runes
         int amount = getAmountOfReward(562, killCount);
         p.getInventory().addItemOrGround(562, amount);
     }
     if (misc.random(1) == 0) { // Coins
         int amount = getAmountOfReward(995, killCount);
         p.getInventory().addItemOrGround(995, amount);
     }
     if (misc.random(1) == 0) {
         int amount = getAmountOfReward(558, killCount); // Mind runes.
         p.getInventory().addItemOrGround(558, amount);
     }
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:39,代码来源:Barrows.cs

示例12: showBobDialogue

        public static void showBobDialogue(Player p, int status)
        {
            p.getPackets().softCloseInterfaces();
            int index = -1;
            int newStatus = -1;
            if (p.getTemporaryAttribute("bobsAxesBarrowItem") != null) {
                int item = (int)p.getTemporaryAttribute("bobsAxesBarrowItem");
                index = getIndex(item);
                if (index == -1) {
                    return;
                } else if (item == (int)DATA[index][0]) {
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("That item isn't broken..", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    return;
                } else if (item != (int)DATA[index][1]) {
                    return;
                }
            }
            switch(status) {
                case 101:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("That'll cost you " + ((int)DATA[index][2]).ToString("#,##0") + " gold coins to fix, are you sure?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 102;
                    break;

                case 102:
                    p.getPackets().modifyText("Yes, I'm sure!", 557, 2);
                    p.getPackets().modifyText("On second thoughts, no thanks.", 557, 3);
                    p.getPackets().sendChatboxInterface2(557);
                    newStatus = 103;
                    break;

                case 103:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("Yes, I'm sure!", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 104;
                    break;

                case 104:
                    if (!p.getInventory().hasItemAmount(995, (int)DATA[index][2])) {
                        p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                        p.getPackets().modifyText("Bob", 241, 3);
                        p.getPackets().modifyText("You don't have enough money to pay for the repair!", 241, 4);
                        p.getPackets().animateInterface(9827, 241, 2);
                        p.getPackets().sendChatboxInterface2(241);
                        break;
                    } else {
                        if (!p.getInventory().hasItem((int)DATA[index][1])) {
                            p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                            p.getPackets().modifyText("Bob", 241, 3);
                            p.getPackets().modifyText("The item seems to have gone from your inventory.", 241, 4);
                            p.getPackets().animateInterface(9827, 241, 2);
                            p.getPackets().sendChatboxInterface2(241);
                            break;
                        } else if (p.getInventory().deleteItem(995, (int)DATA[index][2])) {
                            p.getInventory().replaceSingleItem((int)DATA[index][1], (int)DATA[index][0]);
                            p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                            p.getPackets().modifyText("Bob", 241, 3);
                            p.getPackets().modifyText("There you go, happy doing business with you!", 241, 4);
                            p.getPackets().animateInterface(9827, 241, 2);
                            p.getPackets().sendChatboxInterface2(241);
                            p.getPackets().sendMessage("You pay Bob his fee and he repairs your " + (string)DATA[index][3] + ".");
                            break;
                        }
                    }
                    break;

                case 105:
                    p.getPackets().sendPlayerHead(64, 2);
                    p.getPackets().modifyText(p.getLoginDetails().getUsername(), 64, 3);
                    p.getPackets().modifyText("On second thoughts, no thanks.", 64, 4);
                    p.getPackets().animateInterface(9827, 64, 2);
                    p.getPackets().sendChatboxInterface2(64);
                    newStatus = 106;
                    break;

                case 106:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Ok, but don't expect my prices to change anytime soon!", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    break;

                case 107:
                    p.getPackets().sendNPCHead(BOB_ID, 241, 2);
                    p.getPackets().modifyText("Bob", 241, 3);
                    p.getPackets().modifyText("Hello there " + p.getLoginDetails().getUsername() + ", what can i do for you?", 241, 4);
                    p.getPackets().animateInterface(9827, 241, 2);
                    p.getPackets().sendChatboxInterface2(241);
                    newStatus = 108;
//.........这里部分代码省略.........
开发者ID:Krill156,项目名称:SharpEMU,代码行数:101,代码来源:BrokenBarrows.cs

示例13: hasRunes

 public static bool hasRunes(Player p, int[] runes, int[] amount)
 {
     for (int i = 0; i < runes.Length; i++)
     {
         if (checkForStaffs(p, runes[i]) != -1)
         {
             if (!p.getInventory().hasItemAmount(runes[i], amount[i]))
             {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:14,代码来源:MagicData.cs

示例14: 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();
        }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:32,代码来源:ItemInteract.cs

示例15: handleEquipItem

 private void handleEquipItem(Player player, Packet packet)
 {
     int item = packet.readLEShort();
     int slot = packet.readShortA();
     int interfaceId = packet.readInt();
     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 (RuneCraft.emptyPouch(player, (RuneCraftData.POUCHES)player.getInventory().getItemInSlot(slot))) {
             return;
         }
         player.getEquipment().equipItem(player.getInventory().getItemInSlot(slot), slot);
     }
 }
开发者ID:Krill156,项目名称:SharpEMU,代码行数:17,代码来源:ItemInteract.cs


注:本文中的WorldServer.player.Player.getInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。