2020-08-19 13:55:48 +02:00
|
|
|
extends Node2D
|
|
|
|
|
2020-08-20 17:03:30 +02:00
|
|
|
signal can_leave
|
|
|
|
var can_leave = false
|
|
|
|
|
2020-08-20 12:01:19 +02:00
|
|
|
onready var dialogue_box = $UI/Dialog
|
2020-08-20 17:32:24 +02:00
|
|
|
onready var music_player = get_node('/root/MusicPlayer') as MusicPlayer
|
2020-08-20 12:01:19 +02:00
|
|
|
|
2020-08-20 10:35:25 +02:00
|
|
|
#0
|
|
|
|
onready var oil_tanker = $OilTanker
|
2020-08-20 13:27:52 +02:00
|
|
|
onready var crab_0 = $OilTanker/Crab
|
2020-08-20 12:01:19 +02:00
|
|
|
export (String, FILE, "*.json") var dialogue_1
|
2020-08-20 17:03:30 +02:00
|
|
|
var leaving_0 = false
|
2020-08-20 10:35:25 +02:00
|
|
|
|
|
|
|
#1
|
|
|
|
onready var oil_tanker_inside_1 = $InsideOilTanker
|
|
|
|
onready var player_1 = $InsideOilTanker/Player
|
|
|
|
onready var next_trigger_1 = $InsideOilTanker/NextTrigger
|
2020-08-20 12:01:19 +02:00
|
|
|
onready var dialogue_trigger_1 = $InsideOilTanker/DialogueTrigger
|
|
|
|
export (String, FILE, "*.json") var dialogue_2
|
2020-08-20 10:35:25 +02:00
|
|
|
|
|
|
|
#2
|
2020-08-19 18:59:29 +02:00
|
|
|
onready var oil_tanker_inside_2 = $InsideOilTanker2
|
2020-08-20 10:35:25 +02:00
|
|
|
onready var camera_2 = $InsideOilTanker2/Camera2D
|
|
|
|
onready var player_2 = $InsideOilTanker2/Player
|
|
|
|
onready var prop1 = $InsideOilTanker2/Parallax/Prop1
|
|
|
|
onready var prop2 = $InsideOilTanker2/Parallax/Prop2
|
|
|
|
onready var next_trigger_2 = $InsideOilTanker2/NextTrigger
|
2020-08-20 12:01:19 +02:00
|
|
|
export (String, FILE, "*.json") var dialogue_3
|
2020-08-20 13:07:50 +02:00
|
|
|
export (String, FILE, "*.json") var dialogue_4
|
2020-08-20 10:35:25 +02:00
|
|
|
|
|
|
|
#3
|
|
|
|
onready var herbert_must_go_3 = $HerbertMustGo
|
2020-08-20 13:07:50 +02:00
|
|
|
export (String, FILE, "*.json") var dialogue_5
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func _ready():
|
2020-08-20 12:01:19 +02:00
|
|
|
assert(dialogue_1 != null)
|
|
|
|
assert(dialogue_2 != null)
|
|
|
|
assert(dialogue_3 != null)
|
|
|
|
assert(dialogue_4 != null)
|
2020-08-20 13:07:50 +02:00
|
|
|
assert(dialogue_5 != null)
|
2020-08-20 12:01:19 +02:00
|
|
|
|
2020-08-20 13:27:52 +02:00
|
|
|
crab_0.connect('animation_finished', self, 'end_step_0')
|
2020-08-20 10:35:25 +02:00
|
|
|
next_trigger_1.connect("body_entered", self, 'end_step_1')
|
2020-08-20 12:01:19 +02:00
|
|
|
dialogue_trigger_1.connect("body_entered", self, 'dialogue_2')
|
2020-08-20 10:35:25 +02:00
|
|
|
next_trigger_2.connect("body_entered", self, 'end_step_2')
|
2020-08-19 18:59:29 +02:00
|
|
|
|
2020-08-20 12:01:19 +02:00
|
|
|
yield(dialogue_box.start_dialogue(dialogue_1), 'end')
|
2020-08-20 17:03:30 +02:00
|
|
|
can_leave = true
|
|
|
|
emit_signal('can_leave')
|
2020-08-20 12:01:19 +02:00
|
|
|
|
2020-08-20 10:35:25 +02:00
|
|
|
# oil_tanker.frame = 12
|
|
|
|
# end_step_0()
|
|
|
|
# end_step_1(player_1)
|
2020-08-20 12:01:19 +02:00
|
|
|
# end_step_2(player_2)
|
|
|
|
|
|
|
|
func dialogue_2(body : Node):
|
|
|
|
print('end_step_1')
|
|
|
|
if body.name == "Player":
|
|
|
|
yield(dialogue_box.start_dialogue(dialogue_2), 'end')
|
2020-08-20 17:03:30 +02:00
|
|
|
can_leave = true
|
|
|
|
emit_signal('can_leave')
|
2020-08-20 10:35:25 +02:00
|
|
|
|
|
|
|
func end_step_0():
|
|
|
|
print('end_step_0')
|
2020-08-20 13:27:52 +02:00
|
|
|
if crab_0.frame > 1:
|
2020-08-20 17:03:30 +02:00
|
|
|
leaving_0 = true
|
|
|
|
|
|
|
|
if !can_leave:
|
|
|
|
yield(self, 'can_leave')
|
|
|
|
can_leave = false
|
|
|
|
|
2020-08-20 10:35:25 +02:00
|
|
|
oil_tanker.queue_free()
|
|
|
|
player_1.sleep = false
|
|
|
|
|
|
|
|
func end_step_1(body : Node):
|
|
|
|
print('end_step_1')
|
2020-08-19 18:59:29 +02:00
|
|
|
if body.name == "Player":
|
2020-08-20 17:03:30 +02:00
|
|
|
player_1.sleep = true
|
|
|
|
|
|
|
|
if !can_leave:
|
|
|
|
yield(self, 'can_leave')
|
|
|
|
can_leave = false
|
|
|
|
|
2020-08-20 10:35:25 +02:00
|
|
|
oil_tanker_inside_1.queue_free()
|
|
|
|
|
|
|
|
player_2.sleep = false
|
|
|
|
camera_2.current = true
|
2020-08-20 13:07:50 +02:00
|
|
|
yield(dialogue_box.start_dialogue(dialogue_3), 'end')
|
2020-08-20 17:03:30 +02:00
|
|
|
can_leave = true
|
|
|
|
emit_signal('can_leave')
|
2020-08-20 10:35:25 +02:00
|
|
|
|
|
|
|
func end_step_2(body : Node):
|
|
|
|
print('end_step_2')
|
|
|
|
if body.name == "Player":
|
2020-08-20 12:01:19 +02:00
|
|
|
player_2.sleep = true
|
2020-08-20 17:03:30 +02:00
|
|
|
|
|
|
|
if !can_leave:
|
|
|
|
yield(self, 'can_leave')
|
|
|
|
can_leave = false
|
|
|
|
|
2020-08-20 13:07:50 +02:00
|
|
|
yield(dialogue_box.start_dialogue(dialogue_4), 'end')
|
2020-08-20 10:35:25 +02:00
|
|
|
oil_tanker_inside_2.queue_free()
|
|
|
|
herbert_must_go_3.play('default')
|
|
|
|
|
2020-08-20 12:01:19 +02:00
|
|
|
yield(get_tree().create_timer(1), "timeout")
|
2020-08-20 13:07:50 +02:00
|
|
|
yield(dialogue_box.start_dialogue(dialogue_5), 'end')
|
|
|
|
yield(get_tree().create_timer(0.2), "timeout")
|
2020-08-20 17:32:24 +02:00
|
|
|
music_player.fade_out()
|
2020-08-20 10:35:25 +02:00
|
|
|
get_tree().change_scene("res://scenes/campfire2.tscn")
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func _input(event):
|
2020-08-20 17:03:30 +02:00
|
|
|
if oil_tanker != null && !leaving_0:
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_pressed('right'):
|
2020-08-20 13:27:52 +02:00
|
|
|
if !crab_0.is_playing():
|
|
|
|
crab_0.play('default')
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_released('right'):
|
2020-08-20 13:27:52 +02:00
|
|
|
crab_0.stop()
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
if event.is_action_pressed('left'):
|
2020-08-20 13:27:52 +02:00
|
|
|
if !crab_0.is_playing() && crab_0.frame > 0:
|
|
|
|
crab_0.play('default', true)
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_released('left'):
|
2020-08-20 13:27:52 +02:00
|
|
|
crab_0.stop()
|
2020-08-19 13:55:48 +02:00
|
|
|
|
2020-08-19 18:59:29 +02:00
|
|
|
func _process(delta):
|
2020-08-20 10:35:25 +02:00
|
|
|
if player_2 != null && !player_2.sleep:
|
2020-08-19 18:59:29 +02:00
|
|
|
var screen_width = ProjectSettings.get_setting("display/window/size/width")
|
2020-08-20 10:35:25 +02:00
|
|
|
camera_2.position.x = floor(clamp(player_2.position.x - screen_width / 2.0, 0, oil_tanker_inside_2.texture.get_width() - screen_width))
|
|
|
|
prop2.position.x = floor((260 - camera_2.position.x) * 0.5)
|
|
|
|
prop1.position.x = floor((300 - camera_2.position.x) * 0.75)
|