void Update() { // If the experience matches, do nothing if (mExp == PlayerProfile.experience) { return; } if (mExp < PlayerProfile.experience) { // Experience is being gained -- gain it gradually int prevLevel = PlayerProfile.GetLevelByExp(mExp); mExp += Mathf.RoundToInt(PlayerProfile.expPerLevel * RealTime.deltaTime); if (mExp > PlayerProfile.experience) { mExp = PlayerProfile.experience; } int nextLevel = PlayerProfile.GetLevelByExp(mExp); // Level up! Play the animation, drawing the player's attention if (prevLevel != nextLevel) { if (anim != null && !anim.isPlaying) { anim.Play(); } UIStatus.Show(string.Format(Localization.Get("Level up"), nextLevel)); } UpdateExp(mExp); } else { if (anim != null && !anim.isPlaying) { anim.Play(); } mExp = PlayerProfile.experience; UpdateExp(mExp); } }