public void SetProgressBar(int level, float experience) { _expForThisLevel = ExperienceConst.ExpNeededForLevel(level); _expForNextLevel = ExperienceConst.ExpNeededForLevel(level + 1); LevelText.text = string.Format("Level {0}\tExp: {1}/{2}", level, experience, (int)(_expForNextLevel - _expForThisLevel)); ProgressImage.fillAmount = experience / _expForNextLevel; }
public void Refresh(PlayerGameData playerGameData) { float healthPercent = (float)(playerGameData.Health) / (float)(playerGameData.ShipRef.MaxHealth); float armorPercent = (float)(playerGameData.Armor) / (float)(playerGameData.ShipRef.MaxArmor); float expPercent = (float)(ExperienceConst.ExpNeededForLevel(playerGameData.Level)) / (float)(ExperienceConst.ExpNeededForLevel(playerGameData.Level + 1)); ArmorPercent.text = string.Format("{0}%", (int)(armorPercent * 100)); HealthPercent.text = string.Format("{0}%", (int)(healthPercent * 100)); ExpPercent.text = string.Format("{0}%", (int)(expPercent * 100)); Level.text = string.Format("Ship level {0}", playerGameData.Level); HealthBar.fillAmount = healthPercent; ArmorBar.fillAmount = armorPercent; ExperienceBar.fillAmount = expPercent; }
private bool IsAbleToLevelUp() { return(_playerGameData.Experience >= ExperienceConst.ExpNeededForLevel(_playerGameData.Level + 1)); }