Beispiel #1
0
    public void renewStatisticsData()
    {
        Text text = null;

        FMC_Statistics.Statistics statistics = FMC_GameDataController.instance.getCurrentStatistics();
        talentsProblems = FMC_Statistics.Statistics.getTalentsAndProblems(statistics.dailyData[0].dailyTalentProblemData);

        //if (FMC_GameDataController.instance)
        //    talentsProblems = FMC_GameDataController.instance.getTalentProblemData();

        if (talentsBox)
        {
            text      = talentsBox.GetComponent <Text>();
            text.text = "";
            if (text)
            {
                foreach (string s in talentsProblems.talents)
                {
                    text.text += s;
                }
            }
        }

        text = null;
        if (problemsBox)
        {
            problemsBox.position = new Vector3(Mathf.Abs(talentsBox.position.x), problemsBox.position.y, problemsBox.position.z);
            text      = problemsBox.GetComponent <Text>();
            text.text = "";
            if (text)
            {
                foreach (string s in talentsProblems.problems)
                {
                    text.text += s;
                }
            }
        }

        // Create Custom Exercises etc.
        foreach (GameObject g in allCustomExercises)
        {
            Destroy(g);
        }

        allCustomExercises.Clear();

        int counterText = talentsProblems.talentsInfo.Count > talentsProblems.problemsInfo.Count ? talentsProblems.talentsInfo.Count : talentsProblems.problemsInfo.Count;

        if (talentsProblems.problemsInfo.Count == 0)
        {
            customExercises.gameObject.SetActive(false);
        }
        else
        {
            customExercises.gameObject.SetActive(true);
        }

        if (counterText < 1)
        {
            counterText = 1;
        }

        float textSizeY   = 0.45f;
        float textPadding = (counterText - 1) * textSizeY;

        if (talentsProblems.problemsInfo.Count == 0)
        {
            dynamicallyMoving.transform.localPosition = new Vector3(dynamicallyMoving.transform.localPosition.x, originaldynamicMovingPosY - textPadding, dynamicallyMoving.transform.localPosition.z);
        }
        else
        {
            customExercises.transform.localPosition = new Vector3(customExercises.transform.localPosition.x, originialCustomExercisePosY - textPadding, customExercises.localPosition.z);
        }

        int counterProblems = talentsProblems.problemsInfo.Count;

        GameObject         go;
        FMC_PracticeButton practiceButton;

        for (int i = 0; i < counterProblems; i++)
        {
            go = GameObject.Instantiate(customButtonPrefab);
            go.transform.parent        = exercicesParents[i];
            go.transform.localPosition = new Vector3(0, 0, 0);
            go.name = "Custom Exercise " + i;
            allCustomExercises.Add(go);
            practiceButton           = go.GetComponent <FMC_PracticeButton>();
            practiceButton.text.text = talentsProblems.problems[i];
            practiceButton.initialiseCustomExercise(practiceBoxLayout, menuController, talentsProblems.problemsInfo[i]);
            practiceButton.setLayout(cameraWidth, cameraPosition);
        }

        if (allCustomExercises.Count > 0)
        {
            dynamicallyMoving.transform.position = new Vector3(dynamicallyMoving.transform.position.x, allCustomExercises[allCustomExercises.Count - 1].transform.position.y - 1.0f, dynamicallyMoving.transform.position.z);

            if (iapButton && !FMC_GameDataController.instance.subscriptionIsActive())
            {
                iapButton.gameObject.SetActive(true);
                iapButton.transform.position = new Vector3(iapButtonPositionX.position.x, Mathf.Lerp(allCustomExercises[0].transform.position.y, allCustomExercises[allCustomExercises.Count - 1].transform.position.y, 0.5f), iapButton.position.z);
            }
        }
        else if (iapButton)
        {
            iapButton.gameObject.SetActive(false);
        }
    }
Beispiel #2
0
    public void resetStatisticsData(FMC_Statistics.Statistics.DataPerDay sessionData)
    {
        if (!isInitialised)
        {
            initialise();
        }

        for (int i = 0; i < bubbleParent.childCount; i++)
        {
            Destroy(bubbleParent.GetChild(i).gameObject);
        }

        for (int i = 0; i < numbersParent.childCount; i++)
        {
            Destroy(numbersParent.GetChild(i).gameObject);
        }

        for (int i = 0; i < tasksParent.childCount; i++)
        {
            Destroy(tasksParent.GetChild(i).gameObject);
        }

        for (int i = 0; i < tasksInformationParent.childCount; i++)
        {
            Destroy(tasksInformationParent.GetChild(i).gameObject);
        }

        talents.text          = "";
        problems.text         = "";
        statisticsTags.text   = "";
        statisticsValues.text = "";
        currentStatisticTags.Clear();
        currentStatisticValues.Clear();

        tasks = GameObject.Instantiate(tasksPrefab).GetComponent <Text>();
        tasks.transform.SetParent(tasksParent, false);
        tasks.transform.localPosition = new Vector3(0, 0, 0);
        taskInformations = GameObject.Instantiate(tasksPrefab).GetComponent <Text>();
        taskInformations.transform.SetParent(tasksInformationParent, false);
        taskInformations.transform.localPosition = new Vector3(0, 0, 0);
        taskInformations.alignment = TextAnchor.UpperRight;
        numbers = GameObject.Instantiate(numbersPrefab).GetComponent <Text>();
        numbers.transform.SetParent(numbersParent, false);
        numbers.transform.localPosition = new Vector3(0, 0, 0);

        currentTalentsAndProblems = FMC_Statistics.Statistics.getTalentsAndProblems(sessionData.dailyTalentProblemData);
        currentStatisticTags      = sessionData.getStatisticsTags();
        currentStatisticValues    = sessionData.getStatisticsValues();

        int tasksEntries     = sessionData.allSessionTasks.Count;
        int talentsEntries   = currentTalentsAndProblems.talents.Count;
        int problemsEntries  = currentTalentsAndProblems.problems.Count;
        int statisticEntries = currentStatisticValues.Count;

        float totalTasksHeight      = tasksTextHeight * ((tasksEntries /* * 12*/) + 2);
        float totalTasksHeight02    = tasksTextHeight * (tasksEntries);
        float totaltalentsHeight    = talentsTextHeight * (talentsEntries + 2);
        float totalProblemsHeight   = problemsTextHeight * (problemsEntries + 2);
        float totalStatisticsHeight = statisticsTextHeight * (statisticEntries + 2);

        talentsParent.transform.position    = new Vector3(talentsParent.transform.position.x, pastTasksParent.transform.position.y - totalTasksHeight, talentsParent.transform.position.z);
        problemsParent.transform.position   = new Vector3(problemsParent.transform.position.x, talentsParent.transform.position.y - totaltalentsHeight, problemsParent.transform.position.z);
        statisticsParent.transform.position = new Vector3(statisticsParent.transform.position.x, problemsParent.transform.position.y - totalProblemsHeight, statisticsParent.transform.position.z);
        fullBoxSize = (transform.position.y - (selfSpriteRenderer.size.y * 0.5f)) - (statisticsParent.transform.position.y - totalStatisticsHeight);

        //if (indicator)
        //    indicator.transform.Translate(0, -totalTasksHeight02, 0);

        float      currentYPosition = 0;
        GameObject bubble;
        int        counter = 0;

        for (int i = 0; i < tasksEntries; i++)
        {
            bool correct = (sessionData.allSessionTasks[i].answeredCorrectly && !sessionData.allSessionTasks[i].answeredUsingBomb);
            bool wrong   = (!sessionData.allSessionTasks[i].answeredCorrectly && !sessionData.allSessionTasks[i].answeredUsingBomb);

            // Create Bubbles
            if (correct)
            {
                bubble = GameObject.Instantiate(bubbleRightPrefab);
                bubble.transform.parent        = bubbleParent;
                bubble.transform.localPosition = new Vector3(0, -(currentYPosition /* + (tasksTextHeight * 0.5f)*/), 0);
            }
            else if (wrong)
            {
                bubble = GameObject.Instantiate(bubbleWrongPrefab);
                bubble.transform.parent        = bubbleParent;
                bubble.transform.localPosition = new Vector3(0, -(currentYPosition /* + (tasksTextHeight * 0.5f)*/), 0);
            }
            else
            {
                bubble = GameObject.Instantiate(bubbleNeutralPrefab);
                bubble.transform.parent        = bubbleParent;
                bubble.transform.localPosition = new Vector3(0, -(currentYPosition /* + (tasksTextHeight * 0.5f)*/), 0);
            }

            // Fill Tasks and Numbers
            if (counter > 30)
            {
                tasks = GameObject.Instantiate(tasksPrefab).GetComponent <Text>();
                tasks.transform.SetParent(tasksParent, false);
                tasks.transform.localPosition = new Vector3(0, -currentYPosition, 0);

                taskInformations = GameObject.Instantiate(tasksPrefab).GetComponent <Text>();
                taskInformations.transform.SetParent(tasksInformationParent, false);
                taskInformations.transform.localPosition = new Vector3(0, -currentYPosition, 0);
                taskInformations.alignment = TextAnchor.UpperRight;

                numbers = GameObject.Instantiate(numbersPrefab).GetComponent <Text>();
                numbers.transform.SetParent(numbersParent, false);
                numbers.transform.localPosition = new Vector3(0, -currentYPosition, 0);

                counter = 0;
            }

            // Create Numbers
            numbers.text += (i + 1) + "\n";

            if (correct)
            {
                tasks.text += "<color=#498e31>";
            }
            else if (wrong)
            {
                tasks.text += "<color=#e50000>";
            }
            tasks.text += sessionData.allSessionTasks[i].task + " = " + sessionData.allSessionTasks[i].userAnswer + "\n";
            if (correct || wrong)
            {
                tasks.text += "</color>";
            }



            if (correct)
            {
                taskInformations.text += "<color=#000000>" + sessionData.allSessionTasks[i].timeNeeded.ToString("F1") + "s</color>\n";
            }
            else if (wrong)
            {
                taskInformations.text += "<color=#000000>" + sessionData.allSessionTasks[i].timeNeeded.ToString("F1") + "s</color>\n";
            }
            else if (sessionData.allSessionTasks[i].answeredUsingBomb)
            {
                taskInformations.text += "(" + jumpedText + ")\n";
            }

            currentYPosition += tasksTextHeight;
            counter++;
        }

        for (int i = 0; i < talentsEntries; i++)
        {
            talents.text += currentTalentsAndProblems.talents[i];
        }

        for (int i = 0; i < problemsEntries; i++)
        {
            problems.text += currentTalentsAndProblems.problems[i];
        }

        for (int i = 0; i < statisticEntries; i++)
        {
            statisticsTags.text   += currentStatisticTags[i] + "\n";
            statisticsValues.text += currentStatisticValues[i] + "\n";
        }
    }