Inheritance: MonoBehaviour
Example #1
0
        public IconText(string t, Texture2D iconSprite, Vector2 iconSize, Vector2 position, float scale, Color color, TextAlignment alignment, TextEffect effect = TextEffect.None, float alpha = 1.0f)
            : base(position,new Vector2(0,-1),Vector2.Zero)
        {
            text = new Text(t,  position, scale, color, effect);
            icon = new DrawableAsset<Texture2D>(Vector2.Zero, new Vector2(0, -1), iconSize, iconSprite);

            this.alignment = alignment;
            UpdateAlignment();
        }
Example #2
0
 public Text(string text,  Vector2 position, float scale, Color color, TextEffect effect = TextEffect.None, float alpha = 1.0f)
     : base(position, new Vector2(1, 0), TextSettings.CurrentFont.MeasureString(text) * scale)
 {
     this.text = text;
     this.scale = this.sScale =  scale;
     this.effect = effect;
     this.mainColor = color;
     this.altColor = Color.Yellow;
     this.maxAlpha = this.alpha = alpha;
     this.rotation = 0.0f;
     this.rotationIncrement = 0.001f;
     this.currentColor = this.mainColor;
     cooldown = 3.0f;
 }
Example #3
0
 // 各種コンポーネントセット
 public void Set()
 {
     m_DialogEffect = m_Instance.GetComponent <DialogEffect>();
     m_TextEffect   = m_Instance.GetComponent <TextEffect>();
     m_GIController = m_Instance.GetComponent <RealtimeGIController>();
 }
Example #4
0
        /// <summary>
        /// Draw glyphrun
        /// </summary>
        /// <param name="drawingContext">The drawing context to draw into </param>
        /// <param name="foregroundBrush">
        /// The foreground brush of the glyphrun. Pass in "null" to draw the
        /// glyph run with the foreground in TextRunProperties.
        /// </param>
        /// <param name="glyphRun">The GlyphRun to be drawn </param>
        /// <returns>bounding rectangle of drawn glyphrun</returns>
        /// <Remarks>
        /// TextEffect drawing code may use a different foreground brush for the text.
        /// </Remarks>
        internal Rect DrawGlyphRun(
            DrawingContext drawingContext,
            Brush foregroundBrush,
            GlyphRun glyphRun
            )
        {
            Debug.Assert(_shapeable != null);

            Rect inkBoundingBox = glyphRun.ComputeInkBoundingBox();

            if (!inkBoundingBox.IsEmpty)
            {
                // glyph run's ink bounding box is relative to its origin
                inkBoundingBox.X += glyphRun.BaselineOrigin.X;
                inkBoundingBox.Y += glyphRun.BaselineOrigin.Y;
            }

            if (drawingContext != null)
            {
                int pushCount = 0;              // the number of push we do
                try
                {
                    if (_textEffects != null)
                    {
                        // we need to push in the same order as they are set
                        for (int i = 0; i < _textEffects.Count; i++)
                        {
                            // get the text effect by its index
                            TextEffect textEffect = _textEffects[i];

                            if (textEffect.Transform != null && textEffect.Transform != Transform.Identity)
                            {
                                drawingContext.PushTransform(textEffect.Transform);
                                pushCount++;
                            }

                            if (textEffect.Clip != null)
                            {
                                drawingContext.PushClip(textEffect.Clip);
                                pushCount++;
                            }

                            if (textEffect.Foreground != null)
                            {
                                // remember the out-most non-null brush
                                // this brush will be used to draw the glyph run
                                foregroundBrush = textEffect.Foreground;
                            }
                        }
                    }

                    _shapeable.Draw(drawingContext, foregroundBrush, glyphRun);
                }
                finally
                {
                    for (int i = 0; i < pushCount; i++)
                    {
                        drawingContext.Pop();
                    }
                }
            }

            return(inkBoundingBox);
        }
Example #5
0
 public void SetEffect(TextEffect e)
 {
     this.effect = e;
 }
 public void ChangeTextEffect( TextEffect ef )
 {
     textEffect = ef;
     CommitChanges();
 }
 // sets all future letters' effects
 public void switchEffect(TextEffect newEffect)
 {
     currentEffect = newEffect;
 }
 public void resetString(Vector2 startingLocation)
 {
     text = "";
     letters = new List<TextLetter> ();
     currentEffect = TextEffect.NONE;
     escaping = false;
     location = startingLocation;
 }
Example #9
0
        public FrameworkContentElementStoryboardExample()
        {
            // Create a name scope for the document.
            NameScope.SetNameScope(this, new NameScope());
            this.Background = Brushes.White;

            // Create a run of text.
            Run theText = new Run(
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." +
                "Ut non lacus. Nullam a ligula id leo adipiscing ornare." +
                " Duis mattis. ");

            // Create a TextEffect
            TextEffect animatedSpecialEffect = new TextEffect();

            animatedSpecialEffect.Foreground    = Brushes.OrangeRed;
            animatedSpecialEffect.PositionStart = 0;
            animatedSpecialEffect.PositionCount = 0;

            // Assign the TextEffect a name by
            // registering it with the page, so that
            // it can be targeted by storyboard
            // animations
            this.RegisterName("animatedSpecialEffect", animatedSpecialEffect);

            // Apply the text effect to the run.
            theText.TextEffects = new TextEffectCollection();
            theText.TextEffects.Add(animatedSpecialEffect);

            // Create a paragraph to contain the run.
            Paragraph animatedParagraph = new Paragraph(theText);

            animatedParagraph.Background = Brushes.LightGray;
            animatedParagraph.Padding    = new Thickness(20);

            this.Blocks.Add(animatedParagraph);
            BlockUIContainer controlsContainer = new BlockUIContainer();

            //
            // Create an animation and a storyboard to animate the
            // text effect.
            //
            Int32Animation countAnimation =
                new Int32Animation(0, 127, TimeSpan.FromSeconds(10));

            Storyboard.SetTargetName(countAnimation, "animatedSpecialEffect");
            Storyboard.SetTargetProperty(countAnimation,
                                         new PropertyPath(TextEffect.PositionCountProperty));
            myStoryboard = new Storyboard();
            myStoryboard.Children.Add(countAnimation);

            //
            // Create a button to start the storyboard.
            //
            Button beginButton = new Button();

            beginButton.Content = "Begin";
            beginButton.Click  += new RoutedEventHandler(beginButton_Clicked);

            controlsContainer.Child = beginButton;
            this.Blocks.Add(controlsContainer);
        }
 public void AddTextEffect(Entity entity, TextEffect textEffect)
 {
     if(_buffers.ContainsKey(entity))
         _buffers[entity].AddTextEffect(textEffect);
 }
Example #11
0
 // Start is called before the first frame update
 void Start()
 {
     creatureDown = false;
     _text        = GameObject.FindGameObjectWithTag("gametext").GetComponent <TextEffect>();
 }
Example #12
0
        private void ApplyFormat(FormatLabelElement[] Elements)
        {
            Stack bold        = new Stack();
            Stack italic      = new Stack();
            Stack underline   = new Stack();
            Stack forecolor   = new Stack();
            Stack backcolor   = new Stack();
            Stack fontsize    = new Stack();
            Stack fontname    = new Stack();
            Stack link        = new Stack();
            Stack effectcolor = new Stack();
            Stack effect      = new Stack();

            bold.Push(this.Font.Bold);
            italic.Push(this.Font.Italic);
            underline.Push(this.Font.Underline);
            forecolor.Push(this.ForeColor);
            backcolor.Push(Color.Transparent);
            fontsize.Push((int)(this.Font.Size * 1.3));
            fontname.Push(this.Font.Name);
            effect.Push(TextEffect.None);
            effectcolor.Push(Color.Black);
            link.Push(null);


            foreach (FormatLabelElement Element in Elements)
            {
                switch (Element.TagName)
                {
                case "b":
                {
                    bold.Push(true);
                    break;
                }

                case "a":
                {
                    //underline.Push (true);
                    //forecolor.Push (_l);
                    link.Push(Element);
                    break;
                }

                case "i":
                case "em":
                {
                    italic.Push(true);
                    break;
                }

                case "u":
                {
                    underline.Push(true);
                    break;
                }

                case "font":
                {
                    string _fontname    = GetAttrib("face", Element.Tag);
                    string _size        = GetAttrib("size", Element.Tag);
                    string _color       = GetAttrib("color", Element.Tag);
                    string _effectcolor = GetAttrib("effectcolor", Element.Tag);
                    string _effect      = GetAttrib("effect", Element.Tag);


                    if (_size == "")
                    {
                        fontsize.Push(fontsize.Peek());
                    }
                    else
                    {
                        fontsize.Push(int.Parse(_size));
                    }

                    if (_fontname == "")
                    {
                        fontname.Push(fontname.Peek());
                    }
                    else
                    {
                        fontname.Push(_fontname);
                    }

                    if (_color == "")
                    {
                        forecolor.Push(forecolor.Peek());
                    }
                    else
                    {
                        forecolor.Push(Color.FromName(_color));
                    }

                    if (_effectcolor == "")
                    {
                        effectcolor.Push(effectcolor.Peek());
                    }
                    else
                    {
                        effectcolor.Push(Color.FromName(_effectcolor));
                    }

                    if (_effect == "")
                    {
                        effect.Push(effect.Peek());
                    }
                    else
                    {
                        effect.Push(Enum.Parse(typeof(TextEffect), _effect, true));
                    }

                    break;
                }

                case "br":
                {
                    Element.NewLine = true;
                    break;
                }

                case "hr":
                {
                    Element.NewLine = true;
                    break;
                }

                case "h3":
                {
                    fontsize.Push((int)(this.Font.Size * 1.4));
                    bold.Push(true);
                    Element.NewLine = true;
                    break;
                }

                case "h4":
                {
                    fontsize.Push((int)(this.Font.Size * 1.2));
                    bold.Push(true);
                    Element.NewLine = true;
                    break;
                }

                case "/b":
                {
                    bold.Pop();
                    break;
                }

                case "/a":
                {
                    //underline.Pop ();
                    //forecolor.Pop ();
                    link.Pop();
                    break;
                }

                case "/i":
                case "/em":
                {
                    italic.Pop();
                    break;
                }

                case "/u":
                {
                    underline.Pop();
                    break;
                }

                case "/font":
                {
                    fontname.Pop();
                    fontsize.Pop();
                    forecolor.Pop();
                    effect.Pop();
                    effectcolor.Pop();
                    break;
                }

                case "/h3":
                {
                    fontsize.Pop();
                    bold.Pop();
                    Element.NewLine = true;
                    break;
                }

                case "/h4":
                {
                    fontsize.Pop();
                    bold.Pop();
                    Element.NewLine = true;
                    break;
                }

                default:
                {
                    break;
                }
                }


                //---------------------------------------------------------------------
                bool Bold                   = (bool)bold.Peek();
                bool Italic                 = (bool)italic.Peek();
                bool Underline              = (bool)underline.Peek();
                FormatLabelElement Link     = (FormatLabelElement)link.Peek();
                string             FontName = (string)fontname.Peek();
                int        FontSize         = (int)fontsize.Peek();
                Color      BackColor        = (Color)backcolor.Peek();
                Color      ForeColor        = (Color)forecolor.Peek();
                TextEffect Effect           = (TextEffect)effect.Peek();
                Color      EffectColor      = (Color)effectcolor.Peek();

                FontStyle fs = 0;
                if (Bold)
                {
                    fs |= FontStyle.Bold;
                }
                if (Italic)
                {
                    fs |= FontStyle.Italic;
                }
                if (Underline)
                {
                    fs |= FontStyle.Underline;
                }

                Font font = new Font(FontName, FontSize, fs);
                Element.Font        = font;
                Element.BackColor   = BackColor;
                Element.ForeColor   = ForeColor;
                Element.Link        = Link;
                Element.Effect      = Effect;
                Element.EffectColor = EffectColor;
            }
        }
Example #13
0
 public TextSystem(string fontName, ContentManager Content)
 {
     letters = new List<TextLetter> ();
     font = Content.Load<Texture2D> ("Fonts/" + fontName);
     StreamReader fontMeta = new StreamReader("Content/Fonts/" + fontName + "_meta");
     letterSize = new Vector2(int.Parse(fontMeta.ReadLine()), int.Parse(fontMeta.ReadLine()));
     fontMeta.Close();
     ra = new Random ();
     currentEffect = TextEffect.NONE;
     escaping = false;
     currentLine = 0;
     text = "";
 }
 public void AddTextEffect(TextEffect textEffect)
 {
     TextEffects.Enqueue(textEffect);
 }
Example #15
0
        /// <summary>
        /// Creates a new instance of a HappyWordAnimation. Initializes the animation based on the
        /// specified paramaters.
        /// </summary>
        /// <param name="w">The CaptionWord to base the animation off of.</param>
        /// begins.</param>
        /// <param name="t">The Textblock that this animation will be applied to.</param>
        public HappyWordAnimation(CaptionWord w, CaptionTextBlock t) : base(w, t)
        {
            //Settings dependent on intensity
            double dur         = 0;
            double scalefinish = 0;
            double yFinish     = 0;

            switch (w.Intensity)
            {
            case Intensity.Low:
                dur         = 0.75;
                scalefinish = 1.1;
                yFinish     = 20;
                break;

            case  Intensity.Medium:
                dur         = 0.65;
                scalefinish = 1.2;
                yFinish     = 40;
                break;

            case Intensity.High:
                dur         = 0.60;
                scalefinish = 1.3;
                yFinish     = 40;
                break;

            case Intensity.None:
            default:
                //TODO handle exception
                break;
            }

            //Animation duration
            Duration duration = TimeSpan.FromSeconds(dur);

            StringBuilder b = new StringBuilder(t.Caption.Text);

            //Formatted text up until the index of the caption
            var captionFT = new FormattedText
                            (
                b.ToString(0, w.BeginIndex),
                CultureInfo.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface(t.FontFamily, t.FontStyle, t.FontWeight, t.FontStretch),
                t.FontSize,
                Brushes.Black //Colour does not matter here
                            );

            //Formatted text of the emotive caption word
            var wordFT = new FormattedText
                         (
                w.Text,
                CultureInfo.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface(t.FontFamily, t.FontStyle, t.FontWeight, t.FontStretch),
                t.FontSize,
                Brushes.Black //Colour does not matter here
                         );


            TextEffect e1 = new TextEffect
            {
                PositionStart = w.BeginIndex,
                PositionCount = w.Length,
                Transform     = new ScaleTransform
                {
                    //TODO: Fix centering
                    CenterX = captionFT.Width + wordFT.Width / 2,
                    CenterY = captionFT.Height,
                },
            };

            this.TextEffects.Add(e1);

            DoubleAnimationUsingKeyFrames a1 = new DoubleAnimationUsingKeyFrames
            {
                BeginTime = TimeSpan.FromSeconds(t.Caption.Begin),
                Duration  = duration,
            };

            a1.KeyFrames.Add(new LinearDoubleKeyFrame(0.5, KeyTime.FromPercent(0)));
            a1.KeyFrames.Add(new LinearDoubleKeyFrame(scalefinish, KeyTime.FromPercent(0.5)));
            a1.KeyFrames.Add(new LinearDoubleKeyFrame(1, KeyTime.FromPercent(1)));

            this.Animations.Add(a1);
            this.AnimationTargets.Add(new AnimationTargetString("Transform.ScaleX", 0));

            //Make second animation for y scale
            DoubleAnimationUsingKeyFrames a2 = a1.Clone();

            this.Animations.Add(a2);
            this.AnimationTargets.Add(new AnimationTargetString("Transform.ScaleY", 0));

            TextEffect e2 = new TextEffect //Yfinish effect
            {
                PositionStart = w.BeginIndex,
                PositionCount = w.Length,
                Transform     = new TranslateTransform(),
            };

            this.TextEffects.Add(e2);

            DoubleAnimationUsingKeyFrames a3 = new DoubleAnimationUsingKeyFrames
            {
                BeginTime = TimeSpan.FromSeconds(t.Caption.Begin),
                Duration  = duration,
            };

            a3.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(0)));
            a3.KeyFrames.Add(new LinearDoubleKeyFrame(-yFinish, KeyTime.FromPercent(0.5)));
            a3.KeyFrames.Add(new LinearDoubleKeyFrame(0, KeyTime.FromPercent(1)));

            this.Animations.Add(a3);
            this.AnimationTargets.Add(new AnimationTargetString("Transform.Y", 1));

            //alpha effect
            TextEffect e3 = new TextEffect()
            {
                PositionStart = w.BeginIndex,
                PositionCount = w.Length,
            };

            e3.Foreground = t.Foreground;

            this.TextEffects.Add(e3);

            ColorAnimationUsingKeyFrames a4 = new ColorAnimationUsingKeyFrames
            {
                BeginTime = TimeSpan.FromSeconds(t.Caption.Begin),
                Duration  = duration,
            };

            System.Windows.Media.Color fgColor = t.Caption.Speaker.Font.ForegroundColour.ToMediaColor();

            a4.KeyFrames.Add(new LinearColorKeyFrame(fgColor, KeyTime.FromPercent(0)));
            a4.KeyFrames.Add(new LinearColorKeyFrame(Color.FromArgb(100, fgColor.R, fgColor.G, fgColor.B),
                                                     KeyTime.FromPercent(0.5)));
            a4.KeyFrames.Add(new LinearColorKeyFrame(fgColor, KeyTime.FromPercent(1)));

            this.Animations.Add(a4);
            this.AnimationTargets.Add(new AnimationTargetString("Foreground."
                                                                + SolidColorBrush.ColorProperty.ToString(), 2));
        }
Example #16
0
 internal static extern void Text_SetTextEffect(IntPtr handle, TextEffect textEffect);
Example #17
0
 /// <summary>
 /// Set text effect.
 /// </summary>
 private void SetTextEffect(TextEffect textEffect)
 {
     Runtime.ValidateRefCounted(this);
     Text_SetTextEffect(handle, textEffect);
 }
Example #18
0
    private void PopulateModifierList(string text)
    {
        MatchCollection matches = Regex.Matches(text, tag_pattern);

        totalTextModifiers = new List <TextEffect>();

        // there has to be a better way, but right now my brain is tired
        int last_bold_index        = -1;
        int last_italics_index     = -1;
        int last_size_index        = -1;
        int last_color_index       = -1;
        int last_shake_index       = -1;
        int last_wiggle_index      = -1;
        int last_underline_index   = -1;
        int last_subscript_index   = -1;
        int last_superscript_index = -1;
        int substract_index        = 0;

        if (matches.Count > 0)
        {
            foreach (Match match in matches)
            {
                // create text modifiers
                if (match.Value.Equals("<b>"))
                {
                    TextEffect bold = new TextEffect();
                    bold.type        = TextEffect.TextEffectType.kBold;
                    bold.start_tag   = "<b>";
                    bold.end_tag     = "</b>";
                    bold.hasEndTag   = true;
                    bold.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(bold);
                    last_bold_index  = totalTextModifiers.Count - 1;
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("</b>"))
                {
                    if (last_bold_index >= 0)
                    {
                        totalTextModifiers[last_bold_index].end_index = match.Index - substract_index;
                        last_bold_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("<i>"))
                {
                    TextEffect italics = new TextEffect();
                    italics.type        = TextEffect.TextEffectType.kItalics;
                    italics.start_tag   = "<i>";
                    italics.end_tag     = "</i>";
                    italics.hasEndTag   = true;
                    italics.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(italics);
                    last_italics_index = totalTextModifiers.Count - 1;
                    substract_index   += match.Value.Length;
                }
                else if (match.Value.Equals("</i>"))
                {
                    if (last_italics_index >= 0)
                    {
                        totalTextModifiers[last_italics_index].end_index = match.Index - substract_index;
                        last_italics_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("<u>"))
                {
                    TextEffect underline = new TextEffect();
                    underline.type        = TextEffect.TextEffectType.kUnderline;
                    underline.start_tag   = "<u>";
                    underline.end_tag     = "</u>";
                    underline.hasEndTag   = true;
                    underline.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(underline);
                    last_underline_index = totalTextModifiers.Count - 1;
                    substract_index     += match.Value.Length;
                }
                else if (match.Value.Equals("</u>"))
                {
                    if (last_underline_index >= 0)
                    {
                        totalTextModifiers[last_underline_index].end_index = match.Index - substract_index;
                        last_underline_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("<sup>"))
                {
                    TextEffect superscript = new TextEffect();
                    superscript.type        = TextEffect.TextEffectType.kSuperscript;
                    superscript.start_tag   = "<sup>";
                    superscript.end_tag     = "</sup>";
                    superscript.hasEndTag   = true;
                    superscript.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(superscript);
                    last_superscript_index = totalTextModifiers.Count - 1;
                    substract_index       += match.Value.Length;
                }
                else if (match.Value.Equals("</sup>"))
                {
                    if (last_superscript_index >= 0)
                    {
                        totalTextModifiers[last_superscript_index].end_index = match.Index - substract_index;
                        last_superscript_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("<sub>"))
                {
                    TextEffect subscript = new TextEffect();
                    subscript.type        = TextEffect.TextEffectType.kSubscript;
                    subscript.start_tag   = "<sub>";
                    subscript.end_tag     = "</sub>";
                    subscript.hasEndTag   = true;
                    subscript.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(subscript);
                    last_subscript_index = totalTextModifiers.Count - 1;
                    substract_index     += match.Value.Length;
                }
                else if (match.Value.Equals("</sub>"))
                {
                    if (last_subscript_index >= 0)
                    {
                        totalTextModifiers[last_subscript_index].end_index = match.Index - substract_index;
                        last_subscript_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("<ln>"))
                {
                    TextEffect linebreak = new TextEffect();
                    linebreak.type        = TextEffect.TextEffectType.kLineBreak;
                    linebreak.start_tag   = "<ln>";
                    linebreak.hasEndTag   = false;
                    linebreak.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(linebreak);
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<sprite="))
                {
                    TextEffect sprite = new TextEffect();
                    sprite.type        = TextEffect.TextEffectType.kSprite;
                    sprite.start_tag   = match.Value;
                    sprite.hasEndTag   = false;
                    sprite.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(sprite);
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<size="))
                {
                    TextEffect size = new TextEffect();
                    size.type        = TextEffect.TextEffectType.kSize;
                    size.start_tag   = match.Value;
                    size.end_tag     = "</size>";
                    size.hasEndTag   = true;
                    size.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(size);
                    last_size_index  = totalTextModifiers.Count - 1;
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("</size>"))
                {
                    if (last_size_index >= 0)
                    {
                        totalTextModifiers[last_size_index].end_index = match.Index - substract_index;
                        last_size_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<color="))
                {
                    TextEffect color = new TextEffect();
                    color.type        = TextEffect.TextEffectType.kColor;
                    color.start_tag   = match.Value;
                    color.end_tag     = "</color>";
                    color.hasEndTag   = true;
                    color.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(color);
                    last_color_index = totalTextModifiers.Count - 1;
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Equals("</color>"))
                {
                    if (last_color_index >= 0)
                    {
                        totalTextModifiers[last_color_index].end_index = match.Index - substract_index;
                        last_color_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<sp="))
                {
                    TextEffect speed = new TextEffect();
                    speed.type            = TextEffect.TextEffectType.kSpeed;
                    speed.tag_data        = match.Value.Substring("<sp=".Length, match.Value.Length - "<sp=".Length - 1);
                    speed.start_tag       = match.Value;
                    speed.hasEndTag       = false;
                    speed.isOneTimeEffect = false;
                    speed.start_index     = match.Index - substract_index;
                    totalTextModifiers.Add(speed);
                    last_color_index = totalTextModifiers.Count - 1;
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<shake="))
                {
                    TextEffect shake = new TextEffect();
                    shake.type        = TextEffect.TextEffectType.kShake;
                    shake.tag_data    = match.Value.Substring("<shake=".Length, match.Value.Length - "<shake=".Length - 1);
                    shake.start_tag   = match.Value;
                    shake.hasEndTag   = true;
                    shake.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(shake);
                    last_shake_index = totalTextModifiers.Count - 1;
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("</shake>"))
                {
                    if (last_shake_index >= 0)
                    {
                        totalTextModifiers[last_shake_index].end_index = match.Index - substract_index;
                        last_shake_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<wiggle="))
                {
                    TextEffect wiggle = new TextEffect();
                    wiggle.type        = TextEffect.TextEffectType.kWiggle;
                    wiggle.tag_data    = match.Value.Substring("<wiggle=".Length, match.Value.Length - "<wiggle=".Length - 1);
                    wiggle.start_tag   = match.Value;
                    wiggle.hasEndTag   = true;
                    wiggle.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(wiggle);
                    last_wiggle_index = totalTextModifiers.Count - 1;
                    substract_index  += match.Value.Length;
                }
                else if (match.Value.Contains("</wiggle>"))
                {
                    if (last_wiggle_index >= 0)
                    {
                        totalTextModifiers[last_wiggle_index].end_index = match.Index - substract_index;
                        last_wiggle_index = -1;
                    }
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<p>"))
                {
                    TextEffect pause = new TextEffect();
                    pause.type        = TextEffect.TextEffectType.kPause;
                    pause.start_tag   = match.Value;
                    pause.hasEndTag   = false;
                    pause.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(pause);
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<p="))
                {
                    TextEffect pause = new TextEffect();
                    pause.type        = TextEffect.TextEffectType.kPause;
                    pause.tag_data    = match.Value.Substring("<p=".Length, match.Value.Length - "<p=".Length - 1);
                    pause.start_tag   = match.Value;
                    pause.hasEndTag   = false;
                    pause.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(pause);
                    substract_index += match.Value.Length;
                }
                else if (match.Value.Contains("<wait>"))
                {
                    TextEffect wait = new TextEffect();
                    wait.type        = TextEffect.TextEffectType.kWait;
                    wait.start_tag   = match.Value;
                    wait.hasEndTag   = false;
                    wait.start_index = match.Index - substract_index;
                    totalTextModifiers.Add(wait);
                    substract_index += match.Value.Length;
                }
            }
        }
    }
 public TextSystem(string fontName, ContentManager Content)
 {
     letters = new List<TextLetter> ();
     font = Content.Load<Texture2D> ("Fonts/" + fontName);
     ra = new Random ();
     currentEffect = TextEffect.NONE;
     escaping = false;
     currentLine = 0;
     text = "";
 }
Example #20
0
    private void DoModifierAction(TextEffect mod, GameObject textChar)
    {
        switch (mod.type)
        {
        case TextEffect.TextEffectType.kLineBreak:
        {
            NewLine();
            textChar.GetComponent <RectTransform>().position = startPos;
            break;
        }

        case TextEffect.TextEffectType.kSpeed:
        {
            current_char_delay = float.Parse(mod.tag_data);
            break;
        }

        case TextEffect.TextEffectType.kShake:
        {
            Vector3     charPos = startPos + new Vector3(currentLineOffset, 0, 0);
            ShakeLetter shake   = textChar.GetComponent <ShakeLetter>();
            string[]    tags    = mod.tag_data.Split(",".ToCharArray());
            if (tags.Length > 1)
            {
                shake.shake_radius = float.Parse(tags[0]);
                shake.shake_speed  = float.Parse(tags[1]);
            }

            if (isActiveDialogue)
            {
                shake.StartShake(startPos, currentLineOffset);
            }
            else
            {
                shake.StartShake(charPos);
            }

            break;
        }

        case TextEffect.TextEffectType.kWiggle:
        {
            WiggleLetter  wiggle = textChar.GetComponent <WiggleLetter>();
            CharacterText carTex = textChar.GetComponent <CharacterText>();
            string[]      tags   = mod.tag_data.Split(",".ToCharArray());
            if (tags.Length > 1)
            {
                wiggle.wiggle_height = float.Parse(tags[0]);
                wiggle.wiggle_speed  = float.Parse(tags[1]);
            }
            wiggle.StartWiggle(isActiveDialogue);
            break;
        }

        case TextEffect.TextEffectType.kPause:
        {
            isPaused = true;
            if (mod.tag_data != null)
            {
                pause_time = float.Parse(mod.tag_data);
            }
            else
            {
                pause_time = default_pause_time;
            }
            break;
        }

        case TextEffect.TextEffectType.kWait:
        {
            //isWaiting = true;
            break;
        }
        }
    }
 // sets all letters' effects
 public void setEffect(TextEffect newEffect)
 {
     foreach (TextLetter tl in letters) {
         tl.effect = newEffect;
     }
 }
Example #22
0
 public void SetTextEffect(TextEffect effect)
 {
     this.textSource.EffectCollection.Add(effect);
 }
Example #23
0
 /// <summary>
 /// Access this renderer behind an effect function.
 /// </summary>
 public static TextEffect Effect(this ITextRenderer renderer, TextEffect.Func effect)
 {
     return new TextEffect(renderer, effect);
 }
Example #24
0
 public void setEffect(TextEffect effect)
 {
     this.textEffect = effect;
 }
Example #25
0
    private void preCreateControlCommand(string command)
    {
        string[] cmds = command.Split(':');
        string[] args = new string[0];
        if (cmds.Length == 2)
        {
            args    = cmds[1].Split(',');
            cmds[1] = args[0];
        }
        switch (cmds[0].ToLower())
        {
        case "noskip":
            currentSkippable = false;
            break;

        case "instant":
            this.displayImmediate = true;
            break;

        case "color":
            currentColor = ParseUtil.getColor(cmds[1]);
            break;

        case "starcolor":
            Color starColor = ParseUtil.getColor(cmds[1]);
            if (textQueue[currentLine].Text[0] == '*')
            {
                letterReferences[0].color = starColor;
            }
            if (textQueue[currentLine] is SelectMessage)
            {
                int indexOfStar = textQueue[currentLine].Text.IndexOf('*');     // HACK oh my god lol
                if (indexOfStar > -1)
                {
                    letterReferences[indexOfStar].color = starColor;
                }
            }
            break;

        case "font":
            AudioClip oldClip = letterSound.clip;
            setFont(SpriteFontRegistry.Get(cmds[1]));
            letterSound.clip = oldClip;
            break;

        case "effect":
            switch (cmds[1].ToUpper())
            {
            case "NONE":
                textEffect = null;
                break;

            case "TWITCH":
                if (args.Length > 1)
                {
                    textEffect = new TwitchEffect(this, ParseUtil.getFloat(args[1]));
                }
                else
                {
                    textEffect = new TwitchEffect(this);
                }
                break;

            case "SHAKE":
                if (args.Length > 1)
                {
                    textEffect = new ShakeEffect(this, ParseUtil.getFloat(args[1]));
                }
                else
                {
                    textEffect = new ShakeEffect(this);
                }
                break;

            case "ROTATE":
                if (args.Length > 1)
                {
                    textEffect = new RotatingEffect(this, ParseUtil.getFloat(args[1]));
                }
                else
                {
                    textEffect = new RotatingEffect(this);
                }
                break;
            }
            break;
        }
    }
Example #26
0
 private void OverHitTextReturnToPool(TextEffect text)
 {
     deActiveHitDamageTextPool.Add(text);
     activeHitDamageTextPool.Remove(text);
 }