Supermarket shelf behaviour script.
Inheritance: UnityEngine.MonoBehaviour, ISelectable
        public AddToCart(Customer customer, string desiredProduct, Shelf shelf)
            : base(customer)
        {
            this.desiredProduct = desiredProduct;
            this.shelf = shelf;

            interactionZone = shelf.ClosestInteractionZone(customer.Position);
            Vector3 destination = interactionZone.transform.position;
            moveControl.SetDestination(destination);

            // Think about the desired product
            GameObject product = supermarket.Catalogue[desiredProduct].Model;
            customer.Think(product);
        }
 // Wander until a shelf that stocks the product is found
 // On each trigger enter, check if its desired product
 // If it is, move to it
 // On reaching it, get product.
 public override void OnAwareOf(Shelf shelf)
 {
     base.OnAwareOf(shelf);
     // Is it a shelf?
     // Does it stock product?
     // Switch to AddToShelf state
     if (shelf.Contains(product))
     {
         customer.SetState(new AddToCart(customer, product, shelf));
     }
 }
        public void DisplayShelf(Shelf shelf)
        {
            gameObject.SetActive(true);
            this.shelf = shelf;

            StringBuilder builder = new StringBuilder("This shelf contains: ");
            foreach (KeyValuePair<string, Product> item in shelf.Inventory.Items)
            {
                builder.Append("\n" + item.Value.Quantity + " " + item.Key + "(s)");
            }
            contentsLabel.text =  builder.ToString();
        }
 void NextEmptyShelf()
 {
     shelfToStock = supermarket.NextEmptyShelf();
     if (shelfToStock != null)
     {
         //go stock the shelf
         interactionZone = shelfToStock.ClosestInteractionZone(staff.Position);
         Vector3 destination = interactionZone.transform.position;
         moveControl.SetDestination(destination);
     }
     else
     {
         staff.SetState(new Wander(staff));
     }
 }
 public void OnAwareOf(Shelf shelf)
 {
     state.OnAwareOf(shelf);
 }
        /// <summary>
        /// Adds the given shelf to the supermarket product directory. The directory shows which shelves stock 
        /// which products
        /// </summary>
        /// <param name="product">The product key to add to the directory</param>
        /// <param name="shelf">The shelf that stocks the product</param>
        public void AddToDirectory(string product, Shelf shelf)
        {
            // If product does not exist in directory
            if (!directory.ContainsKey(product))
            {
                // Add a new entry
                directory.Add(product, new List<Shelf>());
            }

            // Add this shelf to product directory so customers can locate it.
            directory[product].Add(shelf);
        }
 /// <summary>
 /// Interface method. Called when a shelf runs out of the given product.
 /// </summary>
 /// <param name="shelf">The shelf that has run out of stock of a product</param>
 /// <param name="product">The product that the shelf has run out of the given product</param>
 public void NotifyShelfEmpty(Shelf shelf, string product)
 {
     if (directory.ContainsKey(product))
     {
         shelvesToStock.Enqueue(shelf);
         // Remove shelf from directory product->shelf listing
         directory[product].Remove(shelf);
         if (directory[product].Count == 0)
         {
             // Remove product from directory
             directory.Remove(product);
         }
     }
 }
 public virtual void OnAwareOf(Shelf shelf)
 {
 }
 public virtual void OnAwareOf(Shelf other)
 {
 }
 public void DisplayShelf(Shelf shelf)
 {
     shelfGUI.DisplayShelf(shelf);
 }