private void OnGameCreated(SocketIOEvent e) { Debug.Log("OnGameCreated"); var game = JsonConvert.DeserializeObject <Game>(e.data.ToString()); GameInfo.RoomId = game.pin; GameInfo.Viewers = game.viewers; OnGameUpdated?.Invoke(); }
private async Task GameLoop() { while (!Grid.IsSnakeDead) { Grid.Update(_currentDirection); await Task.Delay(LoopTimeMs); if (OnGameUpdated != null) { await OnGameUpdated?.Invoke(this); } } await OnGameEnded?.Invoke(this); }
private void GameUpdated(Dictionary <string, object> gameUpdateData, Result outcome) { _player.SetStreak(outcome == Result.Won ? _player.Streak + 1 : 0); _player.ChangeCoinAmount((int)gameUpdateData[HashConstants.GUD_MONEY_CHANGE] * (_player.Streak == 0 ? 1 : _player.Streak)); OnGameUpdated?.Invoke(gameUpdateData, outcome); }