/// <summary> /// Fills the customers shopping list and wallet and sets it to Shop state /// </summary> public void Initialize() { name = NameGenerator.FirstAndLastName(); inventory = new Inventory(); shoppingList = new ShoppingList(); // Randomly generate shoppingList contents float totalCost = 0; foreach (Product product in supermarket.Catalogue.Values) { // Each product has a 50% chance to be on shopping list. if (Random.Range(0, 2) == 0) { // Random quota between 1 - 50 int quota = Random.Range(1, 2); shoppingList.Add(product.Name, quota); totalCost += (product.Price * quota); } } // Random money amount up to 250 greater the total cost of good they are purchasing. money = Random.Range(totalCost, totalCost + 250.0f); // Customer starts in 'Shop' state SetState(new Shop(this)); }
void Awake() { interaction = GetComponent<Interactable>(); listeners = new List<IEmptyShelfListener>(); inventory = new Inventory(); selectionCollider = GetComponent<Collider>(); gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUI>(); }