Ejemplo n.º 1
0
        public void IsGameStarted(int gameId)
        {
            GameManager gameManager = new GameManager();

            lock (_syncRoot)
            {
                GameLogicManager gameLogic = new GameLogicManager();

                var game = EntityStateManager.CurrentGames.FirstOrDefault(x => x.GameId == gameId);
                if ((game != null && !game.IsPlayerAIAvailable && game.Players.Count == game.PlayersCount) || (game != null && game.IsPlayerAIAvailable && game.Players.Count == (game.PlayersCount + 1)))
                {
                    game = gameManager.StartGame(game.GameId);
                    if (game != null)
                    {
                        var gameObj = EntityStateManager.CurrentGames.FirstOrDefault(x => x.GameId == game.GameId);
                        gameObj.IsStarted = true;
                        Clients.Group(game.GameCode).allPlayersConnected();

                        // SET UP GAME DATA
                        var sectors = gameLogic.GetSectors();
                        Clients.Group(game.GameCode).setUpSectors(sectors);

                        gameObj.GameDetail = gameLogic.GetGameData(gameObj.GameId);
                        Clients.Group(game.GameCode).setUpGameData(gameObj.GameDetail);
                        Clients.Group(game.GameCode).gameStarted(game);

                        SetupGame(gameObj.GameId);
                    }
                    else
                    {
                        // Need to be implemented
                    }
                }
            }
        }