Ejemplo n.º 1
0
        private float DrawAddPerkGained(float startX, float startY, LevelProgressionStats stats)
        {
            spaceX -= 65;

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 30, height), "Add Perk Gained At lvl:", headerStyle);

            cont = new GUIContent(" - Level:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            perkGainLvl = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, widthS, height), perkGainLvl);
            perkGainLvl = Mathf.Clamp(perkGainLvl, 1, stats.levelCap);


            int perkIdx = perkGainID >= 0 ? TDSEditor.GetPerkIndex(perkGainID) : 0;

            cont = new GUIContent(" - Perk:", "Perk to be gained");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

            perkIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthS + 65, height), perkIdx, perkLabel);
            if (perkIdx > 0)
            {
                perkGainID = perkDB.perkList[perkIdx - 1].ID;
            }
            else
            {
                perkGainID = -1;
            }

            spaceX += 65;


            if (perkGainID >= 0 && GUI.Button(new Rect(startX + 15, startY += spaceY + 2, spaceX + widthS - 15, height + 2), "Add Entry"))
            {
                PerkUnlockingAtLevel item = null;
                int index = 0;

                for (int i = 0; i < stats.perkUnlockingAtLevelList.Count; i++)
                {
                    if (stats.perkUnlockingAtLevelList[i].level == perkGainLvl)
                    {
                        item = stats.perkUnlockingAtLevelList[i];
                        break;
                    }

                    if (stats.perkUnlockingAtLevelList[i].level > perkGainLvl)
                    {
                        index += 1;
                    }
                }

                if (item != null)
                {
                    if (!item.perkIDList.Contains(perkGainID))
                    {
                        item.perkIDList.Add(perkGainID);
                    }
                }
                else
                {
                    item = new PerkUnlockingAtLevel(perkGainLvl);
                    item.perkIDList.Add(perkGainID);

                    stats.perkUnlockingAtLevelList.Insert(index, item);
                }

                perkGainID = -1;

                stats.RearrangePerkUnlockingList();
            }

            return(startY);
        }
Ejemplo n.º 2
0
        private float DrawLevelList(float startX, float startY, LevelProgressionStats stats)
        {
            startX += 60;

            EditorGUI.LabelField(new Rect(startX, startY, width, height), "Exp to level:", headerStyle);
            EditorGUI.LabelField(new Rect(startX + width - 15, startY, width, height), "Perk Gained:", headerStyle);

            startX += 5;

            //string textRS=stats.sumRecursively ? "Σ(" : "";
            //string textRE=stats.sumRecursively ? ")" : "";

            //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width+10, height), "exp = "+textRS+"("+stats.expTHM+"*lvl)+"+stats.expTHC+textRE, headerStyle);

            for (int i = 0; i < stats.expThresholdList.Count; i++)
            {
                float cachedX = startX;

                cont = new GUIContent(" - lvl " + (i + 1) + ":", "");
                EditorGUI.LabelField(new Rect(startX - 60, startY += spaceY, width, height), cont);

                if (i == 0)
                {
                    EditorGUI.LabelField(new Rect(startX, startY, widthS + spaceX - 85, height), "-");
                }
                else
                {
                    stats.expThresholdList[i] = EditorGUI.DelayedIntField(new Rect(startX, startY, widthS + spaceX - 85, height), stats.expThresholdList[i]);
                }

                int index = -1;
                for (int n = 0; n < stats.perkUnlockingAtLevelList.Count; n++)
                {
                    if (stats.perkUnlockingAtLevelList[n].level == i + 1)
                    {
                        index = n;      break;
                    }
                }

                if (index >= 0)
                {
                    float cachedX2 = startX += width - 20;

                    PerkUnlockingAtLevel item = stats.perkUnlockingAtLevelList[index];
                    for (int n = 0; n < item.perkIDList.Count; n++)
                    {
                        int perkIdx = TDSEditor.GetPerkIndex(item.perkIDList[n]);

                        if (perkIdx <= 0)
                        {
                            item.perkIDList.RemoveAt(n); n -= 1;
                        }
                        else
                        {
                            cont = new GUIContent(perkDB.perkList[perkIdx - 1].name, perkDB.perkList[perkIdx - 1].desp);
                            EditorGUI.LabelField(new Rect(startX, startY, width * .75f, height), cont);
                            if (GUI.Button(new Rect(startX - height - 5, startY, height, height), "-"))
                            {
                                item.perkIDList.RemoveAt(n); n -= 1;
                            }
                        }

                        startX += width * .75f;
                    }

                    startX = cachedX2;

                    if (item.perkIDList.Count == 0)
                    {
                        stats.perkUnlockingAtLevelList.RemoveAt(index);
                        stats.RearrangePerkUnlockingList();
                    }
                }

                startX = cachedX;
            }

            return(startY + spaceY + 5);
        }
Ejemplo n.º 3
0
        private float DrawPerkGeneralSetting(float startX, float startY, Perk perk)
        {
            widthS = 50;

            string text = "General Setting " + (!foldGeneral ? "(show)" : "(hide)");

            foldGeneral = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldGeneral, text, foldoutStyle);
            if (foldGeneral)
            {
                startX += 15;

                cont = new GUIContent("Repeatable:", "Check if the ability can be repeatably purchase. For perk that offer straight, one off bonus such as life and resource");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                perk.repeatable = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), perk.repeatable);

                cont = new GUIContent("Limit:", "The amount of time the perk can be repeatably purchase.\nany value <=0 means it's unlimited");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (perk.repeatable)
                {
                    perk.limit = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.limit);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }


                startY += 8;

                cont = new GUIContent("Prerequisite Perk:", "Perks that needs to be purchased before this perk is unlocked and become available");
                EditorGUI.LabelField(new Rect(startX, startY + spaceY, width, height), cont);

                for (int i = 0; i < perk.prereq.Count + 1; i++)
                {
                    int index = (i < perk.prereq.Count) ? TDSEditor.GetPerkIndex(perk.prereq[i]) : 0;
                    index = EditorGUI.Popup(new Rect(startX + spaceX, startY += spaceY, width, height), index, perkLabel);
                    if (index > 0)
                    {
                        int perkID = perkDB.perkList[index - 1].ID;
                        if (perkID != perk.ID && !perk.prereq.Contains(perkID))
                        {
                            if (i < perk.prereq.Count)
                            {
                                perk.prereq[i] = perkID;
                            }
                            else
                            {
                                perk.prereq.Add(perkID);
                            }
                        }
                    }
                    else if (i < perk.prereq.Count)
                    {
                        perk.prereq.RemoveAt(i); i -= 1;
                    }
                }

                startY += 5;

                cont = new GUIContent("Min level required:", "Minimum level to reach before the perk becoming available. (level are specified in GameControl of each scene)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                perk.minLevel = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.minLevel);

                cont = new GUIContent("Min PerkPoint req:", "Minimum perk point to have before the perk becoming available");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                perk.minPerkPoint = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.minPerkPoint);

                startY += 5;

                cont = new GUIContent("Cost:", "The perk currency required to purchase the perk");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                perk.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), perk.cost);
            }

            return(startY + spaceY);
        }