Beispiel #1
0
    private void ModifyChoice(int choiceNum, GameObject choiceGO, MainText currentNode)
    {
        Choice currChoice = currentNode.GetChoiceList()[choiceNum];

        choiceGO.transform.GetChild(0).GetComponent <Text>().text = currChoice.GetChoiceText();
        choiceGO.GetComponent <ChoiceButton>().SetOnPressedEvent(currChoice.GetOnChosenEvent());
        choiceGO.GetComponent <ChoiceButton>().SetMyChoice(currChoice);

        if (currChoice.CheckSeen())
        {
            choiceGO.GetComponent <Image>().color = Color.cyan;
        }
        else
        {
            choiceGO.GetComponent <Image>().color = Color.white;
        }
    }
    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();
                }
            }
        }
    }