void SetMessageCursorMode(string Mode) { if (Mode == "Confirm") { MessageCursorIsSelecting = false; MessageCursorRenderer.sprite = ConfirmationCursor; MessageCursor.transform.localPosition = new Vector3(0.9f, -0.2f, 0); } else if (Mode == "Select") { MessageCursorIsSelecting = true; MessageCursorRenderer.sprite = SelectionCursor; MessageCursor.transform.localPosition = new Vector3(-0.75f, -0.17f, 0); CurrentMenuState = MenuState; OptionA.SetActive(true); OptionB.SetActive(true); } }
// Use this for initialization void Start() { PersistantValues.currentUser.score = 0; easyIndex = Random.Range(0, PersistantValues.DatabaseEasy); mediumIndex = Random.Range(0, PersistantValues.DatabaseMedium); hardIndex = Random.Range(0, PersistantValues.DatabaseHard); PersistantValues.easyQuestionSelector [easyIndex] = 0; TextStaticQuestions.text = "Question 1:"; QuestionText.text = PersistantValues.EasyQuestions [easyIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.EasyQuestions [easyIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.EasyQuestions [easyIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.EasyQuestions [easyIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.EasyQuestions [easyIndex].OptionD; easyQuestionIndex = 1; Debug.Log("Max easy questions = " + PersistantValues.MaxEasyQuestions); Debug.Log("Max medium questions = " + PersistantValues.MaxMediumQuestions); Debug.Log("Max hard questions = " + PersistantValues.MaxHardQuestions); }
public void ToggleMenu() { ToggleActive(Menu); ToggleActive(MenuCursor); Message.SetActive(false); MessageCursor.SetActive(false); OptionA.SetActive(false); OptionB.SetActive(false); AricomonSpawner asp = AricomonSpawner.GetComponent(typeof(AricomonSpawner)) as AricomonSpawner; if (PlayerScript.speed == 0) { PlayerScript.speed = 5; asp.OpenMenu = false; } else { PlayerScript.speed = 0; asp.OpenMenu = true; } }
public void OnNextClick() { Debug.Log(easyQuestionIndex + " " + mediumQuestionIndex + " " + hardQuestionIndex); if (ticked()) { if (easyQuestionIndex < PersistantValues.MaxEasyQuestions) { int answerIndex = PersistantValues.EasyQuestions [easyIndex].answer; if ((answerIndex == 1 && OptionA.isOn == true) || (answerIndex == 2 && OptionB.isOn == true) || (answerIndex == 3 && OptionC.isOn == true) || (answerIndex == 4 && OptionD.isOn == true)) { PersistantValues.currentUser.score += 4; Debug.Log("Adding 4."); } else { PersistantValues.currentUser.score += 8; Debug.Log("Adding 8."); } } else if (mediumQuestionIndex < PersistantValues.MaxMediumQuestions) { int answerIndex = PersistantValues.MediumQuestions [mediumIndex].answer; if ((answerIndex == 1 && OptionA.isOn == true) || (answerIndex == 2 && OptionB.isOn == true) || (answerIndex == 3 && OptionC.isOn == true) || (answerIndex == 4 && OptionD.isOn == true)) { PersistantValues.currentUser.score += 4; Debug.Log("Adding 4."); } else { PersistantValues.currentUser.score += 8; Debug.Log("Adding 8."); } } else if (hardQuestionIndex < PersistantValues.MaxHardQuestions) { int answerIndex = PersistantValues.HardQuestions [hardIndex].answer; if ((answerIndex == 1 && OptionA.isOn == true) || (answerIndex == 2 && OptionB.isOn == true) || (answerIndex == 3 && OptionC.isOn == true) || (answerIndex == 4 && OptionD.isOn == true)) { PersistantValues.currentUser.score += 4; Debug.Log("Adding 4."); } else { PersistantValues.currentUser.score += 8; Debug.Log("Adding 8."); } } else { EndGame(); //PersistantValues.currentUser.deviation = (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) * 4 - PersistantValues.currentUser.score; //SceneManager.LoadScene ("ResultScreen"); } if (easyQuestionIndex != PersistantValues.MaxEasyQuestions) { while (PersistantValues.easyQuestionSelector [easyIndex] == 0) { easyIndex = Random.Range(0, PersistantValues.DatabaseEasy); } QuestionText.text = PersistantValues.EasyQuestions [easyIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.EasyQuestions [easyIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.EasyQuestions [easyIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.EasyQuestions [easyIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.EasyQuestions [easyIndex].OptionD; ++easyQuestionIndex; TextStaticQuestions.text = "Question " + (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) + ":"; PersistantValues.easyQuestionSelector [easyIndex] = 0; } else if (mediumQuestionIndex != PersistantValues.MaxMediumQuestions) { while (PersistantValues.mediumQuestionSelector [mediumIndex] == 0) { mediumIndex = Random.Range(0, PersistantValues.DatabaseMedium); } QuestionText.text = PersistantValues.MediumQuestions [mediumIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.MediumQuestions [mediumIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.MediumQuestions [mediumIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.MediumQuestions [mediumIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.MediumQuestions [mediumIndex].OptionD; ++mediumQuestionIndex; TextStaticQuestions.text = "Question " + (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) + ":"; PersistantValues.mediumQuestionSelector [mediumIndex] = 0; } else if (hardQuestionIndex != PersistantValues.MaxHardQuestions) { while (PersistantValues.hardQuestionSelector [hardIndex] == 0) { hardIndex = Random.Range(0, PersistantValues.DatabaseHard); } QuestionText.text = PersistantValues.HardQuestions [hardIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.HardQuestions [hardIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.HardQuestions [hardIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.HardQuestions [hardIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.HardQuestions [hardIndex].OptionD; ++hardQuestionIndex; TextStaticQuestions.text = "Question " + (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) + ":"; PersistantValues.hardQuestionSelector [hardIndex] = 0; } else { EndGame(); //PersistantValues.currentUser.deviation = (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) * 4 - PersistantValues.currentUser.score; //SceneManager.LoadScene ("ResultScreen"); } } else { //EditorUtility.DisplayDialog ("No slot selected!", "Please select one slot.", "Okay"); Dialogue.GenerateDialogue("No answer selected!"); } OptionA.isOn = OptionB.isOn = OptionC.isOn = OptionD.isOn = false; }
public void OnSkipClick() { if (skipCountRemaining > 0) { Debug.Log(easyQuestionIndex + " " + mediumQuestionIndex + " " + hardQuestionIndex); if (ticked()) { Dialogue.GenerateDialogue("Please uncheck the answer and then skip the question!"); } else { skipCountRemaining = skipCountRemaining - 1; PersistantValues.currentUser.score += 1; Debug.Log("Adding 1"); if (easyQuestionIndex != PersistantValues.MaxEasyQuestions) { while (PersistantValues.easyQuestionSelector [easyIndex] == 0) { easyIndex = Random.Range(0, PersistantValues.DatabaseEasy); } QuestionText.text = PersistantValues.EasyQuestions [easyIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.EasyQuestions [easyIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.EasyQuestions [easyIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.EasyQuestions [easyIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.EasyQuestions [easyIndex].OptionD; ++easyQuestionIndex; TextStaticQuestions.text = "Question " + (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) + ":"; PersistantValues.easyQuestionSelector [easyIndex] = 0; } else if (mediumQuestionIndex != PersistantValues.MaxMediumQuestions) { while (PersistantValues.mediumQuestionSelector [mediumIndex] == 0) { mediumIndex = Random.Range(0, PersistantValues.DatabaseMedium); } QuestionText.text = PersistantValues.MediumQuestions [mediumIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.MediumQuestions [mediumIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.MediumQuestions [mediumIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.MediumQuestions [mediumIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.MediumQuestions [mediumIndex].OptionD; ++mediumQuestionIndex; TextStaticQuestions.text = "Question " + (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) + ":"; PersistantValues.mediumQuestionSelector [mediumIndex] = 0; } else if (hardQuestionIndex != PersistantValues.MaxHardQuestions) { while (PersistantValues.hardQuestionSelector [hardIndex] == 0) { hardIndex = Random.Range(0, PersistantValues.DatabaseHard); } QuestionText.text = PersistantValues.HardQuestions [hardIndex].Question; OptionA.GetComponentInChildren <Text> ().text = "A: " + PersistantValues.HardQuestions [hardIndex].OptionA; OptionB.GetComponentInChildren <Text> ().text = "B: " + PersistantValues.HardQuestions [hardIndex].OptionB; OptionC.GetComponentInChildren <Text> ().text = "C: " + PersistantValues.HardQuestions [hardIndex].OptionC; OptionD.GetComponentInChildren <Text> ().text = "D: " + PersistantValues.HardQuestions [hardIndex].OptionD; ++hardQuestionIndex; TextStaticQuestions.text = "Question " + (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) + ":"; PersistantValues.hardQuestionSelector [hardIndex] = 0; } else { EndGame(); //PersistantValues.currentUser.deviation = (easyQuestionIndex + mediumQuestionIndex + hardQuestionIndex) * 4 - PersistantValues.currentUser.score; //SceneManager.LoadScene ("ResultScreen"); //EditorUtility.DisplayDialog ("No more questions!", PersistantValues.currentUser.Name + " scored " +PersistantValues.currentUser.score, "Okay"); } } SkipButton.GetComponentsInChildren <Text> ()[0].text = "Skip (" + skipCountRemaining + " remaining)"; } else { } }
void Update() { if (Input.GetButtonDown("Jump")) { ToggleMenu(); } if (MenuCursor.activeSelf) { if (Input.GetButtonDown("Up") && MenuState != 0) // Moves cursor with up arrow { MenuState--; MenuCursor.transform.Translate(new Vector3(0, 0.48f, 0)); } else if (Input.GetButtonDown("Down") && MenuState != 6) // Moves cursor with down arrow { MenuState++; MenuCursor.transform.Translate(new Vector3(0, -0.48f, 0)); } if (Input.GetAxis("Mouse X") != 0 || Input.GetAxis("Mouse Y") != 0) { if (Input.mousePosition.y < 480) { MenuState = 6; MenuCursor.transform.localPosition = new Vector3(-1.3f, -1.44f, 0); } else if (Input.mousePosition.y < 515) { MenuState = 5; MenuCursor.transform.localPosition = new Vector3(-1.3f, -0.96f, 0); } else if (Input.mousePosition.y < 550) { MenuState = 4; MenuCursor.transform.localPosition = new Vector3(-1.3f, -0.48f, 0); } else if (Input.mousePosition.y < 585) { MenuState = 3; MenuCursor.transform.localPosition = new Vector3(-1.3f, 0, 0); } else if (Input.mousePosition.y < 620) { MenuState = 2; MenuCursor.transform.localPosition = new Vector3(-1.3f, 0.48f, 0); } else if (Input.mousePosition.y < 655) { MenuState = 1; MenuCursor.transform.localPosition = new Vector3(-1.3f, 0.96f, 0); } else { MenuState = 0; MenuCursor.transform.localPosition = new Vector3(-1.3f, 1.44f, 0); } if (OptionA.activeSelf) { if (Input.mousePosition.x <= 325) { OptionState = 0; MessageCursor.transform.localPosition = new Vector3(-0.75f, -0.17f, 0); } else { OptionState = 1; MessageCursor.transform.localPosition = new Vector3(0.05f, -0.17f, 0); } } } if (Input.GetButtonDown("Fire1") || Input.GetMouseButtonDown(0)) { ToggleActive(Message); ToggleActive(MessageCursor); OptionA.SetActive(false); OptionB.SetActive(false); if (Message.activeSelf) { switch (MenuState) { case 3: SaveScript.Save("firedSave"); // Saves the game MessageText.text = "The game was saved!"; SetMessageCursorMode("Confirm"); break; case 4: if (File.Exists(Application.persistentDataPath + "/firedSave")) // Loads save data { LoadScript.Load("firedSave"); } MessageText.text = "The game was loaded!"; SetMessageCursorMode("Confirm"); break; case 6: MessageText.text = "Are you sure you want to quit?"; SetMessageCursorMode("Select"); break; default: MessageText.text = "This feature has not been implemented yet."; SetMessageCursorMode("Confirm"); break; } } else { switch (CurrentMenuState) { case 6: switch (OptionState) { case 0: Application.Quit(); break; default: break; } break; } } } } if (MessageCursor.activeSelf) { if (MessageCursorIsSelecting) { if (Input.GetButtonDown("Left") && OptionState != 0) { OptionState--; MessageCursor.transform.localPosition = new Vector3(-0.75f, -0.17f, 0); } else if (Input.GetButtonDown("Right") && OptionState != 1) { OptionState++; MessageCursor.transform.localPosition = new Vector3(0.05f, -0.17f, 0); } } else { if (MessageCursor.transform.localPosition.y >= -0.17f) { MessageCursorIsGoingUp = false; } else if (MessageCursor.transform.localPosition.y <= -0.2f) { MessageCursorIsGoingUp = true; } if (MessageCursorIsGoingUp) { MessageCursor.transform.Translate(new Vector3(0, 0.0055f, 0)); } else { MessageCursor.transform.Translate(new Vector3(0, -0.0055f, 0)); } } } }