示例#1
0
        public void CannotAddThreeCrossbowToBackpack()
        {
            Backpack bp       = new Backpack("Small Backpack", 3, 4);
            Crossbow bow      = new Crossbow("Terrible Crossbow", 3, 4);
            Crossbow tooBig   = new Crossbow("Terrible Crossbow", 3, 4);
            bool     expected = false;

            bp.Add(bow);
            bool actual = bp.Add(tooBig);

            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void CannotAddTwoCrossboawsToBackpack()
        {
            Backpack bp      = new Backpack("Small Backpack", 3, 4);
            Crossbow bow     = new Crossbow("Terrible crossbow", 3, 4);
            Crossbow tooMany = new Crossbow("Janky crossbow", 3, 4);

            bool expected = false;

            bp.Add(bow);
            bool actual = bp.Add(tooMany);

            Assert.AreEqual(expected, actual);
        }
示例#3
0
    void Start()
    {
        Character c = GetComponent <Unit>().Character;

        Backpack b = c.Backpack;

        b.EmptyBackpack();

        int level  = c.Level;
        int budget = level;

        if (armor != "")
        {
            Armor a = ArmorDB.Instance.GetArmor(armor, budget);
            if (a == null)
            {
                Debug.LogError(armor + " not found in armor database");
            }
            b.Add(a);
            b.Equip(a);
            budget += level - ArmorDB.Instance.GetLevel(a.Name);
        }
        else
        {
            budget += 2;
        }

        if (weapon != "")
        {
            Weapon w = WeaponDB.Instance.GetWeapon(weapon, budget);
            if (w == null)
            {
                Debug.LogError(weapon + " not found in weapons database");
            }
            b.Add(w);
            b.Equip(w);
        }
        foreach (string e in extras)
        {
            Item i = ItemFactory.CreateItem(e);
            if (i.Name == "Rubbish")
            {
                Debug.LogError(e + " generated Rubbish.");
            }
            if (!c.Backpack.Add(i))
            {
                Debug.LogWarning(c.Name + " ran out of inventory space.");
            }
        }
    }
示例#4
0
 public void AddItemToBackpack(GearItem item)
 {
     if (item != null)
     {
         Backpack.Add(item);
     }
 }
示例#5
0
 public void AddItem(Room[,] world)
 {
     if (world[X,Y].Item != null)
     {
         Backpack.Add((world[X,Y].Item));
         world[X,Y].Item = null;
     }
 }
示例#6
0
 public void PickUp(IPickupAble pickupAble)
 {
     if (pickupAble.Weight + this.CurerentWeight <= this.ObjMaxCap)
     {
         Backpack.Add(pickupAble);
         this.CurerentWeight += pickupAble.Weight;
     }
 }
示例#7
0
 public void Loot(EntityEnemy toLoot)
 {
     AddGold(toLoot.GoldValue);
     foreach (Item i in toLoot.Loot)
     {
         Backpack.Add(i);
     }
 }
示例#8
0
        public void CanAddCrossbowToBackPack()
        {
            Backpack bp       = new Backpack("Small Backpack", 3, 4);
            Crossbow bow      = new Crossbow("Terrible crossbow", 3, 4);
            bool     expected = true;
            bool     actual   = bp.Add(bow);

            Assert.AreEqual(expected, actual);
        }
示例#9
0
        public void CanAddPotionToBackPack()
        {
            Backpack bp       = new Backpack("Small Backpack", 3, 4);
            Heal     heal     = new Heal("Little potion", 3, 4);
            bool     expected = true;
            bool     actual   = bp.Add(heal);

            Assert.AreEqual(expected, actual);
        }
示例#10
0
        public void CannotAddFivePotionsToBackpack()
        {
            Backpack bp    = new Backpack("Small Backpack", 3, 4);
            Heal     heal1 = new Heal("Small heal potion", 1, 1);
            Heal     heal2 = new Heal("Small heal potion", 1, 1);
            Heal     heal3 = new Heal("Small heal potion", 1, 1);
            Heal     heal4 = new Heal("Small heal potion", 1, 1);
            Heal     heal5 = new Heal("Small heal potion", 1, 1);

            bool expected = false;

            bp.Add(heal1);
            bp.Add(heal2);
            bp.Add(heal3);
            bp.Add(heal4);
            bool actual = bp.Add(heal5);

            Assert.AreEqual(expected, actual);
        }
示例#11
0
    void Start()
    {
        Weapon w = new Weapon();

        w.attackInfo = new AttackInfo(new Norange());
        Backpack b = GetComponent <Unit>().Character.Backpack;

        b.Add(w);
        b.Equip(w);
    }
示例#12
0
        private string Wield(Weapon weapon)
        {
            var limbo = Weapon;

            Backpack.Remove(weapon);
            Weapon = weapon;
            if (limbo != null)
            {
                Backpack.Add(Weapon);                // Todo: Or drop weapon
            }
            return($"{Name} wields the {weapon.Name}");
        }
示例#13
0
 public bool AddToBackpack(Item item)
 {
     if (Backpack.Count < 10)
     {
         Backpack.Add(item);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#14
0
 private void ShowInventory(Cell cell, Rect coordinateRect, Backpack donor, Backpack recipient)
 {
     if (cell.CellItem != null)
     {
         GUI.Label(coordinateRect, cell.CellItem.MaxInStack.ToString());
         GUI.Label(new Rect(coordinateRect.x, coordinateRect.y + 20, coordinateRect.width, coordinateRect.height), cell.CellItem.NowInStack.ToString());
         if (GUI.Button(coordinateRect, cell.CellItem.ItemTexture))
         {
             if (isOpenedChest && isOpenedBackpack)
             {
                 if (Input.GetMouseButtonUp(1))
                 {
                     if (cell.CellItem != null && cell.CellItem.Type != Item.ItemType.Ammunition)
                     {
                         Cell commonCell = new Cell(cell.CellIndex);
                         commonCell.CellItem = human.PersonWeapon;
                         cell.CellItem.UseItem(human);
                         cell.CellItem = commonCell.CellItem;
                     }
                     else
                     {
                         cell.CellItem.UseItem(human);
                         if (cell.CellItem.NowInStack == 0)
                         {
                             cell.CellItem = null;
                         }
                     }
                 }
                 else
                 {
                     cell.CellItem = recipient.Add(cell.CellItem);
                 }
             }
         }
     }
     else
     {
         if (GUI.Button(coordinateRect, cell.CellIndex.ToString()))
         {
             if (human.PersonWeapon != null)
             {
                 cell.CellItem = human.PersonWeapon;
                 cell.CellItem.NowInStack++;
                 human.PersonWeapon = null;
             }
         }
     }
 }
示例#15
0
    public virtual void Init()
    {
        backpack = new Backpack(maxItemStack, maxItemWight);
        for(int i=0;i<maxItemStack && i<presetItems.Count; i++)
        {
            if (ItemDatabase.GetItem(presetItems[i].Get_Item_ID()) != null)
                backpack.Add(presetItems[i].Get_Item_ID(),presetItems[i].Get_Stack());
        }

        equipment = new Backpack(maxEqiupStack, maxEqiupWight);
        for(int i=0;i<maxEqiupStack && i<presetEqiup.Count; i++)
        {
            if (ItemDatabase.GetItem(presetEqiup[i].Get_Item_ID()) != null)
                equipment.Add(i, presetEqiup[i].Get_Item_ID(), 1);
        }
    }
示例#16
0
 public override void Attack(Character opponent, int dice, int input, Room[,] world)
 {
     if (dice != input)
     {
         opponent.Health -= 20;
         if (opponent.Health < 1)
         {
              Backpack.Add(opponent);
             world[X,Y].Monster = null;
         }
     }
     else if (input == dice)
     {
         Hunger += 10;
         opponent.Health += 10;
     }
 }
示例#17
0
    public Backpack GetBackpack()
    {
        Backpack tempBackpack = new Backpack();

        foreach (string item in backpack)
        {
            Item tempItem = ItemFactory.CreateItem(item);
            tempBackpack.Add(tempItem);
        }
        foreach (Item i in tempBackpack)
        {
            if (equippedArmor == i.Name || equippedWeapon == i.Name || equippedTrinket == i.Name)
            {
                tempBackpack.Equip((Equipment)i);
            }
        }
        return(tempBackpack);
    }
示例#18
0
 public bool RemoveFromEquipment(int equipmentItemIndex)
 {
     if (Equipment.Count == 0)
     {
         return(false);
     }
     if (Backpack.Count < 10)
     {
         Backpack.Add(Equipment[equipmentItemIndex]);
         Equipment.RemoveAt(equipmentItemIndex);
         Backpack[Backpack.Count - 1].Unequip();
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#19
0
        private void Toggle(ClothingItem item)
        {
            var slot = GetSlot(item); // find a slot corresponding to the item

            if (slot.Value == item)   // if item is equipped
            {
                slot.Value = null;    // remove it from slot
                Backpack.Add(item);   // and put to backpack
            }
            else                      // otherwise if item is not equipped
            {
                if (slot.Value != null)
                {
                    Backpack.Add(slot.Value);      // clear the slot if it was used
                }
                Backpack.Remove(item);             // take item from backpack
                slot.Value = item;                 // and put to the slot
            }
        }
示例#20
0
 ///<summary> algorytm zachłanny zwracający załadowany plecak przez elementy od najlżejszych </summary>
 public void n_element_min_weight()
 {
     LOE = this.bubblesort_min_weight(LOE);
     for(int i = 0; i < LOE.Count; i++)
     {
         while (backpack_space_left(LOE[i]) == true)
         {
             BP.Add(LOE[i]);
             backpackSpaceLeft -= LOE[i].weight;
         }
         if (backpackSpaceLeft == 0)
             break;
     }
 }
        public bool UnequipItem(InventoryItem item)
        {
            if (item == null)
            {
                Debug.LogWarning("Error: UnequipItem(null).");
                return(false);
            }

            var  inventoryItem = Inventory.SingleOrDefault(i => i.ItemDetails.Name.Equals(item.ItemDetails.Name));
            bool isInInventory = Inventory.SingleOrDefault(i => i.ItemDetails.Name.Equals(item.ItemDetails.Name)) != null;

            if (!isInInventory)
            {
                Debug.LogWarning($"The item '{item.ItemDetails.Name}' is not equipped (not in the inventory).");
                return(false);
            }

            var  backpackItem = Backpack.SingleOrDefault(kvp => kvp.Key.ItemDetails.Name.Equals(item.ItemDetails.Name));
            bool isInBackpack = backpackItem.Key != null;

            if (isInBackpack)
            {
                Backpack[backpackItem.Key]++;
            }
            else
            {
                Backpack.Add(inventoryItem, 1);
            }

            Inventory.Remove(inventoryItem);

            OnItemChangedCallback?.Invoke();

            DisplayItems();

            return(true);
        }
示例#22
0
        public void Add(ClothingItem item)
        {
            item.OnToggle += Toggle;

            Backpack.Add(item);
        }
示例#23
0
 public void AddItem(string item)
 {
     Backpack.Add(item);
 }
示例#24
0
            public void UpdateInventoryCache()
            {
                using (new PerformanceLogger("UpdateCachedInventoryData"))
                {
                    Clear();

                    if (!ZetaDia.IsInGame || ZetaDia.Me == null || !ZetaDia.Me.IsValid || ZetaDia.CPlayer == null || !ZetaDia.CPlayer.IsValid)
                    {
                        return;
                    }



                    //var itemList = ZetaDia.Actors.GetActorsOfType<ACDItem>();
                    // Using backpack only for now, as grabbing all ACDItems is just slow and we don't have a use for them yet.
                    //var itemList = ZetaDia.Me.Inventory.Backpack;
                    //var inventory = ZetaDia.Me.Inventory;
                    //Equipped = inventory.Equipped.ToList();
                    //EquippedIds = new HashSet<int>(Equipped.Select(i => i.ActorSNO));
                    //Backpack = inventory.Backpack.ToList();
                    //Stash = inventory.StashItems.ToList();

                    KanaisCubeIds = new HashSet <int>(ZetaDia.CPlayer.KanaisPowersAssignedActorSnoIds);

                    // this turns out to be much faster than accessing ZetaDia.Me.Inventory
                    foreach (var item in ZetaDia.Actors.GetActorsOfType <ACDItem>().ToList())
                    {
                        if (!item.IsValid)
                        {
                            continue;
                        }

                        switch (item.InventorySlot)
                        {
                        case InventorySlot.BackpackItems:
                            Backpack.Add(item);
                            break;

                        //case InventorySlot.SharedStash:
                        //    Stash.Add(item);
                        //    break;

                        case InventorySlot.Bracers:
                        case InventorySlot.Feet:
                        case InventorySlot.Hands:
                        case InventorySlot.Head:
                        case InventorySlot.Waist:
                        case InventorySlot.Shoulders:
                        case InventorySlot.Torso:
                        case InventorySlot.LeftFinger:
                        case InventorySlot.RightFinger:
                        case InventorySlot.RightHand:
                        case InventorySlot.LeftHand:
                        case InventorySlot.Legs:
                        case InventorySlot.Neck:
                        case InventorySlot.Socket:
                            Equipped.Add(item);
                            EquippedIds.Add(item.ActorSNO);
                            break;

                        //case InventorySlot.Buyback:
                        //case InventorySlot.None:
                        default:
                            if ((int)item.InventorySlot == 19)
                            {
                                Equipped.Add(item);
                                EquippedIds.Add(item.ActorSNO);
                            }
                            //Other.Add(item);
                            break;
                        }
                    }

                    //IsGroundItemOverload = (Ground.Count > 50);

                    //Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement,
                    //    "Refreshed Inventory: Backpack={0} Stash={1} Equipped={2} Ground={3}",
                    //    Backpack.Count,
                    //    Stash.Count,
                    //    Equipped.Count,
                    //    Ground.Count);
                }
            }
示例#25
0
 public void PickUp(Item item)
 {
     Backpack.Add(item);
 }