IEnumerator PhoneInteraction() { MainGame.PhoneCallsMade++; IsTextFinished = false; Continue = false; GameObject ImmediateHazard = SinkHazard; Text DisplayText = TextDisplayWindow.GetComponentInChildren <Text>(); DisplayText.text = ""; RawImage DisplayIcon = DisplayIconObject.GetComponent <RawImage>(); TypeWritter TextTypeWritter = TextDisplayWindow.GetComponentInChildren <TypeWritter>(); //Good Call will happen Debug.Log("Good Call Occured"); TextDisplayWindow.SetActive(true); TextDisplayWindow.GetComponent <RawImage>().color = new Color(1.0f, 1.0f, 1.0f); TextTypeWritter.IsTextGood = true; TextTypeWritter.fullText = GoodGreetings[Random.Range(0, GoodGreetings.Count)]; TextTypeWritter.TypeText(); DisplayIcon.texture = GoodIcon; //Waits until Continue == true yield return(new WaitUntil(() => Continue == true)); Continue = false; yield return(new WaitForSeconds(0.5f)); string ResponseText = GoodResponses[Random.Range(0, GoodResponses.Count)]; if (ResponseText.Contains("HAZARD")) { ResponseText = ResponseText.Replace("HAZARD", "A pipe is about to burst?"); } TextTypeWritter.fullText = ResponseText; TextTypeWritter.TypeText(); yield return(new WaitUntil(() => Continue == true)); Continue = false; yield return(new WaitForSeconds(0.5f)); //Dialog Finished, Reset Variables and Handle fixing the Hazard IsTextFinished = false; TextDisplayWindow.SetActive(false); ImmediateHazard.GetComponent <sink>().ResetHazard(true); MainGame.score += 15.0f; AlreadyInACall = false; }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
void Start() { typeWritter = TypeWritter.instance; typeWritter.Type("DialogueTest1.txt"); }
IEnumerator PhoneInteraction() { //Layout///////////////// // - Find which "hazard" is the closest to failing (add in later but use temp variables for now) // -Read all "Hazard" objects and look at their timer variable to decide which one needs fixing // -Add the name of it to a temp string to use in the phone dialog // - Fix the hazard that needs fixing // -Reverse the animation? also the speed of it is based on its time value (which now goes up) // -Free PhoneIsInUse Bool after this action is complete. MainGame.PhoneCallsMade++; IsTextFinished = false; Continue = false; GameObject ImmediateHazard; if (TreeHazard.GetComponent <Tree>().GetTimeRemaining() <= WaterPipeHazard.GetComponent <Well>().GetTimeRemaining()) { ImmediateHazard = TreeHazard; } else { ImmediateHazard = WaterPipeHazard; } Text DisplayText = TextDisplayWindow.GetComponentInChildren <Text>(); DisplayText.text = ""; RawImage DisplayIcon = DisplayIconObject.GetComponent <RawImage>(); TypeWritter TextTypeWritter = TextDisplayWindow.GetComponentInChildren <TypeWritter>(); //Good Call will happen Debug.Log("Good Call Occured"); TextDisplayWindow.SetActive(true); TextDisplayWindow.GetComponent <RawImage>().color = new Color(1.0f, 1.0f, 1.0f); TextTypeWritter.IsTextGood = true; TextTypeWritter.fullText = GoodGreetings[Random.Range(0, GoodGreetings.Count)]; TextTypeWritter.TypeText(); DisplayIcon.texture = GoodIcon; //Waits until Continue == true yield return(new WaitUntil(() => Continue == true)); Continue = false; yield return(new WaitForSeconds(0.5f)); string ResponseText = GoodResponses[Random.Range(0, GoodResponses.Count)]; if (ResponseText.Contains("HAZARD")) { if (ImmediateHazard.name == "tree") { ResponseText = ResponseText.Replace("HAZARD", "A falling tree?"); } else { ResponseText = ResponseText.Replace("HAZARD", "A pipe is about to burst?"); } } TextTypeWritter.fullText = ResponseText; TextTypeWritter.TypeText(); yield return(new WaitUntil(() => Continue == true)); Continue = false; yield return(new WaitForSeconds(0.5f)); //Dialog Finished, Reset Variables and Handle fixing the Hazard IsTextFinished = false; TextDisplayWindow.SetActive(false); if (ImmediateHazard.name == "tree") { Debug.Log("Reset Tree Called"); ImmediateHazard.GetComponent <Tree>().ResetHazard(true); } MainGame.score += 15.0f; AlreadyInACall = false; }