-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCellEnemy.gd
42 lines (36 loc) · 1.11 KB
/
CellEnemy.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
extends "res://Enemy.gd"
signal healed_cell()
export var hits_to_heal = 3
var hit1 = preload("res://assets/audio/hit-1.wav")
var squish2 = preload("res://assets/audio/squish-2.wav")
func _on_Enemy_body_entered(node: Node):
if node.is_in_group('bullets'):
hits_to_heal -= 1
if hits_to_heal == 0:
heal()
else:
play_sound(hit1)
elif node.is_in_group('player'):
die()
func die(play_sound = true):
$AnimationPlayer.stop()
.die()
func heal(play_sound = true):
self.collision_mask = 0
self.collision_layer = 0
var direction = 0
self.rotation = direction
self.linear_velocity = Vector2(500, 0)
self.linear_velocity = self.linear_velocity.rotated(direction)
$AnimationPlayer.stop()
$Tween.interpolate_property($Sprite, "modulate",
$Sprite.modulate, Color(1, 1, 1, 1), 0.33,
Tween.TRANS_LINEAR, Tween.EASE_OUT)
$Tween.start()
if (play_sound):
play_sound(squish2)
var player = get_node("../../Player")
self.connect("killed_enemy", player, "_on_player_killed_enemy")
emit_signal("killed_enemy", immunity_value)
self.connect("healed_cell", player, "_on_player_healed_cell")
emit_signal("healed_cell")