Added dialogue system start point

This commit is contained in:
Paul Norberger
2020-04-19 16:06:50 +02:00
parent 7b4bc33f91
commit 8ef83633fc
11 changed files with 255 additions and 5 deletions

View File

@@ -0,0 +1,40 @@
extends Control
class_name DialougeBox
export(int, 0, 100) var dialogue_identifier := 0 setget set_dialogue_identifier
signal started
signal finished
var _dialogue_pos = 0
onready var dialogues := $Dialogues
var _dialogue = []
onready var label = $"CenterContainer/Label"
onready var animation_player = $AnimationPlayer
func _ready():
set_dialogue_identifier(dialogue_identifier)
update_text()
func _physics_process(delta):
if Input.is_action_just_pressed("skip"):
next()
func set_dialogue_identifier(val):
dialogue_identifier = val
_dialogue = dialogues.get_dialogue(val)
_dialogue_pos = 0
animation_player.play("begin_dialouge")
yield(animation_player, "animation_finished")
func update_text():
print(_dialogue)
label.text = _dialogue[_dialogue_pos]
animation_player.play("next_line")
yield(animation_player, "animation_finished")
func next():
_dialogue_pos += 1_
update_text()

View File

@@ -0,0 +1,95 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Menus/DialogueBox/box.png" type="Texture" id=1]
[ext_resource path="res://Fonts/Harmonic/Harmonic24.tres" type="DynamicFont" id=2]
[ext_resource path="res://Menus/DialogueBox/DialogueBox.gd" type="Script" id=3]
[ext_resource path="res://Menus/DialogueBox/Dialogues.gd" type="Script" id=4]
[sub_resource type="Animation" id=1]
resource_name = "begin_dialouge"
length = 0.5
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("CenterContainer:margin_top")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.2 ),
"transitions": PoolRealArray( 1, 0.8 ),
"update": 0,
"values": [ 280, 235 ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("CenterContainer/Label:percent_visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 1.0 ]
}
[sub_resource type="Animation" id=2]
resource_name = "next_line"
length = 3.0
tracks/0/type = "value"
tracks/0/path = NodePath("CenterContainer/Label:percent_visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 3 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 1.0 ]
}
[node name="DialogueBox" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/begin_dialouge = SubResource( 1 )
anims/next_line = SubResource( 2 )
[node name="Dialogues" type="Node" parent="."]
script = ExtResource( 4 )
[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_left = 0.5
anchor_right = 0.5
margin_left = -240.0
margin_right = 240.0
margin_bottom = 31.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureRect" type="TextureRect" parent="CenterContainer"]
margin_left = 24.0
margin_right = 456.0
margin_bottom = 31.0
texture = ExtResource( 1 )
[node name="Label" type="Label" parent="CenterContainer"]
margin_left = 157.0
margin_top = 3.0
margin_right = 322.0
margin_bottom = 27.0
custom_fonts/font = ExtResource( 2 )
text = "Hahaha, Schmock."
align = 1
percent_visible = 0.0
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -0,0 +1,27 @@
extends Node
var _dialogues = []
func _ready():
_dialogues.append([
"Hero;I... I... I need to go pee",
"Boss;After this you won't need to pee ever again!",
"More text...............",
"Even more text................",
".................................",
".........................",
"...................",
"...",
"We're done here."
])
_dialogues.append([
"Hero;I've come to slay you, you beast!",
"Boss;Well then... step forward!"
])
_dialogues.append([
"Hero;You've killed so many, but you won't kill me!",
"Boss;We'll see about that!"
])
func get_dialogue(id):
return _dialogues[id]

View File

@@ -0,0 +1,2 @@
Hero;I... I... I need to go pee.
Boss;You will never need to pee again!

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/box.png-7dd5d0d3b8d648002389d8b1f9ebe137.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Menus/DialogueBox/box.png"
dest_files=[ "res://.import/box.png-7dd5d0d3b8d648002389d8b1f9ebe137.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@@ -22,4 +22,4 @@ Item = ExtResource( 3 )
[node name="DragSink" parent="." instance=ExtResource( 2 )]
margin_left = 1.19746
margin_right = 1.19745
margin_right = 1.19745