상속: MonoBehaviour
예제 #1
0
    static int get_isActive(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TypewriterEffect obj = (TypewriterEffect)o;
            bool             ret = obj.isActive;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isActive on a nil value"));
        }
    }
예제 #2
0
    static int get_scrollView(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TypewriterEffect obj = (TypewriterEffect)o;
            UIScrollView     ret = obj.scrollView;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index scrollView on a nil value"));
        }
    }
예제 #3
0
    static int get_onFinished(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TypewriterEffect obj = (TypewriterEffect)o;
            System.Collections.Generic.List <EventDelegate> ret = obj.onFinished;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onFinished on a nil value"));
        }
    }
예제 #4
0
    static int get_delayOnNewLine(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            TypewriterEffect obj = (TypewriterEffect)o;
            float            ret = obj.delayOnNewLine;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index delayOnNewLine on a nil value"));
        }
    }
    public void SetText(string text, string icon, int type, string soundName)
    {
        if (mShowText != null)
        {
            mShowText.text = text;
            if (mTypewriterEffect == null)
            {
                mTypewriterEffect = mShowText.gameObject.GetComponent <TypewriterEffect>();
            }
            mTypewriterEffect.EnabledTypewriter();
            mTypewriterEffect.TypeWriteStopEvent += OnTypeWriteStopEvent;

            if (soundName != "")
            {
                mDialogSoundSource = Globals.Instance.MSoundManager.PlayTaskSoundEffect("Sounds/TaskSound/" + soundName);
            }
        }
    }
예제 #6
0
 private void Awake()
 {
     Transform transform = base.transform.FindChild("DialogBg");
     this.content = transform.FindChild("Label").GetComponent<UILabel>();
     this.contentEffect = Tools.GetSafeComponent<TypewriterEffect>(this.content.gameObject);
     EventDelegate.Add(this.contentEffect.onFinished, new EventDelegate.Callback(this.InfoEffectEnd));
     this.contentEffect.enabled = false;
     this.name0 = transform.FindChild("name0").GetComponent<UILabel>();
     this.name1 = transform.FindChild("name1").GetComponent<UILabel>();
     this.slot0 = this.name0.transform.FindChild("slot");
     this.slot1 = this.name1.transform.FindChild("slot");
     this.nextBtn = transform.FindChild("NextBtn").gameObject;
     this.nextBtn.SetActive(false);
     UIEventListener expr_104 = UIEventListener.Get(base.transform.FindChild("FadeBG").gameObject);
     expr_104.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(expr_104.onClick, new UIEventListener.VoidDelegate(this.OnFadeBGClick));
     GamePadMgr.RegClickDelegate(268435455, new GamePadMgr.VoidDelegate(this.ProcessFadeBGClick));
     base.gameObject.SetActive(false);
 }
예제 #7
0
    void StoryReader()
    {
        next = false;
        touchText.SetActive(false);
        storytext = "";

        if (GameObject.Find("Label(Clone)") != null)
        {
            UILabel ula = GameObject.Find("Label(Clone)").GetComponent <UILabel> ();
            ula.GetComponent <TypewriterEffect> ().enabled = false;
            ula.transform.parent = parentobj.transform;

//NGUITools.AddChild(parentobj, ula);
            grid.Reposition();
        }
        ;

        var parent = GameObject.Find("LParent");

        if (nowpage >= maxpage)
        {
            /*Debug.Log ("BUCK!!");
             * nowpage = 0;
             * next = true;*/
            Application.LoadLevel("CharaSelect");
            return;
        }

        NGUITools.AddChild(parent, labelobj);
        UILabel ul = GameObject.Find("Label(Clone)").GetComponent <UILabel> ();

        ul.gameObject.SetActive(false);
        storytext = story.Storys [nowpage];
        ul.text   = storytext;

        nowpage++;

        TypewriterEffect te = ul.GetComponent <TypewriterEffect> ();

        EventDelegate.Set(te.onFinished, onFinishTweenAlpha);
        StartCoroutine("DelayMethod", ul);
    }
예제 #8
0
    protected override void OnAwake()
    {
        Transform pivot = transform.Find("Pivot");

        btnReceive        = pivot.Find("Btn_Receive").gameObject;
        btnContinue       = pivot.Find("Btn_Continue").gameObject;
        mTalkContent      = pivot.Find("Content").GetComponent <UILabel>();
        mTypewriterEffect = mTalkContent.GetComponent <TypewriterEffect>();
        mTalkModelParents[ETaskDialogPos.TYPE_LF] = pivot.Find("LF");
        mTalkModelParents[ETaskDialogPos.TYPE_RT] = pivot.Find("RT");
        mRewardsTrans = pivot.Find("Rewards");
        for (int i = 1; i <= 2; i++)
        {
            Transform p   = mRewardsTrans.Find("Moneys/" + i);
            ItemMoney tab = new ItemMoney();
            tab.moneyTexture = p.Find("Texture").GetComponent <UITexture>();
            tab.moneyNum     = p.Find("Num").GetComponent <UILabel>();
            mMoneys.Add(tab);
        }
    }
예제 #9
0
 public void Finish()
 {
     if (this.mActive)
     {
         this.mActive = false;
         if (!this.mReset)
         {
             this.mCurrentOffset = this.mFullText.get_Length();
             this.mFade.Clear();
             this.mLabel.text = this.mFullText;
         }
         if (this.keepFullDimensions && this.scrollView != null)
         {
             this.scrollView.UpdatePosition();
         }
         TypewriterEffect.current = this;
         EventDelegate.Execute(this.onFinished);
         TypewriterEffect.current = null;
     }
 }
예제 #10
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        NGUIEditorTools.SetLabelWidth(120f);

        serializedObject.Update();

        NGUIEditorTools.DrawProperty(serializedObject, "charsPerSecond");
        NGUIEditorTools.DrawProperty(serializedObject, "fadeInTime");
        NGUIEditorTools.DrawProperty(serializedObject, "delayOnPeriod");
        NGUIEditorTools.DrawProperty(serializedObject, "delayOnNewLine");
        NGUIEditorTools.DrawProperty(serializedObject, "scrollView");
        NGUIEditorTools.DrawProperty(serializedObject, "keepFullDimensions");

        TypewriterEffect tw = target as TypewriterEffect;

        NGUIEditorTools.DrawEvents("On Finished", tw, tw.onFinished);

        serializedObject.ApplyModifiedProperties();
    }
예제 #11
0
 public void Finish()
 {
     if (this.mActive)
     {
         this.mActive = false;
         if (!this.mReset)
         {
             this.mCurrentOffset = this.mFullText.Length;
             this.mFade.Clear();
             this.mLabel.text = this.mFullText;
         }
         if (this.keepFullDimensions && this.scrollView != null)
         {
             this.scrollView.UpdatePosition();
         }
         TypewriterEffect.current = this;
         EventDelegate.Execute(this.onFinished);
         TypewriterEffect.current = null;
     }
 }
예제 #12
0
 public void Finish()
 {
     if (mActive)
     {
         mActive = false;
         if (!mReset)
         {
             mCurrentOffset = mFullText.Length;
             mFade.Clear();
             mLabel.text = mFullText;
         }
         if (keepFullDimensions && scrollView != null)
         {
             scrollView.UpdatePosition();
         }
         current = this;
         EventDelegate.Execute(onFinished);
         current = null;
     }
 }
예제 #13
0
 void BtnClick_OnClickEventHandler(UIButton sender)
 {
     m_iTipIndex++;
     if (m_iTipIndex >= m_lStrTalks.Count)
     {
         WndManager.DestoryDialog <NpcTalksWnd>();
         if (m_iWndType == 1)   //开启进入战斗按钮
         {
             ViewStageWnd wnd = WndManager.FindDialog <ViewStageWnd>();
             if (wnd != null)
             {
                 wnd.MyHead.btnCombat.enabled = true;
                 CmCarbon.StartTalkOver       = true;
             }
             if (m_finishCallBack != null)
             {
                 m_finishCallBack();
             }
         }
     }
     else
     {
         if (m_iWndType == 1)
         {
             SetWndDirection(m_lWndDirs[m_iTipIndex]);
             NGUIUtil.Set2DSprite(MyHead.Spr2dNpcHead, "Textures/npc/", m_lNpcID[m_iTipIndex]);
         }
         NGUIUtil.SetLableText(MyHead.LblTalkDesc, m_lStrTalks[m_iTipIndex]);
         TypewriterEffect twe = MyHead.LblTalkDesc.gameObject.GetComponent <TypewriterEffect>();
         if (twe == null)
         {
             MyHead.LblTalkDesc.gameObject.AddComponent <TypewriterEffect>();
         }
         else     //修复第二次打字效果不触发的问题
         {
             DestroyImmediate(twe);
             MyHead.LblTalkDesc.gameObject.AddComponent <TypewriterEffect>();
         }
     }
 }
예제 #14
0
    // 启动打字机
    private void StartEffect()
    {
        TypewriterEffect title = mTitleEffect.GetComponent("TypewriterEffect") as TypewriterEffect;

        if (title != null)
        {
            title.ReStart();
        }
        else
        {
            mTitleEffect.AddComponent("TypewriterEffect");
        }

        TypewriterEffect content = mContentEffect.GetComponent("TypewriterEffect") as TypewriterEffect;

        if (content != null)
        {
            content.ReStart();
        }
        else
        {
            mContentEffect.AddComponent("TypewriterEffect");
        }
    }
예제 #15
0
 private void Update()
 {
     if (!this.mActive)
     {
         return;
     }
     if (this.mReset)
     {
         this.mCurrentOffset = 0;
         this.mReset = false;
         this.mLabel = base.GetComponent<UILabel>();
         this.mFullText = this.mLabel.processedText;
         this.mFade.Clear();
         if (this.keepFullDimensions && this.scrollView != null)
         {
             this.scrollView.UpdatePosition();
         }
     }
     while (this.mCurrentOffset < this.mFullText.Length && this.mNextChar <= RealTime.time)
     {
         int num = this.mCurrentOffset;
         this.charsPerSecond = Mathf.Max(1, this.charsPerSecond);
         while (NGUIText.ParseSymbol(this.mFullText, ref this.mCurrentOffset))
         {
         }
         this.mCurrentOffset++;
         if (this.mCurrentOffset > this.mFullText.Length)
         {
             break;
         }
         float num2 = 1f / (float)this.charsPerSecond;
         char c = (num >= this.mFullText.Length) ? '\n' : this.mFullText[num];
         if (c == '\n')
         {
             num2 += this.delayOnNewLine;
         }
         else if (num + 1 == this.mFullText.Length || this.mFullText[num + 1] <= ' ')
         {
             if (c == '.')
             {
                 if (num + 2 < this.mFullText.Length && this.mFullText[num + 1] == '.' && this.mFullText[num + 2] == '.')
                 {
                     num2 += this.delayOnPeriod * 3f;
                     num += 2;
                 }
                 else
                 {
                     num2 += this.delayOnPeriod;
                 }
             }
             else if (c == '!' || c == '?')
             {
                 num2 += this.delayOnPeriod;
             }
         }
         if (this.mNextChar == 0f)
         {
             this.mNextChar = RealTime.time + num2;
         }
         else
         {
             this.mNextChar += num2;
         }
         if (this.fadeInTime != 0f)
         {
             TypewriterEffect.FadeEntry item = default(TypewriterEffect.FadeEntry);
             item.index = num;
             item.alpha = 0f;
             item.text = this.mFullText.Substring(num, this.mCurrentOffset - num);
             this.mFade.Add(item);
         }
         else
         {
             this.mLabel.text = ((!this.keepFullDimensions) ? this.mFullText.Substring(0, this.mCurrentOffset) : (this.mFullText.Substring(0, this.mCurrentOffset) + "[00]" + this.mFullText.Substring(this.mCurrentOffset)));
             if (!this.keepFullDimensions && this.scrollView != null)
             {
                 this.scrollView.UpdatePosition();
             }
         }
     }
     if (this.mFade.size != 0)
     {
         int i = 0;
         while (i < this.mFade.size)
         {
             TypewriterEffect.FadeEntry value = this.mFade[i];
             value.alpha += RealTime.deltaTime / this.fadeInTime;
             if (value.alpha < 1f)
             {
                 this.mFade[i] = value;
                 i++;
             }
             else
             {
                 this.mFade.RemoveAt(i);
             }
         }
         if (this.mFade.size == 0)
         {
             if (this.keepFullDimensions)
             {
                 this.mLabel.text = this.mFullText.Substring(0, this.mCurrentOffset) + "[00]" + this.mFullText.Substring(this.mCurrentOffset);
             }
             else
             {
                 this.mLabel.text = this.mFullText.Substring(0, this.mCurrentOffset);
             }
         }
         else
         {
             StringBuilder stringBuilder = new StringBuilder();
             for (int j = 0; j < this.mFade.size; j++)
             {
                 TypewriterEffect.FadeEntry fadeEntry = this.mFade[j];
                 if (j == 0)
                 {
                     stringBuilder.Append(this.mFullText.Substring(0, fadeEntry.index));
                 }
                 stringBuilder.Append('[');
                 stringBuilder.Append(NGUIText.EncodeAlpha(fadeEntry.alpha));
                 stringBuilder.Append(']');
                 stringBuilder.Append(fadeEntry.text);
             }
             if (this.keepFullDimensions)
             {
                 stringBuilder.Append("[00]");
                 stringBuilder.Append(this.mFullText.Substring(this.mCurrentOffset));
             }
             this.mLabel.text = stringBuilder.ToString();
         }
     }
     else if (this.mCurrentOffset == this.mFullText.Length)
     {
         TypewriterEffect.current = this;
         EventDelegate.Execute(this.onFinished);
         TypewriterEffect.current = null;
         this.mActive = false;
     }
 }
예제 #16
0
    // Use this for initialization
    void Start()
    {
        dialogTypewriter = dialogText.gameObject.GetComponent <TypewriterEffect>();

        HideDialog();
    }
예제 #17
0
 private void OnEnable()
 {
     text = (TypewriterEffect)target;
 }
예제 #18
0
 // Use this for initialization
 void Start()
 {
     typewriter = GetComponent <TypewriterEffect>();
     label      = GetComponent <UILabel>();
     scrollView = transform.parent.GetComponent <UIScrollView>();
 }
예제 #19
0
    private IEnumerator DoAddMessage(string name, string msg, StoryDirector.POS tail_dir, StoryDirector.MSG_TYPE msg_type)
    {
        typewriter = null;
        Transform table_t     = GetCtrl(UI.TBL_MESSAGE);
        string    prefab_name = "StoryMessageItem0";

        if (msg_type == StoryDirector.MSG_TYPE.MONOLOGUE)
        {
            prefab_name = "StoryMessageItem1";
        }
        Transform message_item_t = Realizes(prefab_name, table_t, true);

        message_item_t.SetSiblingIndex(0);
        UIWidget message_item_w = message_item_t.GetComponent <UIWidget>();

        lastMessageItem   = message_item_t;
        balloon           = base.GetComponent <UISprite>(message_item_t, (Enum)UI.SPR_BALLOON);
        tailLeft          = FindCtrl(message_item_t, UI.SPR_TAIL_L);
        tailRight         = FindCtrl(message_item_t, UI.SPR_TAIL_R);
        tailCenter        = FindCtrl(message_item_t, UI.SPR_TAIL_C);
        nameLabel         = base.GetComponent <UILabel>(message_item_t, (Enum)UI.LBL_NAME);
        messageLabel      = base.GetComponent <UILabel>(message_item_t, (Enum)UI.LBL_MESSAGE);
        initBaseHeight    = message_item_w.height;
        messageLabel.text = " ";
        initMessageHeight = messageLabel.height;
        messageHeight     = initMessageHeight;
        string temp = string.Empty;

        if (messageLabel.Wrap(msg, out temp))
        {
            msg = WordWrap.Convert(messageLabel, msg);
        }
        SetLastMessageFocus(true);
        SetMessageDragEnabled(false);
        if (msg_type == StoryDirector.MSG_TYPE.NORMAL)
        {
            if (tailLeft != null && tail_dir != StoryDirector.POS.LEFT)
            {
                tailLeft.get_gameObject().SetActive(false);
            }
            if (tailRight != null && tail_dir != StoryDirector.POS.RIGHT)
            {
                tailRight.get_gameObject().SetActive(false);
            }
            if (tailCenter != null && tail_dir != StoryDirector.POS.CENTER)
            {
                tailCenter.get_gameObject().SetActive(false);
            }
            nameLabel.text = name;
        }
        UIWidget next_arrow_w = base.GetComponent <UIWidget>((Enum)UI.SPR_NEXT);

        next_arrow_w.get_gameObject().SetActive(false);
        List <UITweener> tweens = new List <UITweener>();

        message_item_t.GetComponentsInChildren <UITweener>(tweens);
        while (tweens.Find((UITweener o) => o.get_enabled()) != null)
        {
            yield return((object)null);
        }
        SoundManager.PlaySystemSE(SoundID.UISE.POPUP, 1f);
        messageLabel.text         = msg;
        typewriter                = messageLabel.get_gameObject().AddComponent <TypewriterEffect>();
        typewriter.charsPerSecond = StoryDirector.SPEED_TYPEWRITER;
        typewriter.ResetToBeginning();
        while (typewriter.isActive)
        {
            yield return((object)null);
        }
        yield return((object)null);

        next_arrow_w.get_gameObject().SetActive(true);
        Vector3[] message_corners    = message_item_w.worldCorners;
        Vector3[] next_arrow_corners = next_arrow_w.worldCorners;
        ((UIRect)next_arrow_w).SetAnchor(null);
        next_arrow_w.cachedTransform.set_position(new Vector3((next_arrow_corners[0].x + next_arrow_corners[2].x) * 0.5f, message_corners[0].y - (next_arrow_corners[1].y - next_arrow_corners[0].y) * 0.5f, next_arrow_corners[0].z));
        SetMessageDragEnabled(true);
        Object.Destroy(typewriter);
        typewriter    = null;
        messageHeight = 0;
        messageNum++;
        coroutine = null;
    }
예제 #20
0
 private void Update()
 {
     if (!this.mActive)
     {
         return;
     }
     if (this.mReset)
     {
         this.mCurrentOffset = 0;
         this.mReset         = false;
         this.mLabel         = base.GetComponent <UILabel>();
         this.mFullText      = this.mLabel.processedText;
         this.mFade.Clear();
         if (this.keepFullDimensions && this.scrollView != null)
         {
             this.scrollView.UpdatePosition();
         }
     }
     if (string.IsNullOrEmpty(this.mFullText))
     {
         return;
     }
     while (this.mCurrentOffset < this.mFullText.get_Length() && this.mNextChar <= RealTime.time)
     {
         int num = this.mCurrentOffset;
         this.charsPerSecond = Mathf.Max(1, this.charsPerSecond);
         if (this.mLabel.supportEncoding)
         {
             while (NGUIText.ParseSymbol(this.mFullText, ref this.mCurrentOffset))
             {
             }
         }
         this.mCurrentOffset++;
         if (this.mCurrentOffset > this.mFullText.get_Length())
         {
             break;
         }
         float num2 = 1f / (float)this.charsPerSecond;
         char  c    = (num < this.mFullText.get_Length()) ? this.mFullText.get_Chars(num) : '\n';
         if (c == '\n')
         {
             num2 += this.delayOnNewLine;
         }
         else if (num + 1 == this.mFullText.get_Length() || this.mFullText.get_Chars(num + 1) <= ' ')
         {
             if (c == '.')
             {
                 if (num + 2 < this.mFullText.get_Length() && this.mFullText.get_Chars(num + 1) == '.' && this.mFullText.get_Chars(num + 2) == '.')
                 {
                     num2 += this.delayOnPeriod * 3f;
                     num  += 2;
                 }
                 else
                 {
                     num2 += this.delayOnPeriod;
                 }
             }
             else if (c == '!' || c == '?')
             {
                 num2 += this.delayOnPeriod;
             }
         }
         if (this.mNextChar == 0f)
         {
             this.mNextChar = RealTime.time + num2;
         }
         else
         {
             this.mNextChar += num2;
         }
         if (this.fadeInTime != 0f)
         {
             TypewriterEffect.FadeEntry item = default(TypewriterEffect.FadeEntry);
             item.index = num;
             item.alpha = 0f;
             item.text  = this.mFullText.Substring(num, this.mCurrentOffset - num);
             this.mFade.Add(item);
         }
         else
         {
             this.mLabel.text = (this.keepFullDimensions ? (this.mFullText.Substring(0, this.mCurrentOffset) + "[00]" + this.mFullText.Substring(this.mCurrentOffset)) : this.mFullText.Substring(0, this.mCurrentOffset));
             if (!this.keepFullDimensions && this.scrollView != null)
             {
                 this.scrollView.UpdatePosition();
             }
         }
     }
     if (this.mCurrentOffset >= this.mFullText.get_Length())
     {
         this.mLabel.text         = this.mFullText;
         TypewriterEffect.current = this;
         EventDelegate.Execute(this.onFinished);
         TypewriterEffect.current = null;
         this.mActive             = false;
         return;
     }
     if (this.mFade.size != 0)
     {
         int i = 0;
         while (i < this.mFade.size)
         {
             TypewriterEffect.FadeEntry fadeEntry = this.mFade[i];
             fadeEntry.alpha += RealTime.deltaTime / this.fadeInTime;
             if (fadeEntry.alpha < 1f)
             {
                 this.mFade[i] = fadeEntry;
                 i++;
             }
             else
             {
                 this.mFade.RemoveAt(i);
             }
         }
         if (this.mFade.size == 0)
         {
             if (this.keepFullDimensions)
             {
                 this.mLabel.text = this.mFullText.Substring(0, this.mCurrentOffset) + "[00]" + this.mFullText.Substring(this.mCurrentOffset);
                 return;
             }
             this.mLabel.text = this.mFullText.Substring(0, this.mCurrentOffset);
             return;
         }
         else
         {
             StringBuilder stringBuilder = new StringBuilder();
             for (int j = 0; j < this.mFade.size; j++)
             {
                 TypewriterEffect.FadeEntry fadeEntry2 = this.mFade[j];
                 if (j == 0)
                 {
                     stringBuilder.Append(this.mFullText.Substring(0, fadeEntry2.index));
                 }
                 stringBuilder.Append('[');
                 stringBuilder.Append(NGUIText.EncodeAlpha(fadeEntry2.alpha));
                 stringBuilder.Append(']');
                 stringBuilder.Append(fadeEntry2.text);
             }
             if (this.keepFullDimensions)
             {
                 stringBuilder.Append("[00]");
                 stringBuilder.Append(this.mFullText.Substring(this.mCurrentOffset));
             }
             this.mLabel.text = stringBuilder.ToString();
         }
     }
 }
예제 #21
0
 // Start is called before the first frame update
 void Start()
 {
     TypeWriter = FindObjectOfType <TypewriterEffect>();
     BallRB     = Ball.GetComponent <Rigidbody>();
     PL2        = FindObjectOfType <PlayerLogic2>();
 }
예제 #22
0
    private void Update()
    {
        if (!mActive)
        {
            return;
        }
        if (mReset)
        {
            mCurrentOffset = 0;
            mReset         = false;
            mLabel         = GetComponent <UILabel>();
            mFullText      = mLabel.processedText;
            mFade.Clear();
            if (keepFullDimensions && scrollView != null)
            {
                scrollView.UpdatePosition();
            }
        }
        while (mCurrentOffset < mFullText.Length && mNextChar <= RealTime.time)
        {
            int num = mCurrentOffset;
            charsPerSecond = Mathf.Max(1, charsPerSecond);
            while (NGUIText.ParseSymbol(mFullText, ref mCurrentOffset))
            {
            }
            mCurrentOffset++;
            if (mCurrentOffset > mFullText.Length)
            {
                break;
            }
            float num2 = 1f / (float)charsPerSecond;
            char  c    = (num >= mFullText.Length) ? '\n' : mFullText[num];
            if (c == '\n')
            {
                num2 += delayOnNewLine;
            }
            else if (num + 1 == mFullText.Length || mFullText[num + 1] <= ' ')
            {
                switch (c)
                {
                case '.':
                    if (num + 2 < mFullText.Length && mFullText[num + 1] == '.' && mFullText[num + 2] == '.')
                    {
                        num2 += delayOnPeriod * 3f;
                        num  += 2;
                    }
                    else
                    {
                        num2 += delayOnPeriod;
                    }
                    break;

                case '!':
                case '?':
                    num2 += delayOnPeriod;
                    break;
                }
            }
            if (mNextChar == 0f)
            {
                mNextChar = RealTime.time + num2;
            }
            else
            {
                mNextChar += num2;
            }
            if (fadeInTime != 0f)
            {
                FadeEntry item = default(FadeEntry);
                item.index = num;
                item.alpha = 0f;
                item.text  = mFullText.Substring(num, mCurrentOffset - num);
                mFade.Add(item);
            }
            else
            {
                mLabel.text = ((!keepFullDimensions) ? mFullText.Substring(0, mCurrentOffset) : (mFullText.Substring(0, mCurrentOffset) + "[00]" + mFullText.Substring(mCurrentOffset)));
                if (!keepFullDimensions && scrollView != null)
                {
                    scrollView.UpdatePosition();
                }
            }
        }
        if (mFade.size != 0)
        {
            int num3 = 0;
            while (num3 < mFade.size)
            {
                FadeEntry value = mFade[num3];
                value.alpha += RealTime.deltaTime / fadeInTime;
                if (value.alpha < 1f)
                {
                    mFade[num3] = value;
                    num3++;
                }
                else
                {
                    mFade.RemoveAt(num3);
                }
            }
            if (mFade.size == 0)
            {
                if (keepFullDimensions)
                {
                    mLabel.text = mFullText.Substring(0, mCurrentOffset) + "[00]" + mFullText.Substring(mCurrentOffset);
                }
                else
                {
                    mLabel.text = mFullText.Substring(0, mCurrentOffset);
                }
                return;
            }
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < mFade.size; i++)
            {
                FadeEntry fadeEntry = mFade[i];
                if (i == 0)
                {
                    stringBuilder.Append(mFullText.Substring(0, fadeEntry.index));
                }
                stringBuilder.Append('[');
                stringBuilder.Append(NGUIText.EncodeAlpha(fadeEntry.alpha));
                stringBuilder.Append(']');
                stringBuilder.Append(fadeEntry.text);
            }
            if (keepFullDimensions)
            {
                stringBuilder.Append("[00]");
                stringBuilder.Append(mFullText.Substring(mCurrentOffset));
            }
            mLabel.text = stringBuilder.ToString();
        }
        else if (mCurrentOffset == mFullText.Length)
        {
            current = this;
            EventDelegate.Execute(onFinished);
            current = null;
            mActive = false;
        }
    }
예제 #23
0
    private IEnumerator OpenQuestion()
    {
        sm.SetBGM("puzzle");
        //恢复默认位置
        QLabel.transform.localPosition       = Vector3.zero;
        QLabel.GetComponent <UILabel>().text = "Question " + reasoningEvent.num;
        QLabel.SetActive(false);
        //3 Question框打开
        questionContainer.SetActive(true);
        float t = 0, alpha = 0;

        while (t < 1)
        {
            t = Mathf.MoveTowards(t, 1, 1 / 0.5f * Time.deltaTime);
            float scale = 2 - t;
            if (t < 0.5)
            {
                alpha = t * 2;
            }
            questionContainer.transform.localScale            = new Vector3(scale, scale, 1);
            questionContainer.GetComponent <UIWidget>().alpha = alpha;
            yield return(null);
        }
        yield return(new WaitForSeconds(0.2f));

        //显示question 并闪烁
        QLabel.SetActive(true);
        for (int i = 0; i < 4; i++)
        {
            QLabel.GetComponent <UILabel>().color = Color.gray;
            yield return(new WaitForSeconds(0.1f));

            QLabel.GetComponent <UILabel>().color = Color.white;
            yield return(new WaitForSeconds(0.1f));
        }
        //移动Qustion到指定位置
        t = 0;
        while (t < 1)
        {
            t = Mathf.MoveTowards(t, 1, 1 / 0.2f * Time.deltaTime);
            float x = t * -360;
            QLabel.transform.localPosition = new Vector3(x, QLabel.transform.localPosition.y);
            yield return(null);
        }
        //4 题目显示
        questionLabel.GetComponent <UILabel>().text = reasoningEvent.question;
        questionLabel.SetActive(true);
        TypewriterEffect te = questionLabel.GetComponent <TypewriterEffect>();

        te.ResetToBeginning();
        while (te.isActive)
        {
            yield return(null);
        }
        yield return(new WaitForSeconds(0.5f));

        //5 选项依次显示
        StartCoroutine(ifevi ? ShowEvidence() : ShowChoice());
        //6 *血条展示
        hpmpManager.gameObject.SetActive(true);
        hpmpManager.ShowBar(true, false);
    }
예제 #24
0
 private void Start()
 {
     _typewriterEffect = GetComponent <TypewriterEffect>();
 }
예제 #25
0
	void Update ()
	{
		if (!mActive) return;

		if (mReset)
		{
			mCurrentOffset = 0;
			mReset = false;
			mLabel = GetComponent<UILabel>();
			mFullText = mLabel.processedText;
			mFade.Clear();

			if (keepFullDimensions && scrollView != null) scrollView.UpdatePosition();
		}

		while (mCurrentOffset < mFullText.Length && mNextChar <= RealTime.time)
		{
			int lastOffset = mCurrentOffset;
			charsPerSecond = Mathf.Max(1, charsPerSecond);

			// Automatically skip all symbols
			while (NGUIText.ParseSymbol(mFullText, ref mCurrentOffset)) { }
			++mCurrentOffset;

			// Reached the end? We're done.
			if (mCurrentOffset > mFullText.Length) break;

			// Periods and end-of-line characters should pause for a longer time.
			float delay = 1f / charsPerSecond;
			char c = (lastOffset < mFullText.Length) ? mFullText[lastOffset] : '\n';

			if (c == '\n')
			{
				delay += delayOnNewLine;
			}
			else if (lastOffset + 1 == mFullText.Length || mFullText[lastOffset + 1] <= ' ')
			{
				if (c == '.')
				{
					if (lastOffset + 2 < mFullText.Length && mFullText[lastOffset + 1] == '.' && mFullText[lastOffset + 2] == '.')
					{
						delay += delayOnPeriod * 3f;
						lastOffset += 2;
					}
					else delay += delayOnPeriod;
				}
				else if (c == '!' || c == '?')
				{
					delay += delayOnPeriod;
				}
			}

			if (mNextChar == 0f)
			{
				mNextChar = RealTime.time + delay;
			}
			else mNextChar += delay;

			if (fadeInTime != 0f)
			{
				// There is smooth fading involved
				FadeEntry fe = new FadeEntry();
				fe.index = lastOffset;
				fe.alpha = 0f;
				fe.text = mFullText.Substring(lastOffset, mCurrentOffset - lastOffset);
				mFade.Add(fe);
			}
			else
			{
				// No smooth fading necessary
				mLabel.text = keepFullDimensions ?
					mFullText.Substring(0, mCurrentOffset) + "[00]" + mFullText.Substring(mCurrentOffset) :
					mFullText.Substring(0, mCurrentOffset);

				// If a scroll view was specified, update its position
				if (!keepFullDimensions && scrollView != null) scrollView.UpdatePosition();
			}
		}

		// Alpha-based fading
		if (mFade.size != 0)
		{
			for (int i = 0; i < mFade.size; )
			{
				FadeEntry fe = mFade[i];
				fe.alpha += RealTime.deltaTime / fadeInTime;
				
				if (fe.alpha < 1f)
				{
					mFade[i] = fe;
					++i;
				}
				else mFade.RemoveAt(i);
			}

			if (mFade.size == 0)
			{
				if (keepFullDimensions) mLabel.text = mFullText.Substring(0, mCurrentOffset) + "[00]" + mFullText.Substring(mCurrentOffset);
				else mLabel.text = mFullText.Substring(0, mCurrentOffset);
			}
			else
			{
				StringBuilder sb = new StringBuilder();

				for (int i = 0; i < mFade.size; ++i)
				{
					FadeEntry fe = mFade[i];

					if (i == 0)
					{
						sb.Append(mFullText.Substring(0, fe.index));
					}

					sb.Append('[');
					sb.Append(NGUIText.EncodeAlpha(fe.alpha));
					sb.Append(']');
					sb.Append(fe.text);
				}

				if (keepFullDimensions)
				{
					sb.Append("[00]");
					sb.Append(mFullText.Substring(mCurrentOffset));
				}

				mLabel.text = sb.ToString();
			}
		}
		else if (mCurrentOffset == mFullText.Length)
		{
			current = this;
			EventDelegate.Execute(onFinished);
			current = null;
			mActive = false;
		}
	}
예제 #26
0
 protected override void OnStart()
 {
     speakLabel = this.GetChild("sperakLabel").GetComponent <UILabel>();
     writer     = speakLabel.GetComponent <TypewriterEffect>();
     bg         = this.GetChild("BG").gameObject;
 }
예제 #27
0
 private void Awake()
 {
     Instance = this;
     uiText   = GetComponent <Text>();
 }
예제 #28
0
    private void OnGUI()
    {
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.Space();

        /*
         *
         * ALL IMAGE RELATED STUFF HANDLED BELOW THE CUT
         * The user will simply choose the shader of their choice, drop it into the object field and use the button to assign the shader.
         * Using toggles to choose between different shaders proved to not be a useful way to assign shaders to game objects.
         * Scripts to handle the shader animation during game mode... leave the user to add the script component themselves?
         * Or add toggles to have the user choose the proper script?
         *
         */

        EditorGUILayout.LabelField("Image effects", EditorStyles.boldLabel);

        EditorGUILayout.HelpBox("To apply shader effects to your image or game object, please put it in the appropriate field below. Then select a shader material and put it in the appropriate field below. Pre-made shaders will also come with a script. Imported or custom shaders will not have scripts applied since there aren't any pre-made scripts available.", MessageType.Info);
        EditorGUILayout.Space();
        img   = (Image)EditorGUILayout.ObjectField("Image content", img, typeof(Image), true);
        media = (GameObject)EditorGUILayout.ObjectField("Media content", media, typeof(GameObject), true);
        mat   = (Material)EditorGUILayout.ObjectField("Material", mat, typeof(Material), true);
        EditorGUILayout.Space();
        if (GUILayout.Button("Apply shader"))
        {
            /*
             *
             * This section handles shaders for image objects
             *
             */

            if (img)
            {
                img.material = mat;
                GameObject go = img.gameObject;

                if (mat.name == "bubble")
                {
                    if (go.GetComponent <bubbleScript>() == null)
                    {
                        go.AddComponent <bubbleScript>();
                    }
                }

                else if (mat.name == "checkerboard")
                {
                    if (go.GetComponent <checkerboardScript>() == null)
                    {
                        go.AddComponent <checkerboardScript>();
                    }
                }

                else if (mat.name == "corrode")
                {
                    if (go.GetComponent <corrodeScript>() == null)
                    {
                        go.AddComponent <corrodeScript>();
                    }
                }

                else if (mat.name == "dissolve1")
                {
                    if (go.GetComponent <dissolve1Script>() == null)
                    {
                        go.AddComponent <dissolve1Script>();
                    }
                }

                else if (mat.name == "Dissolve2")
                {
                    if (go.GetComponent <dissolve2Script>() == null)
                    {
                        go.AddComponent <dissolve2Script>();
                    }
                }

                else if (mat.name == "frost")
                {
                    if (go.GetComponent <frostScript>() == null)
                    {
                        go.AddComponent <frostScript>();
                    }
                }

                else if (mat.name == "lines")
                {
                    if (go.GetComponent <linesScript>() == null)
                    {
                        go.AddComponent <linesScript>();
                    }
                }

                else
                {
                    return;
                }

                EditorUtility.SetDirty(img);
            }

            /*
             *
             * This section handles shaders for other applicable gameobjects
             *
             */

            if (media)
            {
                Renderer rend = media.GetComponent <Renderer>();
                rend.material = mat;

                if (mat.name == "bubble")
                {
                    if (media.GetComponent <bubbleScript>() == null)
                    {
                        media.AddComponent <bubbleScript>();
                    }
                }

                else if (mat.name == "checkerboard")
                {
                    if (media.GetComponent <checkerboardScript>() == null)
                    {
                        media.AddComponent <checkerboardScript>();
                    }
                }

                else if (mat.name == "corrode")
                {
                    if (media.GetComponent <corrodeScript>() == null)
                    {
                        media.AddComponent <corrodeScript>();
                    }
                }

                else if (mat.name == "dissolve1")
                {
                    if (media.GetComponent <dissolve1Script>() == null)
                    {
                        media.AddComponent <dissolve1Script>();
                    }
                }

                else if (mat.name == "Dissolve2")
                {
                    if (media.GetComponent <dissolve2Script>() == null)
                    {
                        media.AddComponent <dissolve2Script>();
                    }
                }

                else if (mat.name == "frost")
                {
                    if (media.GetComponent <frostScript>() == null)
                    {
                        media.AddComponent <frostScript>();
                    }
                }

                else if (mat.name == "lines")
                {
                    if (media.GetComponent <linesScript>() == null)
                    {
                        media.AddComponent <linesScript>();
                    }
                }

                else
                {
                    return;
                }
                EditorUtility.SetDirty(media);
            }
        }

        /*
         *
         * TEXT IMAGE RELATED STUFF HANDLED BELOW THE CUT
         * The user will simply use toggles to assign scripts to their text UI.
         * Toggles will be added to the window as additional effects are produced.
         *
         */

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Text UI", EditorStyles.boldLabel);
        EditorGUILayout.HelpBox("This section handles applying visual effects to text objects. Drop the text object that you'd like to apply a visual effect to below. To apply effects, use the toggles.", MessageType.Info);
        EditorGUILayout.Space();
        text = (GameObject)EditorGUILayout.ObjectField("Text", text, typeof(GameObject), true);

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Text effects", EditorStyles.boldLabel);


        /////////////////////////// TYPEWRITER FX ////////////////////////////
        applyTypewriter = EditorGUILayout.ToggleLeft("Apply typewriter", applyTypewriter);
        if (text)
        {
            if (applyTypewriter == true)
            {
                try
                {
                    if (text.GetComponent <TypewriterEffect>() == null)
                    {
                        text.AddComponent <TypewriterEffect>();
                        EditorUtility.SetDirty(text);
                    }
                }
                catch (UnassignedReferenceException e)
                {
                }
            }

            if (applyTypewriter == false)
            {
                try
                {
                    TypewriterEffect removing = text.GetComponent <TypewriterEffect>();
                    DestroyImmediate(removing);
                    EditorUtility.SetDirty(text);
                }
                catch (UnassignedReferenceException e)
                {
                }
            }
        }

        /////////////////////////// FADE-IN FX ////////////////////////////

        applyFadein = EditorGUILayout.ToggleLeft("Apply fade-in", applyFadein);
        if (text)
        {
            if (applyFadein == true)
            {
                if (text.GetComponent <FadeInEffect>() == null)
                {
                    text.AddComponent <FadeInEffect>();
                    EditorUtility.SetDirty(text);
                }
            }

            if (applyFadein == false)
            {
                try
                {
                    FadeInEffect removing = text.GetComponent <FadeInEffect>();
                    DestroyImmediate(removing);
                    EditorUtility.SetDirty(text);
                }
                catch (UnassignedReferenceException e)
                {
                }
            }
        }

        /////////////////////////// FADE-OUT FX ////////////////////////////

        applyFadeout = EditorGUILayout.ToggleLeft("Apply fade-out", applyFadeout);
        if (text)
        {
            if (applyFadeout == true)
            {
                if (text.GetComponent <FadeOutEffect>() == null)
                {
                    text.AddComponent <FadeOutEffect>();
                    EditorUtility.SetDirty(text);
                }
            }
            if (applyFadeout == false)
            {
                try
                {
                    FadeOutEffect removing = text.GetComponent <FadeOutEffect>();
                    DestroyImmediate(removing);
                    EditorUtility.SetDirty(text);
                }
                catch (UnassignedReferenceException e)
                {
                }
            }
        }
    }
예제 #29
0
 protected override void OnStart()
 {
     typeWriter = this.GetChild("Label").GetComponent <TypewriterEffect>();
 }
예제 #30
0
    /// <summary>
    /// 刷新技能说明处显示信息;
    /// </summary>
    void UpdateDetails(bool needTypeWriterEffect)
    {
        SkillLearnTableItem learnItem = MySkillModule.GetDetailBySkillId(CurSkillId);

        if (learnItem == null)
        {
            return;
        }

        SkillLevelTableItem levelItem = null;
        int levelId = 0;

        int lv = MySkillModule.GetSkillLvBySkillID(CurSkillId);

        if (lv < 0)
        {
            return;
        }

        skillName.text = learnItem.skill_name;

        if (lv == 0)                                //锁定状态/可解锁状态;
        {
            if (!MySkillModule.canOpen(CurSkillId)) //锁定;
            {
                skillLV.text = StringHelper.StringWithColor(FontColor.Red, "未解锁");
            }
            else
            {
                skillLV.text = "[079d6a]可解锁[-]";
            }

            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, 1);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);
            if (levelItem == null)
            {
                Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                return;
            }
            detail1.text = learnItem.skill_desc + "\n" + levelItem.skill_desc.Replace("\\n", "\n");

            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, 2);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);
            if (levelItem == null)
            {
                Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                return;
            }
            detail2.text = levelItem.skill_desc.Replace("\\n", "\n");

            needLvLb.gameObject.SetActive(true);
            int lvUpLv = SkillModule.GetPlayerLvBySkillLevelId(levelId);
            if (lvUpLv > 0)
            {
                PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                if (pdm == null)
                {
                    GameDebug.LogError("f**k");
                    return;
                }

                if (pdm.GetLevel() < lvUpLv)
                {
                    needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Red), lvUpLv);
                }
                else
                {
                    needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Green), lvUpLv);
                }
            }
            else
            {
                needLvLb.text = "";
            }
        }

        else
        {
            skillLV.text = "Lv. " + lv.ToString();

            //levelItem = MySkillModule.GetDetailByCurLvSkillID(CurSkillId, MySkillModule.GetSkillLvBySkillID(CurSkillId) - 1);
            levelId   = SkillModule.SkillLearnToLevel(CurSkillId, lv);
            levelItem = MySkillModule.GetDetailByLevelID(levelId);

            if (levelItem == null)
            {
                Debug.LogError("error le");
                return;
            }

            detail1.text = learnItem.skill_desc + "\n" + levelItem.skill_desc.Replace("\\n", "\n");

            if (MySkillModule.IsFullLv(CurSkillId))
            {
                detail2.text = StringHelper.GetString("skill_full_lv");
                needLvLb.gameObject.SetActive(false);
            }

            else
            {
                levelId   = SkillModule.SkillLearnToLevel(CurSkillId, lv + 1);
                levelItem = MySkillModule.GetDetailByLevelID(levelId);

                if (levelItem == null)
                {
                    Debug.LogError("SkillLevel表格缺少ID为" + levelId.ToString() + "的数据!");
                    return;
                }

                needLvLb.gameObject.SetActive(true);
                int lvUpLv = SkillModule.GetPlayerLvBySkillLevelId(levelId);
                if (lvUpLv > 0)
                {
                    PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                    if (pdm == null)
                    {
                        GameDebug.LogError("f**k");
                        return;
                    }

                    if (pdm.GetLevel() < lvUpLv)
                    {
                        needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Red), lvUpLv);
                    }
                    else
                    {
                        needLvLb.text = string.Format(StringHelper.GetString("skill_open_lv", FontColor.Green), lvUpLv);
                    }
                }
                else
                {
                    needLvLb.text = "";
                }

                detail2.text = levelItem.skill_desc.Replace("\\n", "\n");
            }
        }


        TypewriterEffect te1 = null, te2 = null;

        if (UIEffectManager.IsUIEffectActive <TypewriterEffect>(detail1.gameObject, ref te1))
        {
            if (needTypeWriterEffect)
            {
                te1.ReStart();
            }
            else
            {
                te1.SetProcessText();
            }
        }
        else
        {
            if (needTypeWriterEffect)
            {
                detail1.gameObject.AddMissingComponent <TypewriterEffect>();
            }
        }
        if (UIEffectManager.IsUIEffectActive <TypewriterEffect>(detail2.gameObject, ref te2))
        {
            if (needTypeWriterEffect)
            {
                te2.ReStart();
            }
            else
            {
                te2.SetProcessText();
            }
        }
        else
        {
            if (needTypeWriterEffect)
            {
                detail2.gameObject.AddMissingComponent <TypewriterEffect>();
            }
        }
    }
예제 #31
0
	/// <summary>
	/// Finish the typewriter operation and show all the text right away.
	/// </summary>

	public void Finish ()
	{
		if (mActive)
		{
			mActive = false;

			if (!mReset)
			{
				mCurrentOffset = mFullText.Length;
				mFade.Clear();
				mLabel.text = mFullText;
			}

			if (keepFullDimensions && scrollView != null)
				scrollView.UpdatePosition();

			current = this;
			EventDelegate.Execute(onFinished);
			current = null;
		}
	}
예제 #32
0
 // Start is called before the first frame update
 void Start()
 {
     s_talkRoot = this;
     Typewriter = WillTool.GetChildInDepth <Text>("Content", transform).GetComponent <TypewriterEffect>();
     FirtInit();
 }
예제 #33
0
    void Update()
    {
        if (!mActive)
        {
            return;
        }

        if (mReset)
        {
            mCurrentOffset = 0;
            mReset         = false;
            mLabel         = GetComponent <UILabel>();
            mFullText      = mLabel.processedText;
            mFade.Clear();

            if (keepFullDimensions && scrollView != null)
            {
                scrollView.UpdatePosition();
            }
        }

        while (mCurrentOffset < mFullText.Length && mNextChar <= RealTime.time)
        {
            int lastOffset = mCurrentOffset;
            charsPerSecond = Mathf.Max(1, charsPerSecond);

            // Automatically skip all symbols
            while (NGUIText.ParseSymbol(mFullText, ref mCurrentOffset))
            {
            }
            ++mCurrentOffset;

            // Reached the end? We're done.
            if (mCurrentOffset > mFullText.Length)
            {
                break;
            }

            // Periods and end-of-line characters should pause for a longer time.
            float delay = 1f / charsPerSecond;
            char  c     = (lastOffset < mFullText.Length) ? mFullText[lastOffset] : '\n';

            if (c == '\n')
            {
                delay += delayOnNewLine;
            }
            else if (lastOffset + 1 == mFullText.Length || mFullText[lastOffset + 1] <= ' ')
            {
                if (c == '.')
                {
                    if (lastOffset + 2 < mFullText.Length && mFullText[lastOffset + 1] == '.' && mFullText[lastOffset + 2] == '.')
                    {
                        delay      += delayOnPeriod * 3f;
                        lastOffset += 2;
                    }
                    else
                    {
                        delay += delayOnPeriod;
                    }
                }
                else if (c == '!' || c == '?')
                {
                    delay += delayOnPeriod;
                }
            }

            if (mNextChar == 0f)
            {
                mNextChar = RealTime.time + delay;
            }
            else
            {
                mNextChar += delay;
            }

            if (fadeInTime != 0f)
            {
                // There is smooth fading involved
                FadeEntry fe = new FadeEntry();
                fe.index = lastOffset;
                fe.alpha = 0f;
                fe.text  = mFullText.Substring(lastOffset, mCurrentOffset - lastOffset);
                mFade.Add(fe);
            }
            else
            {
                // No smooth fading necessary
                mLabel.text = keepFullDimensions ?
                              mFullText.Substring(0, mCurrentOffset) + "[00]" + mFullText.Substring(mCurrentOffset) :
                              mFullText.Substring(0, mCurrentOffset);

                // If a scroll view was specified, update its position
                if (!keepFullDimensions && scrollView != null)
                {
                    scrollView.UpdatePosition();
                }
            }
        }

        // Alpha-based fading
        if (mFade.size != 0)
        {
            for (int i = 0; i < mFade.size;)
            {
                FadeEntry fe = mFade[i];
                fe.alpha += RealTime.deltaTime / fadeInTime;

                if (fe.alpha < 1f)
                {
                    mFade[i] = fe;
                    ++i;
                }
                else
                {
                    mFade.RemoveAt(i);
                }
            }

            if (mFade.size == 0)
            {
                if (keepFullDimensions)
                {
                    mLabel.text = mFullText.Substring(0, mCurrentOffset) + "[00]" + mFullText.Substring(mCurrentOffset);
                }
                else
                {
                    mLabel.text = mFullText.Substring(0, mCurrentOffset);
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < mFade.size; ++i)
                {
                    FadeEntry fe = mFade[i];

                    if (i == 0)
                    {
                        sb.Append(mFullText.Substring(0, fe.index));
                    }

                    sb.Append('[');
                    sb.Append(NGUIText.EncodeAlpha(fe.alpha));
                    sb.Append(']');
                    sb.Append(fe.text);
                }

                if (keepFullDimensions)
                {
                    sb.Append("[00]");
                    sb.Append(mFullText.Substring(mCurrentOffset));
                }

                mLabel.text = sb.ToString();
            }
        }
        else if (mCurrentOffset == mFullText.Length)
        {
            current = this;
            EventDelegate.Execute(onFinished);
            current = null;
            mActive = false;
        }
    }
예제 #34
0
        public override void Run()
        {
            UILabel labName;
            UILabel labWords;

            //主角显示在左侧
            if (StoryConst.SELF_ID == this.npcId)
            {
                Singleton <StoryView> .Instance.LeftNPC.SetActive(true);

                Singleton <StoryView> .Instance.RightNPC.SetActive(false);

                sprNPC   = Singleton <StoryView> .Instance.LeftNPCSprite;
                labName  = Singleton <StoryView> .Instance.LeftNPCName;
                labWords = Singleton <StoryView> .Instance.LeftNPCWords;
                NPCBustMgr.Instance.GetBust(MeVo.instance.BustUrl, RoleBustLoaded);
            }
            //NPC显示在右侧
            else
            {
                Singleton <StoryView> .Instance.LeftNPC.SetActive(false);

                Singleton <StoryView> .Instance.RightNPC.SetActive(true);

                sprNPC   = Singleton <StoryView> .Instance.RightNPCSprite;
                labName  = Singleton <StoryView> .Instance.RightNPCName;
                labWords = Singleton <StoryView> .Instance.RightNPCWords;
            }

            talkWindow = Singleton <StoryView> .Instance.TalkWindow;

            //显示对话框
            if (!talkWindow.activeSelf)
            {
                talkWindow.SetActive(true);
            }

            //打字机不能重复利用,需要先删除再创建
            TypewriterEffect typewriter = labWords.GetComponent <TypewriterEffect>();

            if (null != typewriter)
            {
                GameObject.Destroy(typewriter);
            }

            //获得头像、主角名字
            string spriteName = "";
            string roleName   = "";

            if (StoryConst.SELF_ID == this.npcId)
            {
                //主角头像
                spriteName = Singleton <RoleMode> .Instance.GetPlayerHeadSpriteName(MeVo.instance.job);

                roleName = MeVo.instance.Name;
            }
            else
            {
                CreateAction action = Singleton <StoryMode> .Instance.GetCreateAction(this.npcId);

                if (null != action)
                {
                    string resourceId = action.ResourceId;

                    //为怪物
                    if (action.IsMonster)
                    {
                        SysMonsterVo vo = BaseDataMgr.instance.getSysMonsterVo(Convert.ToUInt32(resourceId));
                        if (null != vo)
                        {
                            spriteName = vo.icon.ToString();
                            roleName   = vo.name;
                        }
                    }
                    //为NPC
                    else
                    {
                        SysNpcVo vo = BaseDataMgr.instance.GetNpcVoById(Convert.ToUInt32(resourceId));
                        if (null != vo)
                        {
                            spriteName = vo.halfImgSprite;
                            roleName   = vo.name;
                        }
                    }

                    bust = action.Bust;
                }
            }

            sprNPC.atlas = Singleton <AtlasManager> .Instance.GetAtlas(AtlasManager.Header);

            sprNPC.spriteName = spriteName;
            sprNPC.SetActive(false);
            labName.text  = roleName;
            labWords.text = this.words;

            if (null != bust)
            {
                bust.SetActive(true);
                bustVisible = true;
            }

            if (delay > 0f)
            {
                vp_Timer.In(delay, Finish, 1, 0);
            }

            //增加打字效果(测试先屏蔽)
            //typewriter = labWords.gameObject.AddComponent<TypewriterEffect>();
            //typewriter.charsPerSecond = 20;
            //typewriter.DoTypeEnd = Finish;
        }