public FlashGlanceModel(IExerciseConfiguration config, IExerciseInitVO initVO, ILogger logger, IColorManagerInitializer colorManager) : base(config, initVO, logger)
        {
            _castedConfig = ExerciseConfiguration as FlashGlanceConfiguration;

            _currentSolutionIndex = 0;

            _lastItemId = 0;

            _expressionParser = new ExpressionParser();

            _solutionChain = new List <FlashGlanceRoundItemVO>();
            _allItems      = new List <FlashGlanceRoundItemVO>();
            _allPositions  = new List <SafeHashCodePoint>();
            _freePositions = new HashSet <SafeHashCodePoint>();
            for (int i = 0; i < _castedConfig.MapWidth; i++)
            {
                for (int j = 0; j < _castedConfig.MapHeight; j++)
                {
                    _allPositions.Add(new SafeHashCodePoint(i, j));
                    _freePositions.Add(new SafeHashCodePoint(i, j));
                }
            }

            _random = new Random();

            var startCyphers = _castedConfig.GetStartingCyphersByLevel(initVO.StartDifficulty);

            _lastCypher = _random.Next(startCyphers.Min, startCyphers.Max + 1);

            _minItemAmount = _castedConfig.GetStartingItemsByLevel(initVO.StartDifficulty);
            _colorManager  = colorManager;

            _colors = _colorManager.GetRandomColors(_colorManager.NumColors);
            _colors.Shuffle();
        }
Exemplo n.º 2
0
        public MemoflowModel(IExerciseConfiguration config, IExerciseInitVO initVO, ILogger logger, IColorManagerInitializer colorManager) : base(config, initVO, logger)
        {
            _random = new Random();

            _availableColors = colorManager.GetRandomColors(colorManager.NumColors);
            _availableColors.Shuffle();
        }
Exemplo n.º 3
0
 public ExerciseService(IExerciseConfiguration exerciseConfiguration,
                        IRepositoryService repositoryService, IMuscleServise muscleServise, IEquipmentService equipmentService,
                        IImageService imageService)
 {
     _exerciseConfiguration = exerciseConfiguration;
     _repositoryService     = repositoryService;
     _muscleServise         = muscleServise;
     _equipmentService      = equipmentService;
     _imageService          = imageService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ExerciseEngine.Model.Tutorial.TutorialManager"/> class.
 /// </summary>
 /// <param name="model">Model. For listening for level changes.</param>
 /// <param name="view">View. For triggers fired from the view.</param>
 /// <param name="exerciseConfig">Exercise config. For getting tutorial configurations.</param>
 /// <param name="currentDifficulty">Current difficulty. Starting difficulty of exercises</param>
 public TutorialManager(IExerciseModel model, IExerciseView view, IExerciseConfiguration exerciseConfig)
 {
     _model = model;
     _model.OnTutorialTrigger += OnModelUpdate;
     _view                  = view;
     _view.OnUpdate        += OnViewUpdate;
     _exerciseConfiguration = exerciseConfig;
     _tutorialRuns          = new Dictionary <Type, int>();
     _tutorialLoops         = 0;
     _currentRoundTriggers  = new List <ITutorialTrigger>();
 }
Exemplo n.º 5
0
        public BaseExerciseModel(IExerciseConfiguration config, IExerciseInitVO initVO, ILogger logger)
        {
            _logger = logger;
            ExerciseConfiguration = config;
            ExerciseInitVO        = initVO;
            _exerciseSettings     = initVO.Settings;

            // Init the property changes for tracking
            _propertiesUpdates = new Dictionary <Type, IModelPropertyUpdateVO>();

            _totalGoodRuns       = 0;
            TotalRuns            = 0;
            _currentGoodRuns     = 0;
            _currentBadRuns      = 0;
            GoodRunsInARow       = 0;
            _warmUpRoundsCounter = 1;
            _warmUpEnabeld       = initVO.WarmUpEnabled;

            _startDifficulty = (initVO.StartDifficulty > ExerciseConfiguration.MaxDifficulty) ? ExerciseConfiguration.MaxDifficulty : initVO.StartDifficulty;

#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            _multiplier = InitMultiplier(_startDifficulty, ExerciseConfiguration);
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            // listen to multiplier changes
            _multiplier.OnChanged += OnMultiplierChanged;

#pragma warning disable RECS0021 // Warns about calls to virtual member functions occuring in the constructor
            _bonusScore = GetScoreForStartingDifficulty(_startDifficulty);
#pragma warning restore RECS0021 // Warns about calls to virtual member functions occuring in the constructor

            _currentDifficulty = _startDifficulty;

            AddPropertyUpdate(new BadRunsToLevelDownUpdateVO(ExerciseConfiguration.GetBadRunsByLevel(_startDifficulty), ExerciseConfiguration.GetBadRunsByLevel(_startDifficulty)));
            AddPropertyUpdate(new GoodRunsToLevelUpUpdateVO(ExerciseConfiguration.GetGoodRunsByLevel(_startDifficulty), ExerciseConfiguration.GetGoodRunsByLevel(_startDifficulty)));
            AddPropertyUpdate(new DifficultyUpdateVO(_startDifficulty, _startDifficulty));
            AddPropertyUpdate(new MaxDifficultyUpdateVO(ExerciseConfiguration.MaxDifficulty, ExerciseConfiguration.MaxDifficulty));

            _warmUpState = _warmUpEnabeld && (ExerciseConfiguration.GetWarmUpRoundsByLevel(_currentDifficulty) > 0)?WarmUpState.Enabled:WarmUpState.Disabled;

            if (_warmUpState == WarmUpState.Enabled)
            {
                var originalValue = ExerciseConfiguration.GetWarmUpRoundsByLevel(_currentDifficulty);
                AddPropertyUpdate(new WarmUpUpdateVO(originalValue, originalValue, originalValue));
            }

            _lastRoundLevelChange = LevelState.NEW;
        }
Exemplo n.º 6
0
 protected abstract IExerciseModel CreateModel(ExerciseInitVO initVO, IExerciseConfiguration config,
                                               ILogger logger);
Exemplo n.º 7
0
 protected override IExerciseModel CreateModel(ExerciseInitVO initVO, IExerciseConfiguration config, ILogger logger)
 {
     return(new FlashGlanceModel(config, initVO, logger, colorManager));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Inits the multiplier.
 /// </summary>
 /// <returns>The multiplier.</returns>
 /// <param name="startDifficulty">Start difficulty.</param>
 /// <param name="config">Exercise Config.</param>
 protected virtual IMultiplier InitMultiplier(int startDifficulty, IExerciseConfiguration config)
 {
     return(new DynamicMultiplierConfig(startDifficulty, config.MultiplierSteps));
 }