Ejemplo n.º 1
0
        public void TurnCalculation()
        {
            var stopwatch1 = Stopwatch.StartNew();

            if (_gameSession.SpaceMap.IsEnabled == false)
            {
                return;
            }

            var turnGameSession = _gameSession.DeepClone();

            turnGameSession.AddHistoryMessage($"Calculation start", GetType().Name, true);

            turnGameSession = new SessionEvents().Execute(turnGameSession);

            turnGameSession = new AutomaticLaunchModules().Execute(turnGameSession);

            turnGameSession = new Commands().Execute(turnGameSession);

            turnGameSession.SpaceMap = new Coordinates().Recalculate(turnGameSession.SpaceMap);

            turnGameSession.SpaceMap = new Reloading().Recalculate(turnGameSession);

            turnGameSession.SpaceMap = new AI().Execute(turnGameSession);

            turnGameSession.AddHistoryMessage($"Calculation finished {stopwatch1.Elapsed.TotalMilliseconds} ms.", GetType().Name, true);

            turnGameSession.History.Add(turnGameSession.Turn, turnGameSession.TurnHistory);

            turnGameSession.Turn++;

            _gameSession = turnGameSession;
        }
Ejemplo n.º 2
0
        public void TurnCalculation()
        {
            dictionaryLock.EnterWriteLock();

            var stopwatch = Stopwatch.StartNew();

            var turnGameSession = new GameSession(_gameSession.Clone());

            // TODO: Refactor it
            turnGameSession.Id             = _gameSession.Id;
            turnGameSession.ScenarioEvents = _gameSession.ScenarioEvents.DeepClone();
            turnGameSession.Commands       = GetCommands(_gameSession);

            //-------------------------------------------------------------------------------------------------- Start calculations

            turnGameSession = new Commands().Execute(turnGameSession, _turnSettings, Command);

            turnGameSession = new Coordinates().Recalculate(turnGameSession, _turnSettings);

            turnGameSession = new MissilesActivation().Execute(turnGameSession, _turnSettings);

            turnGameSession = new Reloading().Recalculate(turnGameSession, _turnSettings);

            turnGameSession = new SessionEvents().Execute(turnGameSession);

            turnGameSession.NextTurn();

            //--------------------------------------------------------------------------------------------------- End calculations

            DebugPlayerShipParameters(turnGameSession);

            _gameSession = GameSessionTransfer(turnGameSession, _gameSession);

            _logger.Debug($"Turn {_gameSession.Turn}/{turnGameSession.Turn} Calculation finished {stopwatch.Elapsed.TotalMilliseconds} ms.");

            dictionaryLock.ExitWriteLock();
        }
Ejemplo n.º 3
0
 // Session Events
 private void OnEnable()
 {
     current = this;
 }