Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        //Should find cause to building being null 1/2
        if (Building == null)
        {
            return;
        }

        _upgradesSubPanel = this.transform.GetChild(1);

        //Instantiate buttons
        foreach (GameObject upgrade in Building.Upgrades)
        {
            IBuildingCost buildCost = upgrade.GetComponent <IBuildingCost>();
            buildCost.Init();


            GameObject go     = Instantiate(ButtonTemplate, _upgradesSubPanel);
            Button     button = go.GetComponent <Button>();
            button.onClick.AddListener(() => ClickUpgrade(upgrade));

            _buttons[buildCost] = button;

            IEnumerable <IResource> cost = buildCost.GetResources();
            string costText = string.Join(Environment.NewLine, cost.Select((r) => r.ToString()).ToArray());

            button.GetComponentInChildren <Text>().text = upgrade.name + Environment.NewLine + costText;
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        _buidlingsSubPanel = this.transform.GetChild(0);
        _resourcesSubPanel = this.transform.GetChild(1);

        //Instantiate buttons
        foreach (GameObject building in Builder.Buildings)
        {
            IBuildingCost buildCost = building.GetComponent <IBuildingCost>();
            buildCost.Init();


            GameObject go     = Instantiate(ButtonTemplate, _buidlingsSubPanel);
            Button     button = go.GetComponent <Button>();
            button.onClick.AddListener(() => ClickBuild(building));

            _buttons[buildCost] = button;

            IEnumerable <IResource> cost = buildCost.GetResources();
            string costText = string.Join(Environment.NewLine, cost.Select((r) => r.ToString()).ToArray());

            button.GetComponentInChildren <Text>().text = building.name + Environment.NewLine + costText;
        }
        //Instantiate resource texts for Builder
        foreach (IResource resource in Builder.Resources)
        {
            GameObject text = Instantiate(TextTemplate, _resourcesSubPanel);
            _texts.Add(resource, text.GetComponent <Text>());
        }
    }
Esempio n. 3
0
    private void InstantiateButtons()
    {
        foreach (GameObject building in Builder.Buildings)
        {
            IBuildingCost buildCost = building.GetComponent <IBuildingCost>();
            buildCost.Init();

            GameObject go     = Instantiate(ButtonTemplate, _buidlingsSubPanel);
            Button     button = go.GetComponent <Button>();
            button.onClick.AddListener(() => ClickBuild(building));

            _buttons[buildCost] = button;

            IEnumerable <Resource> cost = buildCost.GetResources();
            string costText             = string.Join(Environment.NewLine, cost.Select((r) => r.ToString()).ToArray());

            button.GetComponentInChildren <Text>().text = building.name + Environment.NewLine + costText;
        }
    }