game: add levelups
This commit is contained in:
@@ -87,10 +87,35 @@ func get_taunted():
|
||||
func toggle_god_mode(value: bool):
|
||||
god_mode = value
|
||||
|
||||
func add_xp(amount: float) -> void:
|
||||
player_stats.current_xp += amount
|
||||
_check_level_up()
|
||||
|
||||
func _check_level_up() -> void:
|
||||
var required_for_level = 25.0
|
||||
if player_stats.current_xp >= required_for_level:
|
||||
player_stats.current_level += 1
|
||||
player_stats.current_xp -= required_for_level
|
||||
_trigger_level_up()
|
||||
|
||||
func _trigger_level_up() -> void:
|
||||
var choice_count = 3
|
||||
var choices: Array[LevelUpChoice] = []
|
||||
print_debug("level up")
|
||||
main_ui.level_up_ui.clear()
|
||||
for i in range(choice_count):
|
||||
# TODO: implement fortune
|
||||
var mod = GlobalConst.draw_random_mod(1.0)
|
||||
var l_choice = preload("res://scenes/managers/ui/level_up_choice.tscn").instantiate()
|
||||
l_choice.mod = mod
|
||||
l_choice.player = self
|
||||
main_ui.level_up_ui.add_choice(l_choice)
|
||||
Engine.time_scale = 0.0
|
||||
main_ui.level_up_ui.visible = true
|
||||
|
||||
func _on_pickup_area_area_entered(area: Area2D) -> void:
|
||||
var body: XPOrb = area.get_parent()
|
||||
if body.is_in_group(GlobalConst.GROUP_XP_ORB):
|
||||
player_stats.current_xp += body.value
|
||||
add_xp(body.value)
|
||||
GlobalConst.sig_debug_stats_set.emit("player_xp", "%s" % player_stats.current_xp)
|
||||
body.queue_free()
|
||||
|
Reference in New Issue
Block a user