Esempio n. 1
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;
     }
 }
Esempio n. 2
0
 private void Update()
 {
     if (!this.mActive)
     {
         return;
     }
     if (this.mReset)
     {
         this.mCurrentOffset = 0;
         this.ff9Signal      = 0;
         this.mReset         = false;
         this.mLabel         = base.GetComponent <UILabel>();
         this.mFullText      = this.mLabel.processedText;
         this.mFade.Clear();
         if (this.keepFullDimensions && this.scrollView != (UnityEngine.Object)null)
         {
             this.scrollView.UpdatePosition();
         }
     }
     if (String.IsNullOrEmpty(this.mFullText))
     {
         return;
     }
     while (this.mCurrentOffset < this.mFullText.Length && this.mNextChar <= RealTime.time)
     {
         Int32 num = this.mCurrentOffset;
         this.charsPerSecond = (Int32)((!this.mDynamicCharsPerSecond.ContainsKey(this.mCurrentOffset)) ? Mathf.Max(1, this.charsPerSecond) : this.mDynamicCharsPerSecond[this.mCurrentOffset]);
         if (this.mWaitList.ContainsKey(this.mCurrentOffset))
         {
             if (this.mWaitList[this.mCurrentOffset] > 0f)
             {
                 Dictionary <Int32, Single> dictionary2;
                 Dictionary <Int32, Single> dictionary = dictionary2 = this.mWaitList;
                 Int32  key2;
                 Int32  key  = key2 = this.mCurrentOffset;
                 Single num2 = dictionary2[key2];
                 dictionary[key] = num2 - ((!HonoBehaviorSystem.Instance.IsFastForwardModeActive()) ? Time.deltaTime : (Time.deltaTime * (Single)FF9StateSystem.Settings.FastForwardFactor));
                 break;
             }
             this.mNextChar = RealTime.time;
         }
         Dialog.DialogImage dialogImage = (Dialog.DialogImage)null;
         if (this.mLabel.supportEncoding)
         {
             while (NGUIText.ParseSymbol(this.mFullText, ref this.mCurrentOffset, ref this.ff9Signal, ref dialogImage))
             {
             }
         }
         if (this.onCharacterFinished != null && dialogImage != null)
         {
             this.onCharacterFinished(base.gameObject, dialogImage.TextPosition);
         }
         this.mCurrentOffset++;
         if (this.mCurrentOffset > this.mFullText.Length)
         {
             break;
         }
         Single num3 = (!HonoBehaviorSystem.Instance.IsFastForwardModeActive()) ? (1f / (Single)this.charsPerSecond) : (1f / (Single)(this.charsPerSecond * FF9StateSystem.Settings.FastForwardFactor));
         Char   c    = (Char)((num >= this.mFullText.Length) ? '\n' : this.mFullText[num]);
         if (c == '\n')
         {
             num3 += 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] == '.')
                 {
                     num3 += this.delayOnPeriod * 3f;
                     num  += 2;
                 }
                 else
                 {
                     num3 += this.delayOnPeriod;
                 }
             }
             else if (c == '!' || c == '?')
             {
                 num3 += this.delayOnPeriod;
             }
         }
         if (this.mNextChar == 0f)
         {
             this.mNextChar = RealTime.time + num3;
         }
         else
         {
             this.mNextChar += num3;
         }
         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 != (UnityEngine.Object)null)
             {
                 this.scrollView.UpdatePosition();
             }
         }
     }
     if (this.mCurrentOffset >= this.mFullText.Length)
     {
         this.mLabel.text = this.mFullText;
     }
     else if (this.mFade.size != 0)
     {
         Int32 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 (Int32 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();
         }
     }
     if (this.mCurrentOffset >= this.mFullText.Length)
     {
         TypewriterEffect.current = this;
         EventDelegate.Execute(this.onFinished);
         TypewriterEffect.current = (TypewriterEffect)null;
         this.mActive             = false;
     }
 }