Ejemplo n.º 1
0
        void Update()
        {
            if (!playing)
            {
                return;
            }
            time += Time.deltaTime;
            if (time.OutOfBounds(0, maxTime))
            {
                playing = false;
                return;
            }
            float length = MathR.Lerp(
                min: (direction) ? 0 : maxLength,
                max: (direction) ? maxLength : 0,
                time: time / maxTime,
                type: MathR.LerpType.LINEAR);

            if (length.OutOfBounds(0, maxLength))
            {
                playing = false;
                return;
            }
            UpdateElements(length);
        }
Ejemplo n.º 2
0
        public float Evaluate(float x, float y, float z)
        {
            int xi0 = ((int)Floor(x)) & TABLE_SIZE_MASK;
            int yi0 = ((int)Floor(y)) & TABLE_SIZE_MASK;
            int zi0 = ((int)Floor(z)) & TABLE_SIZE_MASK;

            int xi1 = (xi0 + 1) & TABLE_SIZE_MASK;
            int yi1 = (yi0 + 1) & TABLE_SIZE_MASK;
            int zi1 = (zi0 + 1) & TABLE_SIZE_MASK;

            float tx = x - (int)Floor(x);
            float ty = y - (int)Floor(y);
            float tz = z - (int)Floor(z);

            float u = MathR.Smoothstep(tx);
            float v = MathR.Smoothstep(ty);
            float w = MathR.Smoothstep(tz);

            // Edge Vectors
            Vector3 c000 = Gradient[HashV3(xi0, yi0, zi0)];
            Vector3 c100 = Gradient[HashV3(xi1, yi0, zi0)];
            Vector3 c010 = Gradient[HashV3(xi0, yi1, zi0)];
            Vector3 c110 = Gradient[HashV3(xi1, yi1, zi0)];

            Vector3 c001 = Gradient[HashV3(xi0, yi0, zi1)];
            Vector3 c101 = Gradient[HashV3(xi1, yi0, zi1)];
            Vector3 c011 = Gradient[HashV3(xi0, yi1, zi1)];
            Vector3 c111 = Gradient[HashV3(xi1, yi1, zi1)];

            float x0 = tx, x1 = tx - 1;
            float y0 = ty, y1 = ty - 1;
            float z0 = tz, z1 = tz - 1;

            // Point Vectors
            Vector3 p000 = new Vector3(x0, y0, z0);
            Vector3 p100 = new Vector3(x1, y0, z0);
            Vector3 p010 = new Vector3(x0, y1, z0);
            Vector3 p110 = new Vector3(x1, y1, z0);

            Vector3 p001 = new Vector3(x0, y0, z1);
            Vector3 p101 = new Vector3(x1, y0, z1);
            Vector3 p011 = new Vector3(x0, y1, z1);
            Vector3 p111 = new Vector3(x1, y1, z1);

            // Lerping
            float a = MathR.Lerp(Vector3.Dot(c000, p000), Vector3.Dot(c100, p100), u);
            float b = MathR.Lerp(Vector3.Dot(c010, p010), Vector3.Dot(c110, p110), u);
            float c = MathR.Lerp(Vector3.Dot(c001, p001), Vector3.Dot(c101, p101), u);
            float d = MathR.Lerp(Vector3.Dot(c011, p011), Vector3.Dot(c111, p111), u);

            float e = MathR.Lerp(a, b, v);
            float f = MathR.Lerp(c, d, v);

            return(MathR.Lerp(e, f, w));
        }
Ejemplo n.º 3
0
    private IEnumerator ActivePillar()
    {
        m_lerp     = 0.0f;
        m_isActive = true;
        m_currentCharacter.Invoke("ActiveCuspe", 0.1f);

        while (m_lerp < 1.0f)
        {
            m_lerp += Time.deltaTime * m_upSpeed;

            transform.localPosition = MathR.Lerp(m_normalPos, m_activePos, m_lerp, m_upInterpolation);

            yield return(null);
        }

        m_currentCharacter = null;
        m_isChanging       = false;
    }
Ejemplo n.º 4
0
    private IEnumerator Lerp(bool win)
    {
        m_lerp = 0.0f;

        while (m_lerp < 1.0f)
        {
            m_lerp += Time.deltaTime * 15.0f;

            transform.localScale = MathR.Lerp(Constantes.VECTOR_3_ZERO, m_scale, m_lerp, INTERPOLATION.ExponentialEaseIn);

            yield return(null);
        }

        if (!win)
        {
            Invoke("Deactive", 0.25f);
        }
    }
Ejemplo n.º 5
0
    private IEnumerator MoveTo()
    {
        while (m_lerp < 1.0f)
        {
            m_lerp += Time.deltaTime;

            m_position      = transform.position;
            m_endPosition   = m_winner.transform.position;
            m_endPosition.z = m_position.z;

            transform.position          = MathR.Lerp(m_position, m_endPosition, m_lerp, INTERPOLATION.Linear);
            mainCamera.orthographicSize = Mathf.Lerp(5.0f, 2.0f, m_lerp);

            yield return(null);
        }

        m_winner.animationController.PlayByType(ANIMATION_TYPE.IDLE);
        m_winner.PlayBallon(true);

        Invoke("Load", 2.0f);
    }
Ejemplo n.º 6
0
    private IEnumerator DeactivePillar()
    {
        if (m_sword != null)
        {
            m_sword.SetState(new Fall());
            m_sword = null;
        }

        m_lerp = 0.0f;
        m_currentCharacter.Invoke("ActiveCuspe", 0.1f);

        while (m_lerp < 1.0f)
        {
            m_lerp += Time.deltaTime * m_downSpeed;

            transform.localPosition = MathR.Lerp(m_activePos, m_normalPos, m_lerp, m_downInterpolation);

            yield return(null);
        }

        m_isActive         = false;
        m_isChanging       = false;
        m_currentCharacter = null;
    }
Ejemplo n.º 7
0
 public static Vector2 Lerp(Vector2 a, Vector2 b, float t)
 {
     return(new Vector2(MathR.Lerp(a.X, b.X, t), MathR.Lerp(a.Y, b.Y, t)));
 }
Ejemplo n.º 8
0
 ///<summary>
 /// Linearly interpolates between 2 vectors
 ///</summary>
 public static Vector3 Lerp(Vector3 a0, Vector3 a1, float t)
 {
     return(new Vector3(MathR.Lerp(a0.X, a1.X, t),
                        MathR.Lerp(a0.Y, a1.Y, t),
                        MathR.Lerp(a0.Z, a1.Z, t)));
 }