示例#1
0
文件: Speech.cs 项目: Silkspectre/rpg
    public void SetConversation(UnfoldedDialog a_Dialog)
    {
        Vector3 t_Scale = transform.localScale;
        Vector3 t_ScaleText = m_Text.transform.localScale;
        RectTransform t_TextRect = m_Text.GetComponent<RectTransform>();
        t_Scale.x = 1.0f;
        t_ScaleText.x = 1.0f;

        if (a_Dialog.Side == UnfoldedDialog.DialogSide.Right)
        {
            t_Scale.x *= -1;
            t_ScaleText.x *= -1;

            if(m_Text.transform.localScale.x>0)
            {
                t_TextRect.offsetMin = new Vector2(20, t_TextRect.offsetMin.y);
            }
        }

        Character t_Character = Global.Singleton.GetCharacter(a_Dialog.Name);
        if (t_Character != null)
        {
            m_Speaker.GetComponent<Image>().sprite = t_Character.Image;
        }
        else Debug.LogWarning("Cannot find Character in global scope for '" + a_Dialog.Name + "'.");

        m_Text.GetComponent<Text>().text = "<B>" + a_Dialog.Name + ":</B> " + a_Dialog.Line;

        transform.localScale = t_Scale;
        m_Text.transform.localScale = t_ScaleText;
    }
示例#2
0
文件: Dialog.cs 项目: Silkspectre/rpg
    void Start()
    {
        m_Speech = GameObject.FindGameObjectWithTag("SpeechUI").GetComponent<Speech>();
        EndConversation();

        StringReader t_Reader = new StringReader(m_DialogFile.text);

        while (true)
        {
            string t_Name = t_Reader.ReadLine();
            if (t_Name == null) break; // no more lines

            int t_Found = m_Characters.IndexOf(t_Name);
            if (t_Found == -1)
            {
                m_Characters.Add(t_Name);
                t_Found = m_Characters.Count - 1;
            }

            UnfoldedDialog.DialogSide t_Side = (t_Found % 2 == 0) ? (UnfoldedDialog.DialogSide.Left) : (UnfoldedDialog.DialogSide.Right);

            string t_Text = t_Reader.ReadLine();
            while (t_Text != null && t_Text != ".END")
            {
                UnfoldedDialog t_Dialog = new UnfoldedDialog();
                t_Dialog.Name = t_Name;
                t_Dialog.Side = t_Side;
                t_Dialog.Line = t_Text;

                m_Dialog.Add(t_Dialog);

                t_Text = t_Reader.ReadLine();
            }

        }
    }