Пример #1
0
    public IEnumerator Back()
    {
        yield return(new WaitUntil(() => ((Input.GetKeyDown(KeyCode.LeftControl) && bci.batTran.ingUnlocked[11]) || bci.bciDone) && isReady)); // Wait until Left Control is pressed

        bci.bciDone = false;

        // If our open menu is BCI specifically, do BCI specific things. Likewise for other menus.
        if (commandOpen == CommandMenus.Fight)
        {
            if (plateMoveInst != null)
            {
                StopCoroutine(plateMoveInst);
            }

            plateMoveInst = BurgerPlateMove(false);
            StartCoroutine(plateMoveInst);

            for (int i = 0; i < ingredientHolder.Length; i++)
            {
                if (gameObject.GetComponent <BattleTransitions>().ingUnlocked[i])
                {
                    ingredientHolder[i].GetComponent <Animator>().SetTrigger("OnOff");
                }
            }

            comboActive = false;
        }

        if (commandOpen != CommandMenus.None) // If we aren't in the base command menu, go back into the command menu.
        {
            Debug.Log("Return to base Command menu.");
            uiAnim.SetBool("BCI", false); // Reset our animator.
            uiAnim.SetBool("ItemCombo", false);
            uiAnim.SetBool("ComboInfo", false);

            ToggleText(comboHolder, false, true);
            ToggleText(itemHolder, false, false);

            commandOpen = CommandMenus.None;
        }


        StartCoroutine(Back()); // Recursive, call itself.
    }
Пример #2
0
    public IEnumerator Confirm(int choice)
    {
        Debug.Log("Confirm choice!");
        yield return(new WaitForSeconds(0));

        if (!ns1.waitForScript)  // As long as we're not waiting for the narrative script, we can confirm an option.
        {
            StartEnemyTimer();   // Start our timer, having selected things.

            switch (commandOpen) // Base how Confirm behaves on which menu we're in.
            {
            case CommandMenus.None:
                if (!backHome || !isReady)     // If we haven't returned to the main menu or are otherwise not ready, don't do anything.
                {
                    break;
                }

                switch (choice) // If we're in the base command menu, select our command.
                {
                case 0:         // Fight
                    if (commandsAvailable[0])
                    {
                        Debug.Log("Fight selected and available!");
                        commandOpen = CommandMenus.Fight;

                        backHome = false;

                        uiAnim.SetBool("BCI", true);         // Turn on BCI. If we're not in a tutorial or midway through, display the combo panel as well.
                        if (displayBCIComboWindow)
                        {
                            uiAnim.SetBool("ComboInfo", true);
                        }

                        yield return(new WaitUntil(() => readyUp && isReady));

                        readyUp = false;
                        isReady = false;

                        row = 2;         // Default to hovering over Lettuce in the BCI menu.
                        col = 1;

                        // Turn on all ingredients within our Ingredient holder, but only if we have them unlocked.
                        for (int i = 0; i < ingredientHolder.Length; i++)
                        {
                            if (gameObject.GetComponent <BattleTransitions>().ingUnlocked[i])
                            {
                                ingredientHolder[i].GetComponent <Animator>().SetTrigger("OnOff");
                            }
                        }

                        // Slide our burger plate in. We create an instance of the coroutine that may be cancelled at any point.

                        if (plateMoveInst != null)
                        {
                            StopCoroutine(plateMoveInst);
                        }

                        plateMoveInst = BurgerPlateMove(true);
                        StartCoroutine(plateMoveInst);


                        burgerSpawner.SetActive(true);
                        bci.spawnReset = false;         // Reset spawnreset.

                        //Indicator.SetActive(false);

                        //choiceText.SetActive(false);

                        StartCoroutine(bci.ComponentSpawn(KeyCode.Space, 3, bci.bottomBun, 0));         // Drop the bottom bun initially, and start up bci.
                        bci.serveStart = true;
                        StartCoroutine(bci.StartStuff());
                        StartCoroutine(bci.enableCheats());

                        yield return(new WaitUntil(() => bci.bciDone || !burgerSpawner.activeInHierarchy));        // Wait until bci deactivates itself by serving a burger or the burger is cancelled, and then we go back to selecting menu options.

                        bci.bciDone = false;
                        Debug.Log("Go back!");

                        //choiceText.SetActive(true);
                    }
                    else
                    {
                        Debug.Log("Fight selected, but unavailable.");
                        // Play error sound here.
                    }

                    break;

                case 1:           // Combo
                                  // Bring up Combo UI here.

                    if (!isReady) // If we aren't allowed to input anything, stop doing what we're doing.
                    {
                        break;
                    }

                    commandOpen = CommandMenus.Combo;
                    uiAnim.SetBool("ItemCombo", true);         // Turn on our Combo menu.
                    if (displayBCIComboWindow)
                    {
                        uiAnim.SetBool("ComboInfo", true);
                    }


                    yield return(new WaitUntil(() => readyUp));

                    readyUp = false;

                    row = 2;         // Default to hovering over Classic Combo.
                    col = 0;

                    ToggleText(comboHolder, true, true);

                    break;

                case 2:         // Items
                    commandOpen = CommandMenus.Item;


                    yield return(new WaitUntil(() => readyUp));

                    readyUp = false;

                    uiAnim.SetBool("ItemCombo", true); // Turn on our Item menu.

                    row = 2;                           // Default to hovering over the item in our first slot.
                    col = 0;

                    ToggleText(itemHolder, true, false);

                    break;

                case 3:         // Run

                    if (commandsAvailable[option])
                    {
                        isReady = false;
                        Player.GetComponent <Animator>().SetTrigger("Run");
                        yield return(new WaitForSeconds(1));

                        StartCoroutine(GetComponent <BattleTransitions>().EndOfBattle(false));
                    }
                    else
                    {
                        isReady            = false;
                        bci.comboText.text = "Can't run from this battle";
                        yield return(new WaitForSeconds(1));

                        yield return(new WaitUntil(() => Input.GetButtonDown("Submit")));

                        bci.comboText.text = "";
                        isReady            = true;
                    }
                    break;
                }     // Base command options. Fight, Combo, Item, Run. Accepts Option as its choice.


                break;

            case CommandMenus.Fight:     // Nothing should happen confirming anything in the fight menu. This stays empty.
                break;

            case CommandMenus.Combo:     // Selects a combo to appear in the info panel, locks it in, and then moves to BCI. Only if the selected combo is unlocked. Takes Index as its choice.
                BattleTransitions batTran = gameObject.GetComponent <BattleTransitions>();

                if (batTran.combosUnlocked[choice])
                {
                    isReady     = false;
                    comboActive = true;
                    string temp = comboOrderText[row][col];     // Store our directions temporarily, and until we're in the bci menu, hide the info text.
                    infoTextSlot.text  = "";
                    comboTextSlot.text = "";
                    commandOpen        = CommandMenus.Fight;
                    uiAnim.SetBool("BCI", true);
                    uiAnim.SetBool("ItemCombo", false);

                    yield return(new WaitUntil(() => readyUp));    // Wait until a bool is called from an animation event, dictating that we're now out of the combo menu.

                    readyUp = false;

                    ToggleText(comboHolder, false, true);

                    yield return(new WaitUntil(() => readyUp));    // Wait until a bool is called from an animation event, dictating that we're now in the BCI menu.

                    readyUp = false;

                    infoTextSlot.text = temp;



                    // And then insert standard BCI stuff.
                    row = 2;     // Default to hovering over Lettuce in the BCI menu.
                    col = 1;

                    // Turn on all ingredients within our Ingredient holder, but only if we have them unlocked.
                    for (int i = 0; i < ingredientHolder.Length; i++)
                    {
                        if (gameObject.GetComponent <BattleTransitions>().ingUnlocked[i])
                        {
                            ingredientHolder[i].GetComponent <Animator>().SetTrigger("OnOff");
                        }
                    }

                    // Slide our burger plate in.

                    if (plateMoveInst != null)
                    {
                        StopCoroutine(plateMoveInst);
                    }

                    plateMoveInst = BurgerPlateMove(true);
                    StartCoroutine(plateMoveInst);

                    isReady = false;        // We are no longer ready, so we activate bci and deactivate our indicator.
                    burgerSpawner.SetActive(true);
                    bci.spawnReset = false; // Reset spawnreset.

                    //Indicator.SetActive(false);

                    //choiceText.SetActive(false);

                    StartCoroutine(bci.ComponentSpawn(KeyCode.Space, 3, bci.bottomBun, 0));     // Drop the bottom bun initially, and start up bci.
                    bci.serveStart = true;
                    StartCoroutine(bci.StartStuff());
                    StartCoroutine(bci.enableCheats());

                    yield return(new WaitUntil(() => bci.bciDone || !burgerSpawner.activeInHierarchy));    // Wait until bci deactivates itself by serving a burger or the burger is cancelled, and then we go back to selecting menu options.

                    bci.bciDone = false;
                    Debug.Log("Go back!");

                    //choiceText.SetActive(true);
                    //isReady = true;
                }

                break;

            case CommandMenus.Item:     // Consume an item. Currently has no function.
                break;
            }
        }
        else
        {
            //Debug.Log("wait for script");
        }
    }