コード例 #1
0
 protected override void ShiftItemDown()
 {
     if (selectID < PerkDB.GetList().Count - 1)
     {
         ShiftItem(1);
     }
 }
コード例 #2
0
 public string GetDespUnavailable()
 {
     if (status == _Status.InsufficientPP)
     {
         return("available after " + minPerkCount + " perks has been purchased");
     }
     if (status == _Status.InsufficientWave)
     {
         return("available after wave " + minWave);
     }
     if (status == _Status.InsufficientLvl)
     {
         return("available in later game");
     }
     if (status == _Status.PrereqNoMet)
     {
         string text = "require ";
         for (int i = 0; i < prereq.Count; i++)
         {
             int idx = PerkDB.GetPrefabIndex(prereq[i]);
             text += (i > 0 ? ", " : "") + PerkDB.GetItem(idx).name;
         }
         return(text);
     }
     return("");
 }
コード例 #3
0
        private void ShiftItem(int dir)
        {
            Perk item = PerkDB.GetList()[selectID];

            PerkDB.GetList()[selectID]       = PerkDB.GetList()[selectID + dir];
            PerkDB.GetList()[selectID + dir] = item;
            selectID += dir;
        }
コード例 #4
0
 private void SelectItem(int newID)
 {
     selectID = newID;
     if (PerkDB.GetList().Count <= 0)
     {
         return;
     }
     selectID = Mathf.Clamp(selectID, 0, PerkDB.GetList().Count - 1);
 }
コード例 #5
0
ファイル: PerkDB.cs プロジェクト: asd540578/TD_Project
 public static PerkDB Init()
 {
     if (instance != null)
     {
         return(instance);
     }
     instance = LoadDB();
     return(instance);
 }
コード例 #6
0
        public static void InitDB()
        {
            if (init)
            {
                return;
            }
            init = true;

            towerDBList     = TowerDB.Load();
            abilityDBList   = AbilityDB.Load();
            perkDBList      = PerkDB.Load();
            fpsWeaponDBList = FPSWeaponDB.Load();
        }
コード例 #7
0
        public static List <Perk> Load()
        {
            GameObject obj = Resources.Load("DB_TDTK/PerkDB", typeof(GameObject)) as GameObject;

                        #if UNITY_EDITOR
            if (obj == null)
            {
                obj = CreatePrefab();
            }
                        #endif

            PerkDB instance = obj.GetComponent <PerkDB>();
            return(instance.perkList);
        }
コード例 #8
0
        public static List <Perk> LoadClone()
        {
            GameObject obj      = Resources.Load("DB_TDTK/PerkDB", typeof(GameObject)) as GameObject;
            PerkDB     instance = obj.GetComponent <PerkDB>();

            List <Perk> newList = new List <Perk>();

            if (instance != null)
            {
                for (int i = 0; i < instance.perkList.Count; i++)
                {
                    newList.Add(instance.perkList[i].Clone());
                }
            }

            return(newList);
        }
コード例 #9
0
        private int _NewItem(int idx = -1)
        {
            Perk item = null;

            if (idx < 0)
            {
                item = new Perk(); item.effect.Reset();
            }
            if (idx >= 0)
            {
                item = PerkDB.GetList()[idx].Clone();
            }

            item.prefabID = TDE.GenerateNewID(PerkDB.GetPrefabIDList());

            PerkDB.GetList().Add(item);
            PerkDB.UpdateLabel();

            return(PerkDB.GetList().Count - 1);
        }
コード例 #10
0
        private static void LoadPerk()
        {
            perkDBPrefab = PerkDB.LoadDB();
            perkList     = perkDBPrefab.perkList;

            for (int i = 0; i < perkList.Count; i++)
            {
                //perkList[i].ID=i;
                if (perkList[i] != null)
                {
                    perkIDList.Add(perkList[i].ID);
                }
                else
                {
                    perkList.RemoveAt(i);
                    i -= 1;
                }
            }

            UpdatePerkNameList();
        }
コード例 #11
0
ファイル: _TDEditor.cs プロジェクト: ledotrong/tower-defense
        public static void LoadPerk()
        {
            perkDB = PerkDB.LoadDB();

            for (int i = 0; i < perkDB.perkList.Count; i++)
            {
                if (perkDB.perkList[i] != null)
                {
                    perkIDList.Add(perkDB.perkList[i].ID);
                }
                else
                {
                    perkDB.perkList.RemoveAt(i);      i -= 1;
                }
            }

            UpdateLabel_Perk();

            TDEditorWindow.SetPerkDB(perkDB, perkIDList, perkLabel);
            TDEditorInspector.SetPerkDB(perkDB, perkIDList, perkLabel);
        }
コード例 #12
0
ファイル: _TDEditor.cs プロジェクト: coollemen/ZombieComing
        public static void Init()
        {
            if (init)
            {
                return;
            }

            init = true;                //Debug.Log(" - Init Editor - ");

            damageTableDB = DamageTableDB.Init();
            rscDB         = RscDB.Init();
            towerDB       = TowerDB.Init();
            creepDB       = CreepDB.Init();
            abilityDB     = AbilityDB.Init();
            perkDB        = PerkDB.Init();
            effectDB      = EffectDB.Init();

            DamageTableDB.UpdateLabel();
            TowerDB.UpdateLabel();
            CreepDB.UpdateLabel();
            AbilityDB.UpdateLabel();
            PerkDB.UpdateLabel();
            EffectDB.UpdateLabel();
        }
コード例 #13
0
ファイル: PerkManager.cs プロジェクト: asd540578/TD_Project
        void Awake()
        {
            instance = this;

            uPIDList = new List <int>();
            aPIDList = new List <int>();
            ePIDList = new List <int>();

            if (carryOver && cached)
            {
                rsc = cachedRsc;
                purchasedPrefabIDList = cachedPurchasedIDList;
            }

            List <Perk> dbList = PerkDB.GetList();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailablePrefabIDList.Contains(dbList[i].prefabID))
                {
                    perkList.Add(dbList[i].Clone());
                }
            }
        }
コード例 #14
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            Undo.RecordObject(instance, "PerkManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Game Scene:", "Check to to indicate if the scene is not an actual game scene\nIntend if the a perk menu scene, purchased perk wont take effect ");
            instance.inGameScene = EditorGUILayout.Toggle(cont, instance.inGameScene);

            cont = new GUIContent("Carry Over:", "Check to have carry the progress made in previous level to this level, the progress made in this level will be carry over to the next level.\n\nIf this is the first level, the specified setting value is used instead");
            instance.carryOver = EditorGUILayout.Toggle(cont, instance.carryOver);

            EditorGUILayout.Space();


            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();

            EditorGUIUtility.labelWidth += 35;
            cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for perk cost");
            instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost);
            EditorGUIUtility.labelWidth  -= 35;

            cont = new GUIContent("Resource:", "The resource used  to cast perk");
            if (instance.useRscManagerForCost)
            {
                EditorGUILayout.LabelField("Resource:", "-");
            }
            else
            {
                instance.rsc = EditorGUILayout.IntField(cont, instance.rsc);
            }

            GUILayout.EndVertical();

            if (!instance.useRscManagerForCost)
            {
                Sprite icon = PerkDB.GetRscIcon();
                icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40));
                PerkDB.SetRscIcon(icon);
            }

            GUILayout.EndHorizontal();


            EditorGUILayout.Space();


            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showList = EditorGUILayout.Foldout(showList, "Show Perk List");
            EditorGUILayout.EndHorizontal();
            if (showList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("EnableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = new List <int>();
                }
                if (GUILayout.Button("DisableAll") && !Application.isPlaying)
                {
                    instance.unavailablePrefabIDList = PerkDB.GetPrefabIDList();
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();


                List <Perk> perkList = PerkDB.GetList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (perkList[i].hideInInspector)
                    {
                        continue;
                    }

                    Perk perk = perkList[i];

                    GUILayout.BeginHorizontal();

                    EditorGUILayout.Space();

                    GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40));
                    TDE.DrawSprite(GUILayoutUtility.GetLastRect(), perk.icon, perk.desp, false);

                    GUILayout.BeginVertical();
                    EditorGUILayout.Space();
                    GUILayout.Label(perk.name, GUILayout.ExpandWidth(false));

                    GUILayout.BeginHorizontal();

                    float cachedL = EditorGUIUtility.labelWidth;      EditorGUIUtility.labelWidth = 80;
                    float cachedF = EditorGUIUtility.fieldWidth;      EditorGUIUtility.fieldWidth = 10;

                    EditorGUI.BeginChangeCheck();
                    bool flag = !instance.unavailablePrefabIDList.Contains(perk.prefabID) ? true : false;
                    flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the perk in this level"), flag);

                    if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                    {
                        if (!flag && !instance.unavailablePrefabIDList.Contains(perk.prefabID))
                        {
                            instance.unavailablePrefabIDList.Add(perk.prefabID);
                            instance.purchasedPrefabIDList.Remove(perk.prefabID);
                        }
                        else if (flag)
                        {
                            instance.unavailablePrefabIDList.Remove(perk.prefabID);
                        }
                    }

                    if (!instance.unavailablePrefabIDList.Contains(perk.prefabID))
                    {
                        EditorGUI.BeginChangeCheck();
                        flag = instance.purchasedPrefabIDList.Contains(perk.prefabID);
                        flag = EditorGUILayout.Toggle(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), flag);

                        if (!Application.isPlaying && EditorGUI.EndChangeCheck())
                        {
                            if (flag)
                            {
                                instance.purchasedPrefabIDList.Add(perk.prefabID);
                            }
                            else
                            {
                                instance.purchasedPrefabIDList.Remove(perk.prefabID);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(" - purchased: ", "- ");
                    }

                    EditorGUIUtility.labelWidth = cachedL;    EditorGUIUtility.fieldWidth = cachedF;

                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
コード例 #15
0
        protected float DrawBasicSetting(float startX, float startY, Perk item)
        {
            //TDE.Label(startX, startY+=spaceY, width, height, "General Setting", "", TDE.headerS);
            string textF = "General 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, "Gained on Wave:", "");	CheckColor(item.autoUnlockOnWave, -1);
            //~ item.autoUnlockOnWave=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), item.autoUnlockOnWave);	ResetColor();

            //~ startY+=10;

            TDE.Label(startX, startY += spaceY, width, height, "Cost:", "The cost of PerkManager resource required for the perk\nUsed when 'Use RscManager For Cost' is disabled in PerkManager");
            item.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.cost);

            TDE.Label(startX, startY += spaceY, width, height, "Cost (Rsc):", "The cost of RscManager resource required for the perk\nUsed when 'Use RscManager For Cost' is enabled in PerkManager");
            //~ while(item.costRsc.Count<RscDB.GetCount()) item.costRsc.Add(0);
            //~ while(item.costRsc.Count>RscDB.GetCount()) item.costRsc.RemoveAt(item.costRsc.Count-1);

            RscManager.MatchRscList(item.costRsc, 0);

            float cachedX = startX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                if (i > 0 && i % 3 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                item.costRsc[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.costRsc[i]);
            }
            startX = cachedX;

            //TDE.Label(startX, startY+=spaceY, width, height, "Repeatabe:", "");
            //item.repeatable=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), item.repeatable);
            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "AutoUnlockOnWave:", "If given a value, the perk will automatically be purchased for the player upon completing the specified wave");  CheckColor(item.autoUnlockOnWave, 0);
            item.autoUnlockOnWave     = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.autoUnlockOnWave);       ResetColor();

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Min Level:", "The minimum level required before the perk becomes available\n\nThis is value of 'Level ID' in GameControl");   CheckColor(item.minLevel, 0);
            item.minLevel             = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minLevel);       ResetColor();

            TDE.Label(startX, startY += spaceY, width, height, "Min Wave:", "The minimum wave required before the perk becomes available");   CheckColor(item.minWave, 0);
            item.minWave              = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minWave); ResetColor();

            TDE.Label(startX, startY += spaceY, width, height, "Min Perk Count:", "The minimum number of perk purchased required before the perk becomes available"); CheckColor(item.minPerkCount, 0);
            item.minPerkCount         = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minPerkCount);       ResetColor();


            TDE.Label(startX, startY += spaceY, width, height, "Prereq Perk:", "Perk(s) required to be purchased before the perk becomes available");
            for (int i = 0; i < item.prereq.Count; i++)
            {
                TDE.Label(startX + spaceX - 20, startY, widthS, height, "-");

                int index = PerkDB.GetPrefabIndex(item.prereq[i]);
                if (index < 0)
                {
                    item.prereq.RemoveAt(i); i -= 1; continue;
                }

                index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label);

                int prefabID = PerkDB.GetItem(index).prefabID;
                if (prefabID != item.prefabID && !item.prereq.Contains(prefabID))
                {
                    item.prereq[i] = prefabID;
                }

                if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                {
                    item.prereq.RemoveAt(i); i -= 1;
                }

                startY += spaceY;
            }

            int newID = -1;           CheckColor(item.prereq.Count, 0);

            newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label);
            if (newID >= 0 && !item.prereq.Contains(newID))
            {
                item.prereq.Add(newID);
            }
            startY += 10;
            ResetColor();

            return(startY);
        }
コード例 #16
0
        protected float DrawEffectSetting(float startX, float startY, Perk item)
        {
            //TDE.Label(startX, startY, spaceX*2, height, "Perk Effect Attribute", "", TDE.headerS);	startY+=spaceY;
            string text = "Perk Effect Attribute ";          //+ (!foldStats ? "(show)" : "(hide)");

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

            startY += spaceY; startX += 12;

            if (item.type == _PerkType.NewTower)
            {
                TDE.Label(startX, startY, width, height, "New Tower:", "The new tower to be added to game");
                item.newTowerPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newTowerPID, TowerDB.label);

                TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting tower that will be replaced");
                item.replaceTowerPID      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceTowerPID, TowerDB.label);
            }

            else if (item.type == _PerkType.NewAbility)
            {
                TDE.Label(startX, startY, width, height, "New Ability:", "The new ability to be added to game");
                item.newAbilityPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newAbilityPID, AbilityDB.label);

                TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting ability that will be replaced");
                item.replaceAbilityPID    = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceAbilityPID, AbilityDB.label);
            }

            else if (item.UseGainValue() || item.UseGainList())
            {
                startY = DrawEffectTypeSetting(startX, startY, item);

                string txtType = item.IsMultiplier() ? "Multiplier:" : "Modifier:";
                if (!item.SupportModNMul())
                {
                    txtType = "Gain:";
                }

                if (item.UseGainValue())
                {
                    string txt = item.UseGainList() ? "Global " : "";

                    TDE.Label(startX, startY, width, height, txt + txtType);                  //"Gain Value:", "");
                    item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain);
                    startY   += spaceY;
                }

                if (item.UseGainList())
                {
                    if (item.gainList.Count < RscDB.GetCount())
                    {
                        item.gainList.Add(0);
                    }
                    if (item.gainList.Count > RscDB.GetCount())
                    {
                        item.gainList.Remove(item.gainList.Count - 1);
                    }

                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i));
                        TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i));                   //" - "+txtType, "");
                        item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gainList[i]);
                        if (i < item.gainList.Count - 1)
                        {
                            startY += spaceY;
                        }
                    }
                }
                else
                {
                    startY -= spaceY;
                }
            }

            else if (item.UseStats())
            {
                string textItem = "";
                if (item.type == _PerkType.ModifyTower)
                {
                    textItem = "towers";
                }
                if (item.type == _PerkType.ModifyAbility)
                {
                    textItem = "abilities";
                }
                if (item.type == _PerkType.ModifyEffect)
                {
                    textItem = "effects";
                }

                TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all " + textItem);
                item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll);

                if (!item.applyToAll)
                {
                    startY += spaceY;
                    if (item.type == _PerkType.ModifyTower)
                    {
                        TDE.Label(startX, startY, width, height, "Target Tower:", "The target towers which this perk should be applied to");
                        for (int i = 0; i < item.towerPIDList.Count; i++)
                        {
                            if (item.towerPIDList[i] < 0)
                            {
                                item.towerPIDList.RemoveAt(i); i -= 1; continue;
                            }

                            int index = TowerDB.GetPrefabIndex(item.towerPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, TowerDB.label);
                            int prefabID = TowerDB.GetItem(index).prefabID;
                            if (prefabID != item.prefabID && !item.towerPIDList.Contains(prefabID))
                            {
                                item.towerPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.towerPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label);
                        if (newIdx >= 0 && !item.towerPIDList.Contains(TowerDB.GetItem(newIdx).prefabID))
                        {
                            item.towerPIDList.Add(TowerDB.GetItem(newIdx).prefabID);
                        }
                    }
                    if (item.type == _PerkType.ModifyAbility)
                    {
                        TDE.Label(startX, startY, width, height, "Target Ability:", "The target abilities which this perk should be applied to");
                        for (int i = 0; i < item.abilityPIDList.Count; i++)
                        {
                            int index = AbilityDB.GetPrefabIndex(item.abilityPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, AbilityDB.label);
                            int prefabID = AbilityDB.GetItem(index).prefabID;
                            if (prefabID != item.prefabID && !item.abilityPIDList.Contains(prefabID))
                            {
                                item.abilityPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.abilityPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, AbilityDB.label);
                        if (newIdx >= 0 && !item.abilityPIDList.Contains(AbilityDB.GetItem(newIdx).prefabID))
                        {
                            item.abilityPIDList.Add(AbilityDB.GetItem(newIdx).prefabID);
                        }
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        TDE.Label(startX, startY, width, height, "Target Effect:", "The target effects which this perk should be applied to");
                        for (int i = 0; i < item.effectPIDList.Count; i++)
                        {
                            int index = EffectDB.GetPrefabIndex(item.effectPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, EffectDB.label);
                            int prefabID = EffectDB.GetItem(index).prefabID;

                            if (prefabID != item.prefabID && !item.effectPIDList.Contains(prefabID))
                            {
                                item.effectPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.effectPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, EffectDB.label);
                        if (newIdx >= 0 && !item.effectPIDList.Contains(EffectDB.GetItem(newIdx).prefabID))
                        {
                            item.effectPIDList.Add(EffectDB.GetItem(newIdx).prefabID);
                        }
                    }
                }

                startY += spaceY + 10;

                startY = DrawEffectTypeSetting(startX, startY, item) - spaceY;

                startY += spaceY;

                _EType eType = _EType.PerkT;

                if (item.type == _PerkType.ModifyAbility)
                {
                    eType = _EType.PerkA;

                    TDE.Label(startX, startY, width, height, "Use Limit:", "Modify the use limit of the ability");
                    if (item.effType == Perk._EffType.Multiplier)
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }
                    else
                    {
                        item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain);
                    }

                    TDE.Label(startX, startY += spaceY, width, height, "Cost:", "Modify/Multiply the activation cost of the ability");
                    item.costMul              = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.costMul);
                    startY += spaceY;
                }
                else if (item.type == _PerkType.ModifyEffect)
                {
                    eType = _EType.PerkE;

                    TDE.Label(startX, startY, width, height, "Duration:", "Modify the duration of the effect");
                    item.effect.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.effect.duration);

                    TDE.Label(startX, startY += spaceY + 5, width, height, "Stun:", "Check to enable the effec to stun. This will only override the default value if it's set to true");
                    item.effect.stun          = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), item.effect.stun);
                    startY += spaceY;
                }

                startY = DrawStats(startX - 12, startY, item.effect.stats, eType) - spaceY;
            }

            else if (item.IsForPerk())
            {
                TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all perk");
                item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll);

                if (!item.applyToAll)
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Target Perk:", "The target perk which this perk affect should be applied to");
                    for (int i = 0; i < item.perkPIDList.Count; i++)
                    {
                        int index = PerkDB.GetPrefabIndex(item.perkPIDList[i]);
                        index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label);
                        int prefabID = PerkDB.GetItem(index).prefabID;
                        if (prefabID != item.prefabID && !item.perkPIDList.Contains(prefabID))
                        {
                            item.perkPIDList[i] = prefabID;
                        }

                        if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                        {
                            item.perkPIDList.RemoveAt(i); i -= 1;
                        }

                        startY += spaceY;
                    }

                    int newID = -1;
                    newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label);
                    if (newID >= 0 && !item.perkPIDList.Contains(newID))
                    {
                        item.perkPIDList.Add(newID);
                    }
                    startY += spaceY + 10;
                }

                TDE.Label(startX, startY, width, height, "Perk Rsc Multiplier:", "Modify/Multiply the purchase cost of the ability");
                item.costMul = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.costMul);

                if (item.gainList.Count < RscDB.GetCount())
                {
                    item.gainList.Add(0);
                }
                if (item.gainList.Count > RscDB.GetCount())
                {
                    item.gainList.Remove(item.gainList.Count - 1);
                }

                for (int i = 0; i < item.gainList.Count; i++)
                {
                    TDE.DrawSprite(new Rect(startX, startY += spaceY, height, height), RscDB.GetIcon(i));
                    TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i) + ":", "");
                    item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.gainList[i]);
                }
            }

            return(startY + spaceY);
        }
コード例 #17
0
ファイル: UIPerkScreen.cs プロジェクト: asd540578/TD_Project
        public override void Start()
        {
            base.Start();

            if (!PerkManager.IsEnabled())
            {
                thisObj.SetActive(false);
                return;
            }

            if (PerkManager.UseRscManagerForCost())
            {
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    if (i > 0)
                    {
                        costItemList.Add(new UIObject(UI.Clone(costItemList[0].rootObj)));
                    }
                    costItemList[i].Init();
                    costItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                }
            }
            else
            {
                costItemList[0].Init();
                costItemList[0].imgMain.sprite = PerkDB.GetRscIcon();
            }

            if (customLayout)
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < itemList.Count; i++)
                {
                    itemList[i].Init();
                    itemList[i].SetCallback(null, null, this.OnItem, null);

                    bool matched = false;
                    for (int n = 0; n < perkList.Count; n++)
                    {
                        if (itemList[i].linkedPerkPID == perkList[n].prefabID)
                        {
                            itemList[i].linkedPerkIdx  = n;    matched = true;
                            itemList[i].imgMain.sprite = perkList[n].icon;
                        }
                    }

                    if (!matched)
                    {
                        Debug.LogWarning("No perk with matching prefab found");
                        itemList[i].rootObj.SetActive(false);
                        continue;
                    }

                    itemList[i].UnparentConnector();
                    itemList[i].UnparentConnectorBase();
                }
            }
            else
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (i > 0)
                    {
                        itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i)));
                    }
                    itemList[i].Init();
                    itemList[i].SetCallback(null, null, this.OnItem, null);
                    itemList[i].linkedPerkIdx  = i;
                    itemList[i].imgMain.sprite = perkList[i].icon;
                }
            }

            buttonPurchase.Init();
            buttonPurchase.SetCallback(null, null, this.OnPurchaseButton, null);

            if (UIControl.IsGameScene())
            {
                buttonClose.Init();
                buttonClose.SetCallback(null, null, this.OnCloseButton, null);
            }

            if (!UIControl.IsGameScene())
            {
                canvasGroup.alpha = 1;
                thisObj.SetActive(true);
                StartCoroutine(DelayUpdateList());
            }
            else
            {
                thisObj.SetActive(false);
            }

            OnItem(itemList[0].rootObj);
        }
コード例 #18
0
		private static void LoadPerk(){
			perkDBPrefab=PerkDB.LoadDB();
			perkList=perkDBPrefab.perkList;
			
			for(int i=0; i<perkList.Count; i++){
				//perkList[i].ID=i;
				if(perkList[i]!=null){
					perkIDList.Add(perkList[i].ID);
				}
				else{
					perkList.RemoveAt(i);
					i-=1;
				}
			}
			
			UpdatePerkNameList();
		}
コード例 #19
0
 protected override void DeleteItem()
 {
     PerkDB.GetList().RemoveAt(deleteID);
     PerkDB.UpdateLabel();
 }
コード例 #20
0
ファイル: UIHUD.cs プロジェクト: asd540578/TD_Project
        // Use this for initialization
        void Start()
        {
            GameObject lastSpaceObj = null;

            if (UIControl.IsGameScene())
            {
                lifeItem.Init();
                waveItem.Init();

                UpdateLifeDisplay(GameControl.GetLife());
                UpdateWaveDisplay(1);

                lastSpaceObj = spaceObjLife;
            }
            else
            {
                waveItem.rootObj.SetActive(false);
                spaceObjWave.SetActive(false);

                lifeItem.rootObj.SetActive(false);
                spaceObjLife.SetActive(false);
            }


            if (UIControl.IsGameScene() || PerkManager.UseRscManagerForCost())
            {
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    if (i > 0)
                    {
                        rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj)));
                    }
                    rscItemList[i].Init();
                    rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);

                    rscItemList[i].rectT.SetSiblingIndex(rscItemList[0].rectT.GetSiblingIndex() + i);
                }
                UpdateResourceDisplay(RscManager.GetResourceList());

                lastSpaceObj = spaceObjRsc;
            }
            else
            {
                rscItemList[0].rootObj.SetActive(false);
                spaceObjRsc.SetActive(false);
            }


            if (!UIControl.IsGameScene() || !AbilityManager.IsEnabled() || AbilityManager.UseRscManagerForCost())
            {
                sliderAbilityRsc.gameObject.SetActive(false);
                spaceObjAbility.SetActive(false);
            }
            else
            {
                imgAbilityRsc.sprite = AbilityDB.GetRscIcon();
                UpdateAbilityRscDisplay(AbilityManager.GetRsc());
                lastSpaceObj = spaceObjAbility;
            }

            if (!PerkManager.IsEnabled() || PerkManager.UseRscManagerForCost())
            {
                perkRscItem.rootObj.SetActive(false);
                //spaceObjPerk.SetActive(false);
                lastSpaceObj.SetActive(false);
            }
            else
            {
                perkRscItem.Init();
                perkRscItem.imgMain.sprite = PerkDB.GetRscIcon();
                UpdatePerkRscDisplay(PerkManager.GetRsc());
            }



            //~ if(!UIControl.DisablePerkScreen()){
            //~ buttonPerk.Init();
            //~ buttonPerk.SetCallback(null, null, this.OnPerkButton, null);
            //~ }
            //~ else{
            //~ if(buttonPerk.rootObj!=null) buttonPerk.rootObj.SetActive(false);
            //~ }


            //~ buttonFF.Init();
            //~ buttonFF.SetCallback(null, null, this.OnFFButton, null);

            //~ buttonPause.Init();
            //~ buttonPause.SetCallback(null, null, this.OnPauseButton, null);
        }
コード例 #21
0
        public void OnGUI()
        {
            TDE.InitGUIStyle();

            if (!CheckIsPlaying())
            {
                return;
            }
            if (window == null)
            {
                Init();
            }


            List <Perk> perkList = PerkDB.GetList();

            Undo.RecordObject(this, "window");
            Undo.RecordObject(PerkDB.GetDB(), "abilityDB");


            if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save"))
            {
                TDE.SetDirty();
            }


            if (GUI.Button(new Rect(5, 5, 120, 25), "Create New"))
            {
                Select(NewItem());
            }
            if (perkList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected"))
            {
                Select(NewItem(selectID));
            }


            float startX = 5; float startY = 55;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }

            Vector2 v2 = DrawPerkList(startX, startY, perkList);

            startX = v2.x + 25;

            if (perkList.Count == 0)
            {
                return;
            }


            Rect visibleRect = new Rect(startX, startY, window.position.width - startX, window.position.height - startY);
            Rect contentRect = new Rect(startX, startY, contentWidth, contentHeight);

            scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect);

            v2            = DrawPerkConfigurator(startX, startY, perkList[selectID]);
            contentWidth  = v2.x - startX;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }
コード例 #22
0
ファイル: W_SpawnEditor.cs プロジェクト: asd540578/TD_Project
        public float DrawGeneratorParameter(float startX, float startY)
        {
            instance.UpdateGeneratorUnitList();

            SpawnGenerator gen = instance.generator;  gen.Init();

            startX += 5;              spaceX += widthS;

            TDE.Label(startX, startY, width, height, "Wave Interval (Min/Max):", "The minimum and maximum value of the interval (in second) between two waves");
            gen.waveIntervalMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), gen.waveIntervalMin);
            gen.waveIntervalMax = EditorGUI.FloatField(new Rect(startX + spaceX + widthS, startY, widthS, height), gen.waveIntervalMax);

            gen.waveIntervalMin = Mathf.Max(0, gen.waveIntervalMin);          gen.waveIntervalMin = Mathf.Max(gen.waveIntervalMin, 0);
            gen.waveIntervalMax = Mathf.Max(0, gen.waveIntervalMax);  gen.waveIntervalMax = Mathf.Max(gen.waveIntervalMax, 0);

            TDE.Label(startX, startY += spaceY, width, height, "Use all path:", "When checked, all available path will be used (provided that there's enough subwave in the wave)");
            gen.useAllPath            = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.useAllPath);

            TDE.Label(startX, startY   += spaceY, width, height, "One SubWave per path:", "When checked, the total subwave count will be limited to number of path available");
            gen.limitSubWaveCountToPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.limitSubWaveCountToPath);

            TDE.Label(startX, startY += spaceY, width, height, "Mirror SubWave:", "When checked, all subwave will be similar except they uses different path");
            gen.similarSubWave        = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.similarSubWave);

            spaceX -= widthS;


            float cachedY = startY += spaceY * 2.5f;      float cachedX = startX;

            TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Wave Setting:", "", TDE.headerS);
            DrawGenAttribute(startX, cachedY, gen.attSubWaveCount, "SubWave Count:", "", null, 1);  startX         += genAttBlockWidth + 10;
            DrawGenAttribute(startX, cachedY, gen.attTotalUnitCount, "Total Unit Count:", "", null, 1);     startX += genAttBlockWidth + 10;

            startX += 15;

            TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Gain On Wave Cleared:", "", TDE.headerS);
            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Life Gain:");              startX += genAttBlockWidth + 10;


            //cachedY=startY+spaceY;	cachedX=startX;
            for (int i = 0; i < gen.attRscGainOnCleared.Count; i++)
            {
                DrawGenAttribute(startX, cachedY, gen.attRscGainOnCleared[i], RscDB.GetName(i), "", RscDB.GetIcon(i));
                startX += genAttBlockWidth + 10;
            }
            //startY+=genAttBlockHeight+spaceY; startX=cachedX;

            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Perk Rsc Gain:", "", PerkDB.GetRscIcon());         startX         += genAttBlockWidth + 10;
            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Ability Rsc Gain:", "", AbilityDB.GetRscIcon());           startX += genAttBlockWidth + 10;

            startY += genAttBlockHeight + spaceY * 2;     startX = cachedX;

            for (int i = 0; i < gen.genItemList.Count; i++)
            {
                if (gen.genItemList[i].prefab == null)
                {
                    gen.genItemList.RemoveAt(i);    i -= 1;
                    continue;
                }
                startY = DrawGenItem(startX, startY, gen.genItemList[i]) + 10;
            }

            return(startY + spaceY * 2);
        }
コード例 #23
0
 public static void SetPerkDB(PerkDB db, List <int> IDList, string[] label)
 {
     perkDB     = db;
     perkIDList = IDList;
     perkLabel  = label;
 }
コード例 #24
0
ファイル: W_SpawnEditor.cs プロジェクト: asd540578/TD_Project
        private float DrawWaveList(float startX, float startY)
        {
            maxSubWaveSize = 1;

            for (int i = 0; i < instance.waveList.Count; i++)
            {
                if (waveFoldList.Count <= i)
                {
                    waveFoldList.Add(true);
                }
                if (waveOFoldList.Count <= i)
                {
                    waveOFoldList.Add(true);
                }

                waveFoldList[i] = EditorGUI.Foldout(new Rect(startX, startY, widthS * 2, 15), waveFoldList[i], "Wave - " + (i + 1), TDE.foldoutS);

                if (removeIdx != i)
                {
                    if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "remove"))
                    {
                        removeIdx = i;
                    }
                    if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "Insert"))
                    {
                        instance.waveList.Insert(i, new Wave());
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "cancel"))
                    {
                        removeIdx = -1;
                    }
                    GUI.color = new Color(1, .2f, .2f, 1f);
                    if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "confirm"))
                    {
                        instance.waveList.RemoveAt(i);
                        removeIdx = -1;   i -= 1; continue;
                    }
                    GUI.color = white;
                }

                Wave wave = instance.waveList[i];

                if (waveFoldList[i])
                {
                    startX += 15;

                    TDE.Label(startX, startY += spaceY, width, 15, "SubWave (" + wave.subWaveList.Count + "):");
                    if (GUI.Button(new Rect(startX + spaceX, startY - 1, widthS, 15), "-1"))
                    {
                        if (wave.subWaveList.Count > 1)
                        {
                            wave.subWaveList.RemoveAt(wave.subWaveList.Count - 1);
                        }
                    }
                    if (GUI.Button(new Rect(startX + spaceX + 50, startY - 1, widthS, 15), "+1"))
                    {
                        wave.subWaveList.Add(new SubWave());
                    }

                    float cachedY = startY + spaceY;
                    for (int n = 0; n < wave.subWaveList.Count; n++)
                    {
                        startY = DrawSubWaveBlock(startX + (n * (subWaveBlockWidth + 10)), cachedY, wave.subWaveList[n], n, i);
                    }

                    startY += 5;

                    TDE.Label(startX, startY, width, height, "Time to Next Wave: ", "Time in second before next wave is spawned");
                    wave.timeToNextWave = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), wave.timeToNextWave);

                    float cachedX = startX;                     //startY+=spaceY;

                    TDE.Label(startX, startY += spaceY, width, height, "Gain On Clear: ", "gain when the wave is cleared", TDE.headerS);
                    TDE.Label(startX         += spaceX, startY, width, height, "Rsc: ", "Resource");          startX += 30;

                    RscManager.MatchRscList(wave.rscGainOnCleared, 0);

                    for (int n = 0; n < RscDB.GetCount(); n++)
                    {
                        TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(n), RscDB.GetName(n));
                        wave.rscGainOnCleared[n] = EditorGUI.FloatField(new Rect(startX + height, startY, widthS - height, height), wave.rscGainOnCleared[n]);
                        startX += widthS + 2;
                    }

                    startX += widthS * .5f;
                    TDE.Label(startX, startY, width, height, "Perk rsc: ", "");
                    TDE.DrawSprite(new Rect(startX += 55, startY, height, height), PerkDB.GetRscIcon());
                    wave.perkRscGainOnCleared       = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.perkRscGainOnCleared);

                    startX += widthS * 1.5f;
                    TDE.Label(startX, startY, width, height, "Ability rsc: ", "");
                    TDE.DrawSprite(new Rect(startX += 65, startY, height, height), AbilityDB.GetRscIcon());
                    wave.abilityRscGainOnCleared    = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.abilityRscGainOnCleared);

                    startX = cachedX;

                    startY += spaceY * 2f;
                    startX -= 15;
                }
                else
                {
                    float cachedX = startX;   startX += 180 + (removeIdx == i ? widthS * 1.5f : 0);

                    for (int n = 0; n < wave.subWaveList.Count; n++)
                    {
                        if (wave.subWaveList[n].prefab == null)
                        {
                            continue;
                        }
                        TDE.DrawSprite(new Rect(startX, startY, height * 1.5f, height * 1.5f), wave.subWaveList[n].prefab.icon);
                        TDE.Label(startX + height * 1.5f + 2, startY, widthS, height, "x" + wave.subWaveList[n].spawnCount);
                        startX += widthS + height * 1.5f;
                    }

                    startX = cachedX;

                    startY += spaceY * 2f;
                }

                maxSubWaveSize = Mathf.Max(waveFoldList[i] ? instance.waveList[i].subWaveList.Count : 1, maxSubWaveSize);
            }

            return(startY + spaceY * 2);
        }
コード例 #25
0
        public void Init()
        {
            if (init)
            {
                return;
            }

            init = true;

            if (instance != null)
            {
                Destroy(gameObject);
                return;
            }

            instance = this;

            //load your custom/saved purchasedIDList here if you are doing a persistent perk system

            List <Perk> dbList = PerkDB.Load();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailableIDList.Contains(dbList[i].ID))
                {
                    Perk perk = dbList[i].Clone();
                    perkList.Add(perk);
                }
            }

            globalTowerModifier     = new PerkTowerModifier();
            globalAbilityModifier   = new PerkAbilityModifier();
            globalFPSWeaponModifier = new PerkFPSWeaponModifier();

            emptyTowerModifier     = new PerkTowerModifier();
            emptyAbilityModifier   = new PerkAbilityModifier();
            emptyFPSWeaponModifier = new PerkFPSWeaponModifier();

            int rscCount = ResourceManager.GetResourceCount();

            for (int i = 0; i < rscCount; i++)
            {
                rscRegen.Add(0);
                rscGain.Add(0);
                rscCreepKilledGain.Add(0);
                rscWaveClearedGain.Add(0);
                rscRscTowerGain.Add(0);
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                if (purchasedIDList.Contains(perkList[i].ID))
                {
                    if (perkList[i].type == _PerkType.NewTower || perkList[i].type == _PerkType.NewAbility || perkList[i].type == _PerkType.NewFPSWeapon)
                    {
                        StartCoroutine(DelayPurchasePerk(perkList[i]));
                    }
                    else
                    {
                        _PurchasePerk(perkList[i], false);                      //dont use rsc since these are pre-purchased perk
                    }
                }
            }

            if (persistantProgress)
            {
                transform.parent = null;
                DontDestroyOnLoad(gameObject);
            }
        }