Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Vector3.Distance(this.gameObject.transform.position, player.transform.position) <= 0.2f)
        {
            if (SceneManager.GetActiveScene().name == "ChineseMinigame4")
            {
                canvas.SetActive(true);
                foreach (GameObject g in levelOverObjects)
                {
                    g.SetActive(false);
                }
                loadSceneManager.TriggerLoad("MapSelect");
            }
            else
            {
                StartCoroutine(WaitForKeyDown(KeyCode.KeypadEnter));
            }
        }

        if (timer != 0)
        {
            foreach (GameObject g in levelOverObjects)
            {
                g.SetActive(true);
            }
        }
        else
        {
            foreach (GameObject g in levelOverObjects)
            {
                g.SetActive(false);
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Sets the next dialogue on button click
    /// </summary>
    /// <param name="index">Index of next dialogue</param>
    public void OnClick(int index)
    {
        if (typer.animComplete)
        {
            UpdateKarma(currentDialogue.EndsScene);

            if (currentDialogue.ResponseCount > 1)
            {
                if (index == 0)
                {
                    goodHeart.SetActive(true);
                }

                else if (index == 1)
                {
                    badHeart.SetActive(true);
                }
            }

            Debug.Log(currentDialogue.EndsScene);
            //If this is the end of the scene, then load the next unity scene
            if (currentDialogue.EndsScene)
            {
                if (useLoadingScreen)
                {
                    loadSceneManager.TriggerLoad(nextScene);
                }
                else
                {
                    SceneManager.LoadScene(nextScene);
                }
            }
            else
            {
                //If the index is beyond the number of options, display the default option
                if (index >= currentDialogue.DialogueCount)
                {
                    index = 0;
                }

                //Display the dialogue at index and deactivate the buttons
                currentDialogue = currentDialogue.NextDialogue(index);

                if (SceneManager.GetActiveScene().name != "Intro")
                {
                    //Update speaker image accordingly
                    if (currentDialogue.Karma < -1)
                    {
                        speakerImg.sprite = speakerAngry;
                    }
                    else if (currentDialogue.Karma > 1)
                    {
                        speakerImg.sprite = speakerHappy;
                    }
                    else
                    {
                        speakerImg.sprite = speakerNeutral;
                    }
                }

                button1.SetActive(false);
                button2.SetActive(false);
                DisplayDialogue(currentDialogue);
            }
        }
    }