Ejemplo n.º 1
0
        /// <summary>
        /// Adjust game parameters from configuration
        /// </summary>
        /// <param name="config">Config.</param>
        private void InitializeQuizzFromConfiguration(GameConfiguration config)
        {
            // Get config
            var modeConfig = config.GetModeConfiguration (Mode, Difficulty);

            Lives = 3; // TODO ?

            // Get values
            if (modeConfig == null) {

                Logger.E( "No configuration for game mode " + Mode + "!");

                mInitialQuestionCount = 5;
                BaseTimeleft = 60;
                mBaseScore = 1;

            } else {
                if (modeConfig.QuestionCount.HasValue) {
                    mInitialQuestionCount = modeConfig.QuestionCount.Value;
                } else {
                    mInitialQuestionCount = 1;
                }
                if (modeConfig.Score.HasValue) {
                    mBaseScore = modeConfig.Score.Value;
                }
                if (modeConfig.Time.HasValue) {
                    BaseTimeleft = modeConfig.Time.Value;
                }
            }

            if (Mode == GameMode.TIME) {
                mInfiniteQuestions = true;
            } else if (Mode == GameMode.SURVIVAL) {
                mInfiniteQuestions = true;
            } else {
                mInfiniteQuestions = false;
            }

            // Transformations
            ImageTransformation = ImageTransformations.NONE;
            TextTransformation = TextTransformations.NONE;

            if (Difficulty == GameDifficulty.NORMAL) {

                ImageTransformation = GetImageTransformation ();

            } else if (Difficulty == GameDifficulty.HARD) {

                ImageTransformation = GetImageTransformation ();
                TextTransformation = TextTransformations.FIRST_LETTER_ONLY;

            } else if (Difficulty == GameDifficulty.INSANE) {

                ImageTransformation = GetImageTransformation ();
                TextTransformation = TextTransformations.UNDERSCORES_ONLY;
            }

            // Static vars
            mAnswerCount = 4;
            mJokerMinPart = 3;

            TimeLeft = BaseTimeleft;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize the quiz with the given parameters
        /// </summary>
        /// <param name="mode">Mode.</param>
        /// <param name="difficulty">Difficulty.</param>
        /// <param name="config">Config.</param>
        /// <param name="databaseFilter">Database filter.</param>
        public void Initialize(GameMode mode, GameDifficulty difficulty, GameConfiguration config, Filter databaseFilter)
        {
            Mode = mode;
            Difficulty = difficulty;
            Filter = databaseFilter;

            Logger.I("Initializing quizz " + Mode + " " + Difficulty + "...");

            // Initialize score, lives, combo
            TimeLeft = -1;
            Score = 0;
            Combo = 1;
            JokerPartCount = 0;
            Results.Clear ();
            StartTime = DateTime.Now;
            mMistakesCount = 0;
            QuestionNumber = 0;

            InitializeQuizzFromConfiguration (config);

            // Get questions
            mCorrectAnswerIds = new List<int> ();
            mQuestionsPool = new Queue<Question> ();

            for (int i=0; i< mInitialQuestionCount; i++) {

                var q = GetRandomQuestion ();
                mQuestionsPool.Enqueue (q);
            }

            Logger.I("Quizz ready: " + mQuestionsPool.Count + " questions in cache!");

            // Get the first
            SetNextQuestion ();

            IsPaused = false;
        }