From 8ef83633fc1d46745522edec477b3dd7284181b8 Mon Sep 17 00:00:00 2001 From: Paul Norberger Date: Sun, 19 Apr 2020 16:06:50 +0200 Subject: [PATCH] Added dialogue system start point --- src/Boss/SlimeBoss/SlimeBoss.tscn | 5 +- src/Menus/DialogueBox/DialogueBox.gd | 40 ++++++++ src/Menus/DialogueBox/DialogueBox.tscn | 95 ++++++++++++++++++ src/Menus/DialogueBox/Dialogues.gd | 27 +++++ src/Menus/DialogueBox/Dialogues/noob_hero.txt | 2 + src/Menus/DialogueBox/box.png | Bin 0 -> 281 bytes src/Menus/DialogueBox/box.png.import | 34 +++++++ src/Menus/DragNDrop/DragNDropUI.tscn | 2 +- src/World.tscn | 15 ++- src/palette.png.import | 34 +++++++ src/project.godot | 6 ++ 11 files changed, 255 insertions(+), 5 deletions(-) create mode 100644 src/Menus/DialogueBox/DialogueBox.gd create mode 100644 src/Menus/DialogueBox/DialogueBox.tscn create mode 100644 src/Menus/DialogueBox/Dialogues.gd create mode 100644 src/Menus/DialogueBox/Dialogues/noob_hero.txt create mode 100644 src/Menus/DialogueBox/box.png create mode 100644 src/Menus/DialogueBox/box.png.import create mode 100644 src/palette.png.import diff --git a/src/Boss/SlimeBoss/SlimeBoss.tscn b/src/Boss/SlimeBoss/SlimeBoss.tscn index a2ae7ef..62953ef 100644 --- a/src/Boss/SlimeBoss/SlimeBoss.tscn +++ b/src/Boss/SlimeBoss/SlimeBoss.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=2] [ext_resource path="res://Overlap/Stats/Stats.tscn" type="PackedScene" id=3] [ext_resource path="res://Boss/SlimeBoss/SlimeBoss.gd" type="Script" id=4] -[ext_resource path="res://Boss/SlimeBoss/Animations/move_down_angry.png" type="Texture" id=5] +[ext_resource path="res://Boss/SlimeBoss/Animations/move_down.png" type="Texture" id=5] [ext_resource path="res://Boss/SlimeBoss/States/Motion/Idle.gd" type="Script" id=7] [ext_resource path="res://Boss/SlimeBoss/States/Motion/Stagger.gd" type="Script" id=8] [ext_resource path="res://Boss/SlimeBoss/States/Motion/Wander.gd" type="Script" id=9] @@ -45,11 +45,9 @@ script = ExtResource( 4 ) [node name="Sprite" type="Sprite" parent="."] position = Vector2( 0.13451, -20.1418 ) -scale = Vector2( 2, 2 ) texture = ExtResource( 5 ) vframes = 10 hframes = 24 -frame = 65 [node name="Hitbox" parent="." instance=ExtResource( 2 )] collision_layer = 0 @@ -98,6 +96,7 @@ script = ExtResource( 10 ) script = ExtResource( 8 ) [node name="AnimationPlayer" type="AnimationPlayer" parent="."] +autoplay = "MoveDown" anims/MoveDown = SubResource( 4 ) [connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"] [connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"] diff --git a/src/Menus/DialogueBox/DialogueBox.gd b/src/Menus/DialogueBox/DialogueBox.gd new file mode 100644 index 0000000..0139da0 --- /dev/null +++ b/src/Menus/DialogueBox/DialogueBox.gd @@ -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() diff --git a/src/Menus/DialogueBox/DialogueBox.tscn b/src/Menus/DialogueBox/DialogueBox.tscn new file mode 100644 index 0000000..8bff972 --- /dev/null +++ b/src/Menus/DialogueBox/DialogueBox.tscn @@ -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 +} diff --git a/src/Menus/DialogueBox/Dialogues.gd b/src/Menus/DialogueBox/Dialogues.gd new file mode 100644 index 0000000..8867e1d --- /dev/null +++ b/src/Menus/DialogueBox/Dialogues.gd @@ -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] diff --git a/src/Menus/DialogueBox/Dialogues/noob_hero.txt b/src/Menus/DialogueBox/Dialogues/noob_hero.txt new file mode 100644 index 0000000..45bb561 --- /dev/null +++ b/src/Menus/DialogueBox/Dialogues/noob_hero.txt @@ -0,0 +1,2 @@ +Hero;I... I... I need to go pee. +Boss;You will never need to pee again! \ No newline at end of file diff --git a/src/Menus/DialogueBox/box.png b/src/Menus/DialogueBox/box.png new file mode 100644 index 0000000000000000000000000000000000000000..33ce24b255dda9515afc92c962fcab8cbdf5deae GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0y~yVB7#?%X6>+$+qGdOMw()age(c!@6@aFM*uPo-U3d z6?5L+*~r`MAmDN_x?4@7`Cbg$-km(tH|8BsIL&GPV(%BBP5KM3hLnG2XfQY}k!*8+ z{p$V940YSq->!)HE6DJHpOIN%QUjxa=K+R}ko545K5K>@m-gkg=X-}<-Om2}E5n%w zD}w73nZOEE5*S>B3>cJj`%D>T+zed4YWMA(HVmFQKxuEFewg%4Czgb$Z32uPsoa7M z(Skq?oDvKZS$G;efPyn->AEoF9Trn!*a#9~VslUdI^ohwpum||%z`HN%EHC{hCuHz Nc)I$ztaD0e0sx)sT?_yK literal 0 HcmV?d00001 diff --git a/src/Menus/DialogueBox/box.png.import b/src/Menus/DialogueBox/box.png.import new file mode 100644 index 0000000..34653b9 --- /dev/null +++ b/src/Menus/DialogueBox/box.png.import @@ -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 diff --git a/src/Menus/DragNDrop/DragNDropUI.tscn b/src/Menus/DragNDrop/DragNDropUI.tscn index e446b88..907efa6 100644 --- a/src/Menus/DragNDrop/DragNDropUI.tscn +++ b/src/Menus/DragNDrop/DragNDropUI.tscn @@ -22,4 +22,4 @@ Item = ExtResource( 3 ) [node name="DragSink" parent="." instance=ExtResource( 2 )] margin_left = 1.19746 -margin_right = 1.19745 \ No newline at end of file +margin_right = 1.19745 diff --git a/src/World.tscn b/src/World.tscn index b88abab..b6e9c47 100644 --- a/src/World.tscn +++ b/src/World.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=2] +[gd_scene load_steps=20 format=2] [ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://World.gd" type="Script" id=2] @@ -18,6 +18,7 @@ [ext_resource path="res://Objects/Slime/Slime.tscn" type="PackedScene" id=16] [ext_resource path="res://Boss/Boss_template.tscn" type="PackedScene" id=17] [ext_resource path="res://Boss/SlimeBoss/SlimeBoss.tscn" type="PackedScene" id=18] +[ext_resource path="res://Menus/DialogueBox/DialogueBox.tscn" type="PackedScene" id=19] [node name="World" type="Node2D"] script = ExtResource( 2 ) @@ -125,6 +126,18 @@ FRICTION = 200 [node name="Bonfire" parent="." instance=ExtResource( 7 )] position = Vector2( 448, 104 ) +[node name="CenterContainer" type="CenterContainer" parent="."] +margin_right = 40.0 +margin_bottom = 40.0 +use_top_left = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="DialogueBox" parent="CenterContainer" instance=ExtResource( 19 )] +anchor_right = 0.0 +anchor_bottom = 0.0 + [editable path="YSort/minion"] [editable path="YSort/minion/Hurtbox"] diff --git a/src/palette.png.import b/src/palette.png.import new file mode 100644 index 0000000..93f6709 --- /dev/null +++ b/src/palette.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/palette.png-d856c922a66047950b8cb0cc7a9eeeb7.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://palette.png" +dest_files=[ "res://.import/palette.png-d856c922a66047950b8cb0cc7a9eeeb7.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 diff --git a/src/project.godot b/src/project.godot index 5fd57ba..686ef74 100644 --- a/src/project.godot +++ b/src/project.godot @@ -14,6 +14,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://Boss/Boss_template.gd" }, { +"base": "Control", +"class": "DialougeBox", +"language": "GDScript", +"path": "res://Menus/DialogueBox/DialogueBox.gd" +}, { "base": "KinematicBody2D", "class": "Player", "language": "GDScript", @@ -36,6 +41,7 @@ _global_script_classes=[ { } ] _global_script_class_icons={ "Boss": "", +"DialougeBox": "", "Player": "", "SlimeBoss": "", "TitleSceenButton": "",