public async Task <int> PlayReplay(List <UctAction> actions, Func <bool> endTurnFunc) { // Wait for GUI initialization await Task.Delay(TimeSpan.FromSeconds(1)); using (new TemporarilySuspendReplayRecording()) { foreach (var action in actions) { while (IsPaused) { await Task.Delay(TimeSpan.FromMilliseconds(100)); } if (action.Type == UctActionType.EndTurn) { ActionEvaluator.FNoCopy(_gameInstance, action); endTurnFunc(); await Task.Delay(200); } else { await SlowPlayAction(_gameInstance, action); } Console.WriteLine($"Replaying {action}"); } } return(actions.Count); }
public async Task <int> SlowMainLoop(Func <bool> turnEndFunc, Action gameFinishedFunc) { // Wait for GUI initialization await Task.Delay(TimeSpan.FromSeconds(1)); State = GameEventState.SettingUpTurn; var state = _gameInstance.State; _gameInstance.Reset(); int totalTurns = 0; state.SlowUpdateIsFinished(_gameInstance.MobManager); while (!_gameInstance.IsFinished) { while (IsPaused) { await Task.Delay(TimeSpan.FromMilliseconds(100)); } totalTurns++; await _gameInstance.CurrentController.SlowPlayTurn(this); ActionEvaluator.FNoCopy(_gameInstance, UctAction.EndTurnAction()); turnEndFunc(); await Task.Delay(200); } ReplayRecorder.Instance.SaveAndClear(_gameInstance); Console.WriteLine(Constants.GetLogBuffer()); gameFinishedFunc(); return(totalTurns); }
private async Task SlowBroadcastAction(UctAction action) { await Task.WhenAll(_subscribers.Select(x => x.SlowActionApplied(action))); ActionEvaluator.FNoCopy(_gameInstance, action); }
public void FastPlayAction(UctAction action) { ActionEvaluator.FNoCopy(_gameInstance, action); }