void UpdateXp(Vector3 position, int xp) { int currentXp = CurrentRunData.Instance.Xp; int levelBefore = XpCalc.GetLevelAtXp(currentXp); if (xp != 0) { var color = Color.magenta; FloatingTextSpawner.Instance.Spawn(position + Vector3.up * 0.5f, $"XP: {xp}", color, 0.2f, 2.0f, TMPro.FontStyles.Normal); } CurrentRunData.Instance.Xp += xp; currentXp += xp; int levelAfter = XpCalc.GetLevelAtXp(currentXp); if (levelAfter > levelBefore) { Timing.RunCoroutine(LevelUpCo(levelAfter).CancelWith(this.gameObject)); } int xpInThisLevel = currentXp - XpCalc.GetTotalXpRequired(levelAfter); int xpRequiredInThisLevel = XpCalc.GetXpRequired(levelAfter); XpWidget.Instance.ShowXp(levelAfter, xpInThisLevel, xpRequiredInThisLevel, currentXp); UpdateDamageBonus(); }
void UpdateDamageBonus() { int level = XpCalc.GetLevelAtXp(CurrentRunData.Instance.Xp); CurrentRunData.Instance.DamageBonus = (level - 1) * GameProgressData.CurrentProgress.DamageBonusPerLevel; UpdateDamageText(); }