示例#1
0
    public void ReplayLevel()
    {
        SortingGame sortingGame = GetComponent <SortingGame>();

        if (sortingGame)
        {
            DataCollectionFileManager.AdjustDataFileForReplay(22); // 22 columns to remove from the file from the current session's row
        }

        InvestigationGame investigationGame = GetComponent <InvestigationGame>();

        if (investigationGame)
        {
            DataCollectionFileManager.AdjustDataFileForReplay(22); // 22 columns to remove from the file from the current session's row
        }

        Quiz quiz = GetComponent <Quiz>();

        if (quiz)
        {
            DataCollectionFileManager.AdjustDataFileForReplay(9); // 9 columns to remove from the file from the current session's row
        }

        SessionManager.Score = SessionManager.scoreBeforeStartLevel;
        _sceneSwitcher.SwitchScene(SceneManager.GetActiveScene().name);
    }
示例#2
0
    private void OnMouseUp()
    {
        BoxCollider2D myCollider = gameObject.GetComponent <BoxCollider2D>();

        BoxCollider2D[] colliders     = new BoxCollider2D[1];
        ContactFilter2D contactFilter = new ContactFilter2D();
        int             colliderCount = myCollider.OverlapCollider(contactFilter, colliders);


        if (colliders[0] != null && colliders[0].gameObject.HasComponent <AnswerDropArea>())
        {
            if (_quiz.correctAnswer == answerIndex)
            {
                _score.AddScore(1 * SessionManager.CurrentDifficulty.pointsGainWhenCorrect);
                _score.CountCorrect();
                DataCollectionFileManager.WriteStringContinuation("correct", true);
            }

            else
            {
                _score.AddScore(-1 * SessionManager.CurrentDifficulty.pointsLossWhenIncorrect);
                _score.CountIncorrect();
                DataCollectionFileManager.WriteStringContinuation("incorrect", true);
            }

            gameObject.SetActive(false);
            //   ResetToStartPosition();
            _quiz.NextQuestion();
        }
    }
示例#3
0
    public void FillInDataCollectionForRemainingObjects()
    {
        //in case the timer runs out of time
        int tempCount = 0;

        tempCount = _rubbishSlotsParent.transform.childCount;

        for (int i = 0; i < tempCount; i++)
        {
            DataCollectionFileManager.WriteStringContinuation("run out of time", true);
            DataCollectionFileManager.WriteStringContinuation("N/A", true);
        }
    }
示例#4
0
    private void DisplayFinishedLevelInfo(bool value) // the bool value decides whether the function using it will add a ; at the end of the file entry or not
    {
        _endScreen.SetActive(true);
        _titleTextBox.text = GameInfo.title;

        int min = Mathf.FloorToInt(_timer.timeLeft / 60);
        int sec = Mathf.FloorToInt(_timer.timeLeft % 60);

        _remainingTimeTextBox.text    = min.ToString("00") + ":" + sec.ToString("00");
        _correctAnswersTextBox.text   = _gameManager.GetComponent <Score>().correct.ToString();
        _incorrectAnswersTextBox.text = _gameManager.GetComponent <Score>().incorrect.ToString();
        _scoreTextBox.text            = SessionManager.Score.ToString();

        // Unity Analytics calls
        _gameManager.GetComponent <DataCollection>().SendFinishedLevelInfo(GameInfo.title, _gameManager.GetComponent <Score>().correct, _gameManager.GetComponent <Score>().incorrect);
        _gameManager.GetComponent <DataCollection>().HelpScreenOpened(GameInfo.title, _amountHelpScreenOpened);
        // Custom Data Collection Calls
        DataCollectionFileManager.WriteStringContinuation(_amountHelpScreenOpened.ToString(), value);
    }
示例#5
0
    public void DidYouKnowAnalytics(string answer)
    {
        if (SessionManager.Consent)
        {
            Dictionary <string, object> didYouKnowInfo = new Dictionary <string, object>();
            didYouKnowInfo.Add("SessionID", SessionManager.SessionId);
            didYouKnowInfo.Add("CurrentDidYouKnowScene", SceneManager.GetActiveScene().name);
            didYouKnowInfo.Add("Answer", answer);
            didYouKnowInfo.Add("TimeSpentOnThePage", Time.timeSinceLevelLoad);

            // Custom Data Collection
            DataCollectionFileManager.WriteStringContinuation(answer, true);
            DataCollectionFileManager.WriteStringContinuation(Time.timeSinceLevelLoad.ToString(), true);

            AnalyticsResult ar = Analytics.CustomEvent("DYK_INFO", didYouKnowInfo);

            Debug.Log("Result = " + ar.ToString());
        }
    }
示例#6
0
    private void OnMouseUp()
    {
        if (!_pauseScreen.activeInHierarchy && !_helpScreen.activeInHierarchy && !_tutorialScreen.activeInHierarchy)
        {
            BoxCollider2D   myCollider    = gameObject.GetComponent <BoxCollider2D>();
            BoxCollider2D[] colliders     = new BoxCollider2D[15];
            ContactFilter2D contactFilter = new ContactFilter2D();
            int             colliderCount = myCollider.OverlapCollider(contactFilter, colliders);

            if (gameObject.HasComponent <Rigidbody2D>())
            {
                gameObject.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
            }

            for (int i = 0; i < colliderCount; i++)
            {
                if (colliders[i].gameObject.HasComponent <Bin>())
                {
                    if (colliders[i].gameObject.GetComponent <Bin>().type == gameObject.GetComponent <Rubbish>().type)
                    {
                        _score.AddScore(1 * SessionManager.CurrentDifficulty.pointsGainWhenCorrect);
                        _score.CountCorrect();
                        DataCollectionFileManager.WriteStringContinuation(gameObject.GetComponent <Rubbish>().type.ToString(), true);
                        DataCollectionFileManager.WriteStringContinuation("correct", true);
                    }

                    else
                    {
                        _score.AddScore(-1 * SessionManager.CurrentDifficulty.pointsLossWhenIncorrect);
                        _score.CountIncorrect();
                        DataCollectionFileManager.WriteStringContinuation(gameObject.GetComponent <Rubbish>().type.ToString(), true);
                        DataCollectionFileManager.WriteStringContinuation("incorrect", true);
                    }

                    _sortingGame.CheckIfFinished();
                    Destroy(gameObject);
                    break;
                }
            }
        }
    }
示例#7
0
    public void FillInDataCollectionForRemainingObjects()
    {
        //in case the timer runs out of time
        int tempCount = 0;

        tempCount = _currentDifficultyQuestions.Count - _currentQuestion;

        for (int i = 0; i < tempCount; i++)
        {
            DataCollectionFileManager.WriteStringContinuation("run out of time", true);
        }

        // Count the difference between amount of questions, and fill in remaining fields with N/A text (for custom data collection)
        int tempQuestionCount = 0;

        tempQuestionCount = 8 - _currentDifficultyQuestions.Count;

        for (int i = 0; i < tempQuestionCount; i++)
        {
            DataCollectionFileManager.WriteStringContinuation("N/A", true);
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.HasComponent <Rubbish>())
        {
            if (other.GetComponent <Rubbish>().type == gameObject.GetComponent <Bin>().type)
            {
                _score.AddScore(1 * SessionManager.CurrentDifficulty.pointsGainWhenCorrect);
                _score.CountCorrect();
                DataCollectionFileManager.WriteStringContinuation(other.GetComponent <Rubbish>().type.ToString(), true);
                DataCollectionFileManager.WriteStringContinuation("correct", true);
            }
            else
            {
                _score.AddScore(-1 * SessionManager.CurrentDifficulty.pointsLossWhenIncorrect);
                _score.CountIncorrect();
                DataCollectionFileManager.WriteStringContinuation(other.GetComponent <Rubbish>().type.ToString(), true);
                DataCollectionFileManager.WriteStringContinuation("incorrect", true);
            }

            Destroy(other.gameObject);
        }
    }
 public void CreateSessionHandler()
 {
     SessionManager.CreateSession();
     DataCollectionFileManager.WriteStringNewLine(SessionManager.SessionId, SessionManager.Consent.ToString());
 }