private void Update() { if (_nodeDictionary[_currNode].GetMainText() != null) { if (_canControlTextDisplay) { if (_displayText.Contains("INSERTOBJECTONE")) { _displayText = _displayText.Replace("INSERTOBJECTONE", UseItemManager.GetItemInUse().name); } ControlOverallTextDisplay(_displayText); } _mainLogText = _displayText; } //print(MyName.GetName()); if (IsShowing()) { if (Input.GetKeyDown(KeyCode.Mouse0)) { if (_clickCounter < 2) { _clickCounter += 1; if (_clickCounter == 1) { if (!SceneManager.GetActiveScene().name.Equals("Prologue")) { string logText = GameObject.Find("LogContent").GetComponent <Text>().text; MainText myCurrNode = _nodeDictionary[_currNode]; logText += "\n" + myCurrNode.GetCurrCharacter() + ":"; logText += "\n" + _mainLogText + "\n"; GameObject.Find("LogContent").GetComponent <Text>().text = logText; } } } if (_clickCounter == 2) { MainText currNode = _nodeDictionary[_currNode]; if (currNode.HasChoice() == false) { currNode.InvokeOnClickedEvent(); if (currNode.goToConsecutiveNodeOnClick) { ChangeNode(int.Parse(currNode.gameObject.transform.GetChild(0).GetComponent <Text>().text) + 1); } } } } } MyButton returnButton = null; if (GameObject.Find("BackArrow") != null) { returnButton = GameObject.Find("BackArrow").GetComponent <MyButton>(); } if (returnButton != null) { if (IsShowing()) { InteractionZone.SetInteractionOn(false); if (returnButton != null) { returnButton.Hide(); } } else { InteractionZone.SetInteractionOn(true); if (returnButton != null && GameObject.Find("Classroom") != null && GameObject.Find("Classroom").GetComponent <SpriteRenderer>().color.a < 1) { returnButton.Show(); } } } if (GameObject.Find("Classroom") != null && GameObject.Find("Classroom").GetComponent <SpriteRenderer>().color.a == 1) { if (returnButton != null) { returnButton.Hide(); } } }
public void ChangeNode(int nodeNum) { _currNode = nodeNum; MainText currNode = _nodeDictionary[_currNode]; string myText = _nodeDictionary[_currNode].GetMainText(); _canControlTextDisplay = false; if (UseItemManager.GetItemInUse() != null) { if (myText.Contains("INSERTOBJECTONE") && myText.Contains("INSERTOBJECTTWO")) { myText = myText.Replace("INSERTOBJECTONE", UseItemManager.GetItemInUse().name); myText = myText.Replace("INSERTOBJECTTWO", UseItemManager.GetApplicableItem().name); if (UseItemManager.GetApplicableItem().GetComponent <TalkingPerson>() != null) { myText = " If you want to show an item to this person, try talking to them and PRESENTING it."; } UseItemManager.SetItemInUse(null); UseItemManager.SetApplicableItem(null); } else if (myText.Contains("INSERTOBJECTONE")) { myText = myText.Replace("INSERTOBJECTONE", UseItemManager.GetItemInUse().name); } else if (UseItemManager.GetApplicableItem() != null) { if (myText.Contains("INSERTOBJECTTWO")) { myText = myText.Replace("INSERTOBJECTTWO", UseItemManager.GetApplicableItem().name); if (UseItemManager.GetApplicableItem().GetComponent <TalkingPerson>() != null) { myText = " If you want to show an item to this person, try talking to them and PRESENTING it."; } } } } else if (myText.Contains("CURRSELECTEDOBJECT")) { if (Item.currSelectedItem != null) { myText = myText.Replace("CURRSELECTEDOBJECT", Item.currSelectedItem.name); } } else if (myText.Contains("CURRTALKINGPERSON")) { if (TalkingPerson.GetCurrSpeakingPerson() != null) { myText = myText.Replace("CURRTALKINGPERSON", TalkingPerson.GetCurrSpeakingPerson().name); } } _displayText = myText; _canControlTextDisplay = true; if (_nodeDictionary.ContainsKey(nodeNum)) { string currSpeakingCharacter = currNode.GetCurrCharacter(); if (currSpeakingCharacter.Equals("Kat") || currSpeakingCharacter.Equals("?") || GameObject.Find(currNode.GetCurrCharacter()) != null || currSpeakingCharacter == "Narrator") { if (GameObject.Find("EpisodeCanvas") != null) { if (!_havingEpisode) { GameObject.Find("EpisodeCanvas").GetComponent <EpisodeCanvas>().StopEpisodeEffect(); } else { GameObject.Find("EpisodeCanvas").GetComponent <EpisodeCanvas>().PlayEpisodeEffect(); } } Show(); currNode.InvokeOnShownEvent(); } else { Hide(); print("!!!SPEAKING CHARACTER IS NOT IN THE SCENE"); } if (GameObject.Find("AyandaImage") != null) { if (currSpeakingCharacter.Equals("Ayanda")) { GameObject.Find("AyandaImage").GetComponent <Image>().enabled = true; } else { GameObject.Find("AyandaImage").GetComponent <Image>().enabled = false; } } if (currNode.HasChoice()) { int numChoices = currNode.GetChoiceList().Count; for (int i = 0; i < numChoices; i++) { GameObject currChoice = Utilities.SearchChild("ChoiceButton" + i, this.gameObject); ModifyChoice(i, currChoice, currNode); } //if (currChild.name.Equals("ChoiceButton0")) //{ // ModifyChoice(0, currChild, currNode); //} //else if (currChild.name.Equals("ChoiceButton1")) //{ // ModifyChoice(1, currChild, currNode); //} //else if (currChild.name.Equals("ChoiceButton2")) //{ // ModifyChoice(2, currChild, currNode); //} } foreach (GameObject currChild in _myChildren) { if (currChild.name.Equals("CurrentCharacterText")) { currChild.GetComponent <Text>().text = currNode.GetCurrCharacter(); } if (currChild.name.Equals("MainText")) { currChild.GetComponent <Text>().text = ""; _displayMainText = true; // currChild.GetComponent<Text>().text = ""; // string mainText = currChild.GetComponent<Text>().text; // string changeText = currNode.GetMainText(); // foreach (char c in changeText.ToCharArray()) // { // mainText += c.ToString(); // currChild.GetComponent<Text>().text = mainText; // } // //currChild.GetComponent<Text>().text = currNode.GetMainText(); } } } }