Exemple #1
0
 /// <summary>
 /// Initializes the lockstep variables.
 /// The turn starts from -2 to allow commands to be scheduled for turn 0.
 /// </summary>
 public void Init()
 {
     currentTurn  = -2;
     commandTurn  = -3;
     currentFrame = 0;
     recoverTime  = 100;
     status       = LockstepStatus.Playing;
 }
Exemple #2
0
 /// <summary>
 /// Process commands for the current turn, recovering from a delay if necessary.
 /// </summary>
 private void ProcessTurn()
 {
     if (status == LockstepStatus.Delay)
     {
         ClearPendingCommands();
         status = LockstepStatus.Playing;
         Simulation.Delay(recoverTime);
     }
     currentData = buffer.Advance();
     currentData.ProcessCommands();
     NextTurn();
 }
Exemple #3
0
 /// <summary>
 /// Tries to step forward with the game.
 /// </summary>
 public void Update()
 {
     if (IsLockstepturn())
     {
         SendPendingCommands();
         if (currentTurn >= 0)   //Execute an actual turn only after the first two starting rounds
         {
             if (!IsLockstepReady())
             {
                 status = LockstepStatus.Delay;
                 UnityEngine.Debug.LogWarning("Not ready for next turn! Stuck at " + CurrentTurn);
                 return;    // no need to go on, there's not enough data to proceed
             }
             ProcessTurn(); //finally ready to process stuff
         }
         else
         {
             NextTurn(); //still in the starting turns, advance without processing
         }
     }
     // frame update functions
     NextFrame();
 }