feat: add a chest node; add logic for random scroll in the chest; add a timer t hide the scroll after;
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
extends StaticBody2D
|
||||
|
||||
var can_interact: bool = false
|
||||
var is_open: bool = false
|
||||
@export var scrolls: Array[Sprite2D]
|
||||
var scroll_number = 0
|
||||
|
||||
func _ready() -> void:
|
||||
scroll_number = randi_range(1, 4)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("Interact") and can_interact:
|
||||
if !is_open:
|
||||
$AudioStreamPlayer.play()
|
||||
$AnimatedSprite2D.play("open")
|
||||
scrolls[scroll_number].visible = true
|
||||
$Timer.start()
|
||||
is_open = true
|
||||
|
||||
|
||||
|
||||
func _on_timer_timeout(scroll_number: int) -> void:
|
||||
scrolls[scroll_number].visible = false
|
||||
Reference in New Issue
Block a user