Wave of item effects and implementation
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user