-
Notifications
You must be signed in to change notification settings - Fork 0
/
NPC.gd
30 lines (23 loc) · 902 Bytes
/
NPC.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
extends Sprite
class_name Interaction3
signal interaction(type)
const ALERT_SCENE: Resource = preload('res://interfaces/dialogue/AlertBox.tscn')
const NEXT_ALERT_SCENE: Resource = preload('res://interfaces/dialogue/AlertNextLevelBox.tscn')
export(String) var scene_path = ''
export(bool) var is_last_level = false
func _ready():
$Sprite/StaticBody2D.connect('body_entered', self, '_on_body_enter')
func _on_body_enter(body: Object) -> void:
if body.get_collision_mask_bit(1):
if body.is_grounded:
var alert_box = null
if not is_last_level:
alert_box = NEXT_ALERT_SCENE.instance()
else:
alert_box = ALERT_SCENE.instance()
alert_box.set_scene_path(scene_path)
alert_box.position = $AlertBoxPosition.position
self.add_child(alert_box)
alert_box.start(body)
emit_signal('interaction', 'WaitForAlertBox')
LevelManager.goto_scene("res://scenes/Level1.tscn")