Beispiel #1
0
 public EffectData(EffectData original)
 {
     effectType = original.effectType;
     startIndex = original.startIndex;
     endIndex   = original.endIndex;
     parameters = original.parameters;
 }
Beispiel #2
0
    IEnumerator OnPlaySubHP(TextEffectType type, int val, Color color, Transform transform, Vector3 offset, bool isFllow)
    {
        int count = 5;

        if (Mathf.Abs(val) < count)
        {
            count = Mathf.Abs(val);
        }

        int v = val / count;

        string txt = "";

        if (v >= 0)
        {
            txt = "+" + v;
        }
        else
        {
            txt = "" + v;
        }

        for (int i = 0; i < count; i++)
        {
            AbstractTextEffect textEffect = Play(type, txt, color, transform, offset, isFllow);
            yield return(new WaitForSeconds(0.15f));
        }
    }
Beispiel #3
0
 private static void AssertNotAutoCloseEffectClose(TextEffectType effectType)
 {
     if (effectType.IsAutoClosingTag())
     {
         throw new Exception($"{effectType} tag cannot be closed");
     }
 }
Beispiel #4
0
 public EffectData(TextEffectType effectType, int startIndex, int endIndex, Dictionary <string, string> parameters)
 {
     this.effectType = effectType;
     this.startIndex = startIndex;
     this.endIndex   = endIndex;
     this.parameters = parameters;
 }
Beispiel #5
0
 public EffectData(EffectData original, int endIndex)
 {
     effectType    = original.effectType;
     startIndex    = original.startIndex;
     parameters    = original.parameters;
     this.endIndex = endIndex;
 }
Beispiel #6
0
    private void OnAppearEffectClose(TextEffectType effectType, int indexInPlainText)
    {
        AssertNotAutoCloseEffectClose(effectType);
        if (appearEffectsStack.Count == 0)
        {
            throw new Exception($"Cannot close {effectType} tag. No tag is opened");
        }
        EffectData currentEffectData = appearEffectsStack.Pop();

        if (currentEffectData.effectType != effectType)
        {
            throw new Exception($"Cannot close {effectType} tag. {currentEffectData.effectType} tag must be closed first.");
        }

        currentEffectData.endIndex = indexInPlainText;
        int effectLength = currentEffectData.endIndex - currentEffectData.startIndex;

        if (effectLength > 0)
        {
            appearEffects.Add(currentEffectData);
            if (appearEffectsStack.Count > 0)
            {
                EffectData previousEffectData = appearEffectsStack.Peek();
                previousEffectData.startIndex = indexInPlainText;
            }
        }
    }
Beispiel #7
0
 private void OntagClose(TextEffectType effectType, int indexInPlainText)
 {
     if (effectType.IsAppearTextEffect())
     {
         OnAppearEffectClose(effectType, indexInPlainText);
     }
     else
     {
         OnAnimationEffectClose(effectType, indexInPlainText);
     }
 }
Beispiel #8
0
    public AbstractTextEffect Play(TextEffectType type, object val, Color color, Transform transform, Vector3 offset, bool isFllow)
    {
        AbstractTextEffect textEffect = Play(type, val, color, transform.position + offset, transform);

        if (isFllow)
        {
            UIFllowWorldPosition uiFllow = textEffect.GetComponent <UIFllowWorldPosition>();
            if (uiFllow == null)
            {
                uiFllow = textEffect.gameObject.AddComponent <UIFllowWorldPosition>();
            }

            uiFllow.targetWorld = transform;
            uiFllow.offset      = offset;
            uiFllow.enabled     = true;
        }
        return(textEffect);
    }
Beispiel #9
0
    private void OnTagOpen(TextEffectType effectType, int indexInPlainText, Group effectParamsGroup)
    {
        EffectData newEffect = new EffectData(
            effectType: effectType,
            startIndex: indexInPlainText,
            endIndex: plainTextLength,
            parameters: ParseEffectParameters(effectParamsGroup.Captures)
            );

        if (effectType.IsAppearTextEffect())
        {
            OnAppearEffectOpen(newEffect);
        }
        else
        {
            OnAnimationEffectOpen(newEffect);
        }
    }
Beispiel #10
0
    private void ParseTextEffectTag(Match match)
    {
        GroupCollection groups           = match.Groups;
        Group           effectNameGroup  = groups[1];
        TextEffectType  effectType       = ParseEffectType(effectNameGroup.Value);
        int             indexInPlainText = match.Index - tagsOffset;

        if (IsOpeningTag(match))
        {
            Group effectParamsGroup = groups[2];
            OnTagOpen(effectType, indexInPlainText, effectParamsGroup);
        }
        else
        {
            OntagClose(effectType, indexInPlainText);
        }
        tagsOffset += match.Value.Length;
    }
Beispiel #11
0
        private void ParseTypeParams(TextEffectType type, string paramString)
        {
            switch (type)
            {
            case TextEffectType.Fast:
            case TextEffectType.Slow:
                Speed = int.Parse(paramString);
                break;

            case TextEffectType.Wait:
                Wait = int.Parse(paramString);
                break;

            case TextEffectType.Color:
                Color = ParseColor(paramString);
                break;
            }
        }
Beispiel #12
0
    public AbstractTextEffect PlayHP(float hp, Transform transform, Vector3 offset, bool isFllow = false)
    {
        int val = (int)hp;

        if (val == 0)
        {
            return(null);
        }

        string txt;
        Color  color;

        if (hp >= 0)
        {
            txt   = "+" + val;
            color = colorHP_Plus;
        }
        else
        {
            txt   = "" + val;
            color = colorHP_Minus;
        }

        TextEffectType     type       = TextEffectType.Normal;
        AbstractTextEffect textEffect = null;

//		if(val < 0)
//		{
//			type = TextEffectType.Damage;
//
//			StartCoroutine(OnPlaySubHP(type, val, color, transform, offset, isFllow));
//		}
//		else
//		{
//			textEffect = OnPlaySubHP(type, txt, color, transform, offset, isFllow);
//		}
        if (val < 0)
        {
            type = TextEffectType.Damage;
        }
        textEffect = Play(type, txt, color, transform, offset, isFllow);

        return(textEffect);
    }
Beispiel #13
0
    private void OnAnimationEffectClose(TextEffectType effectType, int indexInPlainText)
    {
        EffectData currentEffectData = openedAnimationEffect;

        openedAnimationEffect = null;

        if (currentEffectData == null)
        {
            throw new Exception($"Cannot close {effectType} tag. No tag is opened");
        }
        if (currentEffectData.effectType != effectType)
        {
            throw new Exception($"Cannot close {effectType} tag. {currentEffectData.effectType} tag must be closed first.");
        }
        currentEffectData.endIndex = indexInPlainText;
        int effectLength = currentEffectData.endIndex - currentEffectData.startIndex;

        if (effectLength > 0)
        {
            animationEffects.Add(currentEffectData);
        }
    }
Beispiel #14
0
    public AbstractTextEffect Play(TextEffectType type, object val, Color color, Vector3 worldPosition, System.Object uid)
    {
        TextEffectPool pool = poolDict[type];

        AbstractTextEffect textEffect = null;

        if (type == TextEffectType.Damage)
        {
            if (uidTextEffectDict.ContainsKey(uid))
            {
                textEffect = uidTextEffectDict[uid];
            }
        }

        if (textEffect == null)
        {
            textEffect = pool.Get();
            textEffect.transform.SetParent(transform, false);
//			textEffect.transform.localScale = Vector3.one;
            textEffect.pool = pool;

            if (type == TextEffectType.Damage)
            {
                uidTextEffectDict.Add(uid, textEffect);
            }
        }


        Vector3 pt = mainCamera.WorldToScreenPoint(worldPosition).SetZ(0);

        (textEffect.transform as RectTransform).anchoredPosition = pt * rate;
        textEffect.gameObject.SetActive(true);
        textEffect.Play(val, color);
//		Debug.Log("textEffect.Play txt=" + val + " color=" + color );
        return(textEffect);
    }
Beispiel #15
0
 public static bool IsAutoClosingTag(this TextEffectType effect) =>
 Array.IndexOf(autoCloseTextEffects, effect) != -1;
Beispiel #16
0
 public AbstractTextEffect Play(TextEffectType type, object val, Color color, Transform transform)
 {
     return(Play(type, val, color, transform.position, transform));
 }
Beispiel #17
0
 public EffectData(TextEffectType effectType, int startIndex, int endIndex)
 {
     this.effectType = effectType;
     this.startIndex = startIndex;
     this.endIndex   = endIndex;
 }
Beispiel #18
0
 public static bool IsAppearTextEffect(this TextEffectType effect) =>
 Array.IndexOf(appearTextEffects, effect) != -1;
Beispiel #19
0
 public bool Is(TextEffectType type)
 {
     return(EffectTypes.Contains(type));
 }
Beispiel #20
0
        /// <summary>
        /// Creates new line column object.
        /// </summary>
        /// <param name="parent">Parent.</param>
        /// <param name="content">Content.</param>
        /// <param name="isLeft">If set to <c>true</c> is left.</param>
        /// <param name="style">The style.</param>
        private void CreateLineColumn(Transform parent, string content, bool isLeft, UITooltipLines.LineStyle style)
        {
            // Create the game object
            GameObject obj = new GameObject("Column", typeof(RectTransform), typeof(CanvasRenderer));

            obj.layer = this.gameObject.layer;
            obj.transform.SetParent(parent);

            // Set the pivot to top left
            (obj.transform as RectTransform).pivot = new Vector2(0f, 1f);

            // Set a fixed size for attribute columns
            if (style == UITooltipLines.LineStyle.Attribute)
            {
                VerticalLayoutGroup   vlg  = this.gameObject.GetComponent <VerticalLayoutGroup>();
                HorizontalLayoutGroup phlg = parent.gameObject.GetComponent <HorizontalLayoutGroup>();
                LayoutElement         le   = obj.AddComponent <LayoutElement>();
                le.preferredWidth = (this.m_Rect.sizeDelta.x - vlg.padding.horizontal - phlg.padding.horizontal) / 2f;
            }

            // Prepare the text component
            Text text = obj.AddComponent <Text>();

            text.text            = content;
            text.supportRichText = true;
            text.alignment       = (isLeft) ? TextAnchor.LowerLeft : TextAnchor.LowerRight;

            // Prepare some style properties
            TextEffectType effect         = TextEffectType.None;
            Color          effectColor    = Color.white;
            Vector2        effectDistance = new Vector2(1f, -1f);
            bool           effectUseAlpha = true;

            switch (style)
            {
            case UITooltipLines.LineStyle.Title:
                text.font        = this.m_TitleFont;
                text.fontStyle   = this.m_TitleFontStyle;
                text.fontSize    = this.m_TitleFontSize;
                text.lineSpacing = this.m_TitleFontLineSpacing;
                text.color       = this.m_TitleFontColor;
                effect           = this.m_TitleTextEffect;
                effectColor      = this.m_TitleTextEffectColor;
                effectDistance   = this.m_TitleTextEffectDistance;
                effectUseAlpha   = this.m_TitleTextEffectUseGraphicAlpha;
                break;

            case UITooltipLines.LineStyle.Attribute:
                text.font        = this.m_AttributeFont;
                text.fontStyle   = this.m_AttributeFontStyle;
                text.fontSize    = this.m_AttributeFontSize;
                text.lineSpacing = this.m_AttributeFontLineSpacing;
                text.color       = this.m_AttributeFontColor;
                effect           = this.m_AttributeTextEffect;
                effectColor      = this.m_AttributeTextEffectColor;
                effectDistance   = this.m_AttributeTextEffectDistance;
                effectUseAlpha   = this.m_AttributeTextEffectUseGraphicAlpha;
                break;

            case UITooltipLines.LineStyle.Description:
                text.font        = this.m_DescriptionFont;
                text.fontStyle   = this.m_DescriptionFontStyle;
                text.fontSize    = this.m_DescriptionFontSize;
                text.lineSpacing = this.m_DescriptionFontLineSpacing;
                text.color       = this.m_DescriptionFontColor;
                effect           = this.m_DescriptionTextEffect;
                effectColor      = this.m_DescriptionTextEffectColor;
                effectDistance   = this.m_DescriptionTextEffectDistance;
                effectUseAlpha   = this.m_DescriptionTextEffectUseGraphicAlpha;
                break;
            }

            // Add text effect component
            if (effect == TextEffectType.Shadow)
            {
                Shadow s = obj.AddComponent <Shadow>();
                s.effectColor     = effectColor;
                s.effectDistance  = effectDistance;
                s.useGraphicAlpha = effectUseAlpha;
            }
            else if (effect == TextEffectType.Outline)
            {
                Outline o = obj.AddComponent <Outline>();
                o.effectColor     = effectColor;
                o.effectDistance  = effectDistance;
                o.useGraphicAlpha = effectUseAlpha;
            }
        }
Beispiel #21
0
 public TextEffectConfig(TextEffectType effectType)
 {
     this.effectType = effectType;
     parameters      = new Dictionary <string, string>();
 }
Beispiel #22
0
 public TextEffectConfig(TextEffectType effectType, Dictionary <string, string> parameters)
 {
     this.effectType = effectType;
     this.parameters = parameters;
 }