Пример #1
0
    public void ChangeState(FlowStates state)
    {
        string temp;

        switch (currState) //OnStateExit
        {
        case FlowStates.state_travelRestrictions:
        case FlowStates.state_whatTravelRestrictions:
        case FlowStates.state_dietryRestrictions:
        case FlowStates.state_confirmSettings:
        case FlowStates.state_addItems:
        case FlowStates.state_verifyItems:
        case FlowStates.state_continueOrCheckout:
        case FlowStates.state_verifyCart:
        case FlowStates.state_addOrRemove:
        case FlowStates.state_removeItems:
        case FlowStates.state_verifyRemoveItems:
        case FlowStates.state_storeSuggestion:
        case FlowStates.state_planRoute:
            speechToText.text = "default";
            waitingOnResponse = true;
            break;

        default:
            break;
        }
        currState = state;
        switch (currState) //OnStateEnter
        {
        case FlowStates.state_travelRestrictions:
            TTSManager.Instance.TextToSpeech("Hello, do you have any travel restrictions?");
            break;

        case FlowStates.state_whatTravelRestrictions:
            TTSManager.Instance.TextToSpeech("How far in meters are you willing to travel?");
            break;

        case FlowStates.state_dietryRestrictions:
            TTSManager.Instance.TextToSpeech("What dietry restrictions do you have? If you don't have any, say no");
            break;

        case FlowStates.state_confirmSettings:
            temp = "So you are willing to travel ";
            if (mWillingToTravel == -1)
            {
                temp += "any amount of";
            }
            else
            {
                temp += mWillingToTravel.ToString();
            }
            temp += " meters and you ";
            if (amHalal)
            {
                temp += "are halal. ";
            }
            else
            {
                temp += "have no dietry restrictions. ";
            }
            temp += "Did I get that right?";
            TTSManager.Instance.TextToSpeech(temp);
            break;

        case FlowStates.state_addItems:
            TTSManager.Instance.TextToSpeech("What would you like to buy?");
            break;

        case FlowStates.state_verifyItems:
            temp  = "The item I found is ";
            temp += itemSearched.GetItemName();
            temp += " and it costs ";
            temp += itemSearched.GetDollars().ToString();
            temp += " dollars and ";
            temp += itemSearched.GetCents().ToString();
            temp += " cents. How many would you like to buy? If you do not want it, say no.";
            TTSManager.Instance.TextToSpeech(temp);
            break;

        case FlowStates.state_continueOrCheckout:
            TTSManager.Instance.TextToSpeech("Would you like to continue shopping?");
            break;

        case FlowStates.state_verifyCart:
            temp = "Currently, your cart has";
            foreach (baseGroceryItemSO item in itemsBought)
            {
                temp += ". ";
                temp += item.GetAmountInCart().ToString();
                temp += " ";
                temp += item.GetItemName();
            }
            temp += ". Would you like to change anything in your cart?";
            TTSManager.Instance.TextToSpeech(temp);
            break;

        case FlowStates.state_addOrRemove:
            TTSManager.Instance.TextToSpeech("Would you like to add or remove items?");
            break;

        case FlowStates.state_removeItems:
            TTSManager.Instance.TextToSpeech("What would you like to remove?");
            break;

        case FlowStates.state_verifyRemoveItems:
            temp  = "The item I found is ";
            temp += itemSearched.GetItemName();
            temp += " and it costs ";
            temp += itemSearched.GetDollars().ToString();
            temp += " dollars and ";
            temp += itemSearched.GetCents().ToString();
            temp += " cents and you have ";
            temp += itemSearched.GetAmountInCart().ToString();
            temp += " amount in your cart. How many would you like to remove? If you do not want to remove it, say no.";
            TTSManager.Instance.TextToSpeech(temp);
            break;

        case FlowStates.state_storeSuggestion:
            //Hardcode
            if (milkBought)
            {
                TTSManager.Instance.TextToSpeech("One supermarket I can suggest is Nex Supermarket. It is 200 meters away, is crowded and does not have milk. Another suggestion is Prime Supermarket, It is 3500 meters away, is not crowded and has everything you want. Which one would you prefer?");
            }
            else
            {
                TTSManager.Instance.TextToSpeech("One supermarket I can suggest is Nex Supermarket. It is 200 meters away, is crowded and has everything you want. Another suggestion is Prime Supermarket, It is 3500 meters away, is not crowded and has everything you want. Which one would you prefer?");
            }
            break;

        case FlowStates.state_planRoute:
            //Hardcode
            if (nexChosen)
            {
                TTSManager.Instance.TextToSpeech("Ok, I have planned a route to nex supermarket. Thank you for using my assistance!");
            }
            else
            {
                TTSManager.Instance.TextToSpeech("Ok, I have planned a route to prime supermarket. Thank you for using my assistance!");
            }
            break;

        default:
            break;
        }
    }