public void SetTopScore(int score)
 {
     if (score < 10)
     {
         TopScoreTextInstance.SetTextData("0" + score.ToString());
     }
     else
     {
         TopScoreTextInstance.SetTextData(score.ToString());
     }
     TopScoreTextInstance.CreateAllObjects();
 }
 public void Update()
 {
     if (!Hidden)
     {
         CountdownNumber.SetTextData(Mathf.FloorToInt(CountdownFrom + CountdownStartTime - Time.time).ToString());
         CountdownNumber.CreateAllObjects();
         if (Time.time > CountdownStartTime + CountdownFrom)
         {
             FinishCountdown();
         }
     }
 }
예제 #3
0
    public void CreateObjects()
    {
        AnswerTextInstance = Instantiate(AnswerTextPrefab).GetComponent <PollTextComponent>();
        AnswerTextInstance.transform.SetParent(transform);
        AnswerTextInstance.transform.position = Data.AnswerTextPosition;

        SelectYourAnswerTextInstance = Instantiate(SelectYourAnswerTextPrefab).GetComponent <PollTextComponent>();
        SelectYourAnswerTextInstance.transform.SetParent(transform);

        AnswerTextInstance.SetTextData(Data.AnswerText);
        AnswerTextInstance.CreateAllObjects();

        AnswerButtonTextInstance = Instantiate(AnswerButtonTextPrefab).GetComponent <PollButtonComponent>();
        AnswerButtonTextInstance.transform.SetParent(transform);
        AnswerButtonTextInstance.transform.position = Data.AnswerButtonTextPosition;
        AnswerButtonTextInstance.SetButtonTextData(Data.AnswerButtonText);
        AnswerButtonTextInstance.CreateAllObjects();

        if (Data.Correct)
        {
            CorrectOrIncorrectBackgroundInstance = Instantiate(AnswerCorrectBackgroundPrefab).GetComponent <PollImageComponent>();
        }
        else
        {
            CorrectOrIncorrectBackgroundInstance = Instantiate(AnswerIncorrectBackgroundPrefab).GetComponent <PollImageComponent>();
        }
        CorrectOrIncorrectBackgroundInstance.transform.SetParent(transform);
        CorrectOrIncorrectBackgroundInstance.transform.position = Data.AnswerButtonTextPosition + new Vector3(0, 0, 0.5f);

        SelectedCorrectBackgroundInstance = Instantiate(SelectedCorrectBackgroundPrefab).GetComponent <PollImageComponent>();
        SelectedCorrectBackgroundInstance.transform.SetParent(transform);
        SelectedCorrectBackgroundInstance.transform.position = Data.AnswerButtonTextPosition + new Vector3(0, 0, 0.5f);

        AnswerBackgroundInstance = Instantiate(AnswerBackgroundPrefab).GetComponent <PollImageComponent>();
        AnswerBackgroundInstance.transform.SetParent(transform);
        AnswerBackgroundInstance.transform.position = Data.AnswerButtonTextPosition;

        SelectedImageSequenceInstance = Instantiate(SelectedImageSequencePrefab).GetComponent <PollImageSequenceComponent>();
        SelectedImageSequenceInstance.transform.SetParent(transform);
        SelectedImageSequenceInstance.transform.position = Data.AnswerButtonTextPosition + new Vector3(0, 0, 0.5f);
        if (Data.Correct)
        {
            SelectedImageSequenceInstance.SetImageSequenceFolder("Poll/Images/CorrectAnswer");
        }
        else
        {
            SelectedImageSequenceInstance.SetImageSequenceFolder("Poll/Images/IncorrectAnswer");
        }
        SelectedImageSequenceInstance.CreateObjects(false);
        SelectedImageSequenceInstance.SetLoop(false);
        HideObjects();
    }
    public void ShowAsCorrectOrIncorrect()
    {
        QuestionTextInstance.SetTextData(Data.QuestionTextConfirmation);
        QuestionTextInstance.CreateAllObjects();
        QuestionTextInstance.AnimateFadeIn(5);

        if (SelectedAnswer != null)
        {
            SelectedAnswer.ShowAsCorrectOrIncorrect();
        }
        foreach (var answer in PollAnswerInstances)
        {
            answer.ShowIfCorrect();
        }
        StartCoroutine(HideCorrectAnswerAndShowConfirmation());
    }
 public void Update()
 {
     if (FramesSinceUpdateValues > SlowTime)
     {
         FramesSinceUpdateValues = 0;
         if (CurrentScore < Score)
         {
             CurrentScore++;
         }
         else
         {
             if (CurrentHours < TotalTime.Hours)
             {
                 CurrentHours++;
             }
             else
             {
                 if (CurrentMinutes < TotalTime.Minutes)
                 {
                     CurrentMinutes++;
                 }
                 else
                 {
                     if (CurrentSeconds < TotalTime.Seconds)
                     {
                         CurrentSeconds++;
                     }
                 }
             }
         }
         if (CurrentScore < 10)
         {
             CorrectAnswersText.SetTextData("0" + CurrentScore.ToString());
         }
         else
         {
             CorrectAnswersText.SetTextData(CurrentScore.ToString());
         }
         CorrectAnswersText.CreateAllObjects();
         TotalTimeLabelText.SetTextData(string.Format("{0:N0}:{1:N0}:{2:N0}",
                                                      CurrentHours < 10 ? "0" + CurrentHours.ToString() : CurrentHours.ToString(),
                                                      CurrentMinutes < 10 ? "0" + CurrentMinutes.ToString() : CurrentMinutes.ToString(),
                                                      CurrentSeconds < 10 ? "0" + CurrentSeconds.ToString() : CurrentSeconds.ToString()));
         TotalTimeLabelText.CreateAllObjects();
     }
     FramesSinceUpdateValues++;
 }
    private void LoadNextConfirmationSequence()
    {
        var percentLoaded = ((float)(LoadConfirmationSequenceIndex) / PollData.QuestionsData.Count) * 100;

        LoadingTextInstance.SetTextData("LOADING... (" + percentLoaded.ToString("00") + "%)");
        LoadingTextInstance.CreateAllObjects();

        if (LoadConfirmationSequenceIndex > PollData.QuestionsData.Count - 1)
        {
            LoadedConfirmationSequences = true;
        }
        else
        {
            var loadConfirmationInstance = Instantiate(LoadPrefab).GetComponent <PollImageSequenceComponent>();
            loadConfirmationInstance.transform.SetParent(ConfirmationObj.transform);
            loadConfirmationInstance.SetImageSequenceFolder("Poll/Images/Confirmations/" + PollData.QuestionsData[LoadConfirmationSequenceIndex].ConfirmationDirectory);
            loadConfirmationInstance.CreateObjects(false);
            LoadConfirmationSequenceInstances.Add(loadConfirmationInstance);
            StartCoroutine(CheckConfirmationImageSequence());
        }
    }
    private void CreateObjects()
    {
        Hidden = false;
        Destroy(TestKnowledgeInstance);

        TitleTextInstance      = Instantiate(TitleTextPrefab).GetComponent <PollTextComponent>();
        TitleTextInstance.name = "Poll Title";
        TitleTextInstance.transform.SetParent(transform);
        TitleTextInstance.transform.position = Data.PollTitlePosition;
        TitleTextInstance.SetTextData(Data.PollTitle);
        TitleTextInstance.CreateAllObjects();

        var questionsObject = new GameObject("Questions");

        questionsObject.transform.SetParent(transform);
        QuestionInstances = new List <PollQuestionComponent>();
        foreach (var pollQuestionData in Data.QuestionsData)
        {
            var pollQuestionInstance = Instantiate(QuestionPrefab).GetComponent <PollQuestionComponent>();
            pollQuestionInstance.name = "Question";
            pollQuestionInstance.transform.SetParent(questionsObject.transform);
            pollQuestionInstance.SetPollQuestionData(pollQuestionData);
            pollQuestionInstance.CreateObjects();
            QuestionInstances.Add(pollQuestionInstance);
        }

        TopScoreTitleInstance.ShowObjects();
        TopScoreTextInstance.ShowObjects();
        TopScoreTextLabelInstance.ShowObjects();
        YourScoreTextInstance.ShowObjects();
        YourScoreTextLabelInstance.ShowObjects();
        BtnStartOver.gameObject.SetActive(false);
        SetYourScore(0);
        var topScore = m_LeaderboardData.PlayerData.OrderByDescending(pd => pd.PlayerScore).FirstOrDefault();

        if (topScore != null)
        {
            SetTopScore(topScore.PlayerScore);
        }
    }
    public void CreateObjects()
    {
        QuestionTextInstance      = Instantiate(QuestionTextPrefab).GetComponent <PollTextComponent>();
        QuestionTextInstance.name = "Question Text";
        QuestionTextInstance.transform.SetParent(transform);
        QuestionTextInstance.transform.position = Data.QuestionTextPosition;
        QuestionTextInstance.SetTextData(Data.QuestionText);
        QuestionTextInstance.CreateAllObjects();

        QuestionLegalTextInstance      = Instantiate(QuestionLegalTextPrefab).GetComponent <PollTextComponent>();
        QuestionLegalTextInstance.name = "Question Legal Text";
        QuestionLegalTextInstance.transform.SetParent(transform);
        QuestionLegalTextInstance.transform.position = Data.QuestionLegalTextPosition;
        QuestionLegalTextInstance.SetTextData(Data.QuestionLegalText);
        QuestionLegalTextInstance.CreateAllObjects();

        AnswersObject = new GameObject("Answers");
        AnswersObject.transform.SetParent(transform);
        PollAnswerInstances = new List <PollAnswerComponent>();
        for (var i = 0; i < Data.PollAnswersData.Count; i++)
        {
            var pollAnswerInstance = Instantiate(AnswerPrefab).GetComponent <PollAnswerComponent>();
            pollAnswerInstance.name = "Answer";
            pollAnswerInstance.transform.SetParent(AnswersObject.transform);
            pollAnswerInstance.SetQuestionParent(this);
            pollAnswerInstance.SetPollAnswerData(Data.PollAnswersData[i]);
            pollAnswerInstance.CreateObjects();
            PollAnswerInstances.Add(pollAnswerInstance);
        }
        AnswerBackgroundInstance = Instantiate(AnswerBackgroundPrefab, AnswersObject.transform).GetComponent <PollImageComponent>();
        AnswerTimerInstance      = AnswerBackgroundInstance.GetComponentInChildren <PollTimerComponent>();
        AnswerTimerInstance.CreateObjects(false);
        AnswersObject.transform.position += new Vector3(100, AnswersObject.transform.position.y, AnswersObject.transform.position.z);

        HideObjects();
    }
예제 #9
0
 public void CreateObjects()
 {
     Text.CreateAllObjects();
 }