Beispiel #1
0
    // INTERNALS

    public void Seek(float i_Time, out TransformData o_Data)
    {
        o_Data = default(TransformData);

        int   index;
        float timestamp;

        if (m_Buffer.TryGetIndex(i_Time, out index, out timestamp))
        {
            TransformData data;
            if (m_Buffer.TryGetData(index, out data, out timestamp))
            {
                TransformData nextData;
                float         nextTimestamp;
                if (!m_Buffer.TryGetData(index + 1, out nextData, out nextTimestamp))
                {
                    nextTimestamp = timestamp;
                    nextData      = data;
                }

                float p = MathUtils.GetClampedPercentage(i_Time, timestamp, nextTimestamp);

                Vector3    targetPosition = Vector3.Lerp(data.position, nextData.position, p);
                Quaternion targetRotation = Quaternion.Lerp(data.rotation, nextData.rotation, p);
                Vector3    targetScale    = Vector3.Lerp(data.scale, nextData.scale, p);

                TransformData targetData = new TransformData(targetPosition, targetRotation, targetScale);
                o_Data = targetData;
            }
        }
    }
    public void UpdatePlay(float i_LastPlayedTime, float i_PlayTime)
    {
        int   lastIndexPlayed;
        float lastPlayedTimestamp;

        if (m_Buffer.TryGetIndex(i_LastPlayedTime, out lastIndexPlayed, out lastPlayedTimestamp))
        {
            int   index;
            float timestamp;
            if (m_Buffer.TryGetIndex(i_PlayTime, out index, out timestamp))
            {
                for (int i = lastIndexPlayed; i <= index; ++i)
                {
                    float t;
                    m_Buffer.GetData(i, out t);

                    if (t > i_LastPlayedTime && t <= i_PlayTime)
                    {
                        m_ActionTest.ForceEffect();
                    }
                }
            }
        }
    }
Beispiel #3
0
    void Update()
    {
        m_Timer += Time.deltaTime;

        if (Input.GetKeyDown(m_PushKey))
        {
            m_Buffer.Push(m_Timer, Random.Range(0, 101));
            Debug.Log("Push at t: " + m_Timer);
        }
        else
        {
            if (Input.GetKeyDown(m_GetKey))
            {
                int   index;
                float t;
                if (m_Buffer.TryGetIndex(m_TimeToSearch, out index, out t))
                {
                    Debug.Log("Data found: " + index + ", " + t);
                }
            }
        }
    }