Exemplo n.º 1
0
    void Update()
    {
        if (state == eFSStateGolf.idle)
        {
            return;
        }
        float u  = (Time.time - timeStart) / timeDuration;
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {
            state       = eFSStateGolf.pre;
            txt.enabled = false;
        }
        else
        {
            if (u >= 1)
            {
                uC    = 1;
                state = eFSStateGolf.post;
                if (reportFinishTo != null)
                {
                    reportFinishTo.SendMessage("FSCallback", this);
                    Destroy(gameObject);
                }
                else
                {
                    state = eFSStateGolf.idle;
                }
            }
            else
            {
                state       = eFSStateGolf.active;
                txt.enabled = true;
            }
            Vector2 pos = Utils.Bezier(uC, bezierPts);
            rectTrans.anchorMin = rectTrans.anchorMax = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <Text>().fontSize = size;
            }
        }
    }
Exemplo n.º 2
0
    public void Init(List <Vector2> ePts, float eTimeS = 0, float eTimeD = 1)
    {
        rectTrans = GetComponent <RectTransform>();
        rectTrans.anchoredPosition = Vector2.zero;

        txt = GetComponent <Text>();

        bezierPts = new List <Vector2>(ePts);

        if (ePts.Count == 1)
        {
            transform.position = ePts[0];
            return;
        }

        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = eFSStateGolf.pre;
    }