-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript_disparo.gd
52 lines (38 loc) · 1.23 KB
/
script_disparo.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
51
52
extends Node2D
var tipoDisparo: int
var velocidade = 300
var danoDisparo1 = 1
var danoDisparo2 = 3
# Called when the node enters the scene tree for the first time.
func _ready():
$Disparo1.visible = false
$Disparo2.visible = false
if (tipoDisparo==1):
$Disparo1.visible = true
elif (tipoDisparo==2):
$Disparo2.visible = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
position.y -= (velocidade * delta)
func acerto_disparo(area2dInimigo):
if (area2dInimigo.name=="Inimigo"):
#Animação do inimigo explodindo
#Realiza o dano no inimigo para que ele possa receber mais de um tiro
var dano = 0
if (tipoDisparo==1):
dano = danoDisparo1
elif (tipoDisparo==2):
dano = danoDisparo2
area2dInimigo.velocidade -= 25
area2dInimigo.qtd_vida -= dano
if (area2dInimigo.qtd_vida<=0):
#desativa o colision shape
area2dInimigo.get_node("CollisionShape2D").set_deferred("disable", true)
area2dInimigo.get_node("AnimationPlayer").play("explodindo")
else:
area2dInimigo.get_node("AnimationPlayer").play("sofrendo")
#Apaga o disparo
queue_free()
func _on_AudioStreamPlayer_finished():
$AudioStreamPlayer.stop()
$AudioStreamPlayer.queue_free()