| @@ -1,10 +1,14 @@ | |||
| [gd_scene load_steps=2 format=3 uid="uid://fe1lihrecu3u"] | |||
| [gd_scene load_steps=3 format=3 uid="uid://fe1lihrecu3u"] | |||
| [ext_resource type="Script" path="res://scripts/Analyzers/analyzers.gd" id="1_u0rar"] | |||
| [ext_resource type="Script" path="res://scripts/Analyzers/level_1.gd" id="2_masw0"] | |||
| [node name="Analyzers" type="Node"] | |||
| script = ExtResource("1_u0rar") | |||
| [node name="Level 1" type="Node" parent="."] | |||
| script = ExtResource("2_masw0") | |||
| [node name="Timer" type="Timer" parent="."] | |||
| [node name="Timer" type="Timer" parent="Level 1"] | |||
| [connection signal="timeout" from="Level 1/Timer" to="Level 1" method="_on_timer_timeout"] | |||
| @@ -1,10 +1,11 @@ | |||
| [gd_scene load_steps=6 format=3 uid="uid://daggped4nujna"] | |||
| [gd_scene load_steps=7 format=3 uid="uid://daggped4nujna"] | |||
| [ext_resource type="Script" path="res://scripts/Main Interface.gd" id="1_ltn0e"] | |||
| [ext_resource type="PackedScene" uid="uid://bc2qthu8tugim" path="res://scenes/click_target.tscn" id="2_2hdm6"] | |||
| [ext_resource type="PackedScene" uid="uid://c4ocioaw64kq2" path="res://scenes/messages.tscn" id="2_d66gc"] | |||
| [ext_resource type="PackedScene" uid="uid://b6w7cs7fffyv7" path="res://scenes/generators.tscn" id="3_qm46o"] | |||
| [ext_resource type="PackedScene" uid="uid://fe1lihrecu3u" path="res://scenes/analyzers.tscn" id="4_kptdw"] | |||
| [ext_resource type="Script" path="res://scripts/flag_keeper.gd" id="6_1or7f"] | |||
| [node name="Main" type="Node2D"] | |||
| @@ -19,6 +20,9 @@ script = ExtResource("1_ltn0e") | |||
| [node name="ClickTarget" parent="Main Interface" instance=ExtResource("2_2hdm6")] | |||
| [node name="Flag Keeper" type="Node" parent="Main Interface"] | |||
| script = ExtResource("6_1or7f") | |||
| [connection signal="narration_end_introduction" from="Messages" to="Main Interface" method="_on_messages_narration_end_introduction"] | |||
| [connection signal="end_introduction" from="Messages/Narration" to="Main Interface" method="_on_narration_end_introduction"] | |||
| [connection signal="gl1_click" from="Generators/Level 1" to="Messages/Score" method="_on_level_1_gl_1_click"] | |||
| @@ -1,7 +1,7 @@ | |||
| extends Node | |||
| @onready var l1 = $"Level 1" | |||
| @onready var timer = $Timer | |||
| @onready var timer = $"Level 1/Timer" | |||
| # Called when the node enters the scene tree for the first time. | |||
| @@ -0,0 +1,16 @@ | |||
| extends Node | |||
| @onready var timer = $Timer | |||
| # 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 | |||
| func _on_timer_timeout(): | |||
| pass # Replace with function body. | |||
| @@ -1,6 +1,7 @@ | |||
| extends Button | |||
| @export var cost_per_tick: int = -1 | |||
| @onready var main_interface = $"../.." | |||
| # Called when the node enters the scene tree for the first time. | |||
| func _ready(): | |||
| @@ -9,5 +10,5 @@ func _ready(): | |||
| # Called every frame. 'delta' is the elapsed time since the previous frame. | |||
| func _process(delta): | |||
| pass | |||
| text = "Add L1 Analyzer (costs " + str(main_interface.l1_generator_purchase_cost) + ")" | |||
| @@ -1,6 +1,6 @@ | |||
| extends Button | |||
| @export var current_cost = 10 | |||
| @onready var main_interface = $"../.." | |||
| # Called when the node enters the scene tree for the first time. | |||
| func _ready(): | |||
| @@ -9,5 +9,5 @@ func _ready(): | |||
| # Called every frame. 'delta' is the elapsed time since the previous frame. | |||
| func _process(delta): | |||
| pass | |||
| text = "Add L1 Generator (costs " + str(main_interface.l1_generator_purchase_cost) + ")" | |||
| @@ -4,8 +4,9 @@ extends Button | |||
| # Called when the node enters the scene tree for the first time. | |||
| func _ready(): | |||
| pressed.connect($"../..::_on_energy_creator_pressed".bind(energy_created)) | |||
| pass | |||
| # Called every frame. 'delta' is the elapsed time since the previous frame. | |||
| func _process(delta): | |||
| pass | |||
| @@ -18,13 +18,17 @@ signal button_click | |||
| @onready var second_scores = [] | |||
| @export var energy_creator_click_value = 1 | |||
| @export var l1_generator_initial_cost = 10 | |||
| @export var l1_generator_purchase_cost = -10 | |||
| @export var l1_generator_click_value = 1 | |||
| @export var l1_analyzer_initial_cost = 25 | |||
| @export var l1_analyzer_click_cost = -1 | |||
| @export var l1_generator_mult = 1.15 | |||
| @export var l1_generator_num = 0 | |||
| @export var l1_analyzer_purchase_cost = -25 | |||
| @export var l1_analyzer_click_cost = -2.5 | |||
| @export var l1_analyzer_mult = 1.25 | |||
| @export var l1_analyzer_num = 0 | |||
| signal interface_ready | |||
| signal score_update(value) | |||
| signal score_update(value: float) | |||
| # Called when the node enters the scene tree for the first time. | |||
| func _ready(): | |||
| @@ -32,7 +36,6 @@ func _ready(): | |||
| # This is set in inspector options, but just in case. | |||
| messages.narration.json_content = get_json_file_content(messages.narration.lines_file_path) | |||
| click_target.buy_l1.visible = false | |||
| click_target.buy_l1.text = "Add L1 Generator (costs " + str(generators.l1.cost) + ")" | |||
| print("Emitting interface_ready signal.") | |||
| interface_ready.emit() | |||
| @@ -42,63 +45,11 @@ func _process(delta): | |||
| pass | |||
| func update_score(new_score): | |||
| messages.score.update(new_score) | |||
| score_update.emit(new_score) | |||
| if messages.score.total_score == 1: | |||
| await get_tree().create_timer(0.5).timeout | |||
| messages.message.show_message_by_id(2) | |||
| await get_tree().create_timer(1).timeout | |||
| messages.message.show_message_by_id(3) | |||
| pass | |||
| elif messages.score.total_score == 10: | |||
| await get_tree().create_timer(0.5).timeout | |||
| messages.message.show_message_by_id(4) | |||
| await get_tree().create_timer(1).timeout | |||
| messages.message.show_message_by_id(5) | |||
| await get_tree().create_timer(1).timeout | |||
| messages.message.show_message_by_id(6) | |||
| await get_tree().create_timer(1).timeout | |||
| messages.message.show_message_by_id(7) | |||
| await get_tree().create_timer(1).timeout | |||
| messages.message.show_message_by_id(8) | |||
| await get_tree().create_timer(1).timeout | |||
| click_target.buy_l1.visible = true | |||
| messages.message.show_message_by_id(9) | |||
| func _on_add_item_target_pressed(): | |||
| if messages.score.current_score < autoclicker_cost: | |||
| pass | |||
| else: | |||
| generators.l1.click_value += 1 | |||
| if not generators.l1.l1_auto_display.visible: | |||
| generators.l1.l1_auto_text.text = generators.l1.text1 + str(generators.l1.click_value) + "x" + generators.l1.text2 | |||
| generators.l1.l1_auto_display.show() | |||
| generators.l1.start_clicking() | |||
| messages.message.show_message_by_id(10) | |||
| messages.score.update(0 - autoclicker_cost) | |||
| autoclicker_cost = (autoclicker_cost * 1 + (generators.l1.click_value)) * 1.5 | |||
| click_target.buy_l1.text = "Buy Autoclicker (costs " + str(autoclicker_cost) + ")" | |||
| func _on_sps_timer_timeout(): | |||
| if len(messages.score.prev_second_scores) >= 5: | |||
| messages.score.prev_second_scores.pop_at(0) | |||
| messages.score.prev_second_scores.append(messages.score.current_second_score) | |||
| messages.score.current_second_score = 0 | |||
| var avg_score: float = messages.score.prev_second_scores.reduce(func(acc, c): return acc + c, 0) | |||
| current_per_second_score = avg_score / len(messages.score.prev_second_scores) | |||
| messages.sps.text = str(current_per_second_score) + " per second" | |||
| messages.sps_timer.start() | |||
| func get_text_file_content(file_path): | |||
| var file = FileAccess.open(file_path, FileAccess.READ) | |||
| var content = file.get_as_text() | |||
| return content | |||
| func get_json_file_content(file_path): | |||
| var file = FileAccess.open(file_path, FileAccess.READ) | |||
| var content = file.get_as_text() | |||
| var json_content = JSON.parse_string(content) | |||
| return json_content | |||
| func _on_message_timer_timeout(): | |||
| pass # Replace with function body. | |||
| @@ -109,16 +60,26 @@ func update_second_score(new_score): | |||
| func _on_narration_end_introduction(): | |||
| click_target.energy_creator.visible = true | |||
| func _on_energy_creator_pressed(): | |||
| messages.sps.visible = true | |||
| update_score(energy_creator_click_value) | |||
| func _on_buy_l_1_generator_pressed(): | |||
| update_score(l1_generator_initial_cost) | |||
| update_score(l1_generator_purchase_cost) | |||
| l1_generator_purchase_cost *= l1_generator_mult | |||
| func _on_buy_l_1_analyzer_pressed(): | |||
| update_score(l1_analyzer_purchase_cost) | |||
| l1_analyzer_purchase_cost *= l1_analyzer_mult | |||
| # UTILITY FUNCTIONS | |||
| func get_text_file_content(file_path): | |||
| var file = FileAccess.open(file_path, FileAccess.READ) | |||
| var content = file.get_as_text() | |||
| return content | |||
| func _on_buy_l_1_analyzer_pressed(): | |||
| update_score(l1_analyzer_initial_cost) | |||
| func get_json_file_content(file_path): | |||
| var file = FileAccess.open(file_path, FileAccess.READ) | |||
| var content = file.get_as_text() | |||
| var json_content = JSON.parse_string(content) | |||
| return json_content | |||
| @@ -51,6 +51,7 @@ func display_introduction(): | |||
| func _on_interface_ready(): | |||
| print("Narration received interface_ready signal.") | |||
| var main_sequence_messages = json_content["main_sequence_messages"] | |||
| print("Got JSON content keys " + ", ".join(main_sequence_messages.keys())) | |||
| for section in main_sequence_messages.keys(): | |||
| message_lines[section] = [] | |||
| @@ -27,7 +27,6 @@ func update(score): | |||
| func update_text(score_num): | |||
| text = "Energy: " + str(current_score) | |||
| func _on_interface_ready(): | |||
| pass # Replace with function body. | |||
| @@ -0,0 +1,26 @@ | |||
| extends Node | |||
| @onready var main_interface = $"../.." | |||
| @onready var flags: Dictionary | |||
| # Called when the node enters the scene tree for the first time. | |||
| func _ready(): | |||
| flags = { | |||
| "total_score": { | |||
| "next": 0, | |||
| "list": [1,10,], | |||
| }, | |||
| "current_score": { | |||
| "next": 0, | |||
| "list": [], | |||
| }, | |||
| "narration_milestones": { | |||
| "next": 0, | |||
| "list": [], | |||
| } | |||
| } | |||
| # Called every frame. 'delta' is the elapsed time since the previous frame. | |||
| func _process(delta): | |||
| pass | |||
| @@ -1,77 +1,30 @@ | |||
| { | |||
| "main_sequence_messages": { | |||
| "introduction": [ | |||
| { | |||
| "id": 0, | |||
| "text": "Welcome to SPARK, the Species Preservation and Reconstruction Kit.", | |||
| }, | |||
| { | |||
| "id": 1, | |||
| "text": "I'll add a button below this text. Please click it once." | |||
| } | |||
| ], | |||
| "get_to_10": [ | |||
| { | |||
| "id": 0, | |||
| "text": "Well done! You'll notice that your energy total has gone up." | |||
| }, | |||
| { | |||
| "id": 1, | |||
| "text": "Go ahead and click a few more times. Your target energy is 10." | |||
| } | |||
| ], | |||
| "explain_mechanism": [ | |||
| { | |||
| "id": 0, | |||
| "text": "Good work. The SPARK click mechanism works a little like an old engine." | |||
| }, | |||
| { | |||
| "id": 1, | |||
| "text": "You have to crank it a few times to get it started." | |||
| }, | |||
| { | |||
| "id": 2, | |||
| "text": "Each click provides a little bit of the energy that SPARK needs to operate." | |||
| }, | |||
| { | |||
| "id": 3, | |||
| "text": "But now that we've got some energy in the bank, we can start the engines up, so to speak." | |||
| }, | |||
| { | |||
| "id": 4, | |||
| "text": "With the energy your clicks have yielded, you can start up an automated generator." | |||
| }, | |||
| { | |||
| "id": 5, | |||
| "text": "I've added a button where you can do just that." | |||
| } | |||
| ], | |||
| "bought_generator": [ | |||
| { "id": 0, | |||
| "text": "The generator will yield the equivalent of one click per second." | |||
| }, | |||
| { | |||
| "id": 1, | |||
| "text": "You can use your energy to activate additional generators. Their total output is shown above." | |||
| } | |||
| ], | |||
| "afford_analyzer": [ | |||
| { | |||
| "id": 0, | |||
| "text": "Once you have enough energy stored, you can turn on an analyzer." | |||
| }, | |||
| { | |||
| "id": 1, | |||
| "text": "Analyzers use energy to scan DNA fragments and work out how they fit together." | |||
| }, | |||
| { | |||
| "id": 3, | |||
| "text": "And before you ask, we know all of these fragments are less than a myriad old." | |||
| }, | |||
| { | |||
| "id": 4, | |||
| "text": "They've decayed a bit, but they're still readable." | |||
| } | |||
| "main_sequence_messages": [ | |||
| [ | |||
| "Welcome to SPARK, the Species Preservation and Reconstruction Kit.", | |||
| "I'll add a button below this text. Please click it once." | |||
| ], | |||
| [ | |||
| "Well done! You'll notice that your energy total has gone up.", | |||
| "Go ahead and click a few more times. Your target energy is 10." | |||
| ], | |||
| [ | |||
| "Good work. The SPARK click mechanism works a little like an old engine.", | |||
| "You have to crank it a few times to get it started.", | |||
| "Each click provides a little bit of the energy that SPARK needs to operate.", | |||
| "But now that we've got some energy in the bank, we can start the engines up, so to speak.", | |||
| "With the energy your clicks have yielded, you can start up an automated generator.", | |||
| "I've added a button where you can do just that." | |||
| ], | |||
| [ | |||
| "The generator will yield the equivalent of one click per second.", | |||
| "You can use your energy to activate additional generators. Their total output is shown above." | |||
| ], | |||
| [ | |||
| "Once you have enough energy stored, you can turn on an analyzer.", | |||
| "Analyzers use energy to scan DNA fragments and work out how they fit together.", | |||
| "And before you ask, we know all of these fragments are less than a myriad old.", | |||
| "They've decayed a bit, but they're still readable." | |||
| ] | |||
| } | |||
| ] | |||
| } | |||