2022-11-27 19:55:11 -07:00
|
|
|
extends SpotLight
|
|
|
|
|
2022-12-30 15:17:26 -07:00
|
|
|
var timer = null
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
randomize()
|
|
|
|
timer = Timer.new()
|
|
|
|
timer.wait_time = rand_range(0.1, 0.2)
|
|
|
|
timer.connect("timeout", self, "on_timer_timeout")
|
|
|
|
add_child(timer)
|
|
|
|
timer.start()
|
|
|
|
|
|
|
|
func on_timer_timeout():
|
|
|
|
timer.wait_time = rand_range(0.05, 0.15)
|
|
|
|
self.light_energy = rand_range(1.25, 1.5)
|
|
|
|
|
2022-11-27 19:55:11 -07:00
|
|
|
func _input(_event):
|
|
|
|
if Input.is_action_just_pressed("toggle_flashlight"):
|
|
|
|
toggle()
|
|
|
|
|
|
|
|
func toggle():
|
|
|
|
visible = not visible
|
|
|
|
$AudioStreamPlayer.pitch_scale = rand_range(0.5, 1.2)
|
|
|
|
$AudioStreamPlayer.play()
|
2023-01-02 23:48:46 -07:00
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
if visible:
|
2023-01-03 00:11:47 -07:00
|
|
|
Dialogic.set_variable("flashlight_seconds", float(Dialogic.get_variable("flashlight_seconds"))+delta)
|