Exemplo n.º 1
0
    public void ButtonClicked()
    {
        //go is the button playerh as clicked.
        var    go   = EventSystem.current.currentSelectedGameObject;
        string name = go.ToString();
        //Name of the gameobject that is compared later.
        string testName = go.GetComponentInChildren <Text>().text;

        for (int i = 0; i < qList.Count; i++)
        {
            //Check that the quest is valid and in the list.
            if (qList[i].name.Contains(testName))
            {
                //Open up the quest information.
                questMenu.SetActive(!questMenu.activeSelf);

                //Set the quest from the list.
                GameObject thisQuest = qList[i];

                //Get a quest name string to use for populating later.
                string thisQuestname = thisQuest.GetComponent <testquest>().questname;

                //Actually displays the quest name in the UI.
                questNameDisplay.text = thisQuestname;

                //Populates list of villagers the player has hired.
                characterHolder = scriptGetter.returnGameObjects(currentRecruitedVill);

                //Allows access to the dropdown in a variable.
                var dropdown = characterDropdown.transform.GetComponent <Dropdown>();
                dropdown.options.Clear();
                dropdown.options.Add(new Dropdown.OptionData()
                {
                    text = "Select who will go"
                });

                //Populates the drop down with who the player has recruited.
                foreach (GameObject questParticipant in characterHolder)
                {
                    foreach (var x in characterHolder)
                    {
                        Debug.Log(x);
                    }
                    Debug.Log(characterHolder + "Character Holder");
                    //create holder for dropdown data
                    var tempDropDownOption = new Dropdown.OptionData();
                    //sets the name of the option
                    adventurerStatHolder real_name = questParticipant.GetComponent <adventurerStatHolder>();
                    // tempDropDownOption.text = questParticipant.name;
                    tempDropDownOption.text = real_name.adventurerName;
                    //adds the tearDownOption
                    dropdown.options.Add(tempDropDownOption);
                }
            }
        }
    }