Browse Source

Add fadein and fadeout to dialogues and other improvements

levelz999
Alice Gaudon 10 months ago
parent
commit
533f41fedf
14 changed files with 100 additions and 38 deletions
  1. +6
    -0
      BlackScreen.tscn
  2. +17
    -17
      dialogues/End_Lie.json
  3. +3
    -2
      dialogues/oilTanker1.json
  4. +1
    -1
      dialogues/oilTanker2.json
  5. +1
    -3
      dialogues/oilTanker3.json
  6. +2
    -3
      dialogues/oilTanker4.json
  7. +5
    -0
      dialogues/oilTanker5.json
  8. +6
    -0
      project.godot
  9. +0
    -1
      scenes/campfire.tscn
  10. +7
    -1
      scenes/dialogue.tscn
  11. +1
    -1
      scenes/oil_tanker.tscn
  12. +25
    -0
      scripts/BlackScreen.gd
  13. +19
    -5
      scripts/DialogueBox.gd
  14. +7
    -4
      scripts/oil_tanker.gd

+ 6
- 0
BlackScreen.tscn View File

@ -0,0 +1,6 @@
[gd_scene format=2]
[node name="BlackScreen" type="Polygon2D"]
modulate = Color( 1, 1, 1, 0.905882 )
color = Color( 0, 0, 0, 1 )
polygon = PoolVector2Array( 0, 0, 192, 0, 192, 108, 0, 108 )

+ 17
- 17
dialogues/End_Lie.json View File

@ -1,29 +1,29 @@
[
{"name": "Ely", "text": "I am a part of a non-profit organisation."},
{"name": "Crab", "text": "A what?"},
{"name": "Ely", "text": "I am a part of a non-profit organization."},
{"name": "Herbert", "text": "A what?"},
{"name": "Ely", "text": "A bunch of people doing things more or less selflessly."},
{"name": "Crab", "text": "Oh, that's nice!"},
{"name": "Ely", "text": "Yeah, and our goal is to scan the ocean to find potential garbage and wrecks left by other hu-... uh... other [wave amp=20 freq=2]hoomans[wave/]."},
{"name": "Crab", "text": "How neat!"},
{"name": "Herbert", "text": "Oh, that's nice!"},
{"name": "Ely", "text": "We scan the ocean to find the garbage left by other hu-... uh... other [wave amp=20 freq=2]hoomans[/wave]."},
{"name": "Herbert", "text": "How neat!"},
{"name": "Ely", "text": "We're mostly pals enjoying scuba diving together and collecting small funds for bigger organizations."},
{"name": "Ely", "text": "And... you see, the oil tanker you found..."},
{"name": "Ely", "text": "We were supposed to go through it and gather some pieces of information for later dismantlement."},
{"name": "Ely", "text": "We were supposed to go through it and gather pieces of information for later dismantlement."},
{"name": "Ely", "text": "But... as you can tell, it didn't go well."},
{"name": "Ely", "text": "The sea was angry, thunderous even..."},
{"name": "Ely", "text": "And we lost our ship."},
{"name": "Ely", "text": "I don't even know were my friends are..."},
{"name": "Ely", "text": "..."},
{"name": "Crab", "text": "..."},
{"name": "Herbert", "text": "..."},
{"name": "Ely", "text": "Crap..."},
{"name": "Ely", "text": "... I don't know why I'm telling you all of that, it's not even really what happened..."},
{"name": "Ely", "text": "... I don't know why I'm telling you all of that, it's not even what really happened..."},
{"name": "Ely", "text": "..."},
{"name": "Ely", "text": "I-I don't want to tell you the truth..."},
{"name": "Crab", "text": "..."},
{"name": "Crab", "text": "That was a beautiful tale."},
{"name": "Crab", "text": "In a sense, it brings me hope to know you're aware that oil tankers are bad."},
{"name": "Crab", "text": "Lie or not, your story tells me something about hoomans and about you."},
{"name": "Crab", "text": "Something good..."},
{"animation": "fadeout", "timer": 4, "auto": true},
{"timer": 2, "auto": true},
{"name": "Crab", "text": "Thank you.", "expression": "black"}
{"name": "Ely", "text": "I-I don't want you to know the truth..."},
{"name": "Herbert", "text": "..."},
{"name": "Herbert", "text": "That was a beautiful tale."},
{"name": "Herbert", "text": "In a sense, it brings me hope to know you're aware that oil tankers are bad."},
{"name": "Herbert", "text": "Lie or not, your story tells me something about hoomans and about you."},
{"name": "Herbert", "text": "Something good..."},
{"name": "Herbert", "animation": "fadeout", "timer": 4, "auto": true},
{"timer": 2, "auto": true, "expression": "black"},
{"name": "Herbert", "text": "Thank you.", "expression": "black"}
]

+ 3
- 2
dialogues/oilTanker1.json View File

@ -1,5 +1,6 @@
[
{"animation": "fadein", "timer": 2, "auto": true},
{"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}
{"name": "Herbert", "text": "It was a recently sunk oil tanker.", "timer": 4, "auto": true, "upside_down": true},
{"name": "Herbert", "text": "I had to investigate further.", "timer": 4, "auto": true, "upside_down": true}
]

+ 1
- 1
dialogues/oilTanker2.json View File

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

+ 1
- 3
dialogues/oilTanker3.json View File

@ -1,5 +1,3 @@
[
{"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}
{"name": "Herbert", "text": "The inside was full of oil, I was really close.", "upside_down": true, "timer": 6, "auto": true}
]

+ 2
- 3
dialogues/oilTanker4.json View File

@ -1,5 +1,4 @@
[
{"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..."}
{"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}
]

+ 5
- 0
dialogues/oilTanker5.json 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..."}
]

+ 6
- 0
project.godot View File

@ -9,6 +9,11 @@
config_version=4
_global_script_classes=[ {
"base": "CanvasItem",
"class": "BlackScreen",
"language": "GDScript",
"path": "res://scripts/BlackScreen.gd"
}, {
"base": "Node",
"class": "DialogueAction",
"language": "GDScript",
@ -40,6 +45,7 @@ _global_script_classes=[ {
"path": "res://scripts/game1/LogEntity.gd"
} ]
_global_script_class_icons={
"BlackScreen": "",
"DialogueAction": "",
"DialogueBox": "",
"Flatfish": "",


+ 0
- 1
scenes/campfire.tscn View File

@ -21,7 +21,6 @@ __meta__ = {
}
[node name="Dialog" parent="UI" instance=ExtResource( 3 )]
visible = false
[node name="IntroScript" type="Node" parent="."]
script = ExtResource( 4 )


+ 7
- 1
scenes/dialogue.tscn View File

@ -1,10 +1,12 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=13 format=2]
[ext_resource path="res://images/ui/dialogue_bg.png" type="Texture" id=1]
[ext_resource path="res://fonts/dialog_default_font.tres" type="DynamicFont" id=2]
[ext_resource path="res://scripts/DialogueBox.gd" type="Script" id=3]
[ext_resource path="res://fonts/dialogue_default_font_italic.tres" type="DynamicFont" id=4]
[ext_resource path="res://fonts/dialogue_default_font_mono_aka_small.tres" type="DynamicFont" id=5]
[ext_resource path="res://BlackScreen.tscn" type="PackedScene" id=6]
[ext_resource path="res://scripts/BlackScreen.gd" type="Script" id=7]
[sub_resource type="VisualShaderNodeColorConstant" id=1]
constant = Color( 0, 0, 0, 0.803922 )
@ -80,6 +82,10 @@ __meta__ = {
name_label_path = NodePath("MarginContainer/VBoxContainer/NameContainer/MarginContainer/CharacterName")
text_label_path = NodePath("MarginContainer/VBoxContainer/TextContainer/MarginContainer/DialogText")
[node name="BlackScreen" parent="." instance=ExtResource( 6 )]
modulate = Color( 1, 1, 1, 0 )
script = ExtResource( 7 )
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0


+ 1
- 1
scenes/oil_tanker.tscn View File

@ -78,6 +78,7 @@ dialogue_1 = "res://dialogues/oilTanker1.json"
dialogue_2 = "res://dialogues/oilTanker2.json"
dialogue_3 = "res://dialogues/oilTanker3.json"
dialogue_4 = "res://dialogues/oilTanker4.json"
dialogue_5 = "res://dialogues/oilTanker5.json"
[node name="HerbertMustGo" type="AnimatedSprite" parent="."]
frames = ExtResource( 7 )
@ -279,4 +280,3 @@ __meta__ = {
}
[node name="Dialog" parent="UI" instance=ExtResource( 9 )]
visible = false

+ 25
- 0
scripts/BlackScreen.gd View File

@ -0,0 +1,25 @@
extends CanvasItem
class_name BlackScreen
var animation_counter = 0.0
var animation_duration : float
var animation = null
func animate(_animation, duration : float):
animation_counter = 0.0
animation_duration = duration
animation = _animation
print('animating!' + (animation if animation != null else 'null') + ' - ' + String(animation_duration))
func _process(delta):
if animation != null:
if animation == 'fadein':
modulate.a = lerp(1, 0, clamp(animation_counter / animation_duration, 0, 1))
elif animation == 'fadeout':
modulate.a = lerp(0, 1, clamp(animation_counter / animation_duration, 0, 1))
elif animation == 'black':
modulate.a = 1
else:
modulate.a = 0
animation_counter += delta

+ 19
- 5
scripts/DialogueBox.gd View File

@ -15,6 +15,8 @@ onready var expression_node = get_node(expression_node_path) as RichTextLabel
onready var music_player = get_node('/root/MusicPlayer') as MusicPlayer
onready var black_screen = $BlackScreen
var dialogue : Array
var index : int
@ -28,6 +30,7 @@ func _ready():
assert(name_label != null)
assert(text_label != null)
assert(music_player != null)
assert(black_screen != null)
func start_dialogue(dialog_path : String) -> DialogueAction:
var dialogue = DialogueAction.new()
@ -51,7 +54,7 @@ func _input(event):
func next() -> void:
index += 1
if index >= dialogue.size():
hide()
$MarginContainer.hide()
emit_signal('end')
return
update()
@ -95,11 +98,21 @@ func update() -> void:
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()
if text == "": $MarginContainer.hide()
else: $MarginContainer.show()
emit_signal('update')
# Animation
var animation = line.get('animation', null)
if animation != null:
print('animate!' + animation)
black_screen.animate(animation, timer)
elif expression == 'black':
black_screen.animate('black', 0)
else:
black_screen.animate(null, timer)
animate_text()
if timer > 0:
@ -113,9 +126,10 @@ func animate_text():
if text_label.text[text_label.visible_characters] == ' ':
text_label.visible_characters += 1
text_label.visible_characters += 1
yield(get_tree().create_timer(0.05), 'timeout')
yield(get_tree().create_timer(0.4 if text_label.text[text_label.visible_characters - 1] == '.' else 0.05), 'timeout')
func stop_waiting():
waiting = false
if auto_advance:
next()

+ 7
- 4
scripts/oil_tanker.gd View File

@ -21,23 +21,24 @@ 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
export (String, FILE, "*.json") var dialogue_4
#3
onready var herbert_must_go_3 = $HerbertMustGo
export (String, FILE, "*.json") var dialogue_4
export (String, FILE, "*.json") var dialogue_5
func _ready():
assert(dialogue_1 != null)
assert(dialogue_2 != null)
assert(dialogue_3 != null)
assert(dialogue_4 != null)
assert(dialogue_5 != 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
@ -63,17 +64,19 @@ func end_step_1(body : Node):
player_2.sleep = false
camera_2.current = true
yield(dialogue_box.start_dialogue(dialogue_3), 'end')
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')
yield(dialogue_box.start_dialogue(dialogue_4), 'end')
oil_tanker_inside_2.queue_free()
herbert_must_go_3.play('default')
yield(get_tree().create_timer(1), "timeout")
yield(dialogue_box.start_dialogue(dialogue_4), 'end')
yield(dialogue_box.start_dialogue(dialogue_5), 'end')
yield(get_tree().create_timer(0.2), "timeout")
get_tree().change_scene("res://scenes/campfire2.tscn")
func _input(event):


Loading…
Cancel
Save