2020-08-19 13:55:48 +02:00
|
|
|
extends Node2D
|
|
|
|
|
2020-08-19 18:59:29 +02:00
|
|
|
# 2
|
|
|
|
onready var oil_tanker_inside_2 = $InsideOilTanker2
|
|
|
|
onready var camera = $InsideOilTanker2/Camera2D
|
|
|
|
onready var player = $InsideOilTanker2/Player
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func _ready():
|
2020-08-19 18:59:29 +02:00
|
|
|
$OilTanker.connect('animation_finished', self, 'end_oil_tanker')
|
|
|
|
$InsideOilTanker/NextTrigger.connect("body_entered", self, 'end_inside_oil_tanker')
|
|
|
|
|
|
|
|
# $OilTanker.frame = 12
|
|
|
|
# end_oil_tanker()
|
|
|
|
# end_inside_oil_tanker($InsideOilTanker/Player)
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func end_oil_tanker():
|
2020-08-19 18:59:29 +02:00
|
|
|
print('end_oil_tanker')
|
|
|
|
if $OilTanker.frame > 1:
|
|
|
|
$OilTanker.queue_free()
|
|
|
|
$InsideOilTanker/Player.sleep = false
|
|
|
|
|
|
|
|
func end_inside_oil_tanker(body : Node):
|
|
|
|
print('end_inside_oil_tanker')
|
|
|
|
if body.name == "Player":
|
|
|
|
$InsideOilTanker.queue_free()
|
|
|
|
$InsideOilTanker2/Player.sleep = false
|
|
|
|
$InsideOilTanker2/Camera2D.current = true
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
func _input(event):
|
2020-08-19 18:59:29 +02:00
|
|
|
if $OilTanker != null:
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_pressed('right'):
|
2020-08-19 18:59:29 +02:00
|
|
|
if !$OilTanker.is_playing():
|
|
|
|
$OilTanker.play('default')
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_released('right'):
|
2020-08-19 18:59:29 +02:00
|
|
|
$OilTanker.stop()
|
2020-08-19 13:55:48 +02:00
|
|
|
|
|
|
|
if event.is_action_pressed('left'):
|
2020-08-19 18:59:29 +02:00
|
|
|
if !$OilTanker.is_playing() && $OilTanker.frame > 0:
|
|
|
|
$OilTanker.play('default', true)
|
2020-08-19 13:55:48 +02:00
|
|
|
if event.is_action_released('left'):
|
2020-08-19 18:59:29 +02:00
|
|
|
$OilTanker.stop()
|
2020-08-19 13:55:48 +02:00
|
|
|
|
2020-08-19 18:59:29 +02:00
|
|
|
func _process(delta):
|
|
|
|
if !$InsideOilTanker2/Player.sleep:
|
|
|
|
var screen_width = ProjectSettings.get_setting("display/window/size/width")
|
|
|
|
camera.position.x = floor(clamp(player.position.x - screen_width / 2.0, 0, oil_tanker_inside_2.texture.get_width() - screen_width))
|
|
|
|
$InsideOilTanker2/Parallax/Prop2.position.x = floor((260 - camera.position.x) * 0.5)
|
|
|
|
$InsideOilTanker2/Parallax/Prop1.position.x = floor((300 - camera.position.x) * 0.75)
|