diver-down/Scenes/spotlight_on_timer.tscn
2022-12-11 14:58:02 -03:00

76 lines
2.1 KiB
Text

[gd_scene load_steps=5 format=2]
[ext_resource path="res://Resources/MoreTextures/lights.png" type="Texture" id=1]
[sub_resource type="GDScript" id=1]
resource_name = "spotlight_on_timer"
script/source = "extends Node2D
export (float) var wait_time = 1.0
export (float) var delay = 0.0
func _ready():
$timer.wait_time=self.wait_time+delay
$timer.start()
$area_2d/collision_polygon_2d.polygon=self.polygon
set_process(true)
func _process(_delta) -> void:
$progress_bar.value=$progress_bar.max_value*($timer.wait_time-$timer.time_left)/$timer.wait_time
for body in $area_2d.get_overlapping_bodies():
if body.is_in_group('Player'):
global.reload_stage()
func _on_timer_timeout():
if self.self_modulate.a==1:
self.self_modulate.a=0
$sprite.frame=1
$area_2d/collision_polygon_2d.disabled=true
else:
self.self_modulate.a=1
$sprite.frame=0
$area_2d/collision_polygon_2d.disabled=false
"
[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 1, 1, 1, 1 )
anti_aliasing_size = 1.0
[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 1, 1, 1, 1 )
draw_center = false
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color( 0.628906, 0.628906, 0.628906, 1 )
anti_aliasing_size = 1.0
[node name="spotlight_on_timer" type="Polygon2D"]
color = Color( 0.807843, 0.678431, 0.45098, 0.247059 )
antialiased = true
polygon = PoolVector2Array( -24, 72, 24, 72, 0.0959015, 0.603569 )
vertex_colors = PoolColorArray( 0, 0, 0, 0.25, 0, 0, 0, 0.25 )
script = SubResource( 1 )
[node name="progress_bar" type="ProgressBar" parent="."]
margin_left = -8.0
margin_top = -10.0
margin_right = 8.0
margin_bottom = -8.0
custom_styles/fg = SubResource( 2 )
custom_styles/bg = SubResource( 3 )
step = 1.0
value = 50.0
percent_visible = false
[node name="sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
hframes = 2
[node name="area_2d" type="Area2D" parent="."]
[node name="collision_polygon_2d" type="CollisionPolygon2D" parent="area_2d"]
[node name="timer" type="Timer" parent="."]
autostart = true
[connection signal="timeout" from="timer" to="." method="_on_timer_timeout"]