public void OpenItemDetails(baseGroceryItemSO itemData) { ToggleCanvas(true); SetNewItemDetail(itemData.GetEnumID()); //HomeUI.Instance.currentScene = App_Scenes.ItemCanvas; }
private void Update() { switch (currState) //OnStateUpdate { case FlowStates.state_travelRestrictions: if (speechToText.text.Contains("yes") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_whatTravelRestrictions); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { mWillingToTravel = -1; ChangeState(FlowStates.state_dietryRestrictions); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_whatTravelRestrictions: if (char.IsDigit(speechToText.text[0]) && speechToText.text.Contains("Final")) { string tempDigit = ""; foreach (char c in speechToText.text) { if (char.IsDigit(c)) { tempDigit += c; } else { break; } } mWillingToTravel = int.Parse(tempDigit); ChangeState(FlowStates.state_dietryRestrictions); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_dietryRestrictions: if (speechToText.text.Contains("hello") && speechToText.text.Contains("Final")) //halal is detected as hello in the ibm stt { amHalal = true; ChangeState(FlowStates.state_confirmSettings); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { amHalal = false; ChangeState(FlowStates.state_confirmSettings); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_confirmSettings: if (speechToText.text.Contains("yes") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_addItems); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_travelRestrictions); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_addItems: if (!waitingOnResponse) { List <baseGroceryItemSO> itemsByName = ItemFinder.Instance.SearchGroceriesSTT(speechToText.text); List <baseGroceryItemSO> itemsByCategory = ItemFinder.Instance.SearchCategoriesSTT(speechToText.text); List <baseGroceryItemSO> itemsSearched = new List <baseGroceryItemSO>(); foreach (baseGroceryItemSO item in itemsByName) { foreach (baseGroceryItemSO categoryItem in itemsByCategory) { if (categoryItem == item) { if (amHalal && !item.IsItemHalal()) { continue; } itemsSearched.Add(item); } } } if (itemsSearched.Count == 0) { foreach (baseGroceryItemSO item in itemsByName) { if (amHalal && !item.IsItemHalal()) { continue; } itemsSearched.Add(item); } foreach (baseGroceryItemSO item in itemsByCategory) { if (amHalal && !item.IsItemHalal()) { continue; } itemsSearched.Add(item); } } if (itemsSearched.Count == 0) { speechToText.text = ""; TTSManager.Instance.TextToSpeech("Sorry, I could not find any matches from your search, please try again."); } else if (itemsSearched.Count == 1) { itemSearched = itemsSearched[0]; ChangeState(FlowStates.state_verifyItems); } else { string temp = "I have found multiple items"; foreach (baseGroceryItemSO item in itemsSearched) { temp += ". "; temp += item.GetItemName(); } temp += ". Which item would you like? You can also search for something else if you'd like."; TTSManager.Instance.TextToSpeech(temp); } waitingOnResponse = true; speechToText.text = "default"; } else if (speechToText.text.Contains("Final")) { waitingOnResponse = false; } break; case FlowStates.state_verifyItems: if (char.IsDigit(speechToText.text[0]) && speechToText.text.Contains("Final")) { string tempDigit = ""; foreach (char c in speechToText.text) { if (char.IsDigit(c)) { tempDigit += c; } else { break; } } amountBought = int.Parse(tempDigit); // If they bought more than 1 item if (amountBought > 1) { // Add it for how many times they wanted it for (int i = 0; i < amountBought; ++i) { ShoppingCart.Instance.AddItem(itemSearched.GetEnumID()); } } else { // They only wanted one ShoppingCart.Instance.AddItem(itemSearched.GetEnumID()); } //add amountBought amount of itemSearched into cart (function) itemSearched.SetAmountInCart(amountBought); itemsBought.Add(itemSearched); //Hardcode if (itemSearched.GetItemName() == "Milk") { milkBought = true; } ChangeState(FlowStates.state_continueOrCheckout); } else if (speechToText.text.Contains("one") && speechToText.text.Contains("Final")) { itemSearched.SetAmountInCart(1); itemsBought.Add(itemSearched); //Hardcode if (itemSearched.GetItemName() == "Milk") { milkBought = true; } ChangeState(FlowStates.state_continueOrCheckout); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_addItems); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_continueOrCheckout: if (speechToText.text.Contains("yes") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_addItems); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { // Open up the cart page here ShoppingCart.Instance.ToggleCartView(); ChangeState(FlowStates.state_verifyCart); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_verifyCart: if (speechToText.text.Contains("yes") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_addOrRemove); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { // Change to Store Selective ShoppingCart.Instance.SelectStorePressed(); ChangeState(FlowStates.state_storeSuggestion); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_addOrRemove: if (speechToText.text.Contains("add") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_addItems); } else if (speechToText.text.Contains("remove") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_removeItems); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_removeItems: if (!waitingOnResponse) { List <baseGroceryItemSO> itemsByName = SearchGroceriesFromCartSTT(speechToText.text); List <baseGroceryItemSO> itemsByCategory = SearchCategoriesFromCartSTT(speechToText.text); List <baseGroceryItemSO> itemsSearched = new List <baseGroceryItemSO>(); foreach (baseGroceryItemSO item in itemsByName) { foreach (baseGroceryItemSO categoryItem in itemsByCategory) { if (categoryItem == item) { itemsSearched.Add(item); } } } if (itemsSearched.Count == 0) { itemsSearched = itemsByName; foreach (baseGroceryItemSO item in itemsByCategory) { itemsSearched.Add(item); } } if (itemsSearched.Count == 0) { speechToText.text = ""; TTSManager.Instance.TextToSpeech("Sorry, I could not find any matches from your search, please try again."); } else if (itemsSearched.Count == 1) { itemSearched = itemsSearched[0]; ChangeState(FlowStates.state_verifyRemoveItems); } else { string temp = "I have found multiple items"; foreach (baseGroceryItemSO item in itemsSearched) { temp += ". "; temp += item.GetItemName(); } temp += ". Which item would you like to remove? You can also search for something else if you'd like."; TTSManager.Instance.TextToSpeech(temp); } waitingOnResponse = true; speechToText.text = "default"; } else if (speechToText.text.Contains("Final")) { waitingOnResponse = false; } break; case FlowStates.state_verifyRemoveItems: if (char.IsDigit(speechToText.text[0]) && speechToText.text.Contains("Final")) { string tempDigit = ""; foreach (char c in speechToText.text) { if (char.IsDigit(c)) { tempDigit += c; } else { break; } } amountBought = int.Parse(tempDigit); //remove amountBought amount of itemSearched into cart (function) itemSearched.SetAmountInCart(itemSearched.GetAmountInCart() - amountBought); if (itemSearched.GetAmountInCart() <= 0) { itemsBought.Remove(itemSearched); //Hardcode if (itemSearched.GetItemName() == "Milk") { milkBought = false; } } ChangeState(FlowStates.state_verifyCart); } else if (speechToText.text.Contains("one") && speechToText.text.Contains("Final")) { //remove amountBought amount of itemSearched into cart (function) itemSearched.SetAmountInCart(itemSearched.GetAmountInCart() - 1); if (itemSearched.GetAmountInCart() <= 0) { itemsBought.Remove(itemSearched); //Hardcode if (itemSearched.GetItemName() == "Milk") { milkBought = false; } } ChangeState(FlowStates.state_verifyCart); } else if (speechToText.text.Contains("no") && speechToText.text.Contains("Final")) { ChangeState(FlowStates.state_removeItems); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_storeSuggestion: if (speechToText.text.Contains("prime") && speechToText.text.Contains("Final")) { //function to plan route //Hardcode nexChosen = false; ChangeState(FlowStates.state_planRoute); } else if (speechToText.text.Contains("next") && speechToText.text.Contains("Final")) //nex is not a word, next is closest { //function to plan route //Hardcode nexChosen = true; ChangeState(FlowStates.state_planRoute); } else if ((speechToText.text.Contains("repeat") || speechToText.text.Contains("again")) && speechToText.text.Contains("Final")) { ChangeState(currState); } break; case FlowStates.state_planRoute: break; default: break; } }
public void AddItemToCart() { ShoppingCart.Instance.AddItem(currentItem.GetEnumID()); }
public void RemoveItemButtonPressed() { ShoppingCart.Instance.RemoveItem(m_SOReference.GetEnumID()); }