Exp system implementation (not yet affecting stats)
This commit is contained in:
@@ -3,6 +3,7 @@ using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
@@ -18,6 +19,8 @@ namespace GameJamDungeon
|
||||
|
||||
public void ApplyCentralImpulseToPlayer(Vector3 velocity);
|
||||
|
||||
public void LevelUp();
|
||||
|
||||
event Player.InventoryButtonPressedEventHandler InventoryButtonPressed;
|
||||
event Player.MinimapButtonHeldEventHandler MinimapButtonHeld;
|
||||
event Player.PauseButtonPressedEventHandler PauseButtonPressed;
|
||||
@@ -81,9 +84,21 @@ namespace GameJamDungeon
|
||||
private float _knockbackStrength = 0.0f;
|
||||
private Vector3 _knockbackDirection = Vector3.Zero;
|
||||
|
||||
private Dictionary<int, int> _expToNextLevel;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += OnAnimationFinished;
|
||||
_expToNextLevel = new Dictionary<int, int>
|
||||
{
|
||||
{ 2, 12 },
|
||||
{ 3, 39 },
|
||||
{ 4, 87 },
|
||||
{ 5, 162 },
|
||||
{ 6, 270 },
|
||||
{ 7, 417 },
|
||||
{ 8, 609 }
|
||||
};
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
@@ -128,6 +143,7 @@ namespace GameJamDungeon
|
||||
|
||||
PlayerData.Inventory.EquippedAccessory.Sync += EquippedAccessory_Sync;
|
||||
PlayerData.CurrentHP.Sync += CurrentHP_Sync;
|
||||
PlayerData.CurrentExp.Sync += CurrentEXP_Sync;
|
||||
|
||||
HealthTimer.WaitTime = _healthTimerWaitTime;
|
||||
}
|
||||
@@ -170,6 +186,16 @@ namespace GameJamDungeon
|
||||
SetPhysicsProcess(true);
|
||||
}
|
||||
|
||||
public void LevelUp()
|
||||
{
|
||||
var nextLevel = PlayerData.CurrentLevel.Value + 1;
|
||||
var expToNextLevel = _expToNextLevel[nextLevel];
|
||||
var newCurrentExp = Mathf.Max(PlayerData.CurrentExp.Value - PlayerData.ExpToNextLevel.Value, 0);
|
||||
PlayerData.SetCurrentLevel(nextLevel);
|
||||
PlayerData.SetExpToNextLevel(expToNextLevel);
|
||||
PlayerData.SetCurrentExp(newCurrentExp);
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed(GameInputs.Inventory))
|
||||
@@ -316,5 +342,11 @@ namespace GameJamDungeon
|
||||
if (newHealth <= 0)
|
||||
Kill();
|
||||
}
|
||||
|
||||
private void CurrentEXP_Sync(int newExp)
|
||||
{
|
||||
if (PlayerData.CurrentExp.Value >= PlayerData.ExpToNextLevel.Value)
|
||||
LevelUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ MaximumHP = 100
|
||||
CurrentVT = 90
|
||||
MaximumVT = 90
|
||||
CurrentExp = 0
|
||||
ExpToNextLevel = 100
|
||||
ExpToNextLevel = 10
|
||||
CurrentLevel = 1
|
||||
CurrentAttack = 50
|
||||
CurrentDefense = 12
|
||||
|
||||
@@ -63,8 +63,7 @@ namespace GameJamDungeon
|
||||
}
|
||||
public void SetCurrentExp(int newValue)
|
||||
{
|
||||
var clampedValue = Mathf.Clamp(newValue, 0, ExpToNextLevel.Value);
|
||||
_currentExp.OnNext(clampedValue);
|
||||
_currentExp.OnNext(newValue);
|
||||
}
|
||||
public void SetCurrentLevel(int newValue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user