示例#1
0
 public Character()
 {
     this.equipment = new Equipment(this);
     this.inventory = new Inventory(this);
     this.cargo = new Cargo(this);
     this.skills = new Skills(this);
     this.skillBar = new SkillBar();
     this.community = new Community();
 }
示例#2
0
        //move item to inventory from cargo
        public Boolean moveFromCargo(Item item, int cargoSlot, int line, int row)
        {
            updateInv();

            Cargo cargo = owner.getCargo();

            cargo.updateCargo();

            //ADD TO INVENTORY
            Item it;

            inv.TryGetValue(row * 100 + line, out it);
            if (it != null && item.getItemID() == it.getItemID() && item.getQuantity() + it.getQuantity() > ItemDataCache.Instance.getItemData(item.getItemID()).getMaxStack())
            {
                Console.WriteLine("Cannot move item [max stack]");
                return(false);
            }

            //get the hashes from all blocking items
            List <int> hash = this.checkBlockingItems(line, row, item);

            //exception in checkBlockingItems
            if (hash == null)
            {
                Console.WriteLine("Cannot buy item [crosses inventory border]");
                return(false);
            }

            //move to an empty slot
            if (hash.Count == 0)
            {
                seq[nextFreeSequence()] = (row * 100) + line;
                putIntoInv(line, row, item);
                cargo.removeItem(cargoSlot);
                saveInv();
                return(true);
            }

            //swap
            if (hash.Count == 1)
            {
                indexHold   = seq.IndexOf(hash[0]);
                indexToSwap = nextFreeSequence();
                if (indexToSwap == -1)
                {
                    Console.WriteLine("Cannot buy item [no free space in inv]");
                    return(false);
                }
                holdingItem = inv[hash[0]];
                removeItemFromInv(hash[0]);
                putIntoInv(line, row, item);
                seq[indexToSwap] = (row * 100) + line;
                seq[indexHold]   = -1;
                cargo.removeItem(cargoSlot);
                saveInv();
                return(true);
            }

            Console.WriteLine("Count {0}", hash.Count);
            return(false);
        }
示例#3
0
 public void setCargo(Cargo cargo)
 {
     this.cargo = cargo;
 }