Exp system implementation (not yet affecting stats)

This commit is contained in:
2024-12-21 16:41:16 -08:00
parent 5d9520bc59
commit 5d2b9ca247
10 changed files with 50 additions and 8 deletions

View File

@@ -23,6 +23,9 @@ namespace GameJamDungeon
[Export]
public int MaxDefense { get; set; }
[Export]
public int ExpFromDefeat { get; set; }
[Export]
public double Luck { get; set; } = 0.05f;

View File

@@ -12,6 +12,7 @@ CurrentAttack = 20
CurrentDefense = 11
MaxAttack = 20
MaxDefense = 11
ExpFromDefeat = 10
Luck = 0.05
TelluricResistance = 0.0
AeolicResistance = 0.0

View File

@@ -12,6 +12,7 @@ CurrentAttack = 20
CurrentDefense = 10
MaxAttack = 20
MaxDefense = 10
ExpFromDefeat = 8
Luck = 0.05
TelluricResistance = 0.0
AeolicResistance = 0.0

View File

@@ -173,6 +173,12 @@ public partial class Game : Node3D, IGame
}
private void OnEnemyDefeated(Vector3 vector, EnemyStatResource resource)
{
GameRepo.PlayerData.SetCurrentExp(GameRepo.PlayerData.CurrentExp.Value + resource.ExpFromDefeat);
DropRestorative(vector);
}
private void DropRestorative(Vector3 vector)
{
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
var restorative = restorativeScene.Instantiate<Restorative>();

View File

@@ -244,7 +244,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
private void PopulatePlayerInfo()
{
FloorLabel.Text = $"Level {GameRepo.CurrentFloor:D2}";
FloorLabel.Text = $"Floor {GameRepo.CurrentFloor:D2}";
if (ItemSlots.Any())
{

View File

@@ -158,8 +158,8 @@ tracks/1/keys = {
[sub_resource type="AnimationLibrary" id="AnimationLibrary_eivo2"]
_data = {
"RESET": SubResource("Animation_dg155"),
"status_up": SubResource("Animation_7by7u")
&"RESET": SubResource("Animation_dg155"),
&"status_up": SubResource("Animation_7by7u")
}
[node name="InventoryMenu" type="Control"]
@@ -552,5 +552,5 @@ layout_mode = 2
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
"": SubResource("AnimationLibrary_eivo2")
&"": SubResource("AnimationLibrary_eivo2")
}

View File

@@ -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();
}
}
}

View File

@@ -20,7 +20,7 @@ MaximumHP = 100
CurrentVT = 90
MaximumVT = 90
CurrentExp = 0
ExpToNextLevel = 100
ExpToNextLevel = 10
CurrentLevel = 1
CurrentAttack = 50
CurrentDefense = 12

View File

@@ -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)
{

View File

@@ -20,7 +20,7 @@ void fragment() {
uv.y += progress / UV.y;
else
uv.y -= progress / UV.y;
// Created jagged edges for each pixel on the x-axis
uv.y -= progress * meltiness * psuedo_rand(UV.x - mod(UV.x, TEXTURE_PIXEL_SIZE.x));