Пример #1
0
    public void DisplayEvent(CampaignState campaignState)
    {
        int currentDepth = campaignState.depth;

        JSONObject eventObject = DataRetriever.GetRandomEventByDepth(currentDepth);

        gameObject.SetActive(true);

        eventTitle.text       = eventObject.GetField(EVENT_NAME).str;
        eventDescription.text = eventObject.GetField(EVENT_DESCRIPTION).str.Replace("\\n", "\n");

        availableOutcomes = eventObject.GetField(OUTCOMES_ARRAY).list;
        int numberOfOutcomes = availableOutcomes.Count;

        for (int i = 0; i < outcomeButtons.Length; i++)
        {
            Button outcomeButton = outcomeButtons[i];
            outcomeButton.onClick.RemoveAllListeners();
            if (i < numberOfOutcomes)
            {
                outcomeButton.onClick.AddListener(GenerateButtonListener(i));
                outcomeButton.gameObject.SetActive(true);
                Text buttonText = buttonTexts[i];
                buttonText.text = availableOutcomes[i].GetField(OUTCOME_BUTTON_TEXT).str;
            }
            else
            {
                outcomeButton.gameObject.SetActive(false);
            }
        }
    }