void LevelUp() { if (CurrentXP >= XpToLevel) { print(CurrentXP); levelUpParticleEffect = Instantiate(levelUpEffect, transform); levelUpParticleEffect.transform.position = gameObject.transform.TransformPoint(Vector3.up * 1); Invoke("CancelParticleEffect", destroyEffectTimer); CurrentXP -= XpToLevel; Level += 1; XpToLevel += Mathf.Round(XpToLevel * multiplierForNextLevel) / Level; playerStats.LevelUpHealthPoints(); playerStats.LevelUpEnergyPoints(); playerStats.LevelUpStrengthPoints(); playerStats.LevelUpMentalAgility(); playerStats.LevelUpHitPoints(); playerStats.LevelUpArmourPoints(); playerStats.CurrentLevel(); playerStats.CurrentXp(); playerStats.MaxXp(); playerStats.SaveStatsToPlayerPrefs(); UpdateXpBar(); } xpText.text = (CurrentXP.ToString() + "/" + XpToLevel.ToString()); levelText.text = (Level.ToString()); }
void UpdateXpBar() { if (xpBar) { xpText.text = (CurrentXP.ToString() + "/" + XpToLevel.ToString()); xpBar.fillAmount = xpAsPercentage; LevelUp(); } }