Exemple #1
0
 private void TakeItemFromShelf()
 {
     if (shoppingList[0].Shelves.Count > 0)
     {
         // There is at least 1 shelf to check for this shopping list item
         Vector3 targetPosition = shoppingList[0].Shelves.Peek().transform.position;
         agent.destination = targetPosition;
         ShopShelf targetShelf = shoppingList[0].Shelves.Peek().GetComponent <ShopShelf>();
         if (Vector3.Distance(transform.position, targetPosition) < 1.5f)
         {
             // Customer is in range of the shelf
             if (targetShelf.CheckIfInStock(1))
             {
                 // In stock, get item
                 targetShelf.RemoveStock(1);
                 inventory.Push(shoppingList[0]);
                 shoppingList.RemoveAt(0);
             }
             else
             {
                 // Item is out of stock on this shelf
                 shoppingList[0].Shelves.Dequeue();
             }
         }
     }
     else
     {
         // Item is out of stock on all shelves
         shoppingList.RemoveAt(0);
         stats.AddHappiness(-10);
     }
 }
Exemple #2
0
 private bool CheckIfInRangeOfShelf()
 {
     foreach (ShopShelf shelf in stockCage.nearbyShelves)
     {
         if (!shelf.CheckIfMaxStock() && shelf.ProductName == productName)
         {
             selectedShelf = shelf;
             return(true);
         }
     }
     selectedShelf = null;
     return(false);
 }
Exemple #3
0
 // Start is called before the first frame update
 new private void Start()
 {
     base.Start();
     shelf    = GetComponent <ShopShelf>();
     textData = shelf.ProductName + "\n" + "Current Stock: " + shelf.CurrentStock + "\n" + "Max Stock: " + shelf.MaxStock;
 }