Exemple #1
0
    public void ShowBattleText(string mainText, Color textColor)
    {
        if (StoryEngine.Instance == null)
        {
            return;
        }

        var         hudRoot = StoryEngine.Instance.HUDRoot;
        HUDTextInfo info    = new HUDTextInfo(transform, $"{mainText}")
        {
            Color = Color.white,
            Speed = Random.Range(0.2f, 1),
            VerticalAceleration    = Random.Range(-2, 2f),
            VerticalPositionOffset = Random.Range(0, 0.8f),
            VerticalFactorScale    = Random.Range(1.2f, 10),
            Side            = (Random.Range(0, 2) == 1) ? bl_Guidance.LeftDown : bl_Guidance.RightDown,
            ExtraDelayTime  = 0.2f,
            AnimationType   = bl_HUDText.TextAnimationType.HorizontalSmall,
            FadeSpeed       = 200,
            ExtraFloatSpeed = -11
        };

        info.Color = textColor;

        info.TextPrefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2/AttackInfoText.prefab");
        hudRoot.NewText(info);
    }
    public void NewStatu(Transform targetTran, Statu statu)
    {
        string text = "";

        switch (statu)
        {
        case Statu.Giddy: text = "眩晕"; break;

        case Statu.Rigidity: text = "硬直"; break;

        case Statu.Falled: text = "倒地"; break;
        }
        HUDTextInfo info = new HUDTextInfo(targetTran, text);

        info.Color = Color.white;
        info.Size  = Random.Range(40, 50);
        info.Speed = Random.Range(10, 20);
        info.VerticalAceleration = 1;
        info.VerticalFactorScale = Random.Range(1.2f, 3);
        info.Side = bl_Guidance.Up;
        info.VerticalPositionOffset = 0;
        info.AnimationSpeed         = 0.5f;
        info.ExtraDelayTime         = 2;
        info.FadeSpeed = 400;
        //Send the information
        HUDRoot.NewText(info);
    }
Exemple #3
0
    public void floatText(Transform transform, string _string)
    {
        HUDTextInfo info = new HUDTextInfo(transform, _string);

        info.Side = bl_Guidance.Up;
        info.Size = 30;
        bl_UHTUtils.GetHUDText.NewText(info);
    }
Exemple #4
0
    //private Color Darken() {

    //}


    private static void WriteText(HUDTextInfo info)
    {
        if (HUDRoot == null)
        {
            HUDRoot = bl_UHTUtils.GetHUDText;
        }
        HUDRoot.NewText(info);
    }
Exemple #5
0
    /// <summary>
    /// send a new event, to create a new floating text
    /// </summary>
    public void NewText(HUDTextInfo info)
    {
        //override animation type
        TextAnimationType tat = (info.AnimationType == TextAnimationType.None) ? m_TextAnimationType : info.AnimationType;


        if (CanReuse && HaveUtil(info.CacheTransform) != null)
        {
            bl_Text t = HaveUtil(info.CacheTransform);

            //check for new lines
            //if you want add a new line to the current text simple send a text with the subfix '\n' in the end
            string text         = t.m_text + info.Text;
            bool   hasOtherLine = false;
            int    containCount = 0;
            if (info.Text.Contains("\n") && !string.IsNullOrEmpty(t.m_text))
            {
                string[] tArray = text.Split('\n');
                containCount = tArray.Length;
                hasOtherLine = true;
                text         = string.Join("\n", tArray);
            }

            t.m_text    = (hasOtherLine) ? text : info.Text;
            t.m_Color   = info.Color;
            t.FadeSpeed = (info.FadeSpeed > 0) ? info.FadeSpeed : FadeSpeed;
            t.VerticalPositionOffset = (hasOtherLine) ? 2.2f * containCount : t.VerticalPositionOffset;
            t.Delay      = (Time.time + (DelayStay / 2)) + info.ExtraDelayTime;
            t.FloatSpeed = (FloatingSpeed + info.ExtraFloatSpeed);
            t.Uses++;
            t.PlayAnimation((int)tat, info.AnimationSpeed);
            return;
        }
        GameObject prefab = (info.TextPrefab == null) ? TextPrefab : info.TextPrefab;
        //Create new text info to instantiate
        GameObject go   = Instantiate(prefab) as GameObject;
        bl_Text    item = go.GetComponent <bl_Text>();

        item.m_Speed                = info.Speed;
        item.FadeSpeed              = (info.FadeSpeed > 0) ? info.FadeSpeed : FadeSpeed;
        item.m_Color                = info.Color;
        item.m_Transform            = info.CacheTransform;
        item.m_text                 = info.Text;
        item.m_Size                 = info.Size;
        item.movement               = info.Side;
        item.FloatSpeed             = (FloatingSpeed + info.ExtraFloatSpeed);
        item.VerticalPositionOffset = info.VerticalPositionOffset;
        item.Yquickness             = info.VerticalAceleration;
        item.YquicknessScaleFactor  = info.VerticalFactorScale;
        item.Delay = (Time.time + DelayStay) + info.ExtraDelayTime;
        item.PlayAnimation((int)tat, info.AnimationSpeed);

        go.transform.SetParent(CanvasParent, false);
        go.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;

        texts.Add(item);
    }
Exemple #6
0
    public static void DamageText(Transform transform, float amount, bool isCritical, DamageType type = DamageType.NORMAL)
    {
        HUDTextInfo info = new HUDTextInfo(transform, string.Format("-{0}", ((int)amount).ToString()));

        info.Size  = GetSize(isCritical);
        info.Color = GetColor(type, isCritical);
        info.VerticalPositionOffset = 3 + Random.Range(-1f, 1f);
        info.FadeSpeed = 500;

        WriteText(info);
    }
Exemple #7
0
    public static void HealText(Transform transform, float amount, bool isCritical)
    {
        HUDTextInfo info = new HUDTextInfo(transform, string.Format("+{0}", ((int)amount).ToString()));

        info.Size  = GetSize(isCritical);
        info.Color = Color.green;
        info.VerticalPositionOffset = 3 + Random.Range(-1f, 1f);
        info.FadeSpeed = 500;

        WriteText(info);
    }
Exemple #8
0
    public void NewText(string text, Transform trans, Color color, int size, float speed, float yAcceleration, float yAccelerationScaleFactor, bl_Guidance movement)
    {
        HUDTextInfo info = new HUDTextInfo(trans, text);

        info.Side  = movement;
        info.Size  = size;
        info.Speed = speed;
        info.VerticalAceleration = yAcceleration;
        info.VerticalFactorScale = yAccelerationScaleFactor;
        info.Color = color;
        NewText(info);
    }
    public void NewBackDamageValue(Transform targetTran, int value)
    {
        HUDTextInfo info = new HUDTextInfo(targetTran, "背击- " + value);

        info.Color = Color.magenta;
        info.Size  = Random.Range(40, 50);
        info.Speed = Random.Range(10, 20);
        info.VerticalAceleration    = -1;
        info.VerticalFactorScale    = Random.Range(1.2f, 3);
        info.VerticalPositionOffset = 0;
        info.Side = (Random.Range(0, 2) == 1) ? bl_Guidance.RightDown : bl_Guidance.LeftDown;
        //Send the information
        HUDRoot.NewText(info);
    }
Exemple #10
0
    //说话
    public void Say(string word, float time = 5f)
    {
        var hudRoot = StoryEngine.Instance.HUDRoot;

        HUDTextInfo info = new HUDTextInfo(transform, word)
        {
            Size  = 12,
            Color = Color.white,
            VerticalPositionOffset = 0.5f,
            ExtraDelayTime         = time
        };

        hudRoot.NewText(info);
    }
Exemple #11
0
    // Start is called before the first frame update
    void Start()
    {
        HUDRoot = bl_UHTUtils.GetHUDText;
        HUDTextInfo info2 = new HUDTextInfo(transform, "- " + Random.Range(50, 100));

        info2.Color = Color.white;
        info2.Size  = 20;
        info2.Speed = 0;

        info2.VerticalAceleration    = -3;
        info2.VerticalFactorScale    = 1;
        info2.VerticalFactorScale    = Random.Range(1.2f, 3);
        info2.VerticalPositionOffset = 3;
        HUDRoot.NewText(info2);
    }
    public void NewMiss(Transform targetTran)
    {
        HUDTextInfo info = new HUDTextInfo(targetTran, "闪避");

        info.Color = Color.white;
        info.Size  = Random.Range(40, 50);
        info.Speed = Random.Range(10, 20);
        info.VerticalAceleration = 1;
        info.VerticalFactorScale = Random.Range(1.2f, 3);
        info.Side = bl_Guidance.Up;
        info.VerticalPositionOffset = 0;
        info.AnimationSpeed         = 0.5f;
        info.ExtraDelayTime         = 2;
        info.FadeSpeed = 400;
        //Send the information
        HUDRoot.NewText(info);
    }
Exemple #13
0
    public void NewHUDText(string sub, Color textColor, Transform transform)
    {
        HUDTextInfo info7 = new HUDTextInfo(transform, sub);

        info7.Color = textColor;
        info7.Size  = 20;
        info7.Speed = Random.Range(0.2f, 1);
        info7.VerticalAceleration    = Random.Range(-2, 2f);
        info7.VerticalPositionOffset = 0.2f;
        info7.VerticalFactorScale    = Random.Range(1.2f, 10);
        info7.Side            = (Random.Range(0, 2) == 1) ? bl_Guidance.LeftDown : bl_Guidance.RightDown;
        info7.ExtraDelayTime  = -1;
        info7.AnimationType   = bl_HUDText.TextAnimationType.PingPong;
        info7.FadeSpeed       = 200;
        info7.ExtraFloatSpeed = -11;
        //Send the information
        HUDRoot.NewText(info7);
    }
Exemple #14
0
    public void NewHUDTextUP(string sub, Color textColor, Transform transform)
    {
        HUDTextInfo info7 = new HUDTextInfo(transform, sub);

        info7.Color = textColor;
        info7.Size  = 20;
        info7.Speed = Random.Range(0.9f, 1f);
        info7.VerticalAceleration    = Random.Range(-2, 0f);
        info7.VerticalPositionOffset = 0.2f;
        info7.VerticalFactorScale    = Random.Range(1.2f, 10);
        info7.Side            = bl_Guidance.Up;
        info7.ExtraDelayTime  = -1;
        info7.AnimationType   = bl_HUDText.TextAnimationType.SmallToNormal;
        info7.FadeSpeed       = 200;
        info7.ExtraFloatSpeed = -11;
        //Send the information
        HUDRoot.NewText(info7);
    }
Exemple #15
0
    public override void ShowDamage()
    {
        //JYX2逻辑,不存在MISS
        if (_showDamage <= 0)
        {
            return;
        }

        if (StoryEngine.Instance == null)
        {
            return;
        }

        var    hudRoot    = StoryEngine.Instance.HUDRoot;
        string damageText = "";

        if (_showDamage > 0)
        {
            damageText = $"-{Math.Max(_showDamage, 1)}";
        }
        else
        {
            damageText = "MISS";
        }
        HUDTextInfo info = new HUDTextInfo(transform, $"{damageText}")
        {
            Color = Color.white,
            //Size = Random.Range(1, 12),
            Speed = Random.Range(0.2f, 1),
            VerticalAceleration    = Random.Range(-2, 2f),
            VerticalPositionOffset = Random.Range(0, 0.8f),
            VerticalFactorScale    = Random.Range(1.2f, 10),
            Side            = (Random.Range(0, 2) == 1) ? bl_Guidance.LeftDown : bl_Guidance.RightDown,
            ExtraDelayTime  = 0.2f,
            AnimationType   = bl_HUDText.TextAnimationType.HorizontalSmall,
            FadeSpeed       = 200,
            ExtraFloatSpeed = -11
        };

        info.TextPrefab = Jyx2ResourceHelper.GetCachedPrefab("Assets/Prefabs/Jyx2/AttackInfoText.prefab");
        hudRoot.NewText(info);

        CheckDeath();
    }
Exemple #16
0
    //npc闲聊
    public void DoNpcChat()
    {
        if (m_NpcWords != null && m_NpcWords.Length > 0)
        {
            string      randomWord = m_NpcWords[UnityEngine.Random.Range(0, m_NpcWords.Length)];
            HUDTextInfo info4      = new HUDTextInfo(transform, randomWord)
            {
                Color = Color.white,
                Size  = 15,
                VerticalPositionOffset = 1f,
                VerticalFactorScale    = UnityEngine.Random.Range(1.2f, 3),
                Side           = bl_Guidance.Right,
                FadeSpeed      = 500,
                ExtraDelayTime = 5,
                AnimationType  = bl_HUDText.TextAnimationType.HorizontalSmall
            };
            //Send the information
            var hudRoot = StoryEngine.Instance.HUDRoot;
            hudRoot.NewText(info4);
        }

        transform.LookAt(GameRuntimeData.Instance.Player.View.transform);
    }
Exemple #17
0
        /// <summary>
        ///
        /// </summary>
        private void OnMouseDown()
        {
            switch (m_Type)
            {
            case ExampleType.Friend:
                HUDTextInfo info = new HUDTextInfo(transform, string.Format("+{0}", Random.Range(5, 20).ToString()));
                info.Size  = Random.Range(10, 15);
                info.Color = Color.green;
                info.VerticalPositionOffset = 3;
                HUDRoot.NewText(info);
                break;

            case ExampleType.Enemy:
                //Build the information
                HUDTextInfo info2 = new HUDTextInfo(transform, "- " + Random.Range(50, 100));
                info2.Color = Color.red;
                info2.Size  = Random.Range(6, 15);
                info2.Speed = Random.Range(10, 20);
                info2.VerticalAceleration    = -1;
                info2.VerticalFactorScale    = Random.Range(1.2f, 3);
                info2.VerticalPositionOffset = 3;
                info2.Side = (Random.Range(0, 2) == 1) ? bl_Guidance.RightDown : bl_Guidance.LeftDown;
                //Send the information
                HUDRoot.NewText(info2);
                break;

            case ExampleType.Neutral:
                //Build the information
                string      t     = Text[Random.Range(0, Text.Length)];
                HUDTextInfo info3 = new HUDTextInfo(transform, t);
                info3.Color = Color.white;
                info3.Size  = Random.Range(10, 13);
                info3.Speed = Random.Range(10, 20);
                info3.VerticalAceleration = 1;
                info3.VerticalFactorScale = Random.Range(1.2f, 3);
                info3.Side = bl_Guidance.Up;
                info3.VerticalPositionOffset = 3;
                info3.AnimationSpeed         = 0.5f;
                info3.ExtraDelayTime         = 2;
                info3.FadeSpeed = 400;
                //Send the information
                HUDRoot.NewText(info3);
                break;

            case ExampleType.Info:
                //Build the information
                HUDTextInfo info4 = new HUDTextInfo(transform, InfoText[Random.Range(0, InfoText.Length)]);
                info4.Color = Color.white;
                info4.Size  = Random.Range(5, 12);
                info4.Speed = Random.Range(10, 20);
                info4.VerticalAceleration    = 1;
                info4.VerticalPositionOffset = 5;
                info4.VerticalFactorScale    = Random.Range(1.2f, 3);
                info4.Side           = bl_Guidance.Right;
                info4.TextPrefab     = TextPrefab;
                info4.FadeSpeed      = 500;
                info4.ExtraDelayTime = 5;
                info4.AnimationType  = bl_HUDText.TextAnimationType.HorizontalSmall;
                //Send the information
                HUDRoot.NewText(info4);
                break;

            case ExampleType.NeutralText:
                //Build the information
                HUDTextInfo info5 = new HUDTextInfo(transform, string.Format("Text: {0}", Random.Range(2, 20).ToString()));
                info5.Color = Color.white;
                info5.Size  = Random.Range(10, 15);
                info5.Speed = Random.Range(5, 14);
                info5.VerticalAceleration    = 0.5f;
                info5.VerticalPositionOffset = 3.5f;
                info5.VerticalFactorScale    = Random.Range(1.2f, 3);
                info5.Side           = bl_Guidance.Up;
                info5.ExtraDelayTime = 0.5f;
                info5.AnimationType  = bl_HUDText.TextAnimationType.HorizontalSmall;
                //Send the information
                HUDRoot.NewText(info5);
                break;

            case ExampleType.Points:
                //Build the information
                HUDTextInfo info6 = new HUDTextInfo(transform, string.Format("Points: {0}", Random.Range(2, 20).ToString()));
                info6.Color = Color.white;
                info6.Size  = 4;
                info6.Speed = Random.Range(0.2f, 1);
                info6.VerticalAceleration    = 0.2f;
                info6.VerticalPositionOffset = -4f;
                info6.VerticalFactorScale    = Random.Range(1.2f, 20);
                info6.Side           = bl_Guidance.Down;
                info6.ExtraDelayTime = 0.1f;
                info6.AnimationType  = bl_HUDText.TextAnimationType.SmallToNormal;
                info6.FadeSpeed      = 300;
                //Send the information
                HUDRoot.NewText(info6);
                break;

            case ExampleType.Random:
                //Build the information
                string      sub   = (Random.Range(0, 2) == 1) ? "-" : "+";
                HUDTextInfo info7 = new HUDTextInfo(transform, string.Format("{1}{0}", Random.Range(2, 20).ToString(), sub));
                info7.Color = (Random.Range(0, 2) == 1) ? Color.red : Color.green;
                info7.Size  = Random.Range(1, 12);
                info7.Speed = Random.Range(0.2f, 1);
                info7.VerticalAceleration    = Random.Range(-2, 2f);
                info7.VerticalPositionOffset = 2f;
                info7.VerticalFactorScale    = Random.Range(1.2f, 10);
                info7.Side            = (Random.Range(0, 2) == 1) ? bl_Guidance.LeftDown : bl_Guidance.RightDown;
                info7.ExtraDelayTime  = -1;
                info7.AnimationType   = bl_HUDText.TextAnimationType.PingPong;
                info7.FadeSpeed       = 200;
                info7.ExtraFloatSpeed = -11;
                //Send the information
                HUDRoot.NewText(info7);
                break;

            default:
                Debug.Log("Unknow type");
                break;
            }


            if (m_Particle != null)
            {
                GameObject g = (GameObject)Instantiate(m_Particle, (this.transform.position + Vector3.up), this.transform.rotation);
                Destroy(g, 1.5f);
            }
        }