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] [Export]
public int MaxDefense { get; set; } public int MaxDefense { get; set; }
[Export]
public int ExpFromDefeat { get; set; }
[Export] [Export]
public double Luck { get; set; } = 0.05f; public double Luck { get; set; } = 0.05f;

View File

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

View File

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

View File

@@ -173,6 +173,12 @@ public partial class Game : Node3D, IGame
} }
private void OnEnemyDefeated(Vector3 vector, EnemyStatResource resource) 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 restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
var restorative = restorativeScene.Instantiate<Restorative>(); var restorative = restorativeScene.Instantiate<Restorative>();

View File

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

View File

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

View File

@@ -3,6 +3,7 @@ using Chickensoft.GodotNodeInterfaces;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Chickensoft.SaveFileBuilder; using Chickensoft.SaveFileBuilder;
using Godot; using Godot;
using Godot.Collections;
namespace GameJamDungeon namespace GameJamDungeon
{ {
@@ -18,6 +19,8 @@ namespace GameJamDungeon
public void ApplyCentralImpulseToPlayer(Vector3 velocity); public void ApplyCentralImpulseToPlayer(Vector3 velocity);
public void LevelUp();
event Player.InventoryButtonPressedEventHandler InventoryButtonPressed; event Player.InventoryButtonPressedEventHandler InventoryButtonPressed;
event Player.MinimapButtonHeldEventHandler MinimapButtonHeld; event Player.MinimapButtonHeldEventHandler MinimapButtonHeld;
event Player.PauseButtonPressedEventHandler PauseButtonPressed; event Player.PauseButtonPressedEventHandler PauseButtonPressed;
@@ -81,9 +84,21 @@ namespace GameJamDungeon
private float _knockbackStrength = 0.0f; private float _knockbackStrength = 0.0f;
private Vector3 _knockbackDirection = Vector3.Zero; private Vector3 _knockbackDirection = Vector3.Zero;
private Dictionary<int, int> _expToNextLevel;
public void Initialize() public void Initialize()
{ {
AnimationPlayer.AnimationFinished += OnAnimationFinished; 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() public void Setup()
@@ -128,6 +143,7 @@ namespace GameJamDungeon
PlayerData.Inventory.EquippedAccessory.Sync += EquippedAccessory_Sync; PlayerData.Inventory.EquippedAccessory.Sync += EquippedAccessory_Sync;
PlayerData.CurrentHP.Sync += CurrentHP_Sync; PlayerData.CurrentHP.Sync += CurrentHP_Sync;
PlayerData.CurrentExp.Sync += CurrentEXP_Sync;
HealthTimer.WaitTime = _healthTimerWaitTime; HealthTimer.WaitTime = _healthTimerWaitTime;
} }
@@ -170,6 +186,16 @@ namespace GameJamDungeon
SetPhysicsProcess(true); 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) public override void _UnhandledInput(InputEvent @event)
{ {
if (@event.IsActionPressed(GameInputs.Inventory)) if (@event.IsActionPressed(GameInputs.Inventory))
@@ -316,5 +342,11 @@ namespace GameJamDungeon
if (newHealth <= 0) if (newHealth <= 0)
Kill(); 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 CurrentVT = 90
MaximumVT = 90 MaximumVT = 90
CurrentExp = 0 CurrentExp = 0
ExpToNextLevel = 100 ExpToNextLevel = 10
CurrentLevel = 1 CurrentLevel = 1
CurrentAttack = 50 CurrentAttack = 50
CurrentDefense = 12 CurrentDefense = 12

View File

@@ -63,8 +63,7 @@ namespace GameJamDungeon
} }
public void SetCurrentExp(int newValue) public void SetCurrentExp(int newValue)
{ {
var clampedValue = Mathf.Clamp(newValue, 0, ExpToNextLevel.Value); _currentExp.OnNext(newValue);
_currentExp.OnNext(clampedValue);
} }
public void SetCurrentLevel(int newValue) public void SetCurrentLevel(int newValue)
{ {

View File

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