42 lines
1.3 KiB
GDScript
42 lines
1.3 KiB
GDScript
extends Control
|
|
|
|
@onready var level_label: Label = %LevelLabel
|
|
@onready var health_bar: TextureProgressBar = %HealthBar
|
|
@onready var xp_bar: TextureProgressBar = %XPBar
|
|
@onready var health_label: Label = %HealthLabel
|
|
@onready var inventory: Control = $Inventory
|
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
|
@onready var interact_label: Label = %InteractLabel
|
|
|
|
@export var player: Player
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("open_inventory"):
|
|
toggle_inventory_menu()
|
|
|
|
func update_stats_display() -> void:
|
|
level_label.text = str(player.stats.level)
|
|
xp_bar.max_value = player.stats.perc_level_up_boundary()
|
|
xp_bar.value = player.stats.xp
|
|
inventory.update_stats()
|
|
|
|
func update_health() -> void:
|
|
health_bar.max_value = player.health_component.max_health
|
|
health_bar.value = player.health_component.current_health
|
|
health_label.text = player.health_component.get_health_string()
|
|
|
|
func toggle_inventory_menu() -> void:
|
|
get_tree().paused = !get_tree().paused
|
|
inventory.visible = !inventory.visible
|
|
inventory.update_gear_stats()
|
|
if inventory.visible:
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
else:
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
|
|
func update_interact_text(text: String) -> void:
|
|
animation_player.stop()
|
|
animation_player.play("fade_out_text")
|
|
interact_label.text = text
|
|
|