コード例 #1
0
        private void SetExperienceBar()
        {
            float xp = experience.GetExperiencePoints() - baseStats.GetPointsForCurrentLevel();

            if (xp < 0)
            {
                xp = experience.GetExperiencePoints();
            }

            float xpNeeded = baseStats.GetPointsForNextLevel() - baseStats.GetPointsForCurrentLevel();

            Vector3 newScale = new Vector3(xp / xpNeeded, 1, 1);

            foreground.localScale = newScale;
        }
コード例 #2
0
        private int CalculateLevel()
        {
            if (experience == null)
            {
                return(startingLevel);
            }

            float currentXP = experience.GetExperiencePoints();
            int   maxLevel  = progression.GetMaxLevel(Stat.ExperienceToLevelUp, characterClass);

            for (int level = 1; level <= maxLevel; level++)
            {
                if (currentXP < progression.GetStat(Stat.ExperienceToLevelUp, characterClass, level))
                {
                    return(level);
                }
            }

            return(maxLevel);
        }
コード例 #3
0
        public int CalculateLevel()
        {
            if (experience == null)
            {
                return(startLevel);
            }

            float currentExperience = experience.GetExperiencePoints();
            int   currentLevel      = 1;
            int   maxLevel          = progression.GetLevels(Stat.ExperienceToLevelUp, characterClass);

            for (int i = 0; i < maxLevel; i++)
            {
                float experienceNeedToLevelUp = progression.GetStat(Stat.ExperienceToLevelUp, characterClass, currentLevel);
                if (currentExperience >= experienceNeedToLevelUp)
                {
                    currentLevel++;
                }
            }
            return(currentLevel);
        }
コード例 #4
0
 private void Update()
 {
     GetComponent <Text>().text = String.Format("{0}", experience.GetExperiencePoints());
 }
コード例 #5
0
 void Update()
 {
     experienceText.text = "XP: " + experience.GetExperiencePoints().ToString();
 }