예제 #1
0
        /// <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);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Locate the specified id.
        /// </summary>
        /// <returns>The locate.</returns>
        /// <param name="id">Identifier.</param>
        public GameObject Locate(string id)
        {
            bool result = AreYou(id);

            if (result)
            {
                return(this);
            }
            else
            {
                return(_inventory.Fetch(id));
            }
        }
        public void TestFetchItem()
        {
            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);

            Assert.AreEqual(_myInventory.Fetch("axe"), myGloriousItem);
        }
예제 #4
0
        /// <summary>
        /// Locate the specified id.
        /// </summary>
        /// <returns>The locate.</returns>
        /// <param name="id">Identifier.</param>
        public GameObject Locate(string id)
        {
            //finding bag itself
            bool result = AreYou(id);

            //returning the bag itself
            if (result)
            {
                return(this);
            }
            //finding in the items if not found in myself
            else
            {
                return(_inventory.Fetch(id));
            }
        }