2020-08-19 13:55:48 +02:00
|
|
|
extends Node2D
|
|
|
|
|
2020-08-20 10:35:25 +02:00
|
|
|
#0
|
|
|
|
onready var oil_tanker = $OilTanker
|
|
|
|
|
|
|
|
#1
|
|
|
|
onready var oil_tanker_inside_1 = $InsideOilTanker
|
|
|
|
onready var player_1 = $InsideOilTanker/Player
|
|
|
|
onready var next_trigger_1 = $InsideOilTanker/NextTrigger
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
#3
|
|
|
|
onready var herbert_must_go_3 = $HerbertMustGo
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func _ready():
|
2020-08-20 10:35:25 +02:00
|
|
|
oil_tanker.connect('animation_finished', self, 'end_step_0')
|
|
|
|
next_trigger_1.connect("body_entered", self, 'end_step_1')
|
|
|
|
next_trigger_2.connect("body_entered", self, 'end_step_2')
|
2020-08-19 18:59:29 +02:00
|
|
|
|
2020-08-20 10:35:25 +02:00
|
|
|
# oil_tanker.frame = 12
|
|
|
|
# end_step_0()
|
|
|
|
# end_step_1(player_1)
|
|
|
|
|
|
|
|
func end_step_0():
|
|
|
|
print('end_step_0')
|
|
|
|
if oil_tanker.frame > 1:
|
|
|
|
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 10:35:25 +02:00
|
|
|
oil_tanker_inside_1.queue_free()
|
|
|
|
|
|
|
|
player_2.sleep = false
|
|
|
|
camera_2.current = true
|
|
|
|
|
|
|
|
func end_step_2(body : Node):
|
|
|
|
print('end_step_2')
|
|
|
|
if body.name == "Player":
|
|
|
|
oil_tanker_inside_2.queue_free()
|
|
|
|
herbert_must_go_3.play('default')
|
|
|
|
|
|
|
|
yield(get_tree().create_timer(5), "timeout")
|
|
|
|
get_tree().change_scene("res://scenes/campfire2.tscn")
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func _input(event):
|
2020-08-20 10:35:25 +02:00
|
|
|
if oil_tanker != null:
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_pressed('right'):
|
2020-08-20 10:35:25 +02:00
|
|
|
if !oil_tanker.is_playing():
|
|
|
|
oil_tanker.play('default')
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_released('right'):
|
2020-08-20 10:35:25 +02:00
|
|
|
oil_tanker.stop()
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
if event.is_action_pressed('left'):
|
2020-08-20 10:35:25 +02:00
|
|
|
if !oil_tanker.is_playing() && oil_tanker.frame > 0:
|
|
|
|
oil_tanker.play('default', true)
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_released('left'):
|
2020-08-20 10:35:25 +02:00
|
|
|
oil_tanker.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)
|