Supermarket shelf behaviour script.
Inheritance: UnityEngine.MonoBehaviour, ISelectable
コード例 #1
1
        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);
        }
コード例 #2
0
 // 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));
     }
 }
コード例 #3
0
        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();
        }
コード例 #4
0
 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));
     }
 }
コード例 #5
0
 public void OnAwareOf(Shelf shelf)
 {
     state.OnAwareOf(shelf);
 }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
 /// <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);
         }
     }
 }
コード例 #8
0
 public virtual void OnAwareOf(Shelf shelf)
 {
 }
コード例 #9
0
 public virtual void OnAwareOf(Shelf other)
 {
 }
コード例 #10
0
 public void DisplayShelf(Shelf shelf)
 {
     shelfGUI.DisplayShelf(shelf);
 }