Changed level up to exponential growth
This commit is contained in:
parent
81610a3cb0
commit
8fd7d0131c
4 changed files with 24 additions and 14 deletions
|
|
@ -77,9 +77,7 @@ func generate_random_job() -> JobData:
|
|||
new_job.job_difficulty = random_job.job_difficulty
|
||||
new_job.job_amount = roundf(amount)
|
||||
|
||||
#print('Random amount: %.2f' % amount)
|
||||
#print('Job amount: %.2f' % new_job.job_amount)
|
||||
print('Generated new job: %s (%d € | %d xp | %d pcs)' % [new_job.job_name, new_job.job_reward, new_job.job_experience, new_job.job_amount])
|
||||
#print('Generated new job: %s (%d € | %d xp | %d pcs)' % [new_job.job_name, new_job.job_reward, new_job.job_experience, new_job.job_amount])
|
||||
return new_job
|
||||
|
||||
func _on_job_accepted_pressed(accepted_job) -> void:
|
||||
|
|
|
|||
|
|
@ -3,14 +3,13 @@ extends Node
|
|||
var xp: float = 0:
|
||||
set(value):
|
||||
xp = value
|
||||
xp_changed.emit(xp)
|
||||
|
||||
var money: float = 500:
|
||||
set(value):
|
||||
money = value
|
||||
money_changed.emit(money)
|
||||
|
||||
var level: int = 0:
|
||||
var level: int = 1:
|
||||
set(value):
|
||||
level = value
|
||||
level_changed.emit(level)
|
||||
|
|
@ -41,14 +40,24 @@ func _ready() -> void:
|
|||
func _on_give_experience(amount: float) -> void:
|
||||
print('Gave: %.0f xp' % amount)
|
||||
xp += amount
|
||||
if xp >= 100:
|
||||
while xp >= 100:
|
||||
level += 1
|
||||
xp -= 100
|
||||
|
||||
while xp >= xp_required_for_level(level):
|
||||
xp -= xp_required_for_level(level)
|
||||
level += 1
|
||||
xp_changed.emit(xp)
|
||||
|
||||
func _on_give_money(amount: float) -> void:
|
||||
money += amount
|
||||
|
||||
func xp_required_for_level(player_level: int) -> float:
|
||||
if player_level == 1:
|
||||
return 100.0
|
||||
|
||||
var base_xp = 100 * (player_level - 1)
|
||||
var exponent_xp = pow(player_level - 1, 1.8) * 25
|
||||
|
||||
return float(base_xp + exponent_xp)
|
||||
|
||||
func try_purchase(amount) -> bool:
|
||||
if amount <= money:
|
||||
money -= amount
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ const PRINTER = preload("uid://33ctlyrpibs3")
|
|||
func _ready() -> void:
|
||||
check_debug()
|
||||
|
||||
_on_xp_changed(PlayerData.xp)
|
||||
#_on_xp_changed(PlayerData.xp)
|
||||
%Experience.value = 0
|
||||
_on_level_changed(PlayerData.level)
|
||||
_on_money_changed(PlayerData.money)
|
||||
|
||||
|
|
@ -25,9 +26,13 @@ func _ready() -> void:
|
|||
|
||||
# --- Experience, Level and Money update ---
|
||||
func _on_xp_changed(xp) -> void:
|
||||
%Experience.value = xp
|
||||
var target_xp = PlayerData.xp_required_for_level(PlayerData.level)
|
||||
var required_xp_to_value = (float(PlayerData.xp) / target_xp) * 100
|
||||
%Experience.value = required_xp_to_value
|
||||
|
||||
func _on_level_changed(level) -> void:
|
||||
%Level.text = 'Level: %d' % level
|
||||
|
||||
func _on_money_changed(money) -> void:
|
||||
%Money.text = 'Money: %.2f €' % money
|
||||
|
||||
|
|
|
|||
|
|
@ -288,5 +288,3 @@ autostart = true
|
|||
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons/MenuTabButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher" method="_on_menu_tab_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/PrintersButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_printers_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/FilamentsButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_filaments_button_pressed"]
|
||||
[connection signal="printer_purchase_requested" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Printers" to="." method="_on_printers_printer_purchase_requested"]
|
||||
[connection signal="timeout" from="JobSpawner" to="." method="_on_job_spawner_timeout"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue