public void CanEquipItemIntoTakenSlotIfAutoUnequip() { var inventory = new Inventory(); var item1 = new WeightedItem { Weight = Weight.Heavy, Name = "hello1" }; var item2 = new WeightedItem { Weight = Weight.Heavy, Name = "hello2" }; inventory.Add(item1); inventory.Add(item2); Assert.True(inventory.Equip(item1)); Assert.Same(inventory.HeavySlotItem, item1); Assert.True(inventory.Equip(item2)); Assert.Same(inventory.HeavySlotItem, item2); }
void Start(){ party = new PokeParty(this); inventory = new Inventory(this); //kanto starters, why not party.AddPokemon(new Pokemon(1, true)); party.AddPokemon(new Pokemon(4, true)); party.AddPokemon(new Pokemon(7, true)); Pokedex.states [1] = Pokedex.State.Captured; Pokedex.states [4] = Pokedex.State.Captured; Pokedex.states [7] = Pokedex.State.Captured; inventory.Add(1, 5); //New inventory code references shared item data. (id, quantity) inventory.Add(4, 2); }
public Player(Map map) : base('@', TCODColor.green) { CurrentMap = map; Light = new Light(0, 0, 0); _inventory = new Inventory(this); _inventory.Add(new ItemsData.TorchLight()); Equip(Inventory.GetAtLetter('a')); for (int i = 0; i < 5; i++) { _inventory.Add(new ItemsData.WeakTorch()); } _inventory.Add(new ItemsData.FlashScroll()); _inventory.Add(new ItemsData.FlashScroll()); _inventory.Add(new ItemsData.FlashScroll()); }
public void CanEquipItemIntoEmptySlot() { var inventory = new Inventory(); var item = new WeightedItem { Weight = Weight.Heavy, Name = "hello" }; inventory.Add(item); Assert.True(inventory.Equip(item)); Assert.Same(inventory.HeavySlotItem, item); }
public void CanAddNonWeightedItem() { var inventory = new Inventory(); var item = new Item { Name = "hello" }; inventory.Add(item); Assert.Contains(item, inventory.AllItems); Assert.Contains(item, inventory.UnequippedItems); Assert.DoesNotContain(item, inventory.EquippedItems); }
public void Pickup(Inventory inv) { if (inv?.Add(Item) ?? false) { onPickedUp.Invoke(); Destroy(gameObject); print($"'{inv.name}' picked up item: '{Item.Name}'"); } }
public Trainer(string name) : base() { //Will give to both the player and the npc (just like in multiplayer) this.name = name; party = new PokeParty(this); inventory = new Inventory(this); //kanto starters, why not party.AddPokemon(new Pokemon(1, null, true)); party.AddPokemon(new Pokemon(4, null, true)); party.AddPokemon(new Pokemon(7, null, true)); Pokedex.states [1] = Pokedex.State.Captured; Pokedex.states [4] = Pokedex.State.Captured; Pokedex.states [7] = Pokedex.State.Captured; inventory.Add(1, 5); //New inventory code references shared item data. (id, quantity) inventory.Add(4, 2); }
public void CanEquipSpellBook() { var inventory = new Inventory(); var spellBook = new SpellBook { Name = "hello" }; inventory.Add(spellBook); Assert.Contains(spellBook, inventory.AllItems); Assert.Contains(spellBook, inventory.UnequippedItems); Assert.DoesNotContain(spellBook, inventory.EquippedItems); Assert.Null(inventory.SpellBookItem); inventory.Equip(spellBook); Assert.Contains(spellBook, inventory.AllItems); Assert.DoesNotContain(spellBook, inventory.UnequippedItems); Assert.Contains(spellBook, inventory.EquippedItems); Assert.Same(spellBook, inventory.SpellBookItem); }
public void CanEquipArmor() { var inventory = new Inventory(); var armor = new Armor { Name = "hello" }; inventory.Add(armor); Assert.Contains(armor, inventory.AllItems); Assert.Contains(armor, inventory.UnequippedItems); Assert.DoesNotContain(armor, inventory.EquippedItems); Assert.Null(inventory.ArmorItem); inventory.Equip(armor); Assert.Contains(armor, inventory.AllItems); Assert.DoesNotContain(armor, inventory.UnequippedItems); Assert.Contains(armor, inventory.EquippedItems); Assert.Same(armor, inventory.ArmorItem); }
public void CollectItems(Item item, int amount) { Inventory inventory = GameManager._instance.Inventory; int remainderWeight = inventory.RemainderWeight; ItemSlot slot = _isle.DoneTasks.Container.Find(s => s.Item == _currentItemInfo); int needWeight = item.Weight * amount; if (remainderWeight < needWeight) { Debug.LogError("Remainder weight < need weight"); } inventory.Add(slot.Item, amount); slot.RemoveAmount(amount); UpdateCurrentInfo(item); UpdateByItem(item as CraftableItem, 0, true); }
public void Remove1() { if (itemList[0] == null) { return; } inventory.Add(itemList[0]); itemList[0] = itemList[1]; itemList[1] = itemList[2]; itemList[2] = itemList[3]; itemList[3] = itemList[4]; itemList[4] = itemList[5]; itemList[5] = itemList[6]; itemList[6] = itemList[7]; itemList[7] = null; i--; ChangeCraftUI(); }
private bool CheckStack(Item item) { bool itemsAdded = false; foreach (Item i in Inventory) { //Is the item already there if (i.Name == item.Name) { if (i.ItemType == ItemEquipType.QuestItem) { i.CurStacks += item.CurStacks; if (i.CurStacks > i.MaxStacks) { i.CurStacks = i.MaxStacks; } return(true); } //Is there space in that stack to add the current item if (i.CurStacks + item.CurStacks <= i.MaxStacks) { i.CurStacks += item.CurStacks; itemsAdded = true; return(true); } } } if (!itemsAdded) { //Manually Check Inventory if (Inventory.Count < MaxInventorySpace) { Inventory.Add(item); return(true); } else { Debug.Log("Inventory too full to add more of this stack"); } } return(false); }
public StoredRetainerInventory(IntPtr pointer) { IntPtr position = pointer; EquippedItems = new List <uint>(Core.Memory.ReadArray <uint>(position, 14).Where(i => i != 0)); position = position + (14 * sizeof(uint)); var itemIds = Core.Memory.ReadArray <uint>(position, 175); position = position + (175 * sizeof(uint)); var qtys = Core.Memory.ReadArray <ushort>(position, 175); position = position + (175 * sizeof(ushort)); var crystalQtys = Core.Memory.ReadArray <ushort>(position, 18); for (int i = 0; i < 18; i++) { if (crystalQtys[i] == 0) { continue; } Inventory.Add((uint)(i + 2), crystalQtys[i]); SlotCount.Add((uint)(i + 2), 1); } for (int i = 0; i < 175; i++) { if (itemIds[i] == 0) { FreeSlots++; continue; } if (Inventory.ContainsKey(itemIds[i])) { Inventory[itemIds[i]] += qtys[i]; SlotCount[itemIds[i]]++; } else { Inventory.Add(itemIds[i], qtys[i]); SlotCount.Add(itemIds[i], 1); } } }
private void SpawnSalad() { // Get a random salad from our salad list activeSalad = salads[Random.Range(0, salads.Length)]; // Determine how long customer will wait for item (total time varies depending on # of ingredients float totalTime = activeSalad.ingredients.Length * timePerItem + timeBuffer; // Start the customer's countdown timer statusBar.gameObject.SetActive(true); statusBar.StartCountdownTimer(totalTime); // Display the salad above customer's head foreach (Vegetable vegetable in activeSalad.ingredients) { saladInventory.Add(vegetable); } }
private void Update() { CheckOnItems(); ShowBuildingOrPerson(); if (AddDebugProd) { AddDebugProd = false; _inv.Add(DebugProd, DebugAmount); CheckOnItems(); } if (RemoveDebugProd) { RemoveDebugProd = false; _inv.RemoveByWeight(DebugProd, DebugAmount); CheckOnItems(); } }
public void UpdateLasPurchasePrice(Shop Shop, Unit TransactionUnit, DateTime PurchaseDate, double PurchasePrice) { var itemQuantity = this.Inventory.FirstOrDefault(x => x.Shop == Shop); if (itemQuantity == null) { itemQuantity = ObjectSpace.CreateObject <ItemQuantity>(); itemQuantity.Shop = Shop; itemQuantity.LastPurchaseDate = DateTime.MinValue; itemQuantity.ItemCard = this; Inventory.Add(itemQuantity); } if (PurchaseDate > itemQuantity.LastPurchaseDate) { itemQuantity.LastPurchaseDate = PurchaseDate; itemQuantity.LastPurchasePrice = Math.Round(PurchasePrice / TransactionUnit.ConversionRate, 3); } }
public string DefeatDragon(TreasureItem treasureItem, Dungeon dungeon) { // player defeated dragon, let's remove the dice selection and move companions to graveyard string selectedCompanions = string.Join(", ", PartyDice.Where(d => d.IsSelected).Select(d => d.Name).ToList()); int companionCount = PartyDice.Count(d => d.IsSelected); for (int i = 0; i < companionCount; i++) { UsePartyDie(PartyDice.First(d => d.IsSelected).Companion); } Inventory.Add(treasureItem); string message = $"{SoundManager.DragonDeathSound(true)} <amazon:emotion name=\"excited\" intensity=\"medium\">You used your {selectedCompanions}, to defeat the dragon. You acquired {treasureItem.TreasureType.GetDescription()}. "; message += GainExperiencePoints(1, dungeon); message += "</amazon:emotion>"; return(message); }
public void cannot_catch_bird_if_holding_black_rod() { var blackRod = Objects.Get <BlackRod>(); Inventory.Add(blackRod); var cage = Objects.Get <WickerCage>(); Inventory.Add(cage); var bird = Objects.Get <LittleBird>(); ObjectMap.MoveObject(bird, CurrentRoom.Location); Execute("catch bird"); Assert.Equal("The bird was unafraid when you entered, but as you approach it becomes disturbed and you cannot catch it.", Line1); }
public void PickUp(GameObject player) { Inventory inventory = player.GetComponent <Inventory>(); if (inventory) { bool wasPickedUp = inventory.Add(secondary, quantity); if (wasPickedUp) { Destroy(gameObject); HUD.instance.ActivateButton(false); } } else { Debug.LogError($"Can't find inventory in {player.name}"); } }
public void DropItemAfterDispose() { MessageBus bus = new MessageBus(); List <string> messages = new List <string>(); bus.Subscribe <OutputMessage>(m => messages.Add(m.Text)); Items items = new Items(bus); using (Inventory inv = new Inventory(bus)) { inv.Add("key", new TestItem(bus)); } bus.Send(new DropItemMessage(items, new Word("drop", "THROW"), new Word("key", "KEY"))); messages.Should().BeEmpty(); items.Look("{0}").Should().Be(0); }
public void restate_command_after_incomplete_question() { var response = new FakeCommandPrompt("put bird in cage"); Context.CommandPrompt = response; var bird = Objects.Get <LittleBird>(); Location.Objects.Add(bird); var cage = Objects.Get <WickerCage>(); Inventory.Add(cage); var results = parser.Parse("put bird"); Assert.AreEqual("You catch the bird in the wicker cage.", results[0]); }
public void DropDisallowedItem() { MessageBus bus = new MessageBus(); List <string> messages = new List <string>(); bus.Subscribe <OutputMessage>(m => messages.Add(m.Text)); Items items = new Items(bus); using (Inventory inv = new Inventory(bus)) { inv.Add("key", new TestItem(bus, false)); bus.Send(new DropItemMessage(items, new Word("drop", "THROW"), new Word("key", "KEY"))); bus.Send(new ShowInventoryMessage()); messages.Should().Equal("I won't let you drop this!", "You are carrying:", "a key"); items.Look("{0}").Should().Be(0); } }
//PickUp method that will add an item to hero item inventory public new void PickUp(Item item) { if (item is Treasure) //if it is a tresure, add gold amount to the hero treasure gold amount { Gold.GoldAmount += ((Treasure)item).GoldAmount; } else if (Inventory.Count + 1 <= InventoryCapacity) //else if inventory is not full, add item to the inventory { Inventory.Add(item); item.Owner = this; } else //else display notification showing not enough capacity { Console.WriteLine("You do not have the capacity to pickup: " + item.Name); } item.RoomOccupied = Room; }
public void what_do_you_want_to_put_the_bottle_in() { var response = new FakeCommandPrompt("cage"); Context.CommandPrompt = response; var bird = Objects.Get <LittleBird>(); Location.Objects.Add(bird); var cage = Objects.Get <WickerCage>(); Inventory.Add(cage); var results = parser.Parse("put bird"); Assert.AreEqual("You catch the bird in the wicker cage.", results[0]); }
public void just_put_object_present() { var response = new FakeCommandPrompt("bird in cage"); Context.CommandPrompt = response; var cage = Objects.Get <WickerCage>(); Inventory.Add(cage); var bird = Objects.Get <LittleBird>(); Location.Objects.Add(bird); var results = parser.Parse("put"); Assert.AreEqual("You catch the bird in the wicker cage.", results[0]); }
// Use this for initialization void Start() { Life[0] = 20; MaxLife[0] = 30; Number = 0; Energy = 30; MaxEnergy = 30; Attack = 3; Defence = 2; Speed = 5; Gold = 10; Experience = 3; Description = "数学A"; //ItemDatabase.Instance.Items[1]; Inventory.Add("参考書"); }
public void should_take_bird() { var cage = Objects.Get <WickerCage>(); Inventory.Add(cage); var bird = Objects.Get <LittleBird>(); Location.Objects.Add(bird); var results = parser.Parse("take bird"); Assert.AreEqual(1, results.Count); Assert.AreEqual("You catch the bird in the wicker cage.", results[0]); Assert.IsFalse(Location.Objects.Contains(bird)); Assert.IsTrue(cage.Contains <LittleBird>()); Assert.IsTrue(bird.InInventory); }
public void bird_should_be_released_when_removed() { var bird = Objects.Get <LittleBird>(); var cage = Objects.Get <WickerCage>(); cage.Add(bird); cage.IsOpen = false; Inventory.Add(cage); Assert.IsTrue(cage.Contains <LittleBird>()); var results = parser.Parse("remove bird"); Assert.AreEqual("(The bird is released from the cage.)", results[0]); Assert.IsTrue(Location.Objects.Contains(bird)); Assert.IsFalse(cage.Contains <LittleBird>()); }
public void cannot_take_the_bird_again() { var bird = Objects.Get <LittleBird>(); var cage = Objects.Get <WickerCage>(); cage.Add(bird); cage.IsOpen = false; Inventory.Add(cage); Assert.IsTrue(cage.Contains <LittleBird>()); var results = parser.Parse("take bird"); Assert.AreEqual("You already have the little bird.", results[0]); Assert.AreEqual("If you take it out of the cage it will likely fly away from you.", results[1]); Assert.IsTrue(cage.Contains <LittleBird>()); }
/// <summary> /// Buy the item. /// </summary> /// <param name="orderLine">Order line.</param> void BuyItem(IOrderLine orderLine) { // find item in inventory var item = Inventory.Find(x => x.Name == orderLine.Item.Name); var count = orderLine.Count; // if not found add new item to inventory if (item == null) { Inventory.Add(new Item(orderLine.Item.Name, count)); } // if found increase count else { item.Count += count; } }
// Use this for initialization void Start() { Life[0] = 30; Life[1] = 50; MaxLife[0] = 30; MaxLife[1] = 50; Number = 0; Energy = 30; MaxEnergy = 30; Attack = 5; Defence = 3; Speed = 5; Gold = 20; Experience = 5; Description = "ほげ実"; //ItemDatabase.Instance.Items[1]; Inventory.Add("ほげの実"); }
public override (string, CollisionEvent) TakeItem(Person victim) { if (victim is Citizen) { if (victim.Inventory.Count == 0) { return("Thief tried to steal, but citizen had nothing!", CollisionEvent.FailedRobbery); } var index = Rng.Next(0, victim.Inventory.Count); var item = victim.Inventory[index]; Inventory.Add(item); victim.Inventory.RemoveAt(index); return($"Thief stole: {item.Name}.", CollisionEvent.Robbery); } return(string.Empty, CollisionEvent.NoEvent); }
public void CheckCraftingSlots() { slots = GetComponentsInChildren <InventorySlot>(); for (int i = 25; i > 19; i--) { if (slots[i].item != null) { inventory.Add(slots[i].item); slots[i].ClearSlot(); } else { slots[i].ClearSlot(); } } slots[26].ClearSlot(); }
/// <summary> /// Checks to see if the <c>pack</c> defined in this components yaml prototype /// exists. If so, it fills the reagent inventory list. /// </summary> private void InitializeFromPrototype() { if (string.IsNullOrEmpty(_packPrototypeId)) { return; } var prototypeManager = IoCManager.Resolve <IPrototypeManager>(); if (!prototypeManager.TryIndex(_packPrototypeId, out ReagentDispenserInventoryPrototype packPrototype)) { return; } foreach (var entry in packPrototype.Inventory) { Inventory.Add(new ReagentDispenserInventoryEntry(entry)); } }
public void Equip(Weapons newItem) { int slotIndex = (int)newItem.weaponSlot; Weapons oldItem = null; if (currentWeapons[slotIndex] != null) { oldItem = currentWeapons[slotIndex]; inventory.Add(oldItem); } if (onEquipmentChanged != null) { onEquipmentChanged.Invoke(newItem, oldItem); } currentWeapons[slotIndex] = newItem; }
public void Add(P product, float amt) { if (IsLiquid(product)) { if (product == P.Water) { _waterInventory.Add(product, amt); } else { _liquidInventory.Add(product, amt); } } else { _inventory.Add(product, amt); } RemoveContainerUsed(product); }
public void EquipmentIsSerializable() { Equipment equips = new Equipment(); Inventory inv = new Inventory(); inv.Add(new PoisonArmor()); equips.AddEquip(inv, new BuffParams(new Stats(1, 2, 3, 4, 5), 2), new PoisonArmor()); EquipmentSave initialSaveObject = equips.GetSaveObject(); initialSaveObject.Buffs.ForEach(b => b.Buff.SetupAsCasterNotInParty()); string json = ToJson(initialSaveObject); EquipmentSave newSaveObject = FromJson <EquipmentSave>(json); Equipment newObject = Util.TypeToObject <Equipment>(equips.GetType()); newObject.InitFromSaveObject(newSaveObject); Assert.AreEqual(equips, newObject); CollectionAssert.AreEquivalent(equips, newObject); }
public void should_accept_fresh_batteries() { var fresh = Objects.Get <FreshBatteries>(); Inventory.Add(fresh); lamp.PowerRemaining = 0; Execute("put batteries in lamp"); Assert.Equal(2500, lamp.PowerRemaining); Assert.Contains("I'm taking the liberty of replacing the batteries.", ConsoleOut); var old = Objects.Get <OldBatteries>(); Assert.True(old.InScope); Assert.True(fresh.HaveBeenUsed); }
private int use_opt; //3 = use, 4 = examine, 5 = quit #endregion Fields #region Methods //Ang.invent; //USE GLOBALIZED INVENTORY // Use this for initialization void Start() { itemss = new Inventory (); Item0 = new HealingItem ("Cherry.", "This is a Cherry.", 30, "Heals 30% of \nyour Health.", 1); Item1 = new QuestItem ("Sword.", "This is a Sword.", "It has a cute \ntattoo on its hilt.", 2); Item2 = new QuestItem ("Boob.", "It's a boob.", "Still a boob.", 1); Item3 = new HealingItem ("Cherry.", "This is a\nCherry.", 30, "Heals 30% of \nyour Health.", 1); Item4 = new HealingItem ("Cherry.", "This is a\nCherry.", 30, "Heals 30% of \nyour Health.", 1); itemss.Add (Item0); itemss.Add (Item1); itemss.Add (Item2); itemss.Add (Item0); itemss.Add (Item1); //(string name, string description, string examineText = "A quest item.", //int quantity = 1) //(string name, string description, string examineText = "A healing item.", //int healingAmt, int quantity = 1) inventory = GameObject.Find ("Inventory_BG"); theCanvas = inventory.transform.GetChild (6).gameObject; //theCanvas is the Canvas at index(6), child of Inventory_BG; do not change this variable usePrompt = GameObject.Find ("Use_Prompt"); for (iter = 0; iter < 25; iter++) { if (iter < 6) { inventory.transform.GetChild (iter).gameObject.SetActive(false); //Deactivating everything under Inventory_BG } theCanvas.transform.GetChild (iter).gameObject.SetActive (false); //children of index(6) deactivated } //Making text objects manipulable in script. //example usage: Item0_Deselected_Text.text = Item0_Selected_Text.text = "Item_Name0" Item0_Deselected_Text = theCanvas.transform.GetChild (0).GetComponent<Text>(); Item1_Deselected_Text = theCanvas.transform.GetChild (1).GetComponent<Text>(); Item2_Deselected_Text = theCanvas.transform.GetChild (2).GetComponent<Text>(); Item3_Deselected_Text = theCanvas.transform.GetChild (3).GetComponent<Text>(); Item4_Deselected_Text = theCanvas.transform.GetChild (4).GetComponent<Text>(); Item5_Deselected_Text = theCanvas.transform.GetChild (5).GetComponent<Text>(); Item6_Deselected_Text = theCanvas.transform.GetChild (6).GetComponent<Text>(); Item7_Deselected_Text = theCanvas.transform.GetChild (7).GetComponent<Text>(); Item8_Deselected_Text = theCanvas.transform.GetChild (8).GetComponent<Text>(); Item9_Deselected_Text = theCanvas.transform.GetChild (9).GetComponent<Text>(); Item10_Deselected_Text = theCanvas.transform.GetChild (10).GetComponent<Text>(); Item11_Deselected_Text = theCanvas.transform.GetChild (11).GetComponent<Text>(); Item0_Selected_Text = theCanvas.transform.GetChild (12).GetComponent<Text>(); Item1_Selected_Text = theCanvas.transform.GetChild (13).GetComponent<Text>(); Item2_Selected_Text = theCanvas.transform.GetChild (14).GetComponent<Text>(); Item3_Selected_Text = theCanvas.transform.GetChild (15).GetComponent<Text>(); Item4_Selected_Text = theCanvas.transform.GetChild (16).GetComponent<Text>(); Item5_Selected_Text = theCanvas.transform.GetChild (17).GetComponent<Text>(); Item6_Selected_Text = theCanvas.transform.GetChild (18).GetComponent<Text>(); Item7_Selected_Text = theCanvas.transform.GetChild (19).GetComponent<Text>(); Item8_Selected_Text = theCanvas.transform.GetChild (20).GetComponent<Text>(); Item9_Selected_Text = theCanvas.transform.GetChild (21).GetComponent<Text>(); Item10_Selected_Text = theCanvas.transform.GetChild (22).GetComponent<Text>(); Item11_Selected_Text = theCanvas.transform.GetChild (23).GetComponent<Text>(); Description_Text = theCanvas.transform.GetChild (24).GetComponent<Text>(); usePrompt.SetActive(false); inventory.SetActive (false); InventOpened = false; inventory_focus = true; itemUse_focus = false; usePrompt_focus = false; }
public void CanNotEquipItemNotInInventory() { var inventory = new Inventory(); var item = new WeightedItem { Weight = Weight.Heavy, Name = "hello" }; Assert.False(inventory.Equip(item)); inventory.Add(item); Assert.True(inventory.Equip(item)); }
public void InitializeInventory(Inventory inventoryToInitialize) { for (int i = 0; i < m_startingPageCount; i++) { Page basicPage; if (m_startingPageCount - i > 3) { basicPage = GetBasicPage(); } else { basicPage = ConstructBoostPage(1, Genre.Horror, true); } inventoryToInitialize.Add(basicPage, i); } if (inventoryToInitialize is PlayerInventory) { PlayerInventory playerInv = (PlayerInventory)inventoryToInitialize; playerInv.SortInventory(0, 20); playerInv.SortInventory(20, playerInv.DynamicSize); } }
private void LoadNewActivity(Activity activity) { actTitleBox.Text = activity.Name; actDescriptionBox.Text = activity.Description; skirmishWavesInventoryInternal = new Inventory(); skirmishWavesInventoryInternal.Add(activity.Root); MarkSaved(); SaveSkirmishWaves(); RefreshTreeView(); }
public void CanNotEquipItemIntoTakenSlotIfNoAutoUnequip() { var inventory = new Inventory(); var item1 = new WeightedItem { Weight = Weight.Heavy, Name = "hello1" }; var item2 = new WeightedItem { Weight = Weight.Heavy, Name = "hello2" }; inventory.Add(item1); inventory.Add(item2); Assert.True(inventory.Equip(item1, false)); Assert.Same(inventory.HeavySlotItem, item1); Assert.False(inventory.Equip(item2, false)); Assert.Same(inventory.HeavySlotItem, item1); Assert.NotSame(inventory.HeavySlotItem, item2); Assert.NotNull(inventory.HeavySlotItem); }
/// <summary> /// Initializes the tree view for waves. /// </summary> private void InitWavesTreeView() { skirmishWavesInventoryInternal = null; skirmishWavesTreeView.ItemsSource = null; Inventory waves = skirmishWavesScanner.GetAllWaves(); InventoryItem newItem = new InventoryItem(); newItem.CopyOf = "All Waves"; newItem.SubItems = waves; Inventory mainInventory = new Inventory(); mainInventory.Add(newItem); skirmishWavesInventoryInternal = mainInventory; RefreshTreeView(); }
private Inventory GetInventory(StringReader reader, string initialLine, int desiredTabIndex) { //I am assuming the the inventory of something is defined by the tab index before it. Sub-inventories are tabbed one more in. Inventory thisInventory = new Inventory(); string lineText; if (initialLine == null) { lineText = reader.ReadLine(); lastLineRead = lineText; } else { lineText = initialLine; } int lineTabIndex; if(desiredTabIndex == -1) { lineTabIndex = GetTabIndex(lineText); } else { lineTabIndex = desiredTabIndex; } while (lineText != null) { if (GetPropertyFromLine(lineText) == "AddInventory") { if (GetTabIndex(lineText) == lineTabIndex) { InventoryItem inventoryItem = new InventoryItem(); inventoryItem.Name = GetValueFromLine(lineText); //This assumes that CopyOf will be the first line after a GetInventory lineText = reader.ReadLine(); lastLineRead = lineText; inventoryItem.CopyOf = GetValueFromLine(lineText); inventoryItem.SubItems = GetInventory(reader, null, GetTabIndex(lineText)); lineText = lastLineRead; inventoryItem.ParentInventory = thisInventory; thisInventory.Add(inventoryItem); continue; } if (GetTabIndex(lineText) < lineTabIndex) { return thisInventory; } } lineText = reader.ReadLine(); lastLineRead = lineText; } return thisInventory; }
private static Inventory FindRootInventoryItems(int positionOfSubItems) { Inventory inventory = new Inventory(); int depth = 0; int maxPosition = FindMatchingTagIndex(positionOfSubItems); for (int position = 0; position < maxPosition; position++) { int fullPosition = positionOfSubItems + position; string lookFor = "[InventoryItem"; if (fullPosition + lookFor.Length > maxPosition) { break; } string maybeFind = fileBuffer.Substring(fullPosition, lookFor.Length); if (maybeFind == lookFor) { if (depth == 1) { inventory.Add(MakeItem(positionOfSubItems + position)); } } if (fileBuffer.Substring(fullPosition, 1) == "[") { depth++; } if (fileBuffer.Substring(fullPosition, 1) == "]") { depth--; } } return inventory; }
private void Start() { _inventory = GetComponent<Inventory>(); _inventory.Add(ResourceType, ResourceAmount); }
public void CanNotEquipNonWeightedItem() { var inventory = new Inventory(); var item = new Item { Name = "hello" }; inventory.Add(item); Assert.False(inventory.Equip(item)); }
public void CopyTo(Inventory inventory) { int counter = 0; for (int i = 0; i < Size && counter < inventory.Size; i++) { if (data[i] != null) { inventory.Add(data[i]); //RemoveStack(i); counter++; } } }
public void CollectionBehaviourIsCorrect() { var inventory = new Inventory(); var item1 = new WeightedItem { Weight = Weight.Heavy, Name = "hello1" }; var item2 = new WeightedItem { Weight = Weight.Heavy, Name = "hello2" }; inventory.Add(item1); inventory.Add(item2); Assert.Contains(item1, inventory.AllItems); Assert.Contains(item2, inventory.AllItems); Assert.Contains(item1, inventory.UnequippedItems); Assert.Contains(item2, inventory.UnequippedItems); Assert.DoesNotContain(item1, inventory.EquippedItems); Assert.DoesNotContain(item2, inventory.EquippedItems); Assert.True(inventory.Equip(item1)); Assert.DoesNotContain(item1, inventory.UnequippedItems); Assert.Contains(item2, inventory.UnequippedItems); Assert.Contains(item1, inventory.EquippedItems); Assert.DoesNotContain(item2, inventory.EquippedItems); Assert.True(inventory.Equip(item2)); Assert.Contains(item1, inventory.UnequippedItems); Assert.DoesNotContain(item2, inventory.UnequippedItems); Assert.DoesNotContain(item1, inventory.EquippedItems); Assert.Contains(item2, inventory.EquippedItems); }