Beispiel #1
0
        void Start()
        {
            if (!manuallySetupItem)
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (i == 0)
                    {
                        perkItemList[0].Init();
                    }
                    else if (i > 0)
                    {
                        perkItemList.Add(UIPerkItem.Clone(perkItemList[0].rootObj, "PerkButton" + (i + 1)));
                    }

                    perkItemList[i].imgIcon.sprite = perkList[i].icon;
                    perkItemList[i].perkID         = perkList[i].ID;
                    perkItemList[i].selectHighlight.SetActive(i == 0);

                    perkItemList[i].SetCallback(null, null, this.OnPerkItem, null);
                }

                UpdateContentRectSize();
            }
            else
            {
                for (int i = 0; i < perkItemList.Count; i++)
                {
                    perkItemList[i].Init();
                    perkItemList[i].selectHighlight.SetActive(i == 0);
                    perkItemList[i].SetCallback(null, null, this.OnPerkItem, null);
                }
            }


            List <Rsc> rscList = ResourceManager.GetResourceList();

            for (int i = 0; i < rscList.Count; i++)
            {
                if (i == 0)
                {
                    rscItemList[0].Init();
                }
                else
                {
                    rscItemList.Add(UIObject.Clone(rscItemList[0].rootObj, "Rsc" + (i + 1)));
                }

                rscItemList[i].imgRoot.sprite = rscList[i].icon;
                rscItemList[i].label.text     = "";
            }
            rscRootObj = rscItemList[0].rectT.parent.gameObject;

            butPurchase.Init();

            UpdatePerkItemList();
            UpdateDisplay();

            //thisObj.SetActive(false);
            rectT.localPosition = new Vector3(0, 99999, 0);
        }
Beispiel #2
0
        void Start()
        {
            if (BuildManager.GetInstance() == null)
            {
                return;
            }

            List <UnitTower> towerList = BuildManager.GetTowerList();

            for (int i = 0; i < towerList.Count; i++)
            {
                if (i == 0)
                {
                    buttonList[0].Init();
                }
                else if (i > 0)
                {
                    buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "BuildButton" + (i + 1)));
                }

                buttonList[i].imgIcon.sprite       = towerList[i].iconSprite;
                buttonList[i].imgHighlight.enabled = false;

                if (UIMainControl.InTouchMode())
                {
                    buttonList[i].SetCallback(null, null, this.OnTowerButton, null);
                }
                else
                {
                    buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnTowerButton, null);
                }
            }

            if (!BuildManager.UseDragNDrop())
            {
                canvasGroup.alpha   = 0;
                rectT.localPosition = new Vector3(0, 99999, 0);
            }

            if (!BuildManager.UseDragNDrop() && UIMainControl.UsePieMenu())
            {
                layoutGroup.enabled = false;
                tooltipObj.transform.localPosition -= new Vector3(0, 60, 0);
            }
            else
            {
                layoutGroup.enabled = true;
            }


            List <Rsc> rscList = ResourceManager.GetResourceList();

            for (int i = 0; i < rscList.Count; i++)
            {
                if (i == 0)
                {
                    tooltipRscItemList[0].Init();
                }
                else
                {
                    tooltipRscItemList.Add(UIObject.Clone(tooltipRscItemList[0].rootObj, "Rsc" + (i + 1)));
                }

                tooltipRscItemList[i].imgRoot.sprite = rscList[i].icon;
                tooltipRscItemList[i].label.text     = rscList[i].value.ToString();
            }

            if (!BuildManager.UseDragNDrop())
            {
                butCancelObj.SetActive(false);
            }
            else
            {
                butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>();
                butCancelObj.transform.SetAsLastSibling();
                OnDragNDrop(false);
            }

            tooltipObj.SetActive(false);
        }