Esempio n. 1
0
    private IEnumerator TransitionOut()
    {
        cStartPos   = cutOut.rectTransform.position;
        cStartScale = cutOut.rectTransform.sizeDelta;
        float t = 0f;
        float e;

        while (t <= 1f)
        {
            t += Time.deltaTime * transitionSpeed;
            Vector3 pos = cam.WorldToScreenPoint(cow.position);
            e = Ease.EaseOutBounce(t);
            cutOut.rectTransform.position     = Vector2.Lerp(cStartPos, pos, e);
            cutOut.rectTransform.sizeDelta    = Vector2.Lerp(cStartScale, Vector2.zero, e);
            background.rectTransform.position = centerPos.transform.position;

            yield return(null);
        }
        cutOut.rectTransform.sizeDelta = Vector2.zero;

        yield return(new WaitForSeconds(.2f));

        levelSelect.SetActive(true);
        StartCoroutine(TransitionIn());
    }
Esempio n. 2
0
    private IEnumerator DropFence(FenceObstacle fence, int index)
    {
        float   t = 0f;
        float   s;
        Vector3 startPos = fence.transform.position;
        float   inv;

        while (t < 1f)
        {
            t += Time.deltaTime;
            s  = t < firstContact ? 1f : Ease.EaseOutBounce(t);

            inv = Mathf.InverseLerp(0f, firstContact, t);
            fence.transform.localScale = new Vector3(1f, s, 1f);
            fence.transform.position   = Vector3.Lerp(startPos, fenceObstaclePositions[index], inv);
            yield return(null);
        }
    }
Esempio n. 3
0
    private IEnumerator Bounce()
    {
        Vector3 currPos     = transform.position;
        Vector3 endPos      = currPos;
        float   startHeight = currPos.y + height + Random.Range(-2f, 2f);
        float   startSide   = currPos.x;

        startSide = startSide < 0f
                                ? startSide - sidewaysDistance
                                : startSide + sidewaysDistance;

        currPos.x          = startSide;
        currPos.y          = startHeight;
        transform.position = currPos;

        float delay = Random.Range(.5f, 1.5f);

        yield return(new WaitForSeconds(delay));

        soundController.PlaySoundWithDelay(hittingGrass, 0.2f);


        float time = 0;

        while (time < 1f)
        {
            float bounce   = Ease.EaseOutBounce(time);
            float sideWays = Ease.EaseOutQuint(time);

            time              += Time.deltaTime;
            currPos.x          = Mathf.Lerp(startSide, endPos.x, sideWays);
            currPos.y          = Mathf.Lerp(startHeight, endPos.y, bounce);
            transform.position = currPos;
            yield return(null);
        }
        if (time >= 1f)
        {
            transform.position = endPos;
        }
    }