public void Launch(string segueId, GameMode mode, GameDifficulty difficulty, Filter filter)
        {
            SegueId = segueId;
              SelectedMode = mode;
              SelectedDifficulty = difficulty;
              SelectedFilter = filter;

              if (SelectedFilter == null)
              {
            SelectedFilter = new Filter("0", "Siphon filter", "defaultIcon");
              }

              UIViewController.InvokeInBackground(() => {
            int gamesCount = SelectedFilter.Load();

            mController.BeginInvokeOnMainThread(() => {
              if (gamesCount < 30)
              {
            Dialogs.ShowDebugFilterTooRestrictive();
              }
              else
              {
            mController.PerformSegue(SegueId, mController);
              }
            });
              });
        }
        /// <summary>
        /// Initialize a new quizz game
        /// </summary>
        public void InitializeQuizz(GameMode mode, GameDifficulty diff, Filter f)
        {
            var appDelegate = (AppDelegate) UIApplication.SharedApplication.Delegate;

              // Prepare a quizz
              mQuizz = new Quizz();
              mQuizz.Initialize(mode, diff, appDelegate.Configuration, f);

              // Consume one credit
              PlayerCache.Instance.UseCredit();
        }
        /// <summary>
        /// Read match json and fill the current object
        /// </summary>
        public void FromJson(string jsonRaw)
        {
            JsonValue json = JsonObject.Parse(jsonRaw);

            MatchId = json ["MatchId"];
            Player1Id = json ["Player1Id"];
            Player2Id = json ["Player2Id"];
            IsEnded = Convert.ToBoolean(json ["IsEnded"].ToString());
            Difficulty =  (GameDifficulty)Enum.Parse (typeof(GameDifficulty), json["Difficulty"]);

            Filter = new Filter (json ["Filter"]);

            Turns.Clear ();
            if (json ["Turns"] != null && json ["Turns"] is JsonArray) {
                foreach (JsonObject turnJson in ((JsonArray)json["Turns"])) {

                    int score = Convert.ToInt32 (turnJson ["Score"].ToString());
                    string playerId = turnJson ["PlayerId"];

                    Turns.Add (new VersusMatchTurn () {
                    PlayerId = playerId,
                    Score = score
                });
                }
            }
        }
Exemple #4
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;
        }