private void VerifyLevelToExperienceCalculations()
    {
        for (int i = 1; i < 100; ++i)
        {
            int expLvl = ExperienceRank.ExperienceForLevel(i);
            int lvlExp = ExperienceRank.LevelForExperience(expLvl);

            if (lvlExp != i)
            {
                Debug.Log(string.Format("Mismatch on level:{0} with exp:{1} returned:{2}", i, expLvl, lvlExp), this);
            }
            else
            {
                Debug.Log(string.Format("Level:{0} = Exp:{1}", lvlExp, expLvl), this);
            }
        }
    }
        public static void AwardExperience(int amount, Party party)
        {
            // Grab a list of all of the rank components from our hero party
            var ranks = new List <ExperienceRank>(party.Count);

            for (int i = 0; i < party.Count; ++i)
            {
                ExperienceRank r = party[i].GetComponent <ExperienceRank>();
                if (r != null)
                {
                    ranks.Add(r);
                }
            }

            // Step 1: determine the range in actor level stats
            int min = int.MaxValue;
            int max = int.MinValue;

            for (int i = ranks.Count - 1; i >= 0; --i)
            {
                min = Mathf.Min(ranks[i].Level, min);
                max = Mathf.Max(ranks[i].Level, max);
            }

            // Step 2: weight the amount to award per actor based on their level
            var   weights       = new float[party.Count];
            float summedWeights = 0;

            for (int i = ranks.Count - 1; i >= 0; --i)
            {
                float percent = (float)(ranks[i].Level - min) / (float)(max - min);
                weights[i]     = Mathf.Lerp(minLevelBonus, maxLevelBonus, percent);
                summedWeights += weights[i];
            }

            // Step 3: hand out the weighted award
            for (int i = ranks.Count - 1; i >= 0; --i)
            {
                int subAmount = Mathf.FloorToInt((weights[i] / summedWeights) * amount);
                ranks[i].Experience += subAmount;
            }
        }
        private static void AddRank(GameObject obj, int level)
        {
            ExperienceRank rank = obj.AddComponent <ExperienceRank>();

            rank.Init(level);
        }