Wave of item effects and implementation

This commit is contained in:
2026-02-15 22:44:43 -08:00
parent 5233da4225
commit f09d6ac8e8
57 changed files with 508 additions and 86 deletions

View File

@@ -1,4 +1,5 @@
using Chickensoft.Collections;
using Godot;
using System;
using Zennysoft.Ma.Adapter;
@@ -24,6 +25,8 @@ public class ExperiencePointsComponent : IExperiencePointsComponent
public event Action PlayerLevelUp;
public event Action PlayerLevelDown;
public ExperiencePointsComponent()
{
var firstLevelExpRequirement = ExpToNextLevelCalculation(1);
@@ -73,6 +76,21 @@ public class ExperiencePointsComponent : IExperiencePointsComponent
PlayerLevelUp?.Invoke();
}
public void LevelDown()
{
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
_currentExp.OnNext(0);
if (_level.Value == 1)
return;
var newLevel = Mathf.Max(_level.Value - 1, 1);
_level.OnNext(newLevel);
var expToNextLevel = ExpToNextLevelCalculation(newLevel);
_expToNextLevel.OnNext(expToNextLevel);
PlayerLevelDown.Invoke();
}
private int ExpToNextLevelCalculation(int nextLevel)
{
return (int)(6.5 * nextLevel + 4.5 * Math.Pow(nextLevel, 2) + Math.Pow(nextLevel, 3));