Ejemplo n.º 1
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);
        }