示例#1
0
        private async Task <TronGame> CreateNewGame(TronLobby tronLobby)
        {
            var game = _gameService.CreateNewGame(tronLobby);

            foreach (var player in game.Players)
            {
                await Groups.AddToGroupAsync(player.Key, game.GroupName);
            }

            return(game);
        }
示例#2
0
        public TronGame CreateNewGame(TronLobby tronLobby)
        {
            var groupName = Guid.NewGuid().ToString();

            var game = new TronGame
            {
                GroupName   = groupName,
                State       = GameState.Playing,
                TimeCreated = DateTime.UtcNow,
                Players     = tronLobby.Players,
                Board       = tronLobby.Board
            };

            lock (MapLock)
            {
                foreach (var player in game.Players)
                {
                    Map.Add(player.Key, game);
                }
            }

            return(game);
        }