// Start is called before the first frame update
 void Start()
 {
     ecoGetter  = dataRetriever.GetComponent <EcosystemGetter>();
     dataSetter = uIDataSetter.GetComponent <CreaturePanelPopulator>();
     resPop     = resourcePanel.GetComponent <ResourcePanelPopulator>();
     netsPop    = netsPanel.GetComponent <NetPanelPopulator>();
     actionPop  = actionsPanel.GetComponent <ActionPanelPopulator>();
 }
    public void populateFields()
    {
        ecoGetter = ecoGetterObj.GetComponent <EcosystemGetter>();
        int   x = 158;
        float y = -14;

        // display age
        float      age     = ecoGetter.getAge();
        GameObject created = GameObject.Instantiate(textPrefab);
        Text       txt     = created.GetComponent <Text>();

        txt.text = age.ToString();

        created.transform.SetParent(canvas.transform, false);
        RectTransform transform = created.GetComponent <RectTransform>();

        transform.anchoredPosition = new Vector2(x, y);
        instantiated.Add(created);


        Dictionary <string, Population> populations = ecoGetter.getPopulations();

        x = 250;
        y = -4.7f;

        int i = 0;

        foreach (string key in populations.Keys)
        {
            created = GameObject.Instantiate(keyValPrefab);
            double     rounded = System.Math.Round((double)populations[key].overallVariability, 2);
            int        size    = populations[key].size;
            GameObject keyObj  = created.transform.GetChild(0).gameObject;
            GameObject valObj  = created.transform.GetChild(1).gameObject;
            keyObj.GetComponent <Text>().text = key + ":";

            Debug.Log(size);
            if (i == populations.Count - 1)
            {
                valObj.GetComponent <Text>().text = size.ToString() + ", " + rounded.ToString();
            }
            else
            {
                valObj.GetComponent <Text>().text = size.ToString() + ", " + rounded.ToString() + ";";
            }


            created.transform.SetParent(canvas.transform, false);
            transform = created.GetComponent <RectTransform>();
            transform.anchoredPosition = new Vector2(x, y);

            instantiated.Add(created);

            x += 170;
            i++;
        }
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    public void menuStart()
    {
        ecoGetter = getterObj.GetComponent <EcosystemGetter>();
        int w = ecoGetter.getMapWidth();
        int h = ecoGetter.getMapHeight();

        gameObject.transform.position = new Vector3(w / 2f, h / 2f, -1);
        //gameObject.transform.localScale = new Vector3(h, h, h);
        gameObject.GetComponent <Camera>().orthographicSize = h / 2;
    }