public void setState(FMC_Settings.numberType newNumberType)
 {
     if (newNumberType == FMC_Settings.numberType.core)
     {
         currentState = iterationStates.core;
         information  = FMC_Settings_Input.allInformation.ntCore;
         text.text    = FMC_GameDataController.instance.fullTranslation[FMC_Translation.translations.taskInformation][4];
     }
     else if (newNumberType == FMC_Settings.numberType.neighbour01)
     {
         currentState = iterationStates.neighbour01;
         information  = FMC_Settings_Input.allInformation.ntNeighbour01;
         text.text    = FMC_GameDataController.instance.fullTranslation[FMC_Translation.translations.taskInformation][5];
     }
     else if (newNumberType == FMC_Settings.numberType.neighbour02)
     {
         currentState = iterationStates.neighbour02;
         information  = FMC_Settings_Input.allInformation.ntNeighbour02;
         text.text    = FMC_GameDataController.instance.fullTranslation[FMC_Translation.translations.taskInformation][6];
     }
     else if (newNumberType == FMC_Settings.numberType.mixed)
     {
         currentState = iterationStates.mixed;
         information  = FMC_Settings_Input.allInformation.ntMixed;
         text.text    = FMC_GameDataController.instance.fullTranslation[FMC_Translation.translations.taskInformation][7];
     }
 }
Пример #2
0
    public void setParameters(string _task, float _correctAnswer, int _rangeOfNumbers, FMC_Settings.numberType _numberTypeFront, FMC_Settings.numberType _numberTypeBack, operations _operation, taskTypes _taskType, float _timeSpecification, int _lastNumber)
    {
        task              = _task;
        correctAnswer     = Mathf.RoundToInt(_correctAnswer);
        rangeOfNumbers    = _rangeOfNumbers;
        numberTypeFront   = _numberTypeFront;
        numberTypeBack    = _numberTypeBack;
        operation         = _operation;
        taskType          = _taskType;
        timeSpecification = _timeSpecification;
        answeredUsingBomb = false;
        lastNumber        = _lastNumber;

        wrongAnswerSelection = new float[] { -1, -1, -1 };
        if (rangeOfNumbers >= 10)
        {
            wrongAnswerSelection[0] = Random.Range(0, rangeOfNumbers + 1);
            wrongAnswerSelection[1] = Random.Range(0, rangeOfNumbers + 1);
            wrongAnswerSelection[2] = Random.Range(0, rangeOfNumbers + 1);

            while (wrongAnswerSelection[0] == correctAnswer)
            {
                wrongAnswerSelection[0] = Random.Range(0, rangeOfNumbers + 1);
            }
            while (wrongAnswerSelection[1] == correctAnswer || wrongAnswerSelection[1] == wrongAnswerSelection[0])
            {
                wrongAnswerSelection[1] = Random.Range(0, rangeOfNumbers + 1);
            }
            while (wrongAnswerSelection[2] == correctAnswer || wrongAnswerSelection[2] == wrongAnswerSelection[0] || wrongAnswerSelection[2] == wrongAnswerSelection[1])
            {
                wrongAnswerSelection[2] = Random.Range(0, rangeOfNumbers + 1);
            }
        }
    }
    public void createTask()
    {
        currentSetting            = settingsController.getCurrentSettingValues();
        _rangeOfNumbers           = currentSetting._rangeOfNumbers;
        _numberTypeFront          = currentSetting._numberTypeFront;
        _numberTypeBack           = currentSetting._numberTypeBack;
        _failSaveCounter          = 0;
        _allreadyFellBackToRandom = false;
        //Debug.LogWarning("ntFront: " + _numberTypeFront + "; Back: " + _numberTypeBack);

        if (_numberTypeFront == FMC_Settings.numberType.even || _numberTypeFront == FMC_Settings.numberType.uneven)
        {
            _numberTypeFront = FMC_Settings.numberType.mixed;
        }
        if (_numberTypeBack == FMC_Settings.numberType.even || _numberTypeFront == FMC_Settings.numberType.uneven)
        {
            _numberTypeBack = FMC_Settings.numberType.mixed;
        }

        x = -1;
        y = -1;

        findMethod();

        if (x == -1 && y == -1)
        {
            fallbackRandom();
        }

        FMC_Task t = new FMC_Task();

        setTaskValues(t);

        if (lastTask == null || lastTask.task != t.task || iterations >= 20)
        {
            if (newTaskCreated != null)
            {
                newTaskCreated(t);
            }

            lastTask   = t;
            iterations = 0;

            //t.setUserAnswer(t.correctAnswer, false);
            //FMC_GameDataController.instance.answerTask(t);
        }
        else
        {
            iterations++;
            createTask();
        }
    }
    private void resetData()
    {
        rangeOfNumbers  = 10;
        numberTypeFront = FMC_Settings.numberType.core;

        operationPlusIsPossible    = false;
        operationTimesIsPossible   = false;
        operationMinusIsPossible   = false;
        operationDividedIsPossible = false;

        taskTypeGreaterIsPossible     = false;
        taskTypeSameIsPossible        = false;
        taskTypeSmallerIsPossible     = false;
        taskTypeEqualsIsPossible      = false;
        taskTypeOneTimesOneIsPossible = false;

        timeSpecification = -1;
    }
    private void fallbackRandom()
    {
        Debug.LogWarning("No possible combinations found. Fell Back to random Generation.");

        _failSaveCounter = 0;
        _numberTypeFront = FMC_Settings.numberType.mixed;
        _numberTypeBack  = FMC_Settings.numberType.mixed;

        if (!_allreadyFellBackToRandom)
        {
            findCurrentMethod();
        }
        else
        {
            Debug.LogWarning("Fell back to complete random generation. This is not great.");
            _operation = FMC_Task.operations.plus;
            x          = Random.Range(1, _rangeOfNumbers);
            y          = Random.Range(1, _rangeOfNumbers);
        }

        _allreadyFellBackToRandom = true;
    }
    private void checkInformation(allInformation i, FMC_RadioButton button, bool ntFront, bool ntBack)
    {
        switch (i)
        {
        case allInformation.ron10:
            Int32.TryParse(button.text, out rangeOfNumbers);
            break;

        case allInformation.ron20:
            Int32.TryParse(button.text, out rangeOfNumbers);
            break;

        case allInformation.ron100:
            Int32.TryParse(button.text, out rangeOfNumbers);
            break;

        case allInformation.ron1000:
            Int32.TryParse(button.text, out rangeOfNumbers);
            break;

        case allInformation.ntCore:
            if (ntFront)
            {
                numberTypeFront = FMC_Settings.numberType.core;
            }
            if (ntBack)
            {
                numbeTypeBack = FMC_Settings.numberType.core;
            }
            break;

        case allInformation.ntNeighbour01:
            if (ntFront)
            {
                numberTypeFront = FMC_Settings.numberType.neighbour01;
            }
            if (ntBack)
            {
                numbeTypeBack = FMC_Settings.numberType.neighbour01;
            }
            break;

        case allInformation.ntNeighbour02:
            if (ntFront)
            {
                numberTypeFront = FMC_Settings.numberType.neighbour02;
            }
            if (ntBack)
            {
                numbeTypeBack = FMC_Settings.numberType.neighbour02;
            }
            break;

        //case allInformation.ntEven:
        //    numberTypeFront = FMC_Settings.numberType.even;
        //    break;
        //case allInformation.ntUneven:
        //    numberTypeFront = FMC_Settings.numberType.uneven;
        //    break;
        case allInformation.ntMixed:
            if (ntFront)
            {
                numberTypeFront = FMC_Settings.numberType.mixed;
            }
            if (ntBack)
            {
                numbeTypeBack = FMC_Settings.numberType.mixed;
            }
            break;

        case allInformation.opPlus:
            operationPlusIsPossible = true;
            break;

        case allInformation.opTimes:
            operationTimesIsPossible = true;
            break;

        case allInformation.opMinus:
            operationMinusIsPossible = true;
            break;

        case allInformation.opDivided:
            operationDividedIsPossible = true;
            break;

        case allInformation.ttGreater:
            taskTypeGreaterIsPossible = true;
            break;

        case allInformation.ttSame:
            taskTypeSameIsPossible = true;
            break;

        case allInformation.ttSmaler:
            taskTypeSmallerIsPossible = true;
            break;

        case allInformation.ttEquals:
            taskTypeEqualsIsPossible = true;
            break;

        case allInformation.ttOneTimesOne:
            taskTypeOneTimesOneIsPossible = true;
            break;

        case allInformation.tInfinite:
            timeSpecification = -1;
            break;

        case allInformation.t5:
            int x = 0;
            Int32.TryParse(button.text, out x);
            timeSpecification = (float)x;
            //timeSpecification = 5;
            break;

        case allInformation.t15:
            int y = 0;
            Int32.TryParse(button.text, out y);
            timeSpecification = (float)y;
            //timeSpecification = 15;
            break;

        case allInformation.t30:
            int z = 0;
            Int32.TryParse(button.text, out z);
            timeSpecification = (float)z;
            //timeSpecification = 30;
            break;
        }
    }