Пример #1
0
    public static List <List <Question> > LoadQuestionBank(string text)
    {
        object resultValue = JsonConvert.DeserializeObject <List <Question> >(text);
        var    q1          = (List <Question>)Convert.ChangeType(resultValue, typeof(List <Question>));

        q1 = QuestionsHandler.ReplaceStars(q1);
        var bank = new List <List <Question> > {
            q1, q1, q1
        };

        return(bank);
    }
Пример #2
0
    private void SetNewQuestionData(Question q)
    {
        pool.SetQuestion(q, currentQuestionNum);
        currentQuestion = q;

        QuestionsHandler.Shuffle(rnd, currentQuestion.answers);

        OnNewQuestionData?.Invoke(this,
                                  new NewQuestionArgs {
            q = pool.questions[currentQuestionNum], qNum = currentQuestionNum
        });
    }
Пример #3
0
        //TODO: Quitarle la categoria de la lista de parametros, no la necesita (en realidad no uso ninguno de los parametros xD)
        /// <summary>
        /// Pide las preguntas a la API.
        /// </summary>
        /// <param name="numberOfQuestions">Número de preguntas que se desean obtener</param>
        /// <param name="category">Categoría que tendrán las preguntas</param>
        /// <param name="difficulty">Dificultad de las preguntas a obtener</param>
        /// <param name="type">Tipo de las preguntas a obtener (multichoice o true/false)</param>
        /// <returns></returns>
        public async Task pedirPreguntas(int numberOfQuestions, string category, string difficulty, string type)
        {
            category = Utils.Categories.First(cat => cat.Value == category).Key;

            clsPartida partida = partidas.getMatchByConnectionID(Context.ConnectionId);

            //Si la partida todavía no tiene preguntas (necesario ya que si no se ejecutaría dos veces, ya que cada cliente lo pide una vez)
            if (partida.Preguntas.Count == 0)
            {
                List <clsQuestion> questions = await QuestionsHandler.getQuestions(numberOfQuestions, category, difficulty, type); ///////////////////////////////////////////////////////////////////////////////

                partida.Preguntas = questions;

                Clients.Client(partida.Jugador1.ConnectionID).sendQuestions(partida.Preguntas);
                Clients.Client(partida.Jugador2.ConnectionID).sendQuestions(partida.Preguntas);
            }
        }
Пример #4
0
    void Start()
    {
        lifes               = PlayerPrefs.GetInt("Lifes", 3);
        points              = 0;
        noLoseCount         = PlayerPrefs.GetInt("NumOfJokers", 1);
        halfCount           = PlayerPrefs.GetInt("NumOfJokers", 1);
        skipCount           = PlayerPrefs.GetInt("NumOfJokers", 1);
        questionHanlder     = new QuestionsHandler();
        normalColorAnswer   = new Color(0, 0, 0);
        normalColorAnswer.a = 0.102f;
        wrongColorAnswer    = new Color(255, 0, 0, 200);
        correctColorAnswer  = new Color(0, 255, 0, 200);
        int played_games = PlayerPrefs.GetInt("GamesPlayed", 0);

        PlayerPrefs.SetInt("GamesPlayed", played_games + 1);

        SetQuestionToSceen();
    }
Пример #5
0
    void Start()
    {
        //Making an instance of the QuestionsHandler and loading the questions
        handler     = gameObject.AddComponent <QuestionsHandler>();
        ans_handler = GetComponent <AnswerHandler>();
        handler.loadQuestions();
        _questions = handler.GetQuestions().questions;

        _inventory = FindObjectOfType <InventoryManager>();
        player     = GameObject.Find("Player");
        audioData  = GetComponent <AudioSource>();

        UnityEngine.EventSystems.EventSystem.current.sendNavigationEvents = !UnityEngine.EventSystems.EventSystem.current.sendNavigationEvents;

        for (int i = 0; i < progress; ++i)
        {
            ans_handler.executeAnswer(i);
        }
    }