public Task OnGameUpdate(GameStateUpdate <object> update) { // OnGameUpdate fires when just about anything changes in the game. This might be coins added to a user because of a building, // cards being swapped, etc. Your bot doesn't need to pay attention to these updates if you don't wish, when your bot needs to make // an action OnGameActionRequested will be called with the current game state and a list of possible actions. return(Task.CompletedTask); }
public void Update(GameStateUpdate update) { Player1.PaddlePosition = update.Player1Position; Player2.PaddlePosition = update.Player2Position; Player1.Points = update.Player1Points; Player2.Points = update.Player2Points; Ball.Position = update.BallPosition; }
public override async Task OnGameStateUpdate(GameStateUpdate <object> update) { // OnGameUpdate fires when just about anything changes in the game. This might be coins added to a user because of a building, // cards being swapped, etc. Your bot doesn't need to pay attention to these updates if you don't wish, when your bot needs to make // an action OnGameActionRequested will be called with the current game state and a list of possible actions. Logger.Log(Log.Info, $"Game Update - {update.Type} : {update.Reason}"); await m_logicCore.OnGameUpdate(update); }
async Task SendGameState(GameState session) { ServerPlayer serverPlayer1 = GetPlayerById(session.Player1.Id); ServerPlayer serverPlayer2 = GetPlayerById(session.Player2.Id); GameStateUpdate update = session.GetUpdate(); await Task.WhenAll( BaseServer.SendTo(serverPlayer1.NetPlayer, update, GameNet.ProtocolType.Udp), BaseServer.SendTo(serverPlayer2.NetPlayer, update, GameNet.ProtocolType.Udp) ); }
private void GameLoop() { while (!CancellationToken.IsCancellationRequested) { Thread.Sleep(GameplayConstants.GameTicksPerSecond); _secretData++; _worldStateHandler.OnGameTick(); if (_secretData >= GameplayConstants.InactiveTimeoutDuration * 60000 / GameplayConstants.GameTicksPerSecond) { _entityManager.RemoveInactiveManagers(); _secretData = 0; } } GameStateUpdate?.Invoke(this, new GameStateUpdateEvent { GameState = $"Game Ending..." }); }
public void TestDetectsXWin() { List <string> list = new List <string> { "X", "O", "?", "?", "X", "?", "?", "O", "X" }; ServiceClientCredentials serviceClientCredentials = new TokenCredentials("FakeTokenValue"); TicTacToeSDKClient client = new TicTacToeSDKClient(new Uri("https://localhost:44305"), serviceClientCredentials); GameStateUpdate update = (GameStateUpdate)client.ExecuteMove(new Board(list)); Assert.AreEqual <string> (update.Winner, "X"); Assert.IsNotNull(update.WinPositions); }
public void TestPlaysXFirst() { List <string> list = new List <string> { "?", "?", "?", "?", "?", "?", "?", "?", "?" }; ServiceClientCredentials serviceClientCredentials = new TokenCredentials("FakeTokenValue"); TicTacToeSDKClient client = new TicTacToeSDKClient(new Uri("https://localhost:44305"), serviceClientCredentials); GameStateUpdate update = (GameStateUpdate)client.ExecuteMove(new Board(list)); Assert.AreEqual <string> (update.AzurePlayerSymbol, "X"); Assert.AreEqual <string> (update.Winner, "inconclusive"); Assert.IsNull(update.WinPositions); }
public Node(GameStateUpdate positions) { this.positions = positions; }
/// <summary> /// Updates player's controls. Receieved from the frontend. /// </summary> /// <param name="update"></param> public Task UpdateGameState(GameStateUpdate update) { game.UpdateControls(update); return(Task.CompletedTask); }
// Fires when the game the bot has connected to has a state update. // This doesn't mean the bot must respond, but it can watch updates to know what's happening on other's turns. public abstract Task OnGameStateUpdate(GameStateUpdate <object> update);
void HandleGameStateUpdateMessage(GameStateUpdate message) { GameManager.Instance.Session?.Update(message); }