Esempio n. 1
0
 public void PrintReplay()
 {
     Replay.Snapshot snapshot = _replay.GetNextSnapshot();
     while (snapshot != null)
     {
         Debug.Log("cmd: " + snapshot.commands.ToString() + " tick: " + snapshot.tick.ToString());
         snapshot = _replay.GetNextSnapshot();
     }
 }
Esempio n. 2
0
 public void StartReplaying()
 {
     // prevents start a replay during another replay
     if (_gameMode == GameMode.Playing)
     {
         int delta = Time.frameCount - _time;
         print("FramePassed " + delta.ToString() + " started: " + _time.ToString() + " ended: " + Time.frameCount);
         Debug.Log(_heroController.transform.position);
         _gameMode = GameMode.Replaying;
         _replay.DisableRecording();
         CancelInvoke("ReallyFixedUpdate");
         _heroController.Reset();
         _snapshot       = _replay.GetNextSnapshot();
         _replayGameTick = 0;
         InvokeRepeating("ReallyFixedReplay", 0, _deltaGameTime);
         _time = Time.frameCount;
     }
 }
Esempio n. 3
0
    void ReallyFixedReplay()
    {
        if (_gameMode == GameMode.Replaying)
        {
            _replayGameTick++;

            if (_replayGameTick == _snapshot.tick)
            {
                uint frameCmd = _snapshot.commands;
                _heroController.Perform(frameCmd);
                _snapshot = _replay.GetNextSnapshot();
                if (_snapshot == null)
                {
                    int delta = Time.frameCount - _time;
                    print("FramePassed " + delta.ToString() + " started: " + _time.ToString() + " ended: " + Time.frameCount);
                    Debug.Log("Replay ended");
                    Debug.Log(_heroController.transform.position);
                    CancelInvoke("ReallyFixedReplay");
                    Invoke("StartPlaying", 3.0f);
                }
            }
        }
    }