Beispiel #1
0
    public float GetGravPull(Vector3 pos)
    {
        float dist = Vector3.Distance(pos, transform.position);

        dist = dist.RemapNRB(distForPullMax * transform.localScale.magnitude, distForPullMin * transform.localScale.magnitude, 1f, 0f);

        return(EasingFunction.EaseInQuad(gravPullMin, gravPullMax, dist));
    }
Beispiel #2
0
    void Update()
    {
        if (isDead)
        {
            deadSpeed += deadAccel;
            transform.Translate(0, 0, -deadSpeed);
            if (transform.position.z < -100)
            {
                Destroy(gameObject);
            }
            return;
        }

        // Tilt.
        if (tilt >= GameScript.MAX_TILT)   // Drop the book; the game is over.
        {
            tilt = Mathf.Min(90, tilt + 3);
        }
        float actualTilt = tiltParent.transform.localRotation.eulerAngles.z;

        if (actualTilt != tilt)
        {
            float zRot = Mathf.Abs(tilt - actualTilt) < .5f ? tilt : actualTilt + (tilt - actualTilt) * TILT_TWEEN_SPEED;
            float zRadians = zRot * Mathf.Deg2Rad;
            float zSin = Mathf.Sin(zRadians);
            float z2Sin = Mathf.Sin(zRadians * 2);
            float width = model.transform.localScale.x, height = model.transform.localScale.y * 8;
            float xOff = (height / 2 - width / 2) * zSin + (height / 20) * z2Sin;
            float yOff = (width / 2 - height / 2) * zSin + (height / 5) * z2Sin;
            tiltParent.transform.localPosition = new Vector3(xOff, yOff, 0);
            tiltParent.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, zRot));
        }
        // Tween.
        if (xTweenTime < 1)
        {
            xTweenTime = Mathf.Min(1, xTweenTime + xTweenSpeed);
            if (!ready && xTweenTime >= .9f)
            {
                audioSource.PlayOneShot(thumpClips[Random.Range(0, thumpClips.Length)]);
                ready = true;
            }
            float x = EasingFunction.EaseInOutQuad(xTweenStart, 0, xTweenTime);
            float z = EasingFunction.EaseInQuad(0, 1, xTweenTime);
            if (z > .5)
            {
                z = 1 - z;
            }
            z *= 2;
            float y    = zTweenFront ? z / 2 : 0;
            float xRot = zTweenFront ? z * -3 : 0;
            z *= zTweenFront ? -5f : 2.5f;
            tweenParent.transform.localPosition = new Vector3(x, y, z);
            tweenParent.transform.localRotation = Quaternion.Euler(new Vector3(xRot, 0, 0));
        }
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale > 0 && Time.timeScale != 1)
        {
            if (curv1 > 0)
            {
                Time.timeScale = EasingFunction.EaseInQuart(stunScale, 1, 1 - curv1 / stunCounter);
                curv1         -= Time.unscaledDeltaTime;
            }
            else
            {
                Time.timeScale = 1;
            }
        }

        if (zooning)
        {
            Camera.main.orthographicSize = EasingFunction.EaseOutQuad(camMin, camMax, curv3 / zoonIn);
            if (curv3 > 0)
            {
                curv3 -= Time.unscaledDeltaTime;
            }
            else
            {
                curv2   = zoonOut;
                zooning = false;
            }
        }
        else
        {
            Camera.main.orthographicSize = EasingFunction.EaseInQuad(camMin, camMax, 1 - curv2 / zoonOut);
            if (curv2 > 0)
            {
                curv2 -= Time.unscaledDeltaTime;
            }
            else
            {
                Camera.main.orthographicSize = camMax;
            }
        }
    }