public PerkUnlockingAtLevel Clone()
        {
            PerkUnlockingAtLevel newItem = new PerkUnlockingAtLevel(level);

            newItem.perkIDList = new List <int>(perkIDList);
            return(newItem);
        }
Example #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);
        }
Example #3
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);
        }