Ejemplo n.º 1
0
	public void onModeChanged(int m) {
		switch(m) {
			default:
				inputField1.interactable = toggle1.interactable = false;
				inputField2.interactable = toggle2.interactable = false;
				inputField3.interactable = toggle3.interactable = false;
				inputField4.interactable = toggle4.interactable = false;
				break;
			case 1:
				mode = Question.QuestionType.MODE2_V;
				inputField1.interactable = toggle1.interactable = true;
				inputField2.interactable = toggle2.interactable = true;
				inputField3.interactable = toggle3.interactable = false;
				inputField4.interactable = toggle4.interactable = false;
				break;
			case 2:
				mode = Question.QuestionType.MODE2_H;
				inputField1.interactable = toggle1.interactable = true;
				inputField2.interactable = toggle2.interactable = false;
				inputField3.interactable = toggle3.interactable = true;
				inputField4.interactable = toggle4.interactable = false;
				break;
			case 3:
				mode = Question.QuestionType.MODE4;
				inputField1.interactable = toggle1.interactable = true;
				inputField2.interactable = toggle2.interactable = true;
				inputField3.interactable = toggle3.interactable = true;
				inputField4.interactable = toggle4.interactable = true;
				break;
		}
	}
Ejemplo n.º 2
0
        /// <summary>
        /// Devuelve el numero de preguntas del jugador, filtrando segun los resultado y el tipo
        /// </summary>
        /// <param name="ResultIs">Si es None, se interpreta como todas</param>
        /// <param name="TypeIs">Tipo de pregunta</param>
        /// <param name="RoundId">Id de la ronda, si no se pone, se obtiene de todas las tondas</param>
        /// <returns></returns>
        public int CountQuestions(Question.QuestionResult ResultIs, Question.QuestionType TypeIs, int RoundId = 0)
        {
            string sql = "SELECT PlayerId FROM used_questions WHERE PlayerID = " + Id +
                         (RoundId > 0 ? " AND RoundId = " + RoundId : "") +
                         (ResultIs == Question.QuestionResult.None ? "" : " AND Result = " + (int)ResultIs) +
                         " AND Type = " + (int)TypeIs;

            return(DataBase.Select(sql).Count);
        }
Ejemplo n.º 3
0
    public void onModeChanged(int m)
    {
        switch (m)
        {
        default:
            inputField1.interactable = toggle1.interactable = false;
            inputField2.interactable = toggle2.interactable = false;
            inputField3.interactable = toggle3.interactable = false;
            inputField4.interactable = toggle4.interactable = false;
            break;

        case 1:
            mode = Question.QuestionType.MODE2_V;
            inputField1.interactable = toggle1.interactable = true;
            inputField2.interactable = toggle2.interactable = true;
            inputField3.interactable = toggle3.interactable = false;
            inputField4.interactable = toggle4.interactable = false;
            break;

        case 2:
            mode = Question.QuestionType.MODE2_H;
            inputField1.interactable = toggle1.interactable = true;
            inputField2.interactable = toggle2.interactable = false;
            inputField3.interactable = toggle3.interactable = true;
            inputField4.interactable = toggle4.interactable = false;
            break;

        case 3:
            mode = Question.QuestionType.MODE4;
            inputField1.interactable = toggle1.interactable = true;
            inputField2.interactable = toggle2.interactable = true;
            inputField3.interactable = toggle3.interactable = true;
            inputField4.interactable = toggle4.interactable = true;
            break;
        }
    }
Ejemplo n.º 4
0
    public void loadNewQuestion()
    {
        Question question = getNextQuestion();

        if (question == null)
        {
            EditorUtility.DisplayDialog("Informacija", "Kraj igre", "Povratak u glavni izbornik");
            SceneManager.LoadScene("game_menu");
            return;
        }

        buttonPressed = false;

        List <Answer> answers = question.getAnswers();

        foreach (Answer answer in answers)
        {
            if (answer.isCorrect())
            {
                correctAnswer = answer.getText();
            }
        }

        Question.QuestionType mode = question.getQuestionMode();
        questionText.text = question.getQuestionText();

        // button resizing and positioning based on the question mode
        if (mode == Question.QuestionType.MODE2_V)
        {
            // create button size
            Vector2 buttonSize = new Vector2(430, 350);

            // set buttons 1 and 2 transformations and translations
            answer1.image.rectTransform.sizeDelta = buttonSize;
            answer1.transform.position            = new Vector3(-215 + buttonSize.x, buttonSize.y / 2, 0);

            answer2.image.rectTransform.sizeDelta = buttonSize;
            answer2.transform.position            = new Vector3(215 + buttonSize.x, buttonSize.y / 2, 0);

            // activate buttons 1 and 2
            answer1.gameObject.SetActive(true);
            answer2.gameObject.SetActive(true);
            answer3.gameObject.SetActive(false);
            answer4.gameObject.SetActive(false);

            // set answers text
            answer1.GetComponentInChildren <Text>().text = answers[0].getText();
            answer2.GetComponentInChildren <Text>().text = answers[1].getText();
        }
        else if (mode == Question.QuestionType.MODE2_H)
        {
            // create button size
            Vector2 buttonSize = new Vector2(860, 175);

            // set buttons 1 and 3 transformations and translations
            answer1.image.rectTransform.sizeDelta = buttonSize;
            answer1.transform.position            = new Vector3(buttonSize.x / 2, 49.5f + buttonSize.y + 38, 0);

            answer3.image.rectTransform.sizeDelta = buttonSize;
            answer3.transform.position            = new Vector3(buttonSize.x / 2, -125.5f + buttonSize.y + 38, 0);

            // activate buttons 1 and 3
            answer1.gameObject.SetActive(true);
            answer3.gameObject.SetActive(true);
            answer2.gameObject.SetActive(false);
            answer4.gameObject.SetActive(false);

            // set answers text
            answer1.GetComponentInChildren <Text>().text = answers[0].getText();
            answer3.GetComponentInChildren <Text>().text = answers[1].getText();
        }
        else if (mode == Question.QuestionType.MODE4)
        {
            // create button size
            Vector2 buttonSize = new Vector2(430, 175);

            // set all four buttons transformations and translations
            answer1.image.rectTransform.sizeDelta = buttonSize;
            answer1.transform.position            = new Vector3(-215 + buttonSize.x, 49.5f + buttonSize.y + 38, 0);

            answer2.image.rectTransform.sizeDelta = buttonSize;
            answer2.transform.position            = new Vector3(215 + buttonSize.x, 49.5f + buttonSize.y + 38, 0);

            answer3.image.rectTransform.sizeDelta = buttonSize;
            answer3.transform.position            = new Vector3(-215 + buttonSize.x, -125.5f + buttonSize.y + 38, 0);

            answer4.image.rectTransform.sizeDelta = buttonSize;
            answer4.transform.position            = new Vector3(215 + buttonSize.x, -125.5f + buttonSize.y + 38, 0);

            // activate all four buttons
            answer1.gameObject.SetActive(true);
            answer3.gameObject.SetActive(true);
            answer2.gameObject.SetActive(true);
            answer4.gameObject.SetActive(true);

            // set answers text
            answer1.GetComponentInChildren <Text>().text = answers[0].getText();
            answer2.GetComponentInChildren <Text>().text = answers[1].getText();
            answer3.GetComponentInChildren <Text>().text = answers[2].getText();
            answer4.GetComponentInChildren <Text>().text = answers[3].getText();
        }
    }
Ejemplo n.º 5
0
        public Poll ReadPoll(Telegram.Bot.Types.File file)
        {
            StreamReader sr   = new StreamReader(file.FileStream);
            string       text = "";

            while (!text.Contains("Type"))
            {
                text = sr.ReadLine();
            }
            string[] tempText = text.Split('=');
            int      type     = Convert.ToInt32(tempText[1].Trim());

            Poll.PollType enmType = (Poll.PollType)type;

            while (!text.Contains("Pass"))
            {
                text = sr.ReadLine();
            }
            tempText = text.Split('=');
            string password = tempText[1].Trim();

            text = "";
            while (!text.Contains("QCount"))
            {
                text = sr.ReadLine();
            }
            tempText = text.Split('=');
            int numberOfQuestions = Convert.ToInt32(tempText[1].Trim());

            Poll poll = new Poll("test", "abc", numberOfQuestions);


            int i = 1;

            while (!sr.EndOfStream)
            {
                text = sr.ReadLine();
                if (text.StartsWith($"Q{i}"))
                {
                    string questionContent = text.Substring(text.IndexOf(':') + 1);

                    while (!text.StartsWith("ACount"))
                    {
                        text = sr.ReadLine();
                    }
                    int aCount = Convert.ToInt32(text.Substring(text.IndexOf('=') + 1));

                    while (!text.StartsWith("QType"))
                    {
                        text = sr.ReadLine();
                    }
                    string qType1 = text.Substring(text.IndexOf('=') + 1);
                    Question.QuestionType qType = (Question.QuestionType)Enum.Parse(typeof(Question.QuestionType), qType1);

                    Question question = new Question(questionContent, qType, aCount);
                    poll.Questions.Add(question);

                    int j = 1;
                    while (!text.StartsWith("}"))
                    {
                        text = sr.ReadLine();
                        if (text.StartsWith($"A{j}"))
                        {
                            string tempAnswer = text.Substring(text.IndexOf(':') + 1).Trim();
                            Answer answer     = new Answer(tempAnswer);
                            poll.Questions[i - 1].Answers.Add(answer);
                            j++;
                        }
                    }
                    j = 1;
                    i++;
                }
            }
            foreach (var it in poll.Questions)
            {
                Console.WriteLine(it);
            }

            return(poll);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets the count of wrong answers for the specified type
 /// </summary>
 /// <param name="type">The type</param>
 /// <returns></returns>
 public int GetWrongAnswers(Question.QuestionType type)
 {
     return(m_incorrectResponses[type]);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Called when the player inputs a wrong answer, and will increment that type.
 /// </summary>
 /// <param name="type">The type to increment</param>
 public void WrongAnswer(Question.QuestionType type)
 {
     m_incorrectResponses[type]++;
 }
Ejemplo n.º 8
0
        public static bool AddQuestionToPlayer(int RoundId, int PlayerId, int QuestionId, Question.QuestionType Type)
        {
            string sql = "INSERT INTO used_questions (PlayerId, QuestionId, RoundId, Type, Result) VALUES" +
                         "(" + PlayerId + "," + QuestionId + ", " + RoundId + "," + (int)Type + ", 0)";

            return(Exec(sql));
        }