Exemplo n.º 1
0
    public void ShowText(string text, Vector3 pos, int configId)
    {
        if (string.IsNullOrEmpty(text) || Main.Main3DCamera == null || !Main.Main3DCamera.enabled)
        {
            return;
        }

        var configs = FontConfigFiles;

        if (EntryPoint.Instance.GetUserLanguageCode() == "KR")
        {
            configs = KRFontConfigFiles;
        }

        if (configs == null || configId >= configs.Length || configId < 0)
        {
            Common.HobaDebuger.LogWarningFormat("HUD Text Config id is wrong");
            return;
        }

        GBMFontAndMotionTextModel model = null;

        if (!_ModelCache.TryGetValue(configId, out model))
        {
            model = Resources.Load <GBMFontAndMotionTextModel>(configs[configId]);
            _ModelCache.Add(configId, model);
        }

        if (model != null)
        {
            var hudtext = _HudTextPool.Get() as GameObject;
            //hudtext.SetActive(true);
            var hudTextComp = hudtext.GetComponent <HUDText>();
            if (hudTextComp != null)
            {
                if (model._IsOnTopLayer)
                {
                    hudTextComp.RectTrans.SetParent(transform.GetChild(1), false);
                }
                else
                {
                    hudTextComp.RectTrans.SetParent(transform.GetChild(0), false);
                }

                pos.x += UnityEngine.Random.Range(-model._XRandomNum, model._XRandomNum);
                pos.y += UnityEngine.Random.Range(-model._XRandomNum, model._XRandomNum);
                pos.z += UnityEngine.Random.Range(-model._XRandomNum, model._XRandomNum);

                Vector3 uipos = TranslatePosToUIPos(pos);

                //Debug.LogWarning("uipos " + uipos);
                hudTextComp.Show(text, uipos, model);
            }
        }
    }
Exemplo n.º 2
0
    static public void MotionTextGen()
    {
        string configPath = "Assets/Resources/MotionTextConfig/";

        if (!Directory.Exists(configPath))
        {
            Directory.CreateDirectory(configPath);
        }

        GMotionModel config1 = ScriptableObject.CreateInstance <GMotionModel>();

        AssetDatabase.CreateAsset(config1, configPath + "MotionTemplate.asset");

        GBMFontAndMotionTextModel config2 = ScriptableObject.CreateInstance <GBMFontAndMotionTextModel>();

        AssetDatabase.CreateAsset(config2, configPath + "GBMFontAndMotionTextModel.asset");
    }
Exemplo n.º 3
0
    public void Show(string text, Vector3 uipos, GBMFontAndMotionTextModel config)
    {
        //Debug.LogWarning("Show HUDText " + text + ", " + config.name + ", " + bg_type);

        if (!IsActive())
        {
            gameObject.SetActive(true);
        }


        uipos += new Vector3(config._Offset.x, config._Offset.y, 0);

        RectTrans.localPosition = uipos;
        var fontScale = config._FontScale;

        RectTrans.localScale = Vector3.one * fontScale;
        Label.font           = config._Font;
        //Label.fontSize = config._FontSize;
        Label.text = text;

        if (config._BGType > -1)
        {
            GNewUITools.SetVisible(_NodeBG, true);
            ImageGrpBG.SetImageIndex(config._BGType);
        }
        else
        {
            GNewUITools.SetVisible(_NodeBG, false);
        }

        if (config._MotionList != null)
        {
            for (int i = 0; i < config._MotionList.Count; i++)
            {
                if (config._MotionList[i] == null)
                {
                    continue;
                }

                var motion     = config._MotionList[i];
                var duration   = motion._Duration;
                var dalay      = motion._Delay;
                var motionType = motion.GetMotionType();
                if (motionType == GMotionModel.MotionType.Scale)
                {
                    var model = motion as GMotionScaleModel;
                    RectTrans.DOScale(model._Scale * Vector3.one * fontScale, duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
                else if (motionType == GMotionModel.MotionType.Linear)
                {
                    var model = motion as GMotionLinearModel;
                    RectTrans.DOMove(model.GetDest(transform.position), duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
                else if (motionType == GMotionModel.MotionType.Alpha)
                {
                    var model = motion as GMotionAlphaModel;
                    //DOTween.ToAlpha(() => Label.color, x => Label.color = x, model._Alpha, duration)
                    //    .SetDelay(dalay);

                    DOTween.To(() => CanvasGrp.alpha, x => CanvasGrp.alpha = x, model._Alpha, duration)
                    .SetDelay(dalay);
                }
                else if (motionType == GMotionModel.MotionType.Curve)
                {
                    var model = motion as GMotionCurveModel;
                    RectTrans.DOPath(model.GetCurvePath(transform.position), duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
                else if (motionType == GMotionModel.MotionType.ParaCurve)
                {
                    var model = motion as GMotionParaCurveModel;
                    RectTrans.DOPath(model.GetParaCurvePath(transform.position), duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
            }

            Invoke("OnMotionEnd", MAX_LIFT_TIME);
        }
    }