oil_tanker: add dialogues

This commit is contained in:
Alice Gaudon 2020-08-20 12:01:19 +02:00
parent 46e6815abc
commit 29dcc1630c
14 changed files with 109 additions and 32 deletions

5
dialogues/game1.json Normal file
View File

@ -0,0 +1,5 @@
[
{"name": "Herbert", "text": "As I was on my daily morning walk, I saw something strange."},
{"name": "Herbert", "text": "There was some sort of weird goo floating around."},
{"name": "Herbert", "text": "So I decided to look for the source."}
]

View File

@ -0,0 +1,5 @@
[
{"name": "Herbert", "text": "Finally I found the source.", "timer": 4, "auto": true, "upside_down": true},
{"name": "Herbert", "text": "It was a recently sunk oil tanker.", "timer": 5, "auto": true, "upside_down": true},
{"name": "Herbert", "text": "I had to investigate further.", "timer": 3, "auto": true, "upside_down": true}
]

View File

@ -0,0 +1,3 @@
[
{"name": "Herbert", "text": "The closer I got, the more oil there was.", "timer": 4, "auto": true, "upside_down": true}
]

View File

@ -0,0 +1,5 @@
[
{"name": "Herbert", "text": "The inside was full of oil, I was really close.", "upside_down": true},
{"name": "Herbert", "text": "And there it was, one of the tank was damaged.", "upside_down": true},
{"name": "Herbert", "text": "I'm just a crab, I couldn't do anything about it.", "upside_down": true, "animation": "fadeout", "timer": 2}
]

View File

@ -0,0 +1,5 @@
[
{"name": "Herbert", "text": "Back at my home, there was goo everywhere.", "expression": "black"},
{"animation": "fadein", "timer": 2, "auto": true},
{"name": "Herbert", "text": "My friends and I were forced to move..."}
]

View File

@ -1,4 +1,4 @@
[gd_resource type="SpriteFrames" load_steps=8 format=2]
[gd_resource type="SpriteFrames" load_steps=6 format=2]
[ext_resource path="res://images/campfire/Choice.png" type="Texture" id=1]
@ -14,18 +14,10 @@ region = Rect2( 192, 0, 192, 108 )
atlas = ExtResource( 1 )
region = Rect2( 384, 0, 192, 108 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 192, 108 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 576, 0, 192, 108 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 192, 108 )
[resource]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
@ -33,12 +25,12 @@ animations = [ {
"name": "default",
"speed": 2.0
}, {
"frames": [ SubResource( 3 ), SubResource( 4 ) ],
"frames": [ SubResource( 3 ) ],
"loop": true,
"name": "truth",
"speed": 2.0
}, {
"frames": [ SubResource( 5 ), SubResource( 6 ) ],
"frames": [ SubResource( 5 ) ],
"loop": true,
"name": "lie",
"speed": 2.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -26,8 +26,6 @@ __meta__ = {
}
[node name="Dialogue" parent="UI" instance=ExtResource( 4 )]
name_label_path = NodePath("../Dialogue/MarginContainer/VBoxContainer/MarginContainer/MarginContainer/CharacterName")
text_label_path = NodePath("../Dialogue/MarginContainer/VBoxContainer/MarginContainer2/MarginContainer/DialogText")
[node name="TheChoice" type="AnimatedSprite" parent="."]
visible = false

View File

@ -77,8 +77,8 @@ script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
name_label_path = NodePath("MarginContainer/VBoxContainer/MarginContainer/MarginContainer/CharacterName")
text_label_path = NodePath("MarginContainer/VBoxContainer/MarginContainer2/MarginContainer/DialogText")
name_label_path = NodePath("MarginContainer/VBoxContainer/NameContainer/MarginContainer/CharacterName")
text_label_path = NodePath("MarginContainer/VBoxContainer/TextContainer/MarginContainer/DialogText")
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
@ -100,7 +100,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer"]
[node name="NameContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer"]
margin_top = 47.0
margin_right = 22.0
margin_bottom = 80.0
@ -112,7 +112,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="DialogBackground" type="NinePatchRect" parent="MarginContainer/VBoxContainer/MarginContainer"]
[node name="DialogBackground" type="NinePatchRect" parent="MarginContainer/VBoxContainer/NameContainer"]
show_behind_parent = true
material = SubResource( 5 )
margin_left = 4.0
@ -127,7 +127,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/MarginContainer"]
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/NameContainer"]
margin_left = 4.0
margin_right = 18.0
margin_bottom = 33.0
@ -135,7 +135,7 @@ size_flags_horizontal = 0
custom_constants/margin_right = 4
custom_constants/margin_left = 4
[node name="CharacterName" type="RichTextLabel" parent="MarginContainer/VBoxContainer/MarginContainer/MarginContainer"]
[node name="CharacterName" type="RichTextLabel" parent="MarginContainer/VBoxContainer/NameContainer/MarginContainer"]
margin_left = 4.0
margin_right = 10.0
margin_bottom = 33.0
@ -150,7 +150,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/VBoxContainer"]
[node name="TextContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer"]
show_behind_parent = true
margin_top = 80.0
margin_right = 184.0
@ -159,7 +159,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="DialogBackground2" type="NinePatchRect" parent="MarginContainer/VBoxContainer/MarginContainer2"]
[node name="DialogBackground2" type="NinePatchRect" parent="MarginContainer/VBoxContainer/TextContainer"]
show_behind_parent = true
material = SubResource( 5 )
margin_right = 184.0
@ -173,7 +173,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/MarginContainer2"]
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/VBoxContainer/TextContainer"]
margin_right = 184.0
margin_bottom = 28.0
custom_constants/margin_right = 6
@ -184,7 +184,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="DialogText" type="RichTextLabel" parent="MarginContainer/VBoxContainer/MarginContainer2/MarginContainer"]
[node name="DialogText" type="RichTextLabel" parent="MarginContainer/VBoxContainer/TextContainer/MarginContainer"]
margin_left = 6.0
margin_top = 2.0
margin_right = 178.0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=37 format=2]
[gd_scene load_steps=40 format=2]
[ext_resource path="res://scripts/oil_tanker.gd" type="Script" id=1]
[ext_resource path="res://images/oil_tanker/OilTanker.tres" type="SpriteFrames" id=2]
@ -8,6 +8,8 @@
[ext_resource path="res://scripts/GooEmitter.gd" type="Script" id=6]
[ext_resource path="res://images/oil_tanker/HerbertMustGo.tres" type="SpriteFrames" id=7]
[ext_resource path="res://images/goo/BigGoo1.tres" type="Resource" id=8]
[ext_resource path="res://scenes/dialogue.tscn" type="PackedScene" id=9]
[ext_resource path="res://scripts/UI.gd" type="Script" id=10]
[ext_resource path="res://images/goo/BigGoo2.tres" type="Resource" id=11]
[ext_resource path="res://images/goo/goo5.tres" type="Resource" id=12]
[ext_resource path="res://images/goo/goo8.tres" type="Resource" id=13]
@ -67,8 +69,15 @@ b = Vector2( 107.673, 44.0238 )
[sub_resource type="RectangleShape2D" id=19]
extents = Vector2( 4.85875, 16.0913 )
[sub_resource type="RectangleShape2D" id=21]
extents = Vector2( 4.85875, 16.0913 )
[node name="Node2D" type="Node2D"]
script = ExtResource( 1 )
dialogue_1 = "res://dialogues/oilTanker1.json"
dialogue_2 = "res://dialogues/oilTanker2.json"
dialogue_3 = "res://dialogues/oilTanker3.json"
dialogue_4 = "res://dialogues/oilTanker4.json"
[node name="HerbertMustGo" type="AnimatedSprite" parent="."]
frames = ExtResource( 7 )
@ -251,6 +260,23 @@ shape = SubResource( 18 )
position = Vector2( 197.689, 97.7763 )
shape = SubResource( 19 )
[node name="DialogueTrigger" type="Area2D" parent="InsideOilTanker"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="InsideOilTanker/DialogueTrigger"]
position = Vector2( 84.0628, 97.7763 )
shape = SubResource( 21 )
[node name="OilTanker" type="AnimatedSprite" parent="."]
frames = ExtResource( 2 )
centered = false
[node name="UI" type="Control" parent="."]
margin_right = 192.0
margin_bottom = 108.0
script = ExtResource( 10 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Dialog" parent="UI" instance=ExtResource( 9 )]
visible = false

View File

@ -82,14 +82,21 @@ func update() -> void:
music_player.play(audio)
# UI
name_label.bbcode_text = character_name
name_label.rect_min_size.x = name_label.get_font('normal_font').get_string_size(name_label.text).x
text_label.bbcode_text = text
if text == "":
hide()
var upside_down = line.get('upside_down', false)
if upside_down:
$MarginContainer/VBoxContainer.alignment = BoxContainer.ALIGN_BEGIN
$MarginContainer/VBoxContainer.add_child_below_node($MarginContainer/VBoxContainer/TextContainer, $MarginContainer/VBoxContainer/NameContainer)
else:
show()
$MarginContainer/VBoxContainer.alignment = BoxContainer.ALIGN_END
$MarginContainer/VBoxContainer.add_child_below_node($MarginContainer/VBoxContainer/NameContainer, $MarginContainer/VBoxContainer/TextContainer)
if text != '' and character_name != '':
name_label.bbcode_text = character_name
name_label.rect_min_size.x = name_label.get_font('normal_font').get_string_size(name_label.text).x
text_label.bbcode_text = text
if text == "": hide()
else: show()
emit_signal('update')

5
scripts/UI.gd Normal file
View File

@ -0,0 +1,5 @@
extends Control
func _process(delta):
var origin = get_tree().root.get_viewport().canvas_transform.get_origin()
rect_position.x = -origin.x

View File

@ -50,5 +50,6 @@ func _process(delta):
$Sprite.play('left')
func _physics_process(delta : float):
if sleep: return
apply_central_impulse(dir.normalized() * 10)

View File

@ -1,12 +1,17 @@
extends Node2D
onready var dialogue_box = $UI/Dialog
#0
onready var oil_tanker = $OilTanker
export (String, FILE, "*.json") var dialogue_1
#1
onready var oil_tanker_inside_1 = $InsideOilTanker
onready var player_1 = $InsideOilTanker/Player
onready var next_trigger_1 = $InsideOilTanker/NextTrigger
onready var dialogue_trigger_1 = $InsideOilTanker/DialogueTrigger
export (String, FILE, "*.json") var dialogue_2
#2
onready var oil_tanker_inside_2 = $InsideOilTanker2
@ -15,18 +20,35 @@ 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
export (String, FILE, "*.json") var dialogue_3
#3
onready var herbert_must_go_3 = $HerbertMustGo
export (String, FILE, "*.json") var dialogue_4
func _ready():
assert(dialogue_1 != null)
assert(dialogue_2 != null)
assert(dialogue_3 != null)
assert(dialogue_4 != null)
oil_tanker.connect('animation_finished', self, 'end_step_0')
next_trigger_1.connect("body_entered", self, 'end_step_1')
dialogue_trigger_1.connect("body_entered", self, 'dialogue_2')
next_trigger_2.connect("body_entered", self, 'end_step_2')
yield(get_tree().create_timer(1), "timeout")
yield(dialogue_box.start_dialogue(dialogue_1), 'end')
# oil_tanker.frame = 12
# end_step_0()
# end_step_1(player_1)
# 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')
func end_step_0():
print('end_step_0')
@ -45,10 +67,13 @@ func end_step_1(body : Node):
func end_step_2(body : Node):
print('end_step_2')
if body.name == "Player":
player_2.sleep = true
yield(dialogue_box.start_dialogue(dialogue_3), 'end')
oil_tanker_inside_2.queue_free()
herbert_must_go_3.play('default')
yield(get_tree().create_timer(5), "timeout")
yield(get_tree().create_timer(1), "timeout")
yield(dialogue_box.start_dialogue(dialogue_4), 'end')
get_tree().change_scene("res://scenes/campfire2.tscn")
func _input(event):