Esempio n. 1
0
        public Item GetItem(CONTAINER_TYPE container, int itemID)
        {
            switch (container)
            {
            case CONTAINER_TYPE.INVENTORY:
                foreach (byte i in this.inv.Keys)
                {
                    Item item = this.inv[i];
                    if (item.id != itemID)
                    {
                        continue;
                    }
                    return(item);
                }
                return(null);

            case CONTAINER_TYPE.STORAGE:
                foreach (byte i in this.storage.Keys)
                {
                    Item item = this.storage[i];
                    if (item.id != itemID)
                    {
                        continue;
                    }
                    return(item);
                }
                return(null);

            default:
                return(null);
            }
        }
Esempio n. 2
0
        public DeleteItemResult DeleteItem(CONTAINER_TYPE container, int itemID, byte amount, out byte index, out byte newAmount)
        {
            newAmount = 0;
            index     = 0;

            foreach (byte i in this.inv.Keys)
            {
                Item item = null;
                if (container == CONTAINER_TYPE.INVENTORY)
                {
                    item = this.inv[i];
                }
                if (container == CONTAINER_TYPE.STORAGE)
                {
                    item = this.storage[i];
                }

                if (item.id != itemID)
                {
                    continue;
                }
                if (item.stack < amount)
                {
                    return(DeleteItemResult.ERROR);
                }
                index = i;
                if (item.stack == amount)
                {
                    switch (container)
                    {
                    case CONTAINER_TYPE.INVENTORY:
                        this.inv.Remove(index);
                        break;

                    case CONTAINER_TYPE.STORAGE:
                        this.storage.Remove(index);
                        break;
                    }
                    return(DeleteItemResult.ALL_DELETED);
                }
                else
                {
                    item.stack -= amount;
                    newAmount   = item.stack;
                    return(DeleteItemResult.NOT_ALL_DELETED);
                }
            }

            return(DeleteItemResult.ERROR);
        }
Esempio n. 3
0
        public Item GetItem(CONTAINER_TYPE container, byte index)
        {
            switch (container)
            {
            case CONTAINER_TYPE.INVENTORY:
                if (!this.inv.ContainsKey(index))
                {
                    return(null);
                }
                return(this.inv[index]);

            case CONTAINER_TYPE.STORAGE:
                if (!this.storage.ContainsKey(index))
                {
                    return(null);
                }
                return(this.storage[index]);

            default:
                return(null);
            }
        }
Esempio n. 4
0
        public DeleteItemResult DeleteItem(CONTAINER_TYPE container, byte index, int itemID, byte amount, out byte newAmount)
        {
            newAmount = 0;

            Item item = this.GetItem(container, index);

            if (item == null)
            {
                return(DeleteItemResult.ERROR);
            }
            if (item.id != itemID)
            {
                return(DeleteItemResult.WRONG_ITEMID);
            }
            if (item.stack < amount)
            {
                return(DeleteItemResult.ERROR);
            }
            if (item.stack == amount)
            {
                switch (container)
                {
                case CONTAINER_TYPE.INVENTORY:
                    this.inv.Remove(index);
                    break;

                case CONTAINER_TYPE.STORAGE:
                    this.storage.Remove(index);
                    break;
                }
                return(DeleteItemResult.ALL_DELETED);
            }
            else
            {
                item.stack -= amount;
                newAmount   = item.stack;
                return(DeleteItemResult.NOT_ALL_DELETED);
            }
        }
Esempio n. 5
0
 public void SetContainer(CONTAINER_TYPE type)
 {
     this.PutByte((byte)type, 4);
 }
Esempio n. 6
0
 public void SetContainer(CONTAINER_TYPE type)
 {
     this.PutByte((byte)type, 4);
 }
Esempio n. 7
0
 public void SetContainer(CONTAINER_TYPE container)
 {
     this.PutByte((byte)container, 9);
 }
Esempio n. 8
0
 public void SetContainer(CONTAINER_TYPE container)
 {
     this.PutByte((byte)container, 4);
 }
Esempio n. 9
0
 public Item GetItem(CONTAINER_TYPE container, int itemID)
 {
     switch (container)
     {
         case CONTAINER_TYPE.INVENTORY:
             foreach (byte i in this.inv.Keys)
             {
                 Item item = this.inv[i];
                 if (item.id != itemID) continue;
                 return item;
             }
             return null;
         case CONTAINER_TYPE.STORAGE:
             foreach (byte i in this.storage.Keys)
             {
                 Item item = this.storage[i];
                 if (item.id != itemID) continue;
                 return item;
             }
             return null;
         default:
             return null;
     }
 }
Esempio n. 10
0
 public Item GetItem(CONTAINER_TYPE container, byte index)
 {
     switch (container)
     {
         case CONTAINER_TYPE.INVENTORY:
             if (!this.inv.ContainsKey(index)) return null;
             return this.inv[index];
         case CONTAINER_TYPE.STORAGE :
             if (!this.storage.ContainsKey(index)) return null;
             return this.storage[index];
         default:
             return null;
     }
 }
Esempio n. 11
0
        public DeleteItemResult DeleteItem(CONTAINER_TYPE container,  int itemID, byte amount,out byte index, out byte newAmount)
        {
            newAmount = 0;
            index = 0;

            foreach (byte i in this.inv.Keys)
            {
                Item item = null;
                if (container == CONTAINER_TYPE.INVENTORY)
                    item = this.inv[i];
                if (container == CONTAINER_TYPE.STORAGE)
                    item = this.storage[i];

                if (item.id != itemID) continue;
                if (item.stack < amount) return DeleteItemResult.ERROR;
                index = i;
                if (item.stack == amount)
                {
                    switch (container)
                    {
                        case CONTAINER_TYPE.INVENTORY:
                            this.inv.Remove(index);
                            break;
                        case CONTAINER_TYPE.STORAGE:
                            this.storage.Remove(index);
                            break;
                    }
                    return DeleteItemResult.ALL_DELETED;
                }
                else
                {
                    item.stack -= amount;
                    newAmount = item.stack;
                    return DeleteItemResult.NOT_ALL_DELETED;
                }
            }

            return DeleteItemResult.ERROR;
        }
Esempio n. 12
0
        public DeleteItemResult DeleteItem(CONTAINER_TYPE container, byte index, int itemID, byte amount, out byte newAmount)
        {
            newAmount = 0;

            Item item = this.GetItem(container, index);
            if (item == null) return DeleteItemResult.ERROR;
            if (item.id != itemID) return DeleteItemResult.WRONG_ITEMID;
            if (item.stack < amount) return DeleteItemResult.ERROR;
            if (item.stack == amount)
            {
                switch (container)
                {
                    case CONTAINER_TYPE.INVENTORY:
                        this.inv.Remove(index);
                        break;
                    case CONTAINER_TYPE.STORAGE :
                        this.storage.Remove(index);
                        break;
                }
                return DeleteItemResult.ALL_DELETED;
            }
            else
            {
                item.stack -= amount;
                newAmount = item.stack;
                return DeleteItemResult.NOT_ALL_DELETED;
            }
        }