示例#1
0
        /// <summary>
        /// 拡張タグイベントを取得する
        /// </summary>
        public RichText.ExtraTagEvent[] GetExtraTagEvent(params string[] tFilter)
        {
            RichText tRichText = _richText;

            if (tRichText == null)
            {
                return(null);
            }
            return(tRichText.GetExtraTagEvent(tFilter));
        }
示例#2
0
        // 文章をアニメーション表示させる
        private IEnumerator Play_Coroutine <T>(int tStartLine, int tEndLine, float tCodeTime, bool tIsAbsoluteTime, Func <RichText.ExtraTagEvent, T, IEnumerator> tOnEvent, T tObject, params string[] tFilter)
        {
            RichText tRichText = _richText;

            if (tRichText == null)
            {
                yield break;
            }

            int tLine = line;

            if (tStartLine < 0)
            {
                tStartLine = 0;
            }
            if (tStartLine > (tLine - 1))
            {
                tStartLine = (tLine - 1);
            }

            if (tEndLine < 0)
            {
                tEndLine = tLine;
            }
            if (tEndLine > tLine)
            {
                tEndLine = tLine;
            }

            if (tEndLine >= 0 && tEndLine < (tStartLine + 1))
            {
                tEndLine = (tStartLine + 1);
            }

            if (tCodeTime <= 0)
            {
                tCodeTime = 0.05f;
            }

            //----------------------------------------------------------

            m_Playing      = true;
            m_Pausing      = false;
            m_EventPausing = false;
            m_Break        = false;

            tRichText.viewControllEnabled = true;
            tRichText.lengthOfView        = -1;
            tRichText.startLineOfView     = tStartLine;
            tRichText.endLineOfView       = tEndLine;

            List <RichText.ExtraTagEvent> tEvent = new List <RichText.ExtraTagEvent>();

            RichText.ExtraTagEvent[] tEventTemporary = tRichText.GetExtraTagEvent(tFilter);

            bool f = false;

            if (tEvent != null)
            {
                int i, l = tEventTemporary.Length;
                for (i = 0; i < l; i++)
                {
                    tEvent.Add(tEventTemporary[i]);
                }

                l = tEvent.Count;
                if (l > 0)
                {
                    if (tEvent[l - 1].offset >= tRichText.endOffsetOfView)
                    {
                        // 一番最後にスベントが存在する
                        f = true;
                    }
                }
            }

            if (f == false)
            {
                // 最後の終端を追加する
                tEvent.Add(new RichText.ExtraTagEvent(tRichText.endOffsetOfView, null, null));
            }

            //----------------------------------------------------------

            // タイマー開始
            StartTimer(tIsAbsoluteTime);

            float tTime, t;

            int o = tRichText.startOffsetOfView;

            // イベントでループ
            int e;

            for (e = 0; e < tEvent.Count; e++)
            {
                //--------------------------------------------------------/

                // 1イベントあたりの文字列の表示時間
                tTime = (tEvent[e].offset - o) * tCodeTime;

                tRichText.ratioOfFade       = 0;
                tRichText.startOffsetOfFade = o;
                tRichText.endOffsetOfFade   = tEvent[e].offset;

                // 1イベントの文字列の表示ループ
                t = 0;
                while (t < tTime)
                {
                    if (m_Pausing == true)
                    {
                        // 先にポーズ中かのチェックを入れておかないと1フレーム消費して表示が激遅なる
                        yield return(new WaitWhile(() => m_Pausing == true));
                    }

                    if (m_Break == true)
                    {
                        // 強制終了
                        tRichText.ratioOfFade       = 1;
                        tRichText.startOffsetOfFade = tRichText.startOffsetOfView;
                        tRichText.endOffsetOfFade   = tRichText.endOffsetOfView;

                        m_Break   = false;
                        m_Playing = false;

                        yield break;
                    }

                    t = t + GetDeltaTime();
                    if (t > tTime)
                    {
                        t = tTime;
                    }

                    tRichText.ratioOfFade = t / tTime;

                    yield return(null);
                }

                if (string.IsNullOrEmpty(tEvent[e].tagName) == false)
                {
                    if (tOnEvent != null)
                    {
                        m_EventPausing = true;

                        // イベント用のコールバックを呼び出す
                        m_Callback = tOnEvent(tEvent[e], tObject);
                        yield return(StartCoroutine(m_Callback));

                        m_EventPausing = false;
                    }
                }

                o = tEvent[e].offset;
            }

            m_Break   = false;
            m_Playing = false;

            m_Coroutine = null;
        }