private void UpdateSkillProgressBar(SkillStat skill) { var thisLevelExp = GameMath.LevelToExperience(skill.Level); var nextLevelExp = GameMath.LevelToExperience(skill.Level + 1); var now = skill.Experience - thisLevelExp; var next = nextLevelExp - thisLevelExp; pbSkill.progress = (float)now / (float)next; var expPerHour = skill.GetExperiencePerHour(); if (lblExpPerHour && ExpPerHourVisible) { SetText(lblExpPerHour, Utility.FormatValue(expPerHour) + " xp / h"); } }
private void UpdateSkillProgressBar(SkillStat skill) { var nextLevelExp = GameMath.ExperienceForLevel(skill.Level + 1); pbSkill.Progress = skill.Experience > 0 && nextLevelExp > 0 ? ((float)(skill.Experience / nextLevelExp)) : 0; var expPerHour = skill.GetExperiencePerHour(); var expLeft = nextLevelExp - skill.Experience; if (lblExpPerHour) { SetText(lblExpPerHour, ""); switch (ExpProgressHelpState) { case ExpProgressHelpStates.ExpLeft: SetText(lblExpPerHour, FormatValue((long)expLeft) + " xp"); break; case ExpProgressHelpStates.TimeLeft: { if (expPerHour <= 0 || expLeft <= 0) { break; } var hours = (double)(expLeft / expPerHour); if (hours < 1) { var minutes = hours * 60d; if (minutes > 1) { SetText(lblExpPerHour, (int)minutes + "m"); } else { var seconds = minutes * 60d; SetText(lblExpPerHour, (int)seconds + "s"); } } else { var minutes = (int)(hours - (long)hours) * 60d; if (minutes > 1) { SetText(lblExpPerHour, (int)hours + "h " + minutes + "m"); } else { SetText(lblExpPerHour, (int)hours + "h"); } } } break; case ExpProgressHelpStates.ExpPerHour: if (expPerHour <= 0) { break; } SetText(lblExpPerHour, Utility.FormatValue(expPerHour) + " xp / h"); break; } } }