Ejemplo n.º 1
0
    IEnumerator Move()
    {
        if (UIMoney.Instance == false)
        {
            gameObject.SetActive(false);
            yield break;
        }
        orignalPoint = transform.position;

        float waitTime = Random.Range(0, 0.5f);
        //yield return new WaitForSeconds(waitTime);



        Vector3 direction = new Vector3(Random.Range(0f, 1f), Random.Range(0f, 1f), 0);
        //Debug.Log("방향 : " + direction);
        //float time = Time.unscaledTime;

        //while (true)
        //{
        //    if (AutoGoldGeneration.Instance.texTime < (Time.time - time))
        //    {
        //        break;
        //    }
        //    transform.Translate(direction * (AutoGoldGeneration.Instance.texSpeed) * Time.deltaTime);


        //    yield return null;
        //}


        int a = Random.Range(-1, 1);
        int b = Random.Range(-1, 1);
        //transform.position = Vector2.MoveTowards(transform, )

        float speed     = Random.Range(0.5f, 1.5f);
        float startTime = Time.unscaledTime;

        //float r = Random.Range(-0.5f, 0.5f);
        while (Time.unscaledTime < startTime + 2f)
        {
            float elapsedTime = (Time.unscaledTime - startTime) * 2;

            float t = elapsedTime / 2f;



            transform.position   = Vector3.Lerp(transform.position, UIMoney.Instance.shopMoneyGoldText.transform.position, elapsedTime * speed);
            transform.localScale = Vector3.Lerp(transform.localScale, Vector3.zero, t);
            //transform.position = GetPointOnBezierCurve(orignalPoint, new Vector3(orignalPoint.x, orignalPoint.y + (a*AutoGoldGeneration.Instance.texSpeed), orignalPoint.z), new Vector3(UIMoney.Instance.shopMoneyGoldText.transform.position.x, UIMoney.Instance.shopMoneyGoldText.transform.position.y + (b* AutoGoldGeneration.Instance.texSpeed), UIMoney.Instance.shopMoneyGoldText.transform.position.z), UIMoney.Instance.shopMoneyGoldText.transform.position, elapsedTime * speed);


            //Vector3 center = (orignalPoint + UIMoney.Instance.shopMoneyGoldText.transform.position) * 0.5F;
            //center -= new Vector3(0, r, 0);
            //Vector3 riseRelCenter = orignalPoint - center;
            //Vector3 setRelCenter = UIMoney.Instance.shopMoneyGoldText.transform.position - center;

            //transform.position = Vector3.Slerp(riseRelCenter, setRelCenter, t * speed * AutoGoldGeneration.Instance.moveSpeed);
            //transform.position += center;


            float distance = Vector2.Distance(transform.position, UIMoney.Instance.shopMoneyGoldText.transform.position);
            if (distance < 3f)
            {
                break;
            }



            yield return(null);
        }
        AutoGoldGeneration.ScaleText();
        gameObject.SetActive(false);
    }
Ejemplo n.º 2
0
 private void Awake()
 {
     Instance = this;
 }