diff --git a/Resources/Filaments/filament_pla.tres b/Resources/Filaments/filament_pla.tres new file mode 100644 index 0000000..9c81e12 --- /dev/null +++ b/Resources/Filaments/filament_pla.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="FilamentData" format=3 uid="uid://dvu3hbx3tn0nx"] + +[ext_resource type="Script" uid="uid://cim8peoxip2si" path="res://Resources/filament_data.gd" id="1_7duty"] + +[resource] +script = ExtResource("1_7duty") +material = "PLA" +reward_multiplier = 1.0 +xp_multiplier = 1.0 +amount = 200.0 +price = 4.18 +description = "Filament with reduced plastic content" +metadata/_custom_type_script = "uid://cim8peoxip2si" diff --git a/Resources/filament_data.gd b/Resources/filament_data.gd new file mode 100644 index 0000000..7bf5096 --- /dev/null +++ b/Resources/filament_data.gd @@ -0,0 +1,10 @@ +class_name FilamentData +extends Resource + +@export var material: String +@export var reward_multiplier: float +@export var xp_multiplier: float +@export var amount: float +@export var price: float +@export var description: String = "" +@export var level_req: int = 1 diff --git a/Resources/filament_data.gd.uid b/Resources/filament_data.gd.uid new file mode 100644 index 0000000..0e375c5 --- /dev/null +++ b/Resources/filament_data.gd.uid @@ -0,0 +1 @@ +uid://cim8peoxip2si diff --git a/Scenes/Global/game_data.gd b/Scenes/Global/game_data.gd index 690ab6a..93c3326 100644 --- a/Scenes/Global/game_data.gd +++ b/Scenes/Global/game_data.gd @@ -4,6 +4,7 @@ extends Node signal job_generated(job: Node) signal job_interact signal printer_bought(printer: Node) +signal filament_bought @warning_ignore("unused_signal") signal refresh_printer_dropdown @@ -11,6 +12,7 @@ signal refresh_printer_dropdown var job_spawn_timer: Timer var jobs_array: Array[JobData] var current_job_count: int = 0 +var filaments_array: Array[FilamentData] # - Scenes const JOB_CARD = preload("uid://dvfcie8hqcb0") @@ -40,6 +42,11 @@ func _on_shop_printer_purchase_req(printer_data: PrinterData) -> void: new_printer.initialize_printer(printer_data) PlayerData.owned_printers += 1 +func _on_shop_filament_purchase_req(filament_data: FilamentData) -> void: + if PlayerData.try_purchase(filament_data.price): + filaments_array.append(filament_data) + filament_bought.emit() + #region Job generation func _on_job_spawn_timer_timeout() -> void: diff --git a/Scenes/Global/player_data.gd b/Scenes/Global/player_data.gd index f4480a4..256d527 100644 --- a/Scenes/Global/player_data.gd +++ b/Scenes/Global/player_data.gd @@ -29,7 +29,7 @@ var sell_multiplier: float = 0.5: set(value): sell_multiplier = value -var failure_chance: float = 0.4: +var failure_chance: float = 0.2: set(value): failure_chance = value diff --git a/Scenes/Printer/printer.gd b/Scenes/Printer/printer.gd index 63274a0..e40750e 100644 --- a/Scenes/Printer/printer.gd +++ b/Scenes/Printer/printer.gd @@ -4,12 +4,17 @@ extends PanelContainer @onready var printer_model_label: Label = $MarginContainer/MainArea/PrinterModelLabel @onready var progress_bar: ProgressBar = $MarginContainer/MainArea/PrintInfo/ProgressBar @onready var select_job: OptionButton = $MarginContainer/MainArea/SelectJob -@onready var status_label: Label = $MarginContainer/MainArea/TopInfo/StatusLabel +@onready var status_label: RichTextLabel = $MarginContainer/MainArea/TopInfo/StatusLabel @onready var time_left_label: Label = $MarginContainer/MainArea/PrintInfo/InfoRow2/TimeLeftLabel @onready var start_button: Button = $MarginContainer/MainArea/Buttons/StartButton -@onready var reward_label: Label = $MarginContainer/MainArea/PrintInfo/InfoRow2/RewardLabel -@onready var quality_label: Label = $MarginContainer/MainArea/PrintInfo/InfoRow1/QualityLabel +@onready var reward_label: RichTextLabel = $MarginContainer/MainArea/PrintInfo/InfoRow2/RewardLabel +@onready var quality_label: RichTextLabel = $MarginContainer/MainArea/PrintInfo/InfoRow1/QualityLabel +# RichTextLabel - Colors +var hex_white: String = '#ffffff' +var hex_green: String = '#4ade80' +var hex_blue: String = '#60a5fa' +var hex_red: String = '#f87171' var printer_data: PrinterData var selected_job: JobData @@ -46,8 +51,8 @@ func _process(delta) -> void: reward_label.visible = true set_status() - quality_label.text = 'Quality: %.0f %%' % (print_quality * 100) - reward_label.text = 'Reward: %.2f €' % (selected_job.job_reward * print_quality) + quality_label.text = 'Quality: [color=%s]%.0f%%[/color]' % [hex_green, (print_quality * 100)] + reward_label.text = 'Reward: [color=%s]%.2f €[/color]' % [hex_green, (selected_job.job_reward * print_quality)] var total_time = selected_job.job_time / printer_data.printer_speed var progress = (total_time - time_left) / total_time @@ -93,14 +98,19 @@ func reset_status() -> void: _on_select_job_pressed() func set_status() -> void: + var color_hex: String = hex_white # Default color: white + var status: String if print_failed: - status_label.text = 'Status: Failed' - return - - if is_printing: - status_label.text = 'Status: Printing' + status = 'Failed' + color_hex = hex_red # Failed color: red + elif is_printing: + status = 'Printing' + color_hex = hex_blue # Printing color: blue else: - status_label.text = 'Status: Free' + status = 'Free' + color_hex = hex_green # Free color: green + + status_label.text = 'Status: [color=%s]%s[/color]' % [color_hex, status] func calculate_fail_thresholds() -> Array: var failure_checkpoints: Array = [] diff --git a/Scenes/Printer/printer.tscn b/Scenes/Printer/printer.tscn index 52e3310..9e1973f 100644 --- a/Scenes/Printer/printer.tscn +++ b/Scenes/Printer/printer.tscn @@ -6,8 +6,11 @@ [node name="Printer" type="PanelContainer" unique_id=1372437203] custom_minimum_size = Vector2(0, 150) -offset_right = 271.0 -offset_bottom = 182.0 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 3 script = ExtResource("1_dlbos") @@ -30,11 +33,13 @@ size_flags_horizontal = 3 theme_override_font_sizes/font_size = 30 text = "Printer #1" -[node name="StatusLabel" type="Label" parent="MarginContainer/MainArea/TopInfo" unique_id=2117616913] +[node name="StatusLabel" type="RichTextLabel" parent="MarginContainer/MainArea/TopInfo" unique_id=157586427] layout_mode = 2 size_flags_horizontal = 3 +bbcode_enabled = true text = "Status: Free" horizontal_alignment = 2 +vertical_alignment = 1 [node name="PrinterModelLabel" type="Label" parent="MarginContainer/MainArea" unique_id=666140345] layout_mode = 2 @@ -50,9 +55,10 @@ layout_mode = 2 layout_mode = 2 text = "Material: ###" -[node name="QualityLabel" type="Label" parent="MarginContainer/MainArea/PrintInfo/InfoRow1" unique_id=1362675397] +[node name="QualityLabel" type="RichTextLabel" parent="MarginContainer/MainArea/PrintInfo/InfoRow1" unique_id=937206053] layout_mode = 2 size_flags_horizontal = 3 +bbcode_enabled = true text = "Print quality: ###%" horizontal_alignment = 2 @@ -63,9 +69,10 @@ layout_mode = 2 layout_mode = 2 text = "Time left: ###s" -[node name="RewardLabel" type="Label" parent="MarginContainer/MainArea/PrintInfo/InfoRow2" unique_id=1767576134] +[node name="RewardLabel" type="RichTextLabel" parent="MarginContainer/MainArea/PrintInfo/InfoRow2" unique_id=700892606] layout_mode = 2 size_flags_horizontal = 3 +bbcode_enabled = true text = "Reward: ###€" horizontal_alignment = 2 diff --git a/Scenes/Shop/Filaments/shop_filament_card.gd b/Scenes/Shop/Filaments/shop_filament_card.gd new file mode 100644 index 0000000..2b0bdcf --- /dev/null +++ b/Scenes/Shop/Filaments/shop_filament_card.gd @@ -0,0 +1,34 @@ +extends PanelContainer + +signal buy_filament + +var filament_data: FilamentData +@onready var filament_material: Label = %Material +@onready var description: Label = %Description +@onready var reward_multiplier: Label = %RewardMultiplier +@onready var xp_multiplier: Label = %ExperienceMultiplier +@onready var amount: Label = %Amount +@onready var price_tag: Label = %PriceTag +@onready var buy_button: Button = $Margin/Info/Price/BuyButton + + +func _ready() -> void: + PlayerData.money_changed.connect(_on_toggle_button) + +func initialize_filament(data: FilamentData) -> void: + filament_data = data + filament_material.text = filament_data.material + description.text = filament_data.description + reward_multiplier.text = 'Reward multiplier: x%.1f' % filament_data.reward_multiplier + xp_multiplier.text = 'Experience multiplier: x%.1f' % filament_data.xp_multiplier + amount.text = 'Amount: %.0f g' % filament_data.amount + price_tag.text = 'Price: %.2f €' % filament_data.price + +func _on_buy_button_pressed() -> void: + buy_filament.emit(self) + +func _on_toggle_button(money) -> void: + if PlayerData.money >= filament_data.price: + buy_button.disabled = false + else: + buy_button.disabled = true diff --git a/Scenes/Shop/Filaments/shop_filament_card.gd.uid b/Scenes/Shop/Filaments/shop_filament_card.gd.uid new file mode 100644 index 0000000..a023980 --- /dev/null +++ b/Scenes/Shop/Filaments/shop_filament_card.gd.uid @@ -0,0 +1 @@ +uid://o733qdkp8lxl diff --git a/Scenes/Shop/Filaments/shop_filaments_card.tscn b/Scenes/Shop/Filaments/shop_filaments_card.tscn new file mode 100644 index 0000000..8df8421 --- /dev/null +++ b/Scenes/Shop/Filaments/shop_filaments_card.tscn @@ -0,0 +1,76 @@ +[gd_scene format=3 uid="uid://csq76iufxrb4y"] + +[ext_resource type="Script" uid="uid://o733qdkp8lxl" path="res://Scenes/Shop/Filaments/shop_filament_card.gd" id="1_gtjvs"] + +[node name="FilamentsCard" type="PanelContainer" unique_id=368185874] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_gtjvs") + +[node name="Margin" type="MarginContainer" parent="." unique_id=1163688479] +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="Info" type="VBoxContainer" parent="Margin" unique_id=1453497579] +layout_mode = 2 + +[node name="Title" type="VBoxContainer" parent="Margin/Info" unique_id=1904589169] +layout_mode = 2 + +[node name="Material" type="Label" parent="Margin/Info/Title" unique_id=24143253] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "LOL-CF" + +[node name="Description" type="Label" parent="Margin/Info/Title" unique_id=870869096] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Filament description goes here" + +[node name="Multipliers" type="HBoxContainer" parent="Margin/Info" unique_id=2026319482] +layout_mode = 2 + +[node name="RewardMultiplier" type="Label" parent="Margin/Info/Multipliers" unique_id=867010603] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Reward multiplier: x1.0" + +[node name="ExperienceMultiplier" type="Label" parent="Margin/Info/Multipliers" unique_id=1033367043] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Experience multiplier: x1.0" + +[node name="ProductInfo" type="HBoxContainer" parent="Margin/Info" unique_id=1243250288] +layout_mode = 2 + +[node name="Amount" type="Label" parent="Margin/Info/ProductInfo" unique_id=1356405418] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Amount: 123 g" + +[node name="Price" type="HBoxContainer" parent="Margin/Info" unique_id=926000726] +layout_mode = 2 + +[node name="PriceTag" type="Label" parent="Margin/Info/Price" unique_id=881459224] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +text = "Price: 1.23 €" + +[node name="BuyButton" type="Button" parent="Margin/Info/Price" unique_id=780730344] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Buy" + +[connection signal="pressed" from="Margin/Info/Price/BuyButton" to="." method="_on_buy_button_pressed"] diff --git a/Scenes/Shop/Printers/printer_card.gd b/Scenes/Shop/Printers/shop_printer_card.gd similarity index 100% rename from Scenes/Shop/Printers/printer_card.gd rename to Scenes/Shop/Printers/shop_printer_card.gd diff --git a/Scenes/Shop/Printers/printer_card.gd.uid b/Scenes/Shop/Printers/shop_printer_card.gd.uid similarity index 100% rename from Scenes/Shop/Printers/printer_card.gd.uid rename to Scenes/Shop/Printers/shop_printer_card.gd.uid diff --git a/Scenes/Shop/Printers/printers.gd b/Scenes/Shop/Printers/shop_printers.gd similarity index 100% rename from Scenes/Shop/Printers/printers.gd rename to Scenes/Shop/Printers/shop_printers.gd diff --git a/Scenes/Shop/Printers/printers.gd.uid b/Scenes/Shop/Printers/shop_printers.gd.uid similarity index 100% rename from Scenes/Shop/Printers/printers.gd.uid rename to Scenes/Shop/Printers/shop_printers.gd.uid diff --git a/Scenes/Shop/Printers/printers_card.tscn b/Scenes/Shop/Printers/shop_printers_card.tscn similarity index 93% rename from Scenes/Shop/Printers/printers_card.tscn rename to Scenes/Shop/Printers/shop_printers_card.tscn index d904ada..86ac521 100644 --- a/Scenes/Shop/Printers/printers_card.tscn +++ b/Scenes/Shop/Printers/shop_printers_card.tscn @@ -1,11 +1,14 @@ [gd_scene format=3 uid="uid://bdpqvwvwmaian"] -[ext_resource type="Script" uid="uid://ttfk4n2fkifj" path="res://Scenes/Shop/Printers/printer_card.gd" id="1_tl8ce"] +[ext_resource type="Script" uid="uid://ttfk4n2fkifj" path="res://Scenes/Shop/Printers/shop_printer_card.gd" id="1_tl8ce"] [ext_resource type="StyleBox" uid="uid://csahw36txnewl" path="res://Styles/btn_style_box_green_hover.tres" id="2_tl8ce"] [node name="PrinterCard" type="PanelContainer" unique_id=1714388686] -offset_right = 40.0 -offset_bottom = 40.0 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 size_flags_horizontal = 3 script = ExtResource("1_tl8ce") diff --git a/Scenes/UI/shop_filaments.gd b/Scenes/UI/shop_filaments.gd new file mode 100644 index 0000000..564e432 --- /dev/null +++ b/Scenes/UI/shop_filaments.gd @@ -0,0 +1,22 @@ +extends PanelContainer + +signal filament_purchase_requested(filament_data: FilamentData) + +@export var filaments_array: Array[FilamentData] +const SHOP_FILAMENTS_CARD = preload("uid://csq76iufxrb4y") + + +func _ready() -> void: + generate_filaments() + filament_purchase_requested.connect(GameData._on_shop_filament_purchase_req) + +func generate_filaments() -> void: + for filament in filaments_array: + if PlayerData.level >= filament.level_req: + var new_filament = SHOP_FILAMENTS_CARD.instantiate() + %FilamentList.add_child(new_filament) + new_filament.initialize_filament(filament) + new_filament.buy_filament.connect(_on_buy_filament_pressed) + +func _on_buy_filament_pressed(bought_filament) -> void: + filament_purchase_requested.emit(bought_filament) diff --git a/Scenes/UI/shop_filaments.gd.uid b/Scenes/UI/shop_filaments.gd.uid new file mode 100644 index 0000000..0ba3d74 --- /dev/null +++ b/Scenes/UI/shop_filaments.gd.uid @@ -0,0 +1 @@ +uid://bcowlm04qsgqc diff --git a/Scenes/UI/ui.tscn b/Scenes/UI/ui.tscn index 9e9f579..bfb7722 100644 --- a/Scenes/UI/ui.tscn +++ b/Scenes/UI/ui.tscn @@ -1,9 +1,10 @@ [gd_scene format=3 uid="uid://d24rvu5c0gd1w"] [ext_resource type="Script" uid="uid://d0sgvbphgssmi" path="res://Scenes/UI/ui.gd" id="1_vqjbf"] +[ext_resource type="Script" uid="uid://bcowlm04qsgqc" path="res://Scenes/UI/shop_filaments.gd" id="9_mbl0m"] [ext_resource type="Script" uid="uid://q8cf21vq4ka6" path="res://Scenes/tab_switcher.gd" id="13_vqjbf"] [ext_resource type="Script" uid="uid://cg2kskiky8iur" path="res://Scenes/Shop/shop_tab_switcher.gd" id="14_vqjbf"] -[ext_resource type="Script" uid="uid://d3g5e8wjfqy5i" path="res://Scenes/Shop/Printers/printers.gd" id="15_vqjbf"] +[ext_resource type="Script" uid="uid://d3g5e8wjfqy5i" path="res://Scenes/Shop/Printers/shop_printers.gd" id="15_vqjbf"] [ext_resource type="Script" uid="uid://bed8wdnwod4wu" path="res://Resources/printer_data.gd" id="16_rdojl"] [ext_resource type="Resource" uid="uid://bdis2u0tfvlch" path="res://Resources/Printers/printer_bambulab_A1_mini.tres" id="17_llrls"] [ext_resource type="Resource" uid="uid://b6x4k150ugskw" path="res://Resources/Printers/printer_creality_ender_3.tres" id="18_8rt22"] @@ -295,6 +296,7 @@ unique_name_in_owner = true layout_mode = 2 size_flags_vertical = 3 theme_override_styles/panel = SubResource("StyleBoxFlat_mmlst") +script = ExtResource("9_mbl0m") [node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Filaments" unique_id=1087434821] layout_mode = 2