Esempio n. 1
0
    IEnumerator Opening()
    {
        // Face player if not doing so already...

        if (m_playerBehavior.gameObject.transform.position.x <
            m_npcBehavior.gameObject.transform.position.x)
        {
            var scale = m_npcBehavior.gameObject.transform.localScale;
            scale.x *= -1f;
            m_npcBehavior.gameObject.transform.localScale = scale;
        }

        m_npcBalloon.Stop();
        yield return(new WaitForSecondsRealtime(m_timeToClose));

        m_npcBalloon.Speak(RandomString(m_npcBehavior.openingLine));
        yield return(new WaitForSecondsRealtime(m_timeToRead));

        m_npcBalloon.Stop();
        yield return(new WaitForSecondsRealtime(m_timeToClose));

        StartCoroutine(PlayerResponse());
    }
Esempio n. 2
0
    IEnumerator PlayerResponse()
    {
        m_player.transform.GetChild(1).gameObject.SetActive(true);
        var interactionMenu = m_player.GetComponentInChildren <InteractionMenuLogic>();

        InteractionMenuLogic.InteractionIcon chosenAction;

        // Default spoken line is zombie noises...
        string playerLine = m_playerBehavior.zombieNoises[
            Random.Range(0, m_playerBehavior.zombieNoises.Length)];

        while (true)
        {
            float hInput = Input.GetAxisRaw("MenuHorizontal");
            float vInput = Input.GetAxisRaw("MenuVertical");

            if (hInput == -1f && vInput == 0f)
            {
                // Charm
                chosenAction = InteractionMenuLogic.InteractionIcon.Charm;
                interactionMenu.StartSelectionFX(chosenAction);
                m_dialogueIndex =
                    Random.Range(0, m_npcBehavior.charmPCLine.Length);
                playerLine = m_npcBehavior.charmPCLine[m_dialogueIndex];
                break;
            }

            if (vInput == -1f && hInput == 0f)
            {
                // Think
                chosenAction = InteractionMenuLogic.InteractionIcon.Think;
                interactionMenu.StartSelectionFX(chosenAction);
                m_dialogueIndex =
                    Random.Range(0, m_npcBehavior.thinkPCLine.Length);
                playerLine = m_npcBehavior.thinkPCLine[m_dialogueIndex];
                break;
            }

            if (hInput == 1f && vInput == 0f)
            {
                // Intimidate
                chosenAction = InteractionMenuLogic.InteractionIcon.Intimidate;
                interactionMenu.StartSelectionFX(chosenAction);
                m_dialogueIndex =
                    Random.Range(0, m_npcBehavior.intimidatePCLine.Length);
                playerLine = m_npcBehavior.intimidatePCLine[m_dialogueIndex];
                break;
            }

            if (vInput == 1f && hInput == 0f)
            {
                // Bite
                chosenAction = InteractionMenuLogic.InteractionIcon.Bite;
                interactionMenu.StartSelectionFX(chosenAction);
                m_dialogueIndex = 0;
                break;
            }
            yield return(null);
        }
        yield return(new WaitForSecondsRealtime(m_timeToSeeIconSelection));

        interactionMenu.StopSelectionFX();
        m_player.transform.GetChild(1).gameObject.SetActive(false);

        // Word balloon

        m_playerBalloon.Speak(playerLine);
        yield return(new WaitForSecondsRealtime(m_timeToRead));

        m_playerBalloon.Stop();
        yield return(new WaitForSecondsRealtime(m_timeToClose));

        EvaluatePlayerResponse(chosenAction);
    }