-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtorch.gd
50 lines (41 loc) · 1.82 KB
/
torch.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
extends AnimatedSprite
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
signal stopTimer
signal torchOut(torch)
signal removed(torch)
onready var animationPlayer = get_tree().get_root().get_node("Node2D").get_node("AnimationPlayer")
# Called when the node enters the scene tree for the first time.
func _ready():
play("burn")
$TextureProgress.connect("outOfLight", self, "outOfLight")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#if animationPlayer.current_animation_position >= 25 and animationPlayer.current_animation_position <= 35:
# $Light2D.energy = ((animationPlayer.current_animation_position - 25) * 0.1) + 0.1
#elif animationPlayer.current_animation_position >= 55 and animationPlayer.current_animation_position <= 60:
# $Light2D.energy = 1 + (((55 - animationPlayer.current_animation_position) * 0.1) + 0.1)
#elif animationPlayer.current_animation_position >= 0 and animationPlayer.current_animation_position <= 4:
# $Light2D.energy = (5 - animationPlayer.current_animation_position) * 0.1
#elif animationPlayer.current_animation_position > 4 and animationPlayer.current_animation_position < 25:
# $Light2D.energy = 0.0
#elif animationPlayer.current_animation_position > 35 and animationPlayer.current_animation_position < 55:
# $Light2D.energy = 1.1
#$Light2D.energy = 1.0
if $RayCast2D.is_colliding():
var rayCollision = $RayCast2D.get_collision_point()
rayCollision.y -= 10
set_position(rayCollision)
$RayCast2D.enabled = false
func outOfLight():
emit_signal("torchOut", self)
emit_signal("stopTimer")
play("normal")
$Light2D.enabled = false
$Node2D/Label.text = "Tap to relight"
$Node2D.visible = true
$Node2D/AnimationPlayer.play("flicker")
$disappearTimer.start(10)
func _on_disappearTimer_timeout():
emit_signal("removed", self)