public void VerifyExpList()
 {
     if (expThresholdList.Count == levelCap)
     {
         return;
     }
     expThresholdList = PlayerProgression.GenerateExpTH(sumRecursively, expTHM, expTHC, levelCap);
 }
示例#2
0
        private float DrawExpListGenerator(float startX, float startY, LevelProgressionStats stats)
        {
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Generate Exp List:", headerStyle);

            cont = new GUIContent(" - Sum Recursively:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stats.sumRecursively = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), stats.sumRecursively);

            cont = new GUIContent(" - Increment Rate:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stats.expTHM = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, widthS, height), stats.expTHM);

            cont = new GUIContent(" - Starting Value:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            stats.expTHC = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, widthS, height), stats.expTHC);

            if (GUI.Button(new Rect(startX + 15, startY += spaceY + 2, widthS - 5, height + 2), "Reset"))
            {
                stats.sumRecursively = stats.sumRecursively_Cached;
                stats.expTHM         = stats.expTHM_Cached;
                stats.expTHC         = stats.expTHC_Cached;
            }

            bool regenNeeded = stats.sumRecursively != stats.sumRecursively_Cached;

            regenNeeded = regenNeeded || stats.expTHM != stats.expTHM_Cached;
            regenNeeded = regenNeeded || stats.expTHC != stats.expTHC_Cached;
            regenNeeded = regenNeeded || stats.expThresholdList.Count != stats.levelCap;
            if (regenNeeded)
            {
                GUI.color = new Color(0, 1f, 1f, 1f);
            }

            if (GUI.Button(new Rect(startX + 10 + widthS, startY, spaceX + 5 - 15, height + 2), "Generate Exp"))
            {
                stats.expThresholdList = PlayerProgression.GenerateExpTH(stats.sumRecursively, stats.expTHM, stats.expTHC, stats.levelCap);

                stats.sumRecursively_Cached = stats.sumRecursively;
                stats.expTHM_Cached         = stats.expTHM;
                stats.expTHC_Cached         = stats.expTHC;
            }

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

            cont = new GUIContent("exp = " + textRS + "(" + stats.expTHM + "*lvl)+" + stats.expTHC + textRE, "The formula used to generate current exp list");
            //cont=new GUIContent(" - Starting Value:", "");
            EditorGUI.LabelField(new Rect(startX + spaceX + width - 80, startY, width * 2, height), cont);

            GUI.color = Color.white;

            return(startY);
        }
示例#3
0
        void OnSelectionChange()
        {
            if (window == null)
            {
                return;
            }

            if (Selection.activeGameObject != null)
            {
                selectedComponent = Selection.activeGameObject.GetComponent <PlayerProgression>();
            }
            else
            {
                selectedComponent = null;
            }

            Repaint();
        }
示例#4
0
        private float DrawExpListGenerator(float startX, float startY, LevelProgressionStats stats)
        {
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Generate Exp List:", headerStyle);

            cont = new GUIContent(" - Sum Recursively:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            sumRecursively = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), sumRecursively);

            cont = new GUIContent(" - Increment Rate:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            expTHM = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), expTHM);

            cont = new GUIContent(" - Starting Value:", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            expTHC = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), expTHC);

            if (stats.expThresholdList.Count != stats.levelCap)
            {
                GUI.color = new Color(0, 1f, 1f, 1f);
            }

            if (GUI.Button(new Rect(startX + 15, startY += spaceY + 2, spaceX + widthS - 15, height + 2), "Generate Exp"))
            {
                stats.expThresholdList = PlayerProgression.GenerateExpTH(sumRecursively, expTHM, expTHC, stats.levelCap);

                stats.sumRecursively = sumRecursively;
                stats.expTHM         = expTHM;
                stats.expTHC         = expTHC;
            }

            //public float expTHM=1.5f;
            //public int expTHC=10;

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

            cont = new GUIContent("exp = " + textRS + "(" + stats.expTHM + "*lvl)+" + stats.expTHC + textRE, "The formula used to generate current exp list");
            //cont=new GUIContent(" - Starting Value:", "");
            EditorGUI.LabelField(new Rect(startX + spaceX + width - 80, startY, width * 2, height), cont);

            GUI.color = Color.white;

            return(startY);
        }
示例#5
0
        public static void CopyStats(PlayerProgression progress)                //only used in runtime to load db data to runtime PlayerProgression
        {
            Init();

            //~ progress.levelCap=db.levelCap;

            //~ progress.perkCurrencyGain=db.perkCurrencyGain;

            //~ progress.hitPointGain=db.hitPointGain;
            //~ progress.hitPointRegenGain=db.hitPointRegenGain;
            //~ progress.energyGain=db.energyGain;
            //~ progress.energyRegenGain=db.energyRegenGain;
            //~ progress.speedMulGain=db.speedMulGain;
            //~ progress.dmgMulGain=db.dmgMulGain;
            //~ progress.critChanceMulGain=db.critChanceMulGain;
            //~ progress.critMultiplierMulGain=db.critMultiplierMulGain;

            //~ progress.expThresholdList=new List<int>( db.expThresholdList );
            //~ progress.perkUnlockingAtLevelList=new List<PerkUnlockingAtLevel>( db.perkUnlockingAtLevelList );

            progress.stats = db.stats.Clone();
        }
 void Awake()
 {
     instance = (PlayerProgression)target;
     LoadDB();
 }
示例#7
0
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

            if (window == null)
            {
                Init();
            }

            if (Selection.activeGameObject != null)
            {
                selectedComponent = Selection.activeGameObject.GetComponent <PlayerProgression>();
            }
            else
            {
                selectedComponent = null;
            }

            Undo.RecordObject(this, "window");
            Undo.RecordObject(progressDB, "ProgressDB");
            if (selectedComponent != null)
            {
                Undo.RecordObject(selectedComponent, "PlayerProgression");
            }


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

            if (!ProgressionStats_DB.UpdatedToPost_2018_3())
            {
                GUI.color = new Color(0, 1f, 1f, 1f);
                if (GUI.Button(new Rect(Math.Max(260, window.position.width - 230), 5, 100, 25), "Copy Old DB"))
                {
                    ProgressionStats_DB.CopyFromOldDB();
                }
                GUI.color = Color.white;
            }


            LevelProgressionStats stats = selectedComponent != null ? selectedComponent.stats : progressDB.stats;



            float startX = 5; float startY = 5; spaceX += 25;

            if (selectedComponent != null)
            {
                EditorGUI.HelpBox(new Rect(startX, startY, 250, 25), "Editing selected component", MessageType.Info);
            }
            else
            {
                EditorGUI.HelpBox(new Rect(startX, startY, 250, 25), "Editing Global Setting (DB)", MessageType.Info);
            }
            startY += 35;

            cont = new GUIContent("Level Cap:", "");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont, headerStyle);
            stats.levelCap = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, widthS, height), stats.levelCap);

            if (stats.levelCap != stats.expThresholdList.Count)
            {
                EditorGUI.HelpBox(new Rect(startX + spaceX + widthS + 20, startY, 250, 40), "Experience list doesn't match level cap.\nPlease Regenerate Experience List", MessageType.Warning);
                //EditorGUI.HelpBox(new Rect(startX, startY+spaceY, 250, 40), "Experience list doesn't match level cap.\nPlease Regenerate Experience List", MessageType.Warning);
                //startY+=2*spaceY;
            }

            startY = DrawPerLevelGain(startX, startY + spaceY + 15, stats);

            spaceX -= 25;

            DrawAddPerkGained(startX + spaceX + width - 80, startY + spaceY, stats);

            startY = DrawExpListGenerator(startX, startY + spaceY, stats);


            startY += 2 * spaceY;

            visibleRectList = new Rect(startX, startY, window.position.width - 10, window.position.height - startY - 5);
            contentRectList = new Rect(startX, startY, window.position.width - 25, contentLength);

            GUI.color = new Color(.8f, .8f, .8f, .8f);
            GUI.Box(visibleRectList, "");
            GUI.color = Color.white;

            scrollPosList = GUI.BeginScrollView(visibleRectList, scrollPosList, contentRectList);

            float cachedY = startY;

            startY        = DrawLevelList(startX, startY + 5, stats);
            contentLength = startY - cachedY;

            GUI.EndScrollView();

            if (selectedComponent != null)
            {
                PrefabUtility.RecordPrefabInstancePropertyModifications(selectedComponent);
            }

            if (GUI.changed)
            {
                if (selectedComponent != null)
                {
                    EditorUtility.SetDirty(selectedComponent);
                }
                SetDirtyTDS();
            }

            return(true);
        }
 //only used in runtime to load db data to runtime PlayerProgression
 public static void CopyStats(PlayerProgression progress)
 {
     Init();
     instance.stats = instance.stats.Clone();
 }