void UpdateDisplay()
        {
            lbTowerName.text = sTower.unitName;
            lbTowerDesp.text = sTower.desp;

            int upgradeType  = sTower.GetUpgradeType();                 //0-to next level, 1-to next tower
            int upgradeCount = sTower.GetUpgradeOptionCount();

            for (int i = 0; i < upgradeButtons.Count; i++)
            {
                if (i < upgradeCount)
                {
                    if (upgradeType == 0)
                    {
                        upgradeButtons[i].lbMain.text     = sTower.GetUpgradeCost()[0].ToString("f0");                  //"next level";
                        upgradeButtons[i].imgMain.enabled = false;
                        upgradeButtons[i].imgAlt.enabled  = true;
                    }
                    else if (upgradeType == 1)
                    {
                        UnitTower nextTower = sTower.GetUpgradeTower(i);
                        upgradeButtons[i].lbMain.text     = nextTower.GetCost()[0].ToString("f0");
                        upgradeButtons[i].imgMain.sprite  = nextTower.icon;
                        upgradeButtons[i].imgMain.enabled = true;
                        upgradeButtons[i].imgAlt.enabled  = false;
                    }

                    upgradeButtons[i].SetActive(true);
                }
                else
                {
                    upgradeButtons[i].SetActive(false);
                }
            }

            buttonSell.lbMain.text = sTower.GetSellValue()[0].ToString("f0");
            buttonSell.SetActive(!sTower.disableSelling);

            targetModeObj.SetActive(sTower.IsTurret() && allowTargetModeSwitch);
            UpdateTargetModeDisplay();

            targetDirObj.SetActive(sTower.IsTurret() && sTower.UseDirectionalTargeting() && allowTargetDirSwitch);
            sliderTargetDir.value = sTower.targetingDir;
        }
Exemple #2
0
        public void _ShowSell(UnitTower tower, Vector3 pos, int pivotCorner = 2, Vector3 offset = default(Vector3))
        {
            SetPivot(pivotCorner);

            labelName.text    = "Sell " + tower.unitName;
            labelDesp.enabled = false;

            List <float> cost = tower.GetSellValue();

            for (int i = 0; i < RscManager.GetResourceCount(); i++)
            {
                rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                rscItemList[i].lbMain.text    = cost[i].ToString("f0");
            }

            minHeight      = -1;
            rectT.position = pos + offset;

            canvasGroup.alpha = 1;
            thisObj.SetActive(true);
        }