예제 #1
0
        /// <summary>
        /// 绘制普通对话内容
        /// </summary>
        private void Draw_Content()
        {
            GUILayout.BeginVertical();

            if (!mTitle.IsNullOrEmpty())
            {
                GUILayout.Label(mTitle, mTitleStyle);
            }
            if (!mContent.IsNullOrEmpty())
            {
                if (!mSpeaker.IsNullOrEmpty())
                {
                    GUILayout.Label("[" + mSpeaker + "]: ");
                }

                GUILayout.Label(mContent, mContentStyle);
            }
            GUILayout.Space(20);

            if (GUILayout.Button("next"))
            {
                mPlayer.Next();
            }

            GUILayout.EndVertical();
        }
예제 #2
0
        private void Awake()
        {
            m_BtnBg.onClick.AddListener(() =>
            {
                m_Player.Next();
            });
            m_ChooseRoot.gameObject.SetActive(false);
            m_Player = new DialoguePlayer();

            m_Player.OnDoChoose = (choose) =>
            {
                m_ChooseRoot.gameObject.SetActive(true);
                m_ChooseBtnRoot.transform.RemoveAllChild();
                m_TxtTitle.text   = choose.GetTitle();
                m_TxtContent.text = choose.GetContent();
                var chooses = choose.Chooses;
                for (int i = 0; i < chooses.Count; i++)
                {
                    var choosePicked = chooses[i];
                    var go           = Instantiate(m_BtnPrefab.gameObject, Vector3.zero, Quaternion.identity, m_ChooseBtnRoot.transform);
                    var chooseBtn    = go.GetComponent <DramaChooseBtn>();
                    chooseBtn.Txt.text = chooses[i].Title;
                    chooseBtn.Btn.onClick.AddListener(() =>
                    {
                        m_Player.PickChoose(choosePicked);
                        m_ChooseBtnRoot.transform.RemoveAllChild();
                        m_ChooseRoot.gameObject.SetActive(false);
                    });
                }
            };

            m_Player.OnDoContent = (content) =>
            {
                m_TxtTitle.text   = content.GetTitle();
                m_TxtContent.text = content.GetContent();
            };

            m_Player.OnDoFinish = (finish) =>
            {
                m_TxtTitle.text   = "";
                m_TxtContent.text = "";
                gameObject.SetActive(false);
            };

            m_Player.PlayDialogue(m_BluePrint);
        }