diff --git a/assets/dialogue_system/next.png b/assets/dialogue_system/next.png new file mode 100644 index 0000000..05153b6 Binary files /dev/null and b/assets/dialogue_system/next.png differ diff --git a/assets/dialogue_system/next.png.import b/assets/dialogue_system/next.png.import new file mode 100644 index 0000000..99a05b9 --- /dev/null +++ b/assets/dialogue_system/next.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/next.png-688a916dc919a8216008c3afdd09f990.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/dialogue_system/next.png" +dest_files=[ "res://.import/next.png-688a916dc919a8216008c3afdd09f990.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=true +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=true +svg/scale=1.0 diff --git a/assets/fonts/ZaiRoyalVogueTypewriter1929-L3V1G.ttf b/assets/fonts/ZaiRoyalVogueTypewriter1929-L3V1G.ttf new file mode 100644 index 0000000..fb16333 Binary files /dev/null and b/assets/fonts/ZaiRoyalVogueTypewriter1929-L3V1G.ttf differ diff --git a/project.godot b/project.godot index b97bb81..360bca1 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,10 @@ config/name="Productathon" run/main_scene="res://Player_s.tscn" config/icon="res://icon.png" +[autoload] + +ProgressManager="*res://scenes/ProgressManager.tscn" + [rendering] quality/driver/driver_name="GLES2" diff --git a/resources/dialogue/story.json b/resources/dialogue/story.json index be19a66..e919c30 100644 --- a/resources/dialogue/story.json +++ b/resources/dialogue/story.json @@ -18,5 +18,20 @@ "text": "‘I want the design at any cost ! Any cost...This has to be done in utmost silence and I don’t want too many people spoiling the mission…this man knows all about their language, and almost all that has to be done, take good care of him and you have to do everything else by yourself ! Now leave…'", "type":"assertive", "character": "Boss" + }, + "4" : { + "text": "‘Listen boy…they speak the beautiful language of Sanskrit…and to succeed in what’s laying ahead, you have to learn it….you need to learn Sanskrit’", + "type":"assertive", + "character":"the old man" + }, + "5" : { + "text": "but how ?", + "type":"assertive", + "character": "you" + }, + "6" : { + "text": "‘The best way to learn a language is to be where it is spoken….to listen what’s spoken…but there’s some basics I’ll tell you first’", + "type": "assertive", + "character":"the old man" } } \ No newline at end of file diff --git a/resources/script/DialogueLoader.gd b/resources/script/DialogueLoader.gd index a471402..23f6aa9 100644 --- a/resources/script/DialogueLoader.gd +++ b/resources/script/DialogueLoader.gd @@ -17,5 +17,6 @@ func get_dialogue() -> Dictionary: return dialogue func set_dialogue_file_path(path: String) -> void: + print(path) assert(path.ends_with(".json")) dialogue_file_path = path diff --git a/resources/script/objective.gd b/resources/script/objective.gd new file mode 100644 index 0000000..59866b0 --- /dev/null +++ b/resources/script/objective.gd @@ -0,0 +1,16 @@ +extends Node + + +# Declare member variables here. Examples: +var objective_count = 0 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/scenes/dialog.tscn b/scenes/dialog.tscn index 251b915..8f17e82 100644 --- a/scenes/dialog.tscn +++ b/scenes/dialog.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=5 format=2] -[ext_resource path="res://assets/dialogue_system/next-indicator.png" type="Texture" id=1] -[ext_resource path="res://resources/script/dialog.gd" type="Script" id=2] +[ext_resource path="res://assets/dialogue_system/next.png" type="Texture" id=1] [ext_resource path="res://scenes/DialogueLoader.tscn" type="PackedScene" id=3] [ext_resource path="res://assets/dialogue_Ui/paper_hor.png" type="Texture" id=4] [ext_resource path="res://scenes/dialogue_controller.gd" type="Script" id=5] @@ -18,11 +17,9 @@ margin_left = -512.0 margin_top = -600.0 margin_right = 512.0 margin_bottom = 0.000427246 -script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } -dialogue_file_path = "res://resources/dialogue/first.json" [node name="DialogBox" type="Control" parent="DialogueSystem"] anchor_left = 0.5 @@ -101,4 +98,4 @@ __meta__ = { [node name="Tween" type="Tween" parent="DialogueSystem"] [node name="DialogueLoader" parent="DialogueSystem" instance=ExtResource( 3 )] -[connection signal="button_down" from="DialogueSystem/DialogBox/box/Button" to="DialogueSystem" method="_on_Button_button_down"] +[connection signal="button_down" from="DialogueSystem/DialogBox/box/Button" to="." method="_on_Button_button_down"] diff --git a/scenes/dialog_starting.tscn b/scenes/dialog_starting.tscn new file mode 100644 index 0000000..3fc4d15 --- /dev/null +++ b/scenes/dialog_starting.tscn @@ -0,0 +1,103 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://assets/dialogue_system/next.png" type="Texture" id=1] +[ext_resource path="res://scenes/DialogueLoader.tscn" type="PackedScene" id=3] +[ext_resource path="res://assets/dialogue_Ui/paper_hor.png" type="Texture" id=4] +[ext_resource path="res://scenes/dialogue_controller.gd" type="Script" id=5] + +[node name="CanvasLayer" type="CanvasLayer"] +script = ExtResource( 5 ) +dialogue_file_path = "res://resources/dialogue/story.json" + +[node name="DialogueSystem" type="Control" parent="."] +anchor_left = 0.499001 +anchor_top = 1.0 +anchor_right = 0.499001 +anchor_bottom = 1.0 +margin_left = -512.0 +margin_top = -600.653 +margin_right = 512.0 +margin_bottom = -0.652954 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="DialogBox" type="Control" parent="DialogueSystem"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -20.0 +margin_top = -20.0001 +margin_right = 20.0 +margin_bottom = 20.0001 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="box" type="TextureRect" parent="DialogueSystem/DialogBox"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -305.5 +margin_top = -176.5 +margin_right = 305.5 +margin_bottom = 176.5 +texture = ExtResource( 4 ) +expand = true +stretch_mode = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="dialogue" type="Label" parent="DialogueSystem/DialogBox/box"] +anchor_left = -0.763288 +anchor_top = -1.09389 +anchor_right = -0.102274 +anchor_bottom = -0.46889 +margin_left = 600.0 +margin_top = 446.4 +margin_right = 640.0 +margin_bottom = 460.4 +custom_colors/font_color = Color( 0, 0, 0, 1 ) +text = "Dialogue" +valign = 1 +autowrap = true +__meta__ = { +"_edit_use_anchors_": true +} + +[node name="speaker" type="Label" parent="DialogueSystem/DialogBox/box"] +anchor_left = -0.944145 +anchor_top = -1.00031 +anchor_right = -0.874235 +anchor_bottom = -0.937808 +margin_left = 600.0 +margin_top = 446.4 +margin_right = 640.0 +margin_bottom = 460.4 +custom_colors/font_color = Color( 0, 0, 0, 1 ) +text = "Speaker" +align = 1 +valign = 1 +__meta__ = { +"_edit_use_anchors_": true +} + +[node name="Button" type="Button" parent="DialogueSystem/DialogBox/box"] +margin_left = 479.425 +margin_top = 282.982 +margin_right = 521.425 +margin_bottom = 318.982 +icon = ExtResource( 1 ) +flat = true +expand_icon = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Tween" type="Tween" parent="DialogueSystem"] + +[node name="DialogueLoader" parent="DialogueSystem" instance=ExtResource( 3 )] +[connection signal="button_down" from="DialogueSystem/DialogBox/box/Button" to="." method="_on_Button_button_down"] diff --git a/scenes/dialogue_controller.gd b/scenes/dialogue_controller.gd index b7fcaa9..bfc51e5 100644 --- a/scenes/dialogue_controller.gd +++ b/scenes/dialogue_controller.gd @@ -5,15 +5,55 @@ extends CanvasLayer # var a: int = 2 # var b: String = "text" onready var system = $DialogueSystem -export (String, FILE, "*.json") var dialogue_file_path: String +export (String, FILE, "*.json") var dialogue_file_path: String = "" setget set_dialogue_file_path signal completed # Called when the node enters the scene tree for the first time. +onready var dialogue = $DialogueSystem/DialogBox/box/dialogue +onready var speaker = $DialogueSystem/DialogBox/box/speaker +onready var box = $DialogueSystem/DialogBox/box + + +var index = 0 +var loadedDialogue: Dictionary + +onready var dialogLoader: DialogueLoader = $DialogueSystem/DialogueLoader +onready var tween: Tween = $DialogueSystem/Tween + +var state: Dictionary = {} setget set_state + +func set_state(new_state: Dictionary) -> void: + state = new_state + +func process_state(new_state: Dictionary) -> void: + speaker.text = new_state["character"]+ ":" + dialogue.text = new_state["text"] + tween.interpolate_property(dialogue, "visible_characters", 0, dialogue.text.length(), 0.08 * dialogue.text.length()) + tween.start() + func _ready() -> void: - system.dialogue_file_path = dialogue_file_path + if dialogue_file_path != "": + loadedDialogue = dialogLoader.load_dialogue() + +func _on_Button_button_down() -> void: + tween.stop(dialogue) + dialogue.visible_characters = dialogue.text.length() + index += 1 + if index < loadedDialogue.size(): + set_state(loadedDialogue[String(index)]) + process_state(state) + else: + system.set_visible(false) + emit_signal("completed") func start() -> void: - system.start() + loadedDialogue = dialogLoader.load_dialogue() + system.set_visible(true) + set_state(loadedDialogue[String(index)]) + process_state(state) + +func set_dialogue_file_path(path: String) -> void: + dialogue_file_path = path + yield($DialogueSystem/DialogueLoader, "ready") + $DialogueSystem/DialogueLoader.set_dialogue_file_path(dialogue_file_path) -func _on_DialogueSystem_completed() -> void: - emit_signal("completed") diff --git a/scenes/main.gd b/scenes/main.gd index 7299b24..2fdb508 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -1,7 +1,7 @@ extends Node2D -onready var system = $DialogueSystem - +onready var system = $"initial story" +onready var system_main = $"main_dialogue" # Declare member variables here. Examples: # var a = 2 # var b = "text" @@ -16,3 +16,8 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass + + +func _on_initial_story_completed(): + system_main.dialogue_file_path = "res://resources/dialogue/lesson1.json" + system_main.start() diff --git a/scenes/main.tscn b/scenes/main.tscn index 0ffd77d..77e39a1 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=42 format=2] +[gd_scene load_steps=43 format=2] [ext_resource path="res://resources/tilesets/stone_walls_and_floors.tres" type="TileSet" id=1] [ext_resource path="res://resources/characters/Player.tscn" type="PackedScene" id=2] @@ -38,9 +38,10 @@ [ext_resource path="res://resources/school/platform.tscn" type="PackedScene" id=36] [ext_resource path="res://resources/speaking_characters/group 1.tscn" type="PackedScene" id=37] [ext_resource path="res://resources/speaking_characters/group 2.tscn" type="PackedScene" id=38] -[ext_resource path="res://scenes/dialog.tscn" type="PackedScene" id=39] +[ext_resource path="res://scenes/dialog_starting.tscn" type="PackedScene" id=39] [ext_resource path="res://scenes/main.gd" type="Script" id=40] [ext_resource path="res://resources/transition/transition_F_T.tscn" type="PackedScene" id=41] +[ext_resource path="res://scenes/dialog.tscn" type="PackedScene" id=42] [node name="Node2D" type="Node2D"] script = ExtResource( 40 ) @@ -48,7 +49,9 @@ __meta__ = { "_edit_horizontal_guides_": [ ] } -[node name="DialogueSystem" parent="." instance=ExtResource( 39 )] +[node name="initial story" parent="." instance=ExtResource( 39 )] + +[node name="main_dialogue" parent="." instance=ExtResource( 42 )] [node name="dirt" type="TileMap" parent="."] mode = 1 @@ -897,4 +900,5 @@ position = Vector2( 3388.58, -6526.62 ) [node name="Area2D" parent="." instance=ExtResource( 41 )] position = Vector2( 6916.3, 5517.02 ) rotation = 1.0472 +[connection signal="completed" from="initial story" to="." method="_on_initial_story_completed"] [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]