示例#1
0
    // Called whenever we enter a meatlocker. Determines conversation choice order, saves the game, refills health, and offers fast travel...eventually.
    public IEnumerator MeatLockerEvent(Dialogue dia)
    {
        bool end = false;

        // Wait until we've selected a choice. This is whether or not we use the meat locker to begin with. 1 = yes, 2 = no.
        yield return(new WaitUntil(() => narrMan.choiceMade));

        if (narrMan.choiceSelected == 1)
        {
            // Before saving the game, restore our health. Then, check our meat locker list; if this meat locker has not yet been used, add it to the list. Either way, adjust our last visited meat locker to its index.
            battTran.playerHealth = battTran.playerHealthMax;

            if (!meatLockerList.Contains(SceneManager.GetActiveScene().name))
            {
                meatLockerList.Add(SceneManager.GetActiveScene().name);
            }

            for (int i = 0; i < meatLockerList.Count; i++)
            {
                if (meatLockerList[i] == SceneManager.GetActiveScene().name)
                {
                    meatLockerIndex = i;
                    meatLockerPos   = player.transform.position;
                    i = meatLockerList.Count;
                }
            }

            // Add ingredients we're missing here. Break the loop if we don't have ingredients past a certain point unlocked.
            for (int i = 0; i < battTran.ingredients.Length; i++)
            {
                if (battTran.ingUnlocked[i] && battTran.ingredients[i] == 0)
                {
                    battTran.ingredients[i] = 1;
                }
            }

            // We want to play the animation for climbing in here; We'll need to make it so that dialogue can't progress until the animation ends and saving is done.

            //Okay, actually save once we're inside the meat locker.
            StartCoroutine(SaveGame());
        }
        else if (narrMan.choiceSelected == 2)
        {
            // We cancel the current dialogue and replace it with a new "You refused" piece of dialogue.
            diaHold.CancelDialogue(false);
            yield return(new WaitUntil(() => narrMan.dbChoiceSS));

            diaHold.StartCoroutine(diaHold.GenericInteractableNew(refuseDialogue, this.gameObject, false));
            end = true;
            narrMan.choiceSelected = 0;
        }

        // Wait until we've selected a second choice. This determines fast travel. Alternatively, skip this if we need to end now.
        yield return(new WaitUntil(() => !narrMan.choiceMade || end));

        yield return(new WaitUntil(() => narrMan.choiceMade || end));

        if (narrMan.choiceSelected == 1)
        {
            // For now, this loads our game.
            StartCoroutine(LoadGame(false));
        }
        else if (narrMan.choiceSelected == 2)
        {
            diaHold.CancelDialogue(true);
            yield return(new WaitUntil(() => narrMan.dbChoiceSS));
            //diaHold.StartCoroutine(diaHold.GenericInteractableNew(refuseDialogue));
        }
        yield return(null);
    }