Esempio n. 1
0
        protected List <IRoundItem> GetFirstSteps()
        {
            MemoflowConfiguration memoflowConfig = (MemoflowConfiguration)ExerciseConfiguration;
            //init initial Field
            int numFirststeps            = memoflowConfig.Levels[CurrentDifficulty].NumCards;
            List <IRoundItem> firstSteps = new List <IRoundItem>();

            for (int i = 0; i < numFirststeps; i++)
            {
                if (i == 0)
                {
                    firstSteps.Add(new MemoflowStepVO(_availableSymbols[_random.Next(0, _availableSymbols.Length)],
                                                      _availableColors[_colorIndex],
                                                      _availableColors[_random.Next(0, _availableColors.Length)], _availableRotations[_random.Next(0, _availableRotations.Length)]));
                }
                else
                {
                    double rnd = _random.NextDouble();
                    if (rnd < memoflowConfig.MatchProbability)
                    {
                        var validMatches           = GetValidMatches();
                        MemoflowMatchType newMatch = validMatches[_random.Next(0, validMatches.Length)];
                        firstSteps.Add(CreateStepWithMatch(firstSteps[firstSteps.Count - 1] as MemoflowStepVO, newMatch));
                    }
                    else
                    {
                        firstSteps.Add(CreateStepWithMatch(firstSteps[firstSteps.Count - 1] as MemoflowStepVO, MemoflowMatchType.NO));
                    }
                }
            }
            return(firstSteps);
        }
Esempio n. 2
0
        public override IRoundIndependentUpdateResultVO RoundIndependentUpdate(IRoundIndependentVO data)
        {
            if (data is NumAssetUpdate)
            {
                _numSymbols = ((NumAssetUpdate)data).NumSymbols;

                MemoflowConfiguration memoflowConfig = (MemoflowConfiguration)ExerciseConfiguration;
                SetupMatchTypes(memoflowConfig.StimuliDefinition);
                SetupAvailabilities();
            }
            return(base.RoundIndependentUpdate(data));
        }
Esempio n. 3
0
        private void SetupAvailabilities()
        {
            MemoflowConfiguration memoflowConfig = (MemoflowConfiguration)ExerciseConfiguration;

            if (Array.IndexOf(_matchTypes, MemoflowMatchType.SYMBOL) != -1)
            {
                if (memoflowConfig.MaxSymbols > _numSymbols)
                {
                    throw new Exception("MaxSymbols must not be bigger than _numSymbols");
                }

                var availableSymbols = new HashSet <int>();

                while (availableSymbols.Count < memoflowConfig.MaxSymbols)
                {
                    int symbolId = _random.Next(0, _numSymbols);
                    availableSymbols.Add(symbolId);
                }

                _availableSymbols = new int[availableSymbols.Count];
                availableSymbols.CopyTo(_availableSymbols);
            }
            else
            {
                _availableSymbols = new int[] { _random.Next(0, memoflowConfig.MaxSymbols) };
            }
            if (Array.IndexOf(_matchTypes, MemoflowMatchType.COLOR) != -1)
            {
                // todo: Currently not used for gameplay, if turned on need to be defined how
                //_availableColors = new AvailableColors[memoflowConfig.MaxColors];
                //int numAddedColors = 0;
                //while (numAddedColors < memoflowConfig.MaxColors)
                //{
                //    // todo: might be wrong ... unity uses special border color list
                //    AvailableColors color = memoflowConfig.ColorNamesPerDifficulty[_random.Next(0, memoflowConfig.ColorNamesPerDifficulty.Length)];
                //    if (Array.IndexOf(_availableColors, color) == -1)
                //    {
                //        _availableColors[numAddedColors] = color;
                //        numAddedColors++;
                //    }
                //}
            }
            else
            {
                //_availableColors = new AvailableColors[] { AvailableColors.Orange };
            }
        }
Esempio n. 4
0
        protected IRoundItem CreateStep()
        {
            MemoflowConfiguration nBackConfig = (MemoflowConfiguration)ExerciseConfiguration;
            int            numCards           = nBackConfig.Levels[CurrentDifficulty].NumCards;
            double         rnd  = _random.NextDouble();
            MemoflowStepVO step = _questQueue[_questQueue.Count - numCards + 1] as MemoflowStepVO;

            if (rnd < nBackConfig.MatchProbability)
            {
                var validMatches           = GetValidMatches();
                MemoflowMatchType newMatch = validMatches[_random.Next(0, validMatches.Length)];
                return(CreateStepWithMatch(step as MemoflowStepVO, newMatch));
            }
            else
            {
                return(CreateStepWithMatch(step as MemoflowStepVO, MemoflowMatchType.NO));
            }
        }
Esempio n. 5
0
        public override void CreateRound(Action <IExerciseRoundDataVO> callback, IExerciseRoundConfigurationVO exerciseRoundConfiguration = null)
        {
            MemoflowConfiguration configuration = ExerciseConfiguration as MemoflowConfiguration;


            List <IRoundItem> correctAnswers;

            int numCards          = configuration.Levels[CurrentDifficulty].NumCards;
            var currenQueueLength = _questQueue == null || (_questQueue != null && _questQueue.Count == 0) ?
                                    0 : Math.Min(_questQueue.Count - 1, _questQueue.Count - 1 - numCards);

            string tutorialTextId = "";

            if (_lastRoundLevelChange == LevelState.NEW)
            {
                _questQueue    = GetFirstSteps();
                tutorialTextId = _startTutorialTextId;
            }
            else
            {
                _questQueue.Add(CreateStep());
            }

            if (_lastRoundLevelChange != LevelState.EQUAL)
            {
                _colorIndex = CurrentDifficulty % _availableColors.Length;
                for (int i = currenQueueLength; i < _questQueue.Count; i++)
                {
                    ((MemoflowStepVO)_questQueue[i]).SymbolColor = _availableColors[_colorIndex];
                }
            }

            correctAnswers = new List <IRoundItem>()
            {
                new MemoflowSolution(((MemoflowStepVO)_questQueue[_questQueue.Count - 1]).Match(((MemoflowStepVO)_questQueue[_questQueue.Count - numCards]), _matchTypes))
            };


            _currentRound = new MemoflowRoundDataVO(_questQueue, correctAnswers, _lastRoundLevelChange, _warmUpState, configuration.GetTimeoutByLevel(CurrentDifficulty), numCards, _matchTypes, tutorialTextId);

            base.CreateRound(callback, exerciseRoundConfiguration);
        }
Esempio n. 6
0
        protected virtual MemoflowStepVO CreateStepWithMatch(MemoflowStepVO nbs, MemoflowMatchType matchType)
        {
            MemoflowConfiguration memoflowConfig = (MemoflowConfiguration)ExerciseConfiguration;

            //create completely different step...
            int             symbol      = GetUniqueElement(_availableSymbols, nbs.SymbolId);
            AvailableColors borderColor = GetUniqueElement(_availableColors, nbs.BorderColor);
            float           rotation    = GetUniqueElement(_availableRotations, nbs.Rot);

            //...add a match if necessary
            if (matchType == MemoflowMatchType.COLOR)
            {
                borderColor = nbs.BorderColor;
            }
            if (matchType == MemoflowMatchType.SYMBOL)
            {
                symbol = nbs.SymbolId;
            }
            //if( matchType == MATCH_TYPE.ROTATION) rotation = nbs.rotation;

            //otherwise NO_MATCH was the case.
            return(new MemoflowStepVO(symbol, _availableColors[_colorIndex], borderColor, rotation));
        }