/// <summary> /// Locate the specified id. /// </summary> /// <returns>The locate.</returns> /// <param name="id">Identifier.</param> public GameObject Locate(string id) { //finding myself bool result = AreYou(id); if (result) { return(this); } else { if (!(_location == null)) { return(_location.Locate(id)); } else if (_inventory.HasItem(id)) { return(_inventory.Fetch(id)); } else { return(null); } } }
public void TestFindItem() { Item myGloriousItem = new Item(new string[] { "axe", "kulhara" }, "Sharp hathora", "cuts people like butter"); Item myGloriousItem2 = new Item(new string[] { "gun", "pistol" }, "headshot machine", "opens head like a nut opener"); Item myGloriousItem3 = new Item(new string[] { "shoe", "chappal" }, "Ammi likes", "Used when children are not studying"); Inventory _myInventory = new Inventory(); _myInventory.Put(myGloriousItem); _myInventory.Put(myGloriousItem2); _myInventory.Put(myGloriousItem3); Assert.AreEqual(_myInventory.HasItem("axe"), true); Assert.AreEqual(_myInventory.HasItem("gun"), true); Assert.AreEqual(_myInventory.HasItem("shoe"), true); }