//void showOptions(DialogueDetail detail)
    //{
    //    optionsParent.SetActive(true);

    //    for (int i = 0; i < optionsParent.transform.childCount; ++i)
    //    {
    //        Destroy(optionsParent.transform.GetChild(i).gameObject);
    //    }


    //    int index = 0;
    //    foreach (var option in detail.options)
    //    {
    //        var optionsObj = Instantiate(optionsObject,optionsParent.transform);
    //        int tempIndex = index;
    //        optionsObj.AddComponent<Button>().onClick.AddListener(() =>
    //        {
    //            optionsParent.SetActive(false);
    //            _currentDialogueIndex = tempIndex;
    //            var dialogue = detail.dialogues[tempIndex];
    //            drawDialogueText(dialogue);
    //        });
    //        ++index;
    //        optionsObj.GetComponentInChildren<TextMeshProUGUI>().text = option;
    //    }
    //}

    Sprite getSpriteForChara(DialogueDetail detail)
    {
        var foldername = detail.chara;
        var em         = detail.emotions[_currentDialogueIndex];

        var sprite = Resources.Load <Sprite>("Avatars/" + foldername + "/" + em);

        if (sprite == null)
        {
            sprite = Resources.Load <Sprite>("Avatars/" + foldername + "/normal");
        }

        return(sprite);
    }
Example #2
0
    public void DisplayNextSentence()
    {
        if (details.Count == 0)
        {
            EndDialogue();
            return;
        }
        DialogueDetail detail = details.Dequeue();
        AudioClip      sound  = detail.sound;

        Camera.main.GetComponent <AudioSource>().clip = sound;
        Camera.main.GetComponent <AudioSource>().Play();
        StopAllCoroutines();
        StartCoroutine(TypeSentence(detail));
    }
Example #3
0
    IEnumerator TypeSentence(DialogueDetail detail)
    {
        if (detail.needSelection)
        {
            Contiune.gameObject.SetActive(false);
        }
        else
        {
            Contiune.gameObject.SetActive(true);
        }
        DialogueText.text = "";
        string sentence = LanguageControl.GetValue(detail.key);

        foreach (char letter in sentence.ToCharArray())
        {
            DialogueText.text += letter;
            yield return(new WaitForSeconds(0.05f));
        }

        if (detail.needSelection)
        {
            animator.SetBool("ShowChoice", true);
            choice1.SetText(detail.choice1);
            choice1.name = detail.targetID1.ToString();
            choice2.SetText(detail.choice2);
            choice2.name = detail.targetID2.ToString();
        }

        switch (detail.key)//为了关闭phone call按钮
        {
        case "reporter7":
        case "bmf4":
            SendEvent(Const.E_DialogEnd);
            break;
        }
    }