Created
May 24, 2021 15:35
-
-
Save giftheck/900250209a7b74c78002eb9c506bc457 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using UnityEngine.UI; | |
| public class QuestionActivated : MonoBehaviour | |
| { | |
| public GameObject educationalCanvas; | |
| public Text lessonTextbox; | |
| public string lessonText; | |
| public GameObject correctButton; | |
| public GameObject incorrectButton; | |
| public GameObject continueButton; | |
| public bool isCorrectTheRightAnswer; | |
| public bool takeHealthPunishment; | |
| public string correctResponse; | |
| public string incorrectResponse; | |
| private void Start() | |
| { | |
| } | |
| private void OnTriggerStay(Collider other) | |
| { | |
| if (other.gameObject.tag == "Player") | |
| { | |
| Debug.Log("Woohoo! Detected player in the trigger zone!"); | |
| UpdateTextbox(); | |
| Time.timeScale = 0.0f; | |
| educationalCanvas.SetActive(true); | |
| correctButton.SetActive(true); | |
| incorrectButton.SetActive(true); | |
| continueButton.SetActive(false); | |
| Destroy(gameObject); | |
| } | |
| } | |
| void UpdateTextbox() | |
| { | |
| lessonTextbox.text = lessonText; | |
| if (isCorrectTheRightAnswer == true) | |
| { | |
| correctButton.GetComponent<CorrectOrIncorrectQuestion>().isRightAnswer = true; | |
| correctButton.GetComponent<CorrectOrIncorrectQuestion>().answerText = correctResponse; | |
| incorrectButton.GetComponent<CorrectOrIncorrectQuestion>().isRightAnswer = false; | |
| incorrectButton.GetComponent<CorrectOrIncorrectQuestion>().answerText = incorrectResponse; | |
| if (takeHealthPunishment == true) | |
| { | |
| incorrectButton.GetComponent<CorrectOrIncorrectQuestion>().takeHealthAsPunishment = true; | |
| } | |
| } | |
| else if (isCorrectTheRightAnswer == false) | |
| { | |
| correctButton.GetComponent<CorrectOrIncorrectQuestion>().isRightAnswer = false; | |
| correctButton.GetComponent<CorrectOrIncorrectQuestion>().answerText = incorrectResponse; | |
| incorrectButton.GetComponent<CorrectOrIncorrectQuestion>().isRightAnswer = true; | |
| incorrectButton.GetComponent<CorrectOrIncorrectQuestion>().answerText = correctResponse; | |
| if (takeHealthPunishment == true) | |
| { | |
| correctButton.GetComponent<CorrectOrIncorrectQuestion>().takeHealthAsPunishment = true; | |
| } | |
| else if (takeHealthPunishment == false) | |
| { | |
| Lives.TakeFromLives(-1); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment