Ejemplo n.º 1
0
    private void RecordTransform()
    {
        PlaybackKeyframe newKeyframe = new PlaybackKeyframe();

        newKeyframe.PositionKey = transform.position;
        newKeyframe.RotationKey = transform.rotation;
        newKeyframe.FireKey     = Input.GetAxis("Fire1") != 0;
        newKeyframe.Timestamp   = Time.fixedTime - m_spawnTime;

        if (m_playbackInfo.PlaybackKeys.Count == 0 || !m_playbackInfo.PlaybackKeys[m_playbackInfo.PlaybackKeys.Count - 1].IsEqual(newKeyframe))
        {
            m_playbackInfo.PlaybackKeys.Add(newKeyframe);
        }
    }
Ejemplo n.º 2
0
    private void UpdateRecordedMovement()
    {
        float relativeTime = Time.fixedTime - m_spawnTime;

        while (m_currentPlaybackIndex < m_playbackInfo.PlaybackKeys.Count && m_playbackInfo.PlaybackKeys[m_currentPlaybackIndex].Timestamp < relativeTime)
        {
            PlaybackKeyframe currentKeyframe = m_playbackInfo.PlaybackKeys[m_currentPlaybackIndex];
            m_currentPlaybackIndex++;
            transform.position = currentKeyframe.PositionKey;
            transform.rotation = currentKeyframe.RotationKey;
            if (currentKeyframe.FireKey)
            {
                m_weaponManager.TryFiring();
            }
        }
    }
Ejemplo n.º 3
0
 public bool IsEqual(PlaybackKeyframe other)
 {
     return(PositionKey == other.PositionKey && RotationKey == other.RotationKey && FireKey == other.FireKey);
 }