Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        protected float DrawGeneralSetting(float startX, float startY, UnitTower unit)
        {
            string textF = "General Tower Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }


            startX += 12;

            //TDE.Label(startX, startY+=spaceY, width, height, "Turret:", "");
            //unit.isTurret=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isTurret);
            //TDE.Label(startX, startY+=spaceY, width, height, "AOE:", "");
            //unit.isAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isAOE);
            //TDE.Label(startX, startY+=spaceY, width, height, "Support:", "");
            //unit.isSupport=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSupport);
            //TDE.Label(startX, startY+=spaceY, width, height, "Resource:", "");
            //unit.isResource=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isResource);
            //TDE.Label(startX, startY+=spaceY, width, height, "Mine:", "");
            //unit.isMine=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isMine);
            ////TDE.Label(startX, startY+=spaceY, width, height, "Turret:", "");
            ////unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner);

            //startY+=10;

            if (unit.IsTurret() || unit.IsAOE() || unit.IsMine())
            {
                int tgtGroup = (int)unit.targetGroup;
                cont  = new GUIContent("Target Group:", "The target group of the tower");
                contL = TDE.SetupContL(targetGroupLabel, targetGroupTooltip);
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                tgtGroup         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), tgtGroup, contL);
                unit.targetGroup = (UnitTower._TargetGroup)tgtGroup;
            }

            startY = DrawUnitSetting(startX - 12, startY, unit);

            return(startY);
        }
Esempio n. 3
0
        protected float DrawTowerStats(float startX, float startY, UnitTower unit)
        {
            string textF = "Tower Stats And Upgrade";          //+(!foldStats ? "(show)" : "(hide)");

            foldStats = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldStats, textF, TDE.foldoutS);
            if (!foldStats)
            {
                return(startY);
            }

            startX += 15;

            TDE.Label(startX, startY += spaceY, width, height, "Next Upgrade:", "The tower prefab this tower can be upgraded to");
            for (int i = 0; i < unit.upgradeTowerList.Count; i++)
            {
                if (unit.upgradeTowerList[i] == null)
                {
                    unit.upgradeTowerList.RemoveAt(i);  i -= 1; continue;
                }

                TDE.Label(startX + spaceX - 20, startY, width, height, " - ", "");
                int idx = TowerDB.GetPrefabIndex(unit.upgradeTowerList[i]);
                idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, TowerDB.label);
                if (TowerDB.GetItem(idx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(idx)))
                {
                    unit.upgradeTowerList[i] = TowerDB.GetItem(idx);
                }

                if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, height, height), "-"))
                {
                    unit.upgradeTowerList.RemoveAt(i);      i -= 1; continue;
                }

                startY += spaceY;
            }

            int newIdx = -1;

            if (unit.upgradeTowerList.Count > 0)
            {
                TDE.Label(startX + spaceX - 65, startY, width, height, " Add New:", "");
            }
            newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label);
            if (newIdx >= 0 && TowerDB.GetItem(newIdx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(newIdx)))
            {
                Debug.Log("new index  " + newIdx + "     " + TowerDB.GetItem(newIdx));
                unit.upgradeTowerList.Add(TowerDB.GetItem(newIdx));
            }

            startY += 10;

            //~ if(GUI.Button(new Rect(startX+spaceX+15, startY, width, height), "Add Level")) {
            if (GUI.Button(new Rect(startX, startY + spaceY, width, height), "Add Level"))
            {
                unit.statsList.Add(new Stats());
                unit.statsList[unit.statsList.Count - 1].ResetAsBaseStat();
                foldStats = true;
            }

            startY += spaceY;

            blockWidth = spaceX + 2 * widthS + 26;

            float cachedX = startX;
            float cachedY = (startY += spaceY);

            for (int i = 0; i < unit.statsList.Count; i++)
            {
                GUI.Box(new Rect(startX, cachedY, blockWidth, blockHeight), "");

                EditorGUI.LabelField(new Rect(startX + 6, startY += 3, width, height), "Level " + (i + 1), TDE.headerS);

                GUI.color = new Color(1f, .25f, .25f, 1f);
                if (GUI.Button(new Rect(startX + blockWidth - 1.5f * widthS - 3, startY, widthS * 1.5f, 14), "remove"))
                {
                    if (unit.statsList.Count > 1)
                    {
                        unit.statsList.RemoveAt(i); i -= 1;
                    }
                }
                GUI.color = Color.white;

                _EType tType = _EType.TAOE;
                if (unit.IsTurret())
                {
                    tType = _EType.TTurret;
                }
                else if (unit.IsSupport())
                {
                    tType = _EType.TSupport;
                }
                else if (unit.IsResource())
                {
                    tType = _EType.TRsc;
                }
                else if (unit.IsMine())
                {
                    tType = _EType.TMine;
                }
                else if (unit.IsBlock())
                {
                    tType = _EType.TBlock;
                }


                blockHeight = DrawStats(startX, startY + spaceY + 3, unit.statsList[i], tType, true) - cachedY + 5;
                startY      = cachedY;

                startX += blockWidth + 10;

                maxX = startX;
            }
            startY += blockHeight;
            startX  = cachedX - 15;

            return(startY);
        }