Ejemplo n.º 1
0
        public void GetDataFromServer()
        {
            if (_inProgress)
            {
                return;
            }

            _inProgress = true;

            var sessionData = new GameSessionRefresh().RequestGameSession(_gameServer, Environment.Session.Id);

            Logger.Info($"sessionData {sessionData.Turn} = {sessionData.CelestialObjects.Count} - {sessionData.GameEvents.Count}.");

            var gameSession = new GameSession(sessionData);

            Environment.RefreshGameSession(gameSession);

            OnEndTurn?.Invoke(Environment);

            if (sessionData.IsPause)
            {
                _inProgress = false;
                return;
            }

            // Send to server all commands from previous turn.
            CommandsSending();

            Logger.Info($"sessionData {Environment.Session.Turn} = {Environment.Session.CelestialObjects.Count} - {Environment.Session.GameEvents.Count}.");

            ExecuteGameEvents(Environment.Session);

            _inProgress = false;
        }
Ejemplo n.º 2
0
        public void StartNewGameSession(string scenario)
        {
            var _gameSession = _gameServer.Initialization(scenario);

            Environment.RefreshGameSession(_gameSession);

            UiManager.UiInitialization();

            OnStartGameSession?.Invoke(Environment);

            Scheduler.Instance.ScheduleTask(50, 50, GetDataFromServer, null);
        }