Esempio n. 1
0
 public override void AddFullInventory(Player player)
 {
     for (byte i = 1; i <= 10; i++) { //TODO: Fix hard codec constants
         if (player.GetInventoryItem(i) != null) {
             netmsg.AddByte(0x78);
             netmsg.AddByte(i);
            // AddItem(player.GetInventoryItem(i)[i],
            //     player.gameServRef.gameMap.getItemDesc(player.inventory[i]));
         } else {
             netmsg.AddByte(0x79);
             netmsg.AddByte((byte)i);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Gets the thing with the specified parameters or
        /// null if such a thing can't be found. Note: The thing
        /// must be visible for the player.
        /// </summary>
        /// <param name="player">The player for whom to get the item.</param>
        /// <param name="pos">The position of the item.</param>
        /// <param name="stackpos">The stackposition of the thing.</param>
        /// <param name="usePosZ">Use position.z for index instead of stackpos.</param>
        /// <returns>The thing or null if can't be found.</returns>
        public Thing GetThing(Player player, Position pos, byte stackpos, bool usePosZ)
        {
            //container/inventory
            if (CarryingPos(pos)) {
                if (ContainerPos(pos)) { //From container
                    int containerIndex = pos.y - CONTAINER_HEADER;
                    int itemIndex = usePosZ ? pos.z : stackpos;
                    Container container = player.GetContainerByIndex(containerIndex);
                    if (container == null) {
                        return null;
                    }
                    return container.GetItemByIndex(itemIndex);
                } else { //inventory
                    return player.GetInventoryItem((byte)pos.y);
                }
            } else if (player.CanSee(pos)) { //ground
                if (stackpos == Constants.STACKPOS_TOP_ITEM) {
                    return map.GetTopThing(pos);
                } else {
                    Tile tile = map.GetTile(pos);
                    if (tile == null) {
                        return null;
                    }
                    return tile.GetThing(stackpos);
                }
            }

            return null;
        }
Esempio n. 3
0
 /// <summary>
 /// Add a player's full inventory.
 /// </summary>
 /// <param name="player">The player whose inventory is being updated.</param>
 public override void AddFullInventory(Player player)
 {
     //TODO: List each individually
     for (byte i = 1; i < Constants.INV_MAX; i++) {
         AddInventoryItem(i, player.GetInventoryItem(i));
     }
 }