Ejemplo n.º 1
0
    private bool canCheckNewValues; // After a brief timer upon loading into a new scene, this value gets refreshed; this gives objects time to load.


    void Start()
    {
        //Get ready to assign some shit
        mainCam        = GameObject.FindGameObjectWithTag("MainCamera");
        playerHolder   = GameObject.FindGameObjectWithTag("Player");
        gameController = GameObject.FindGameObjectWithTag("GameController");
        battTran       = gameController.GetComponent <BattleTransitions>();

        /*for (int i = 0; i < scripts.Count; i++)
         * {
         *  dataPaths.Add( Path.Combine(Application.persistentDataPath, "porygon_" + scripts[i].name + ".txt") );
         * }*/
        dataPath = Path.Combine(Application.persistentDataPath, "porygon.txt");

        narrMan = mainCam.GetComponent <NarrativeManager>();
        diaHold = mainCam.GetComponent <DialogueHolder>();

        player     = playerHolder.transform.GetChild(0).gameObject;
        playerAnim = player.GetComponent <Animator>();

        blackScreen = GameObject.FindGameObjectWithTag("BlackScreen").GetComponent <Image>();

        //Debug.Log(saveIcon);

        if (saveIcon == null)
        {
            saveIcon         = GameObject.FindGameObjectsWithTag("SaveIcon")[0].GetComponent <Image>();
            saveIcon.enabled = false;
        }
        if (saveIconText == null)
        {
            saveIconText         = GameObject.FindGameObjectsWithTag("SaveIcon")[1].GetComponent <Image>();
            saveIconText.enabled = false;
        }

        // Quickly make sure that our louNotesSeen list has the same length as our manually set list.
        if (louNotesSeen.Count != louNotes.Count)
        {
            for (int i = louNotesSeen.Count; i < louNotes.Count; i++)
            {
                louNotesSeen.Add(false);
            }
        }

        StartCoroutine(SaveSpin());
    }
Ejemplo n.º 2
0
    public void PseudoStart()
    {
        gameController = GameObject.FindGameObjectWithTag("GameController");
        playerAnim     = GetComponent <Animator>();
        playerSprite   = GetComponent <SpriteRenderer>();



        battTran = gameController.GetComponent <BattleTransitions>();
        damText  = GetComponentInChildren <Canvas>().GetComponentInChildren <Text>();

        tempMoveSpeed  = moveSpeed;
        playColl       = GetComponent <CapsuleCollider2D>();
        baseCollOffset = playColl.offset;
        baseCollSize   = playColl.size;

        ladder.Clear();
    }
Ejemplo n.º 3
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");
        }
    }
Ejemplo n.º 4
0
    public IEnumerator MenuNavigation()
    {
        yield return(new WaitUntil(() => isReady)); // Only navigate through menus if we are ready to do so and not in an inbetween state.

        switch (commandOpen)
        {
        case CommandMenus.None:     // When the menu is in its base state.

            /* uiAnim.SetBool("ItemCombo", false); // Set all animation bools to false here to return the menu to its base state; the menu must move through here in order to go to other states. Except for from combos to BCI.
             * uiAnim.SetBool("ComboInfo", false);
             * uiAnim.SetBool("BCI", false);*/

            // Move through the Command menu vertically or select a highlighted option.
            if (Input.GetKeyDown(KeyCode.DownArrow) && option < 3 && ns1.waitForScript == false)
            {
                option++;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow) && option > 0 && ns1.waitForScript == false)
            {
                option--;
            }
            else if (Input.GetButtonDown("Submit") && enemyReset)
            {
                StartCoroutine(Confirm(option));
            }

            // Reflect the highlighted position with the indicator and change relevant Info panel text. Indicator disables if Option is out of range or if it isn't active in the scene.
            if (option >= 0 && Indicator.activeInHierarchy)
            {
                Indicator.GetComponent <Image>().enabled = true;
                Indicator.transform.localPosition        = optionMovements[option];

                if (bci.isTutorial)
                {
                    infoTextSlot.text = tutCommandInfo[option];
                }
                else
                {
                    infoTextSlot.text = mainCommandInfo[option];
                }
            }
            else
            {
                Indicator.GetComponent <Image>().enabled = false;
            }

            // Hide combo text if we pass through here.
            comboTextSlot.text = "";

            break;

        case CommandMenus.Fight:

            BattleTransitions batTran = gameObject.GetComponent <BattleTransitions>();
            int lastRow = row;
            int lastCol = col;

            // Reminder: Row refers to y coordinate, and col refers to x coordinate.
            // Move vertically through the BCI menu.
            if (Input.GetKeyDown(KeyCode.DownArrow) && row > 0)
            {
                row--;

                // I know this looks like a lot, but basically we convert where we are in our grid to ingredients unlocked through a separate function. So if we are hovering over something we don't have unlocked, increment again; if that's out of range or also not unlocked, return to where we were.
                if (!batTran.ingUnlocked[GridConversion(row, col)] && row > 0 && batTran.ingUnlocked[GridConversion(row - 1, col)])
                {
                    row--;
                }
                else if (!batTran.ingUnlocked[GridConversion(row, col)])
                {
                    row = lastRow;
                }
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow) && row < 3)
            {
                row++;

                if (!batTran.ingUnlocked[GridConversion(row, col)] && row < 3 && batTran.ingUnlocked[GridConversion(row + 1, col)])
                {
                    row++;
                }
                else if (!batTran.ingUnlocked[GridConversion(row, col)])
                {
                    row = lastRow;
                }
            }

            // Move horizontally through the BCI menu.
            if (Input.GetKeyDown(KeyCode.LeftArrow) && col > 0)
            {
                col--;

                if (!batTran.ingUnlocked[GridConversion(row, col)] && col > 0 && batTran.ingUnlocked[GridConversion(row, col - 1)])
                {
                    col--;
                }
                else if (!batTran.ingUnlocked[GridConversion(row, col)])
                {
                    col = lastCol;
                }
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow) && col < 2)
            {
                col++;

                if (!batTran.ingUnlocked[GridConversion(row, col)] && col < 2 && batTran.ingUnlocked[GridConversion(row, col + 1)])
                {
                    col++;
                }
                else if (!batTran.ingUnlocked[GridConversion(row, col)])
                {
                    col = lastCol;
                }
            }


            // After movement has been determined, refresh the information panel as well as the indicator position.
            if (!bci.isTutorial && !comboActive)     // Our default battle case. If we're not in the tutorial fight, use our normal options. Don't ever do this if we currently have a combo selected.
            {
                infoTextSlot.text = mainIngredientInfo[col][row];
            }
            else if (!comboActive)     // If we ARE in the tutorial fight, however, you know how we do.
            {
                infoTextSlot.text = tutIngredientInfo[col][row];
            }

            // Move the indicator to its corresponding ingredient.
            Indicator.transform.localPosition = ingredientPositions[col][row];

            // Move the combo text slot over to its BCI location.
            comboTextSlot.transform.position = comboTextSlotLocations[1].position;

            break;

        case CommandMenus.Combo:     // Our combo menu. Will display combos available; selecting one will replace the standard information in the Info Panel with instructions for the current Combo.

            batTran = gameObject.GetComponent <BattleTransitions>();

            // Reminder: Row refers to y coordinate, and col refers to x coordinate.
            // Move vertically through the Combo
            if (Input.GetKeyDown(KeyCode.DownArrow) && row > 0)
            {
                row--;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow) && row < 2)
            {
                row++;
            }

            // Move horizontally through the Item menu.
            if (Input.GetKeyDown(KeyCode.LeftArrow) && col > 0)
            {
                col--;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow) && col < 6)
            {
                col++;
            }

            // If we have a combo unlocked, we can then display its information in the relevant panels.
            int index = 0;

            // First, determine the index in a single-dimension array of what we have selected. It's fairly simple, thankfully, so a simple switch statement is all that's necessary.
            switch (row)
            {
            case 0:
                index = 14 + col;
                break;

            case 1:
                index = 7 + col;
                break;

            case 2:
                index = col;
                break;
            }

            if (batTran.combosUnlocked[index])
            {
                infoTextSlot.text = comboInfoText[row][col];

                if (displayBCIComboWindow)
                {
                    comboTextSlot.text = comboNameText[index];
                }
                else
                {
                    comboTextSlot.text = "";
                }
            }
            else
            {
                comboTextSlot.text = "";
                infoTextSlot.text  = "Much like someone you know, there's nothing of substance here.";
            }

            // Move the combo text slot over to its Combo Menu location.
            comboTextSlot.transform.position = comboTextSlotLocations[0].position;

            // Move the indicator to its corresponding combo.
            Indicator.transform.localPosition = comboPositions[row][col];

            if (Input.GetButtonDown("Submit"))
            {
                StartCoroutine(Confirm(index));
            }

            break;


        case CommandMenus.Item:
            batTran = gameObject.GetComponent <BattleTransitions>();

            // Reminder: Row refers to y coordinate, and col refers to x coordinate.
            // Move vertically through the Combo
            if (Input.GetKeyDown(KeyCode.DownArrow) && row > 0)
            {
                row--;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow) && row < 2)
            {
                row++;
            }

            // Move horizontally through the Item menu.
            if (Input.GetKeyDown(KeyCode.LeftArrow) && col > 0)
            {
                col--;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow) && col < 6)
            {
                col++;
            }

            // If we have a combo unlocked, we can then display its information in the relevant panels.
            index = 0;

            // First, determine the index in a single-dimension array of what we have selected. It's fairly simple, thankfully, so a simple switch statement is all that's necessary.
            switch (row)
            {
            case 0:
                index = 14 + col;
                break;

            case 1:
                index = 7 + col;
                break;

            case 2:
                index = col;
                break;
            }

            if (batTran.itemsUnlocked[index])
            {
                infoTextSlot.text = itemInfoText[row][col];
            }
            else
            {
                infoTextSlot.text = "Much like someone you know, there's nothing of substance here.";
            }

            // Move the indicator to its corresponding item.
            Indicator.transform.localPosition = comboPositions[row][col];
            break;
        }


        StartCoroutine(MenuNavigation()); // As this is a recursive function, call itself. It should be stopped whenever a new menu state is introduced.
    }