Esempio n. 1
0
    void Update()
    {
        if (paused)
        {
            return;
        }
        if (wasTapped)
        {
            currentLerpTime += Time.deltaTime;
            if (currentLerpTime > lerpTime)
            {
                currentLerpTime = lerpTime;
            }

            float percentage = currentLerpTime / lerpTime;
            transform.position = Vector3.Lerp(transform.position, destination, percentage);

            float distanceLeft = Vector2.Distance(transform.position, destination);
            if (distanceLeft <= 0.2f)
            {
                GameObject         scrapPile = GameObject.FindGameObjectWithTag("Scrap");
                ScrapManagerScript scrap     = scrapPile.GetComponent <ScrapManagerScript> ();
                scrap.addScrap(scrapValue);

                Destroy(this.gameObject);
            }
        }
        else
        {
            // in the meantime, hover
            transform.position = new Vector2(transform.position.x, yOrigin + (Mathf.Sin(Time.time * floatSpeed) * floatStrength));

            autoTapTimer += Time.deltaTime;
            if (autoTapTimer >= autoTapTimout)
            {
                wasTapped = true;
            }
        }
    }
Esempio n. 2
0
 void Start()
 {
     scrapManager = scrapPile.GetComponent <ScrapManagerScript> ();
 }