@@ -1,14 +1,14 @@ | |||
[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"] | |||
[ext_resource type="Script" path="res://scripts/Analyzers/analyzer_level_1.gd" id="2_besvw"] | |||
[node name="Analyzers" type="Node"] | |||
script = ExtResource("1_u0rar") | |||
[node name="Level 1" type="Node" parent="."] | |||
script = ExtResource("2_masw0") | |||
script = ExtResource("2_besvw") | |||
[node name="Timer" type="Timer" parent="Level 1"] | |||
[node name="AnalyzerTimer" type="Timer" parent="."] | |||
[connection signal="timeout" from="Level 1/Timer" to="Level 1" method="_on_timer_timeout"] | |||
[connection signal="timeout" from="AnalyzerTimer" to="Level 1" method="_on_timer_timeout"] |
@@ -27,6 +27,8 @@ script = ExtResource("3_yqqol") | |||
[node name="Buy L1 Analyzer" type="Button" parent="."] | |||
visible = false | |||
offset_right = 8.0 | |||
offset_bottom = 8.0 | |||
offset_left = 538.0 | |||
offset_top = 348.0 | |||
offset_right = 546.0 | |||
offset_bottom = 356.0 | |||
script = ExtResource("4_fpmpw") |
@@ -11,8 +11,20 @@ | |||
[node name="Messages" parent="." instance=ExtResource("2_d66gc")] | |||
[node name="Narration" parent="Messages" index="0"] | |||
offset_top = 169.0 | |||
[node name="Score" parent="Messages" index="1"] | |||
offset_left = 330.0 | |||
offset_top = 130.0 | |||
offset_right = 525.0 | |||
offset_bottom = 156.0 | |||
[node name="Generators" parent="." instance=ExtResource("3_qm46o")] | |||
[node name="Level 1" parent="Generators" index="0"] | |||
click_value = 1 | |||
[node name="Analyzers" parent="." instance=ExtResource("4_kptdw")] | |||
[node name="Main Interface" type="CanvasLayer" parent="."] | |||
@@ -23,9 +35,10 @@ script = ExtResource("1_ltn0e") | |||
[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="section_ended" from="Messages/Narration" to="Main Interface" method="_on_narration_section_ended"] | |||
[connection signal="gl1_click" from="Generators/Level 1" to="Messages/Score" method="_on_level_1_gl_1_click"] | |||
[connection signal="al1_analyze" from="Analyzers/Level 1" to="Messages/Score" method="_on_level_1_al_1_analyze"] | |||
[connection signal="al1_analyze" from="Analyzers/Level 1" to="Main Interface" method="_on_level_1_al_1_analyze"] | |||
[connection signal="interface_ready" from="Main Interface" to="Messages/Narration" method="_on_interface_ready"] | |||
[connection signal="interface_ready" from="Main Interface" to="Messages/Score" method="_on_interface_ready"] | |||
[connection signal="interface_ready" from="Main Interface" to="Generators" method="_on_interface_ready"] |
@@ -26,14 +26,19 @@ offset_bottom = 186.0 | |||
script = ExtResource("3_tungw") | |||
[node name="Score Per Second" type="RichTextLabel" parent="."] | |||
visible = false | |||
offset_left = 339.0 | |||
offset_top = 186.0 | |||
offset_right = 531.0 | |||
offset_bottom = 216.0 | |||
offset_left = 262.0 | |||
offset_top = 65.0 | |||
offset_right = 454.0 | |||
offset_bottom = 95.0 | |||
metadata/_edit_use_anchors_ = true | |||
[node name="SPS Timer" type="Timer" parent="Score Per Second"] | |||
[node name="SPSTimer" type="Timer" parent="Score Per Second"] | |||
autostart = true | |||
[connection signal="end_introduction" from="Narration" to="." method="_on_narration_end_introduction"] | |||
[node name="Usage Per Second" type="RichTextLabel" parent="."] | |||
offset_right = 40.0 | |||
offset_bottom = 40.0 | |||
[node name="UPSTimer" type="Timer" parent="Usage Per Second"] | |||
[connection signal="timeout" from="Score Per Second/SPSTimer" to="Score" method="_on_sps_timer_timeout"] |
@@ -0,0 +1,33 @@ | |||
extends Node | |||
@export var num_analyzers = 1 | |||
@export var analysis_value = 10 | |||
@export var active = false | |||
@onready var analyzer_timer = $"../AnalyzerTimer" | |||
signal al1_analyze(value) | |||
# 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 add_analyzer(): | |||
num_analyzers += 1 | |||
if not active: | |||
start_analyzing() | |||
func start_analyzing(): | |||
if not active: | |||
active = true | |||
analyzer_timer.start() | |||
func _on_analyzer_timer_timeout(): | |||
if active: | |||
print("Emitted analysis.") | |||
al1_analyze.emit(analysis_value * num_analyzers) | |||
analyzer_timer.start() |
@@ -1,7 +1,7 @@ | |||
extends Node | |||
@onready var l1 = $"Level 1" | |||
@onready var timer = $"Level 1/Timer" | |||
@onready var analyzer_timer = $"AnalyzerTimer" | |||
# Called when the node enters the scene tree for the first time. |
@@ -1,16 +0,0 @@ | |||
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. |
@@ -10,5 +10,5 @@ func _ready(): | |||
# Called every frame. 'delta' is the elapsed time since the previous frame. | |||
func _process(delta): | |||
text = "Add L1 Analyzer (costs " + str(main_interface.l1_generator_purchase_cost) + ")" | |||
text = "Add L1 Analyzer (costs " + str(main_interface.l1_analyzer_purchase_cost) + ")" | |||
@@ -1,7 +1,8 @@ | |||
extends Node | |||
@onready var energy_creator = $"Energy Creator" | |||
@onready var buy_l1 = $"Buy L1 Generator" | |||
@onready var buy_l1_generator = $"Buy L1 Generator" | |||
@onready var buy_l1_analyzer = $"Buy L1 Analyzer" | |||
# Called when the node enters the scene tree for the first time. | |||
func _ready(): |
@@ -2,6 +2,7 @@ extends Node | |||
@export var cost = 10 | |||
@export var click_value = 1 | |||
@export var num_generators = 0 | |||
@export var active = false | |||
@onready var generator_timer = $"../GeneratorTimer" | |||
@onready var l1_display = $"L1 Display" | |||
@@ -9,8 +10,9 @@ extends Node | |||
@onready var l1_text | |||
@onready var my_timer | |||
@onready var text1 = "Clicking " | |||
@onready var text2 = " per second!" | |||
@onready var text1 = " generator" | |||
@onready var text2 = " clicking " | |||
@onready var text3 = " per second!" | |||
signal gl1_click(value) | |||
@@ -24,14 +26,21 @@ func _ready(): | |||
func _process(delta): | |||
pass | |||
func add_generator(): | |||
print("Adding 1 level 1 generator. num_generators was " + str(num_generators) + "...") | |||
num_generators = num_generators + 1 | |||
print("Now " + str(num_generators)) | |||
if not active: | |||
start_clicking() | |||
func start_clicking(): | |||
active = true | |||
generator_timer.start() | |||
func _on_generator_timer_timeout(): | |||
if active: | |||
print("Emitted click.") | |||
gl1_click.emit(click_value) | |||
print("click_value is " + str(click_value) + ", num_generators is " + str(num_generators) + ", Level 1 generator emitted click for " + str(click_value * num_generators)) | |||
gl1_click.emit(click_value * num_generators) | |||
generator_timer.start() | |||
func _on_interface_ready(): |
@@ -11,7 +11,7 @@ signal button_click | |||
@onready var analyzers = $"../Analyzers" | |||
# Global variables | |||
@onready var line_thresholds = [1, 5, 10, 25, 75, 300] | |||
#@onready var line_thresholds = [1, 5, 10, 25, 75, 300] | |||
@onready var next_threshold: int | |||
@onready var autoclicker_cost: int = 10 | |||
@onready var current_per_second_score: float = 0.0 | |||
@@ -34,8 +34,8 @@ signal score_update(value: float) | |||
func _ready(): | |||
# SETUP | |||
# This is set in inspector options, but just in case. | |||
click_target.buy_l1_generator.visible = false | |||
messages.narration.json_content = get_json_file_content(messages.narration.lines_file_path) | |||
click_target.buy_l1.visible = false | |||
print("Emitting interface_ready signal.") | |||
interface_ready.emit() | |||
@@ -46,10 +46,11 @@ func _process(delta): | |||
func update_score(new_score): | |||
score_update.emit(new_score) | |||
if messages.score.total_score == 1: | |||
pass | |||
elif messages.score.total_score == 10: | |||
pass | |||
for seq in messages.narration.sequences: | |||
if seq["type"] == "score": | |||
if messages.score.total_score >= seq["value"] and seq["seen"] == false: | |||
messages.narration.display_message_section(seq["name"]) | |||
seq["seen"] = true | |||
func _on_message_timer_timeout(): | |||
pass # Replace with function body. | |||
@@ -57,20 +58,25 @@ func _on_message_timer_timeout(): | |||
func update_second_score(new_score): | |||
pass | |||
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(): | |||
if messages.score.current_score < l1_generator_purchase_cost: | |||
pass | |||
update_score(l1_generator_purchase_cost) | |||
l1_generator_purchase_cost *= l1_generator_mult | |||
l1_generator_purchase_cost = floor(l1_generator_purchase_cost) | |||
generators.l1.add_generator() | |||
func _on_buy_l_1_analyzer_pressed(): | |||
if messages.score.current_score < l1_analyzer_purchase_cost: | |||
pass | |||
update_score(l1_analyzer_purchase_cost) | |||
l1_analyzer_purchase_cost *= l1_analyzer_mult | |||
l1_analyzer_purchase_cost = floor(l1_analyzer_purchase_cost) | |||
analyzers.l1.add_analyzer() | |||
# UTILITY FUNCTIONS | |||
func get_text_file_content(file_path): | |||
@@ -83,3 +89,12 @@ func get_json_file_content(file_path): | |||
var content = file.get_as_text() | |||
var json_content = JSON.parse_string(content) | |||
return json_content | |||
func _on_narration_section_ended(section_name): | |||
if section_name == "introduction": | |||
click_target.energy_creator.visible = true | |||
elif section_name == "explain_mechanism": | |||
click_target.buy_l1_generator.visible = true | |||
elif section_name == "afford_analyzer": | |||
click_target.buy_l1_analyzer.visible = true |
@@ -4,9 +4,7 @@ extends Node | |||
@onready var narration_timer = $Narration/MessageTimer | |||
@onready var score = $Score | |||
@onready var sps = $"Score Per Second" | |||
@onready var sps_timer = $"Score Per Second/SPS Timer" | |||
signal narration_end_introduction | |||
@onready var sps_timer = $"Score Per Second/SPSTimer" | |||
# Called when the node enters the scene tree for the first time. | |||
func _ready(): | |||
@@ -16,7 +14,3 @@ func _ready(): | |||
func _process(delta): | |||
pass | |||
func _on_narration_end_introduction(): | |||
narration_end_introduction.emit() |
@@ -9,8 +9,15 @@ extends RichTextLabel | |||
@onready var lines_file_path = "res://text/message_lines.json" | |||
@export var lines_displayed = [] | |||
@export var sequences = [ | |||
{"value": 0, "type": "score", "name": "introduction", "seen": true, "done": false}, | |||
{"value": 1, "type": "score", "name": "get_to_10", "seen": false, "done": false}, | |||
{"value": 10, "type": "score", "name": "explain_mechanism", "seen": false, "done": false}, | |||
{"value": 25, "type": "score", "name": "bought_generator", "seen": false, "done": false}, | |||
{"value": 100, "type": "scorepersecond", "name": "afford_analyzer", "seen": false, "done": false} | |||
] | |||
signal end_introduction | |||
signal section_ended(section_name) | |||
# Called when the node enters the scene tree for the first time. | |||
func _ready(): | |||
@@ -39,24 +46,21 @@ func _nl_append(msg1, msg2): | |||
func _centered_message(msg): | |||
return "[center]" + msg + "[/center]" | |||
func display_introduction(): | |||
print("Displaying introduction.") | |||
show_message_by_id("introduction", 0) | |||
await get_tree().create_timer(1.0).timeout | |||
show_message_by_id("introduction", 1) | |||
await get_tree().create_timer(0.5).timeout | |||
end_introduction.emit() | |||
func display_message_section(section_name): | |||
print("Displaying " + section_name + ".") | |||
var num_messages = message_lines[section_name].size() | |||
for i in num_messages: | |||
show_message_by_id(section_name, i) | |||
await get_tree().create_timer(1.0).timeout | |||
section_ended.emit(section_name) | |||
func _on_interface_ready(): | |||
print("Narration received interface_ready signal.") | |||
var main_sequence_messages = json_content["main_sequence_messages"] | |||
# These dialogue sets are now lists of lists | |||
print("Got JSON content keys " + ", ".join(main_sequence_messages.keys())) | |||
for section in main_sequence_messages.keys(): | |||
message_lines[section] = [] | |||
var section_lines = main_sequence_messages[section] | |||
section_lines.sort_custom(func(a,b): return a["id"] < b["id"]) | |||
for line in section_lines: | |||
message_lines[section].append(line["text"]) | |||
display_introduction() | |||
print("Got " + str(main_sequence_messages.size()) + " message sections from JSON") | |||
for i in sequences.size(): | |||
var section_name = sequences[i]["name"] | |||
message_lines[section_name] = main_sequence_messages[i] | |||
display_message_section("introduction") |
@@ -2,10 +2,15 @@ extends RichTextLabel | |||
@export var current_score = 0 | |||
@export var current_second_score = 0 | |||
@export var current_score_per_second: float = 0 | |||
@export var current_second_usage = 0 | |||
@export var current_usage_per_second: float = 0 | |||
@export var total_score = 0 | |||
@export var prev_second_scores: Array | |||
@export var prev_second_usages: Array | |||
@onready var score_per_second = $"../Score Per Second" | |||
@onready var sps_timer = $"../Score Per Second/SPSTimer" | |||
@onready var narration = $"../Narration" | |||
# Called when the node enters the scene tree for the first time. | |||
@@ -14,21 +19,54 @@ func _ready(): | |||
# Called every frame. 'delta' is the elapsed time since the previous frame. | |||
func _process(delta): | |||
func _process(_delta): | |||
pass | |||
func update(score): | |||
if score >= 0: | |||
if score == 0: | |||
sps_timer.start() | |||
score_per_second.visible = true | |||
elif score >= 0: | |||
# only count positive scores in SPS | |||
current_second_score += score | |||
total_score += score | |||
current_score += score | |||
total_score += score | |||
update_text(current_score) | |||
func update_text(score_num): | |||
func update_text(_score_num): | |||
text = "Energy: " + str(current_score) | |||
score_per_second.text = "Energy per second: " + str(current_score_per_second) | |||
func _on_interface_ready(): | |||
pass # Replace with function body. | |||
func _on_score_update(click_value): | |||
update(click_value) | |||
func _on_level_1_gl_1_click(value): | |||
#print("Received value " + str(value) + " from level 1 generators") | |||
update(value) | |||
func _on_level_1_al_1_analyze(value): | |||
#print("Received value " + str(value) + " from level 1 analyzers") | |||
update(0-value) | |||
func _on_sps_timer_timeout(): | |||
var loc_current_second = current_second_score | |||
current_second_score = 0 | |||
if len(prev_second_scores) >= 5: | |||
prev_second_scores = prev_second_scores.slice(1,5) | |||
prev_second_scores.append(loc_current_second) | |||
var total_second_score = 0 | |||
var num_scores = 0 | |||
for s in prev_second_scores: | |||
total_second_score += s | |||
num_scores += 1 | |||
if num_scores <= 0: | |||
current_score_per_second = 0 | |||
else: | |||
var real_current_second_score: float = float(total_second_score) / num_scores | |||
print("Total second score: " + str(total_second_score) + ", number of scores: " + str(num_scores) + ", real score: " + str(real_current_second_score)) | |||
current_score_per_second = (floor(real_current_second_score * 100)/100) | |||
sps_timer.start() |