Ejemplo n.º 1
0
    /// <summary>
    /// Sets answerInfo according to supplied color. If color is the random color, this sets the answerID to the supplied answerInfo AnswerID
    /// </summary>
    /// <param name="answerInfo">Answer info.</param>
    /// <param name="color">Color.</param>
    /// <param name="randomColor">Random color.</param>
    private void SetAnswer(ref SpeedTouchAnswerInfo answerInfo, ColorEnum color, ColorEnum randomColor)
    {
        switch (color)
        {
        case ColorEnum.Red:
            answerInfo.SpriteID = SpriteID.Balloon_Red;
            answerInfo.AnswerID = AnswerID.Balloon_Red;
            break;

        case ColorEnum.Blue:
            answerInfo.SpriteID = SpriteID.Balloon_Blue;
            answerInfo.AnswerID = AnswerID.Balloon_Blue;
            break;

        case ColorEnum.Yellow:
            answerInfo.SpriteID = SpriteID.Balloon_Yellow;
            answerInfo.AnswerID = AnswerID.Balloon_Yellow;
            break;

        case ColorEnum.Green:
            answerInfo.SpriteID = SpriteID.Balloon_Green;
            answerInfo.AnswerID = AnswerID.Balloon_Green;
            break;
        }

        if (color == randomColor)
        {
            CurrentColorID = answerInfo.AnswerID;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Gets the current Speed touch question.
    /// </summary>
    /// <returns>The UIQ uestion.</returns>
    /// <param name="questionIndex">Question index.</param>
    /// <param name="answerButtons">Answer buttons.</param>
    public BaseQuestion GetUIQuestion(int questionIndex, int answerButtons = 4)
    {
        SpeedTouch questionType = SpeedTouchList[questionIndex];

        AnswerInfos.Clear();

        CurrentColorID = AnswerID.None;

        int colors = EnumUtil.GetValues <ColorEnum>().Count;

        //Initializing a Question
        BaseQuestion bq = new BaseQuestion();

        bq.IgnoreClickCount       = true;
        bq.IgnoreClickTime        = true;
        bq.HasSequenceAnswer      = false;
        bq.HasBoolValue           = false;
        bq.HasTimerValue          = true;
        bq.HasSequentialQuestions = true;
        bq.Pattern         = QPattern.SpeedTouch;
        bq.QuestionType    = QuestionType.Base;
        bq.TimeForQuestion = 0;
        bq.Options         = new List <AnswerSpriteHolder>();
        for (int i = 0; i < answerButtons; i++)
        {
            AnswerSpriteHolder answer = new AnswerSpriteHolder();
            bq.Options.Add(answer);
        }
        //

        //Getting a random color for the question
        int randomColorIndex = (int)Random.Range(0, colors);

        //Shuffle
        FisherYatesShuffle shuffle = new FisherYatesShuffle(colors);

        shuffle.ShuffleList();
        List <int> colorIndex = shuffle.ShuffledList;

        //Setting up button info for later assignment and setting up current answerID Color for the current question
        for (int i = 0; i < answerButtons; i++)
        {
            SpeedTouchAnswerInfo answerInfo = GetNewAnswerButton();
            SetAnswer(ref answerInfo, (ColorEnum)colorIndex[i], (ColorEnum)randomColorIndex);
            AnswerInfos.Add(answerInfo);
        }

        //Assignment to answer buttons
        SetAnswerOption(ref bq, AnswerInfos, (ColorEnum)randomColorIndex, questionType);

        return(bq);
    }
Ejemplo n.º 3
0
    private void CheckAndRearrangeAnswers(List <SpeedTouchAnswerInfo> answer, int randomPos)
    {
        //Search what is the position of the currentColorId and set it at the correct position
        int index = -1;

        for (int i = 0; i < answer.Count; i++)
        {
            if (CurrentColorID == answer[i].AnswerID && i != randomPos)
            {
                index = i;
            }
        }
        if (index != -1)
        {
            //Debug.Log("index = "+index);
            //return;
            SpeedTouchAnswerInfo answerInfo = answer[index];
            answer[index]     = answer[randomPos];
            answer[randomPos] = answerInfo;
        }
    }