added a dloading screen, currently only used to load sounds in automatically (you can cahnge the sounds in the assets and it will work automatically since this autoload will load it in on game start ready)
47 lines
1.1 KiB
GDScript
47 lines
1.1 KiB
GDScript
extends Node
|
|
|
|
var stamina: float = 100.0
|
|
var flashlight_power: float = 100.0
|
|
var selected_item: int = 0
|
|
var stamina_recharge: bool = true
|
|
var inventory: Array[PackedScene] = [null,null]
|
|
|
|
@onready var ui: Control = %PlayerUi
|
|
@onready var flashlight: SpotLight3D = %Flashlight
|
|
|
|
func next_item():
|
|
if selected_item + 1 > len(inventory) - 1:
|
|
selected_item = 0
|
|
else:
|
|
selected_item += 1
|
|
select_item(selected_item)
|
|
|
|
func prev_item():
|
|
if selected_item - 1 < 0:
|
|
selected_item = len(inventory) - 1
|
|
else:
|
|
selected_item -= 1
|
|
select_item(selected_item)
|
|
|
|
func select_item(index:int):
|
|
selected_item = index
|
|
ui.select_item(index)
|
|
|
|
func get_selected_item() -> PackedScene:
|
|
return inventory[selected_item]
|
|
|
|
func stamina_recharge_off():
|
|
stamina_recharge = false
|
|
|
|
func _on_stamina_reset_timeout() -> void:
|
|
stamina_recharge = true
|
|
|
|
func _ready() -> void:
|
|
get_tree().create_timer(0.1).timeout.connect(func (): select_item(0))
|
|
|
|
func _process(_delta: float) -> void:
|
|
if stamina_recharge:
|
|
stamina = move_toward(stamina, 100, .5)
|
|
if flashlight.visible:
|
|
flashlight_power = move_toward(flashlight_power, 0, .2)
|
|
|