Esempio n. 1
0
    /// <summary>
    /// Refreshes the content canvas.
    /// </summary>
    /// The method is used to initilize all the buttons.
    public void RefreshScroll()
    {
        //Always clean the previous items
        int child = content.childCount;

        for (int i = 0; i < child; i++)
        {
            Destroy(content.GetChild(i).gameObject);
        }

        Dictionary <string, Dictionary <string, string> > handbookDictionary = HandbookSaver.GetHandbook();

        handbookTabs = new GameObject[handbookDictionary.Count];
        int m = 0;

        //Generates new items
        foreach (string formula in handbookDictionary.Keys)
        {
            GameObject handbookItem = Instantiate(reagentButtonPrefab.gameObject) as GameObject;
            handbookItem.name = formula;

            handbookItem.GetComponentInChildren <Text>().text = handbookDictionary[formula]["formula"];
            handbookItem.gameObject.GetComponent <Button> ().onClick.AddListener(() => GoToReagent(handbookItem.name));
            handbookItem.transform.SetParent(content.transform, false);
            handbookTabs[m] = handbookItem;
            m++;
        }
    }
    public void SetValues(string formula)
    {
        Dictionary <string, Dictionary <string, string> > handbookDictionary = HandbookSaver.GetHandbook();

        if (formula != "")
        {
            reagentFormula.text     = formula;
            reagentDescription.text = handbookDictionary [formula] ["description"];
        }
    }
    /// <summary>
    /// Sets the values of the state according to the reagent selected
    /// </summary>
    public void OpenReagentInfo(string formula)
    {
        Dictionary <string, Dictionary <string, string> > handbookDictionary = HandbookSaver.GetHandbook();


        Debug.Log("Opening info of " + formula);
        if (formula != "")
        {
            reagentFormula.text     = formula;
            reagentDescription.text = handbookDictionary [formula] ["description"];
        }
    }
    // Use this for initialization
    public void Start()
    {
        Dictionary <string, Dictionary <string, string> > handbookDictionary = HandbookSaver.GetHandbook();

        foreach (string formula in handbookDictionary.Keys)
        {
            GameObject handbookItem = Instantiate(reagentButtonPrefab.gameObject) as GameObject;
            handbookItem.name = formula;

            handbookItem.GetComponentInChildren <Text>().text = handbookDictionary[formula]["formula"];
            handbookItem.gameObject.GetComponent <Button> ().onClick.AddListener(() => OpenReagent(handbookItem.name));
            handbookItem.transform.SetParent(content.transform, false);
        }
    }