public void Next() { nextButton.SetActive(false); if (GameManager.Instance.isIntro) { introTextIndex++; if (introTextIndex >= introText.Length) { answerCharacterIndex = 0; partialAnswer.text = ""; fullAnswer = ""; GameManager.Instance.isIntro = false; GameManager.Instance.ReturnToMap(); } else { answerCharacterIndex = 0; partialAnswer.text = ""; fullAnswer = introText[introTextIndex]; } } else { partialAnswer.text = ""; currentState = GameScene_SM.INITIALIZING; } }
void OnEnable() { GameManager.Instance.SceneChanged(sceneName); ResetButtons(); questionAsked = -1; answerCharacterIndex = 0; partialAnswer.text = ""; fullAnswer = ""; if (GameManager.Instance.isIntro && introText.Length > 0) { fullAnswer = introText[0]; dialogBox.SetActive(true); currentState = GameScene_SM.ON_INTRO; } else { currentState = GameScene_SM.INITIALIZING; } }
// Use this for initialization void Update() { switch (currentState) { case GameScene_SM.INITIALIZING: LoadButtons(); if (partialAnswer.text == "") { dialogBox.SetActive(false); } if (!unableToGoBack && !GameManager.Instance.isIntro) { EnableGoToMapButton(true); } else { GameManager.Instance.isIntro = false; unableToGoBack = false; } currentState = GameScene_SM.WAITING_FOR_QUESTION; break; case GameScene_SM.WAITING_FOR_QUESTION: if (questionAsked != -1) { EnableGoToMapButton(false); ResetButtons(); dialogBox.SetActive(true); currentState = GameScene_SM.WRITING_ANSWER; } break; case GameScene_SM.WRITING_ANSWER: if (partialAnswer.text.Length == fullAnswer.Length) { currentState = GameScene_SM.ON_ANSWER_FINISH; } else { t += Time.deltaTime * writeSpeed; if (t >= 1) { //ACA partialAnswer.text += fullAnswer[answerCharacterIndex]; answerCharacterIndex++; t -= 1; } } break; case GameScene_SM.ON_ANSWER_FINISH: questionAsked = -1; fullAnswer = ""; nextButton.SetActive(true); //currentState = GameScene_SM.INITIALIZING; break; case GameScene_SM.ON_INTRO: if (partialAnswer.text.Length == fullAnswer.Length) { nextButton.SetActive(true); } else { t += Time.deltaTime * writeSpeed; if (t >= 1) { //ACA partialAnswer.text += fullAnswer[answerCharacterIndex]; answerCharacterIndex++; t -= 1; } } break; } }