Exemplo n.º 1
0
    // Set up the FloatingScore and movement
    // Note the use of parameter defaults for eTimeS & eTimeD
    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)
        {   // If there's only one point
            // ...then just go there.
            transform.position = ePts[0];
            return;
        }

        // If eTimeS is the default, just start at the current time
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = eFSState.pre; // Set it to the pre state, ready to start moving
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // If this is not moving, just return
        if (state == eFSState.idle)
        {
            return;
        }

        // Get u from the current time and duration
        // u ranges from 0 to 1 (usually)
        float u = (Time.time - timeStart) / timeDuration;
        // Use Easing class from Utils to curve the u value
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {                        // If u<0, then we shouldn't move yet.
            state       = eFSState.pre;
            txt.enabled = false; // Hide the score initially
        }
        else
        {
            if (u >= 1)
            {              // If u>=1, we're done moving
                uC    = 1; // Set uC=1 so we don't overshoot
                state = eFSState.post;
                if (reportFinishTo != null)
                { //If there's a callback GameObject
                  // Use SendMessage to call the FSCallback method
                  //  with this as the parameter.
                    reportFinishTo.SendMessage("FSCallback", this);
                    // Now that the message has been sent,
                    //  Destroy this gameObject
                    Destroy(gameObject);
                }
                else
                { // If there is nothing to callback
                  // ...then don't destroy this. Just let it stay still.
                    state = eFSState.idle;
                }
            }
            else
            {
                // 0<=u<1, which means that this is active and moving
                state       = eFSState.active;
                txt.enabled = true; // Show the score once more
            }
            // Use Bézier curve to move this to the right point
            Vector2 pos = Utils.Bezier(uC, bezierPts);
            // RectTransform anchors can be used to position UI objects relative
            //  to total size of the screen
            rectTrans.anchorMin = rectTrans.anchorMax = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                // If fontSizes has values in it
                // ...then adjust the fontSize of this GUIText
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <Text>().fontSize = size;
            }
        }
    }
Exemplo n.º 3
0
    public void Init(List <Vector2> ePts, float eTimeS = 0, float eTimeD = 1)
    {
        rectTrans = GetComponent <RectTransform>();
        if (SceneManager.GetActiveScene().name == "__Prospector_Scene_0")
        {
            rectTrans.anchoredPosition = new Vector2(Screen.width / 3, Screen.height / 2);
        }
        else
        {
            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 = eFSState.pre;
    }
Exemplo n.º 4
0
    // Set up the FloatingScore and movement
    // Note the use of parameter defaults for eTimeS & eTimeD
    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)
        {   // If there's only one point
            // ...then just go there.
            transform.position = ePts[0];
            return;
        }

        // If eTimeS is the default, just start at the current time
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = eFSState.pre;  // Set it to the pre state, ready to start moving
                
    }
    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 is the default, just start at the current time
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = eFSState.pre;
    }
Exemplo n.º 6
0
         // Set up the FloatingScore and movement
         // Note the use of parameter defaults for eTimeS & eTimeD
        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)  
        {
                     // If there's only one point
                     // ...then just go there.
                    transform.position  =  ePts[0];

                    return;
                  
        }

           
              // If eTimeS is the default, just start at the current time
              if (eTimeS  ==  0)  eTimeS  =  Time.time;

              timeStart     =  eTimeS;
              timeDuration  =  eTimeD;

           state  =  eFSState.pre;  // Set it to the pre state, ready to start moving
                
    }
Exemplo n.º 7
0
    void Update()
    {
        if (state == eFSState.idle)
        {
            return;
        }


        float u = (Time.time - timeStart) / timeDuration;

        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {
            state = eFSState.pre;

            txt.enabled = false;
        }
        else
        {
            if (u >= 1)
            {
                uC = 1;

                state = eFSState.post;

                if (reportFinishTo != null)
                {
                    reportFinishTo.SendMessage("FSCallback", this);

                    Destroy(gameObject);
                }
                else
                {
                    state = eFSState.idle;
                }
            }
            else
            {
                state = eFSState.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.º 8
0
    // Update is called once per frame
    void Update()
    {
        // if its not moving, just return
        if (state == eFSState.idle)
        {
            return;
        }

        // Get u from the current time and duration. u ranges from 0 to 1
        float u  = (Time.time - timeStart) / timeDuration;
        float uC = Easing.Ease(u, easingCurve); // use easing class to curve the u value

        if (u < 0)                              // we should not move
        {
            state       = eFSState.pre;
            txt.enabled = false;        // hide the score
        }
        else
        {
            if (u >= 1)                 // we are done moving
            {
                uC    = 1;              // set uC = 1 so we dont overshoot
                state = eFSState.post;

                if (reportFinishTo != null)      // if theres a callback GO
                {
                    // use SendMessage to call the FSCallback method with this as a parameter
                    reportFinishTo.SendMessage("FSCallback", this);
                    Destroy(gameObject);
                }
                else
                {
                    // if theres noting to callback. dont destroy just stay still.
                    state = eFSState.idle;
                }
            }
            else
            {
                // 0 <= u < 1, then it is active and moving
                state       = eFSState.active;
                txt.enabled = true;         // show the score;
            }

            Vector2 pos = Utils.Bezier(uC, bezierPts);
            rectTrans.anchorMin = rectTrans.anchorMax = pos;    // position UI objs relative to total size of screen

            if (fontSizes != null && fontSizes.Count > 0)
            {
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <Text>().fontSize = size;
            }
        }
    }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (state == eFSState.idle)
        {
            return;
        }
        //设置贝塞尔函数的插值系数,和时间相关
        float u = (Time.time - timeStart) / timeDuration;
        //使用Easing中的方法来Curve u的值
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {
            //说明还没到timeState的时间
            state       = eFSState.pre;
            txt.enabled = false;     //把显示txt的HighScore先隐藏
        }
        else
        {
            if (u > 1)
            {
                uC    = 1;
                state = eFSState.post;
                if (reportFinishTo != null)
                {
                    // 如果存在一个回传函数,用SendMessage来调用FSCallback方法
                    reportFinishTo.SendMessage("FSCallback", this);
                    Destroy(gameObject);
                }
                else
                {
                    //如果没有可回传的
                    state = eFSState.idle;
                }
            }
            else
            {
                // u在0到1之间
                state       = eFSState.active;
                txt.enabled = true;
            }
            Vector2 pos = Utils.Bezier(uC, bezierPts);
            rectTrans.anchorMin = rectTrans.anchorMax = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                //如果fontSizes有值,则把GUIText的fontSize设置成按时间变化
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <Text>().fontSize = size;
            }
        }
    }
    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;
        }
        state = eFSState.pre;
    }
Exemplo n.º 11
0
    public Text txt;                                 //this.gameObject的其中一个component

    //初始化贝塞尔曲线的两个点、开始、持续时间
    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];   //如果输入的List只有一个点,把this.gameObject的位置设置成该点的位置
            return;
        }

        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;
        state        = eFSState.pre; //准备移动的阶段
    }
Exemplo n.º 12
0
    // Set up the FloatingScore and movement
    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 = eFSState.pre;          // set it to the pre state, ready to start moving
    }
Exemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        // If this is not moving, just return
        if (state == eFSState.idle)
        {
            return;
        }
        // Get u from the current time and duration
        // u ranges from 0 to 1 (usually)
        float u = (Time.time - timeStart) / timeDuration;
        // Use Easing class from Utils to curve the u value
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {
            // If u<0, then we shouldn't move yet.
            state       = eFSState.pre;
            txt.enabled = false;
            // Hide the score initially
        }
        else
        {
            if (u >= 1)
            {
                // If u>=1, we're done moving
                uC = 1;
                // Set uC=1 so we don't overshoot
                state = eFSState.post;
                if (reportFinishTo != null)
                {
                    //If there's a callback GameObject
                    // Use SendMessage to call the FSCallback method
                    //  with this as the parameter.
                    reportFinishTo.SendMessage("FSCallback", this);
                    // Now that the message has been sent,
                    // Destroy this gameObject
                    Destroy(gameObject);
                }
                else
                {
                    // If there is nothing to callback
                    // ...then don't destroy this. Just let it stay still.
                    state = eFSState.idle;
                }
            }
            else
            {
                // 0<=u<1, which means that this is active and moving
                state       = eFSState.active;
                txt.enabled = true;
                // Show the score once more
            }
            // Use Bézier curve to move this to the right point
            Vector2 pos = Utils.Bezier(uC, bezierPts);
            // RectTransform anchors can be used to position UI objects relative
            //  to total size of the screen 
            rectTrans.anchorMin = rectTrans.anchorMax = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                // If fontSizes has values in it
                // ...then adjust the fontSize of this GUIText

                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <Text>().fontSize = size;
            }
        }
    }
Exemplo n.º 14
0
        // Update is called once per frame
        void Update ()  
    {
                // If this is not moving, just return
                if (state  ==  eFSState.idle)  return;

           
                // Get u from the current time and duration
                // u ranges from 0 to 1 (usually)
                   float u  =  (Time.time  -  timeStart) / timeDuration;
                // Use Easing class from Utils to curve the u value
                   float uC  =  Easing.Ease (u,  easingCurve);

               if (u < 0)   {
                  // If u<0, then we shouldn't move yet.
                          state  =  eFSState.pre;

                      txt.enabled =  false;  // Hide the score initially
                        
        }  else  {
                      if (u >= 1)   {
                                          // If u>=1, we're done moving
                              uC  =  1;   // Set uC=1 so we don't overshoot

                                  state  =  eFSState.post;
                              if (reportFinishTo  !=  null)   {
                                       //If there's a callback GameObject
                                       // Use SendMessage to call the FSCallback method
                                       //  with this as the parameter.
                                      reportFinishTo.SendMessage("FSCallback",  this);
                                       // Now that the message has been sent,
                                       //  Destroy this gameObject
                                      Destroy (gameObject);

                                  
                }  else   {
                                       // If there is nothing to callback
                                       // ...then don't destroy this. Just let it stay still.
                                          state  =  eFSState.idle;

                                  
                }
                          
            }  else  {
                              // 0<=u<1, which means that this is active and moving
                       state  =  eFSState.active;

                              txt.enabled  =  true;  // Show the score once more
                               
            }
                         // Use Bézier curve to move this to the right point
                               Vector2 pos  =  Utils.Bezier(uC,  bezierPts);
                         // RectTransform anchors can be used to position UI objects relative
                         //  to total size of the screen 
                       rectTrans.anchorMin  =  rectTrans.anchorMax  =  pos;

                       if (fontSizes  !=  null  &&  fontSizes.Count > 0)   {
                                // If fontSizes has values in it
                                // ...then adjust the fontSize of this GUIText
                                   int size  =  Mathf.RoundToInt( Utils.Bezier(uC,  fontSizes)  );

                               GetComponent <Text>().fontSize  =  size;
                          
            }
                    
        }
            
    }