Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="GameSyncManager{T}"/> to handle a given <typeparamref name="T"/> game state.
 /// </summary>
 /// <param name="gameState">The initial game state of the game, from which all turns will be played.</param>
 /// <param name="saveService">The <see cref="IGameSaveService{T}"/> which will be used to create save copies of the <typeparamref name="T"/> game state.</param>
 public GameSyncManager(T gameState, IGameSaveService <T> saveService)
 {
     GameState        = gameState;
     SaveService      = saveService;
     InitialGameState = SaveService.Copy(GameState);
     ActionsList      = new List <IGameAction <T> >();
     NewActionsList   = new List <IGameAction <T> >();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Reconstructs the <see cref="State.GameState"/> from the initial <see cref="State.GameState"/> provided to the <see cref="GameSyncManager{T}"/> and the existing collection <see cref="Actions"/>.
 /// </summary>
 public void RebuildGameState()
 {
     GameState = SaveService.Copy(InitialGameState);
     foreach (var action in Actions.Concat(NewActionsList))
     {
         if (action.CanUpdate(GameState))
         {
             action.Update(GameState);
         }
     }
 }