private void StartLocalGame()
        {
            var levelAssetLocalName = _levelNames[_currentLevelIndex];

            var parameters = new GameSessionStartParameters
            {
                MatchesToWin   = 5,
                MatchTime      = _matchTimeSeconds,
                SessionName    = "Local Session",
                LevelAssetPath = GetFilePathFromLevelName(levelAssetLocalName),
                ProvidePlayerFigureController = ProvideFigureController
            };
            var gameSession = new GameSessionImp(parameters);

            for (var i = 0; i < _playerCount; i++)
            {
                gameSession.AddMember(MemberType.ActivePlayer);
            }
            for (var i = 0; i < _comPlayerCount; i++)
            {
                gameSession.AddMember(MemberType.Computer);
            }

            gameSession.StartMatch();
            _stateChangeInformation = StateChangeInformation.StateChange(typeof(WaitState), typeof(SlideTransition), gameSession);
        }
Ejemplo n.º 2
0
        public void Activate(GameSessionStartParameters parameters)
        {
            if (IsActive)
            {
                return;
            }

            lock (_sessionAccessLockObject)
            {
                _gameSession = new GameSessionImp(parameters);
                IsActive     = true;
            }

            _executionThread = new Thread(OnUpdateSession);
            _executionThread.Start();
        }
Ejemplo n.º 3
0
        public bool ActivateSession(GameClient client, GameSessionStartParameters parameters)
        {
            var session = GetNextDeactivatedSession();

            if (session == null)
            {
                return(false);
            }

            client.Session = session;
            client.IsSessionAdministrator = true;
            session.JoinClient(client);
            session.Activate(parameters);

            return(true);
        }
Ejemplo n.º 4
0
        private void HandleClientCreateGame(ClientCreateGameSessionMessage message)
        {
            var clientToCreateSession = _clientManager.GetClientById(message.ClientId);

            if (clientToCreateSession == null)
            {
                return;
            }

            var startParameters = new GameSessionStartParameters
            {
                MatchTime      = message.MatchTime,
                MatchesToWin   = message.MatchesToWin,
                SessionName    = message.GameName,
                LevelAssetPath = "levels/Rookie.xml"
            };

            if (!_sessionPool.ActivateSession(clientToCreateSession, startParameters))
            {
                Tracer.PrintWarning(string.Format("Could not create Session for client {0}.", message.ClientId));
            }
        }