Compare commits
4 commits
81610a3cb0
...
a540ae1f83
| Author | SHA1 | Date | |
|---|---|---|---|
| a540ae1f83 | |||
| b918871be2 | |||
| da014a5341 | |||
| 8fd7d0131c |
15 changed files with 120 additions and 26 deletions
|
|
@ -8,5 +8,6 @@ printer_manufacturer = "Bambulab"
|
|||
printer_type = "A1 Mini"
|
||||
printer_speed = 4.0
|
||||
printer_quality = 3.5
|
||||
printer_level_req = 5
|
||||
printer_price = 350.0
|
||||
metadata/_custom_type_script = "uid://bed8wdnwod4wu"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
script = ExtResource("1_nuksd")
|
||||
printer_manufacturer = "Creality"
|
||||
printer_type = "Ender-3 V3 SE"
|
||||
printer_speed = 2.0
|
||||
printer_quality = 2.0
|
||||
printer_speed = 1.0
|
||||
printer_quality = 1.0
|
||||
printer_price = 200.0
|
||||
metadata/_custom_type_script = "uid://bed8wdnwod4wu"
|
||||
|
|
|
|||
|
|
@ -8,5 +8,6 @@ printer_manufacturer = "Prusa Research"
|
|||
printer_type = "MK4S"
|
||||
printer_speed = 4.5
|
||||
printer_quality = 5.0
|
||||
printer_level_req = 10
|
||||
printer_price = 850.0
|
||||
metadata/_custom_type_script = "uid://bed8wdnwod4wu"
|
||||
|
|
|
|||
|
|
@ -5,4 +5,5 @@ extends Resource
|
|||
@export var printer_type: String
|
||||
@export_range(1, 5) var printer_speed: float
|
||||
@export_range(1, 5) var printer_quality: float
|
||||
@export var printer_level_req: int = 1
|
||||
@export var printer_price: float
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ func _on_shop_printer_purchase_req(printer_data: PrinterData) -> void:
|
|||
var new_printer = PRINTER.instantiate()
|
||||
printer_bought.emit(new_printer)
|
||||
new_printer.initialize_printer(printer_data)
|
||||
PlayerData.owned_printers += 1
|
||||
|
||||
|
||||
#region Job generation
|
||||
|
|
@ -76,10 +77,8 @@ func generate_random_job() -> JobData:
|
|||
new_job.job_experience = random_job.job_experience * amount
|
||||
new_job.job_difficulty = random_job.job_difficulty
|
||||
new_job.job_amount = roundf(amount)
|
||||
|
||||
#print('Random amount: %.2f' % amount)
|
||||
#print('Job amount: %.2f' % new_job.job_amount)
|
||||
print('Generated new job: %s (%d € | %d xp | %d pcs)' % [new_job.job_name, new_job.job_reward, new_job.job_experience, new_job.job_amount])
|
||||
|
||||
#print('Generated new job: %s (%d € | %d xp | %d pcs)' % [new_job.job_name, new_job.job_reward, new_job.job_experience, new_job.job_amount])
|
||||
return new_job
|
||||
|
||||
func _on_job_accepted_pressed(accepted_job) -> void:
|
||||
|
|
|
|||
|
|
@ -5,21 +5,26 @@ var xp: float = 0:
|
|||
xp = value
|
||||
xp_changed.emit(xp)
|
||||
|
||||
var money: float = 500:
|
||||
var money: float = 200:
|
||||
set(value):
|
||||
money = value
|
||||
money_changed.emit(money)
|
||||
|
||||
var level: int = 0:
|
||||
var level: int = 1:
|
||||
set(value):
|
||||
level = value
|
||||
level_changed.emit(level)
|
||||
|
||||
var max_order_amount: int = 10:
|
||||
var max_order_amount: int = 3:
|
||||
set(value):
|
||||
max_order_amount = value
|
||||
max_order_amount_changed.emit(max_order_amount)
|
||||
|
||||
var owned_printers: int = 0:
|
||||
set(value):
|
||||
owned_printers = value
|
||||
owned_printers_changed.emit(value)
|
||||
|
||||
var sell_multiplier: float = 0.5
|
||||
|
||||
var jobs: Array[JobData]
|
||||
|
|
@ -29,6 +34,7 @@ signal xp_changed(new_xp)
|
|||
signal money_changed(new_money)
|
||||
signal level_changed(new_level)
|
||||
signal max_order_amount_changed(new_max_order_amount)
|
||||
signal owned_printers_changed(new_amount)
|
||||
|
||||
# Signal - functions
|
||||
signal give_experience(xp_amount)
|
||||
|
|
@ -41,14 +47,23 @@ func _ready() -> void:
|
|||
func _on_give_experience(amount: float) -> void:
|
||||
print('Gave: %.0f xp' % amount)
|
||||
xp += amount
|
||||
if xp >= 100:
|
||||
while xp >= 100:
|
||||
level += 1
|
||||
xp -= 100
|
||||
|
||||
while xp >= xp_required_for_level(level):
|
||||
xp -= xp_required_for_level(level)
|
||||
level += 1
|
||||
|
||||
func _on_give_money(amount: float) -> void:
|
||||
money += amount
|
||||
|
||||
func xp_required_for_level(player_level: int) -> float:
|
||||
if player_level == 1:
|
||||
return 100.0
|
||||
|
||||
var base_xp = 100 * (player_level - 1)
|
||||
var exponent_xp = pow(player_level - 1, 1.8) * 25
|
||||
|
||||
return float(base_xp + exponent_xp)
|
||||
|
||||
func try_purchase(amount) -> bool:
|
||||
if amount <= money:
|
||||
money -= amount
|
||||
|
|
|
|||
|
|
@ -11,7 +11,11 @@ var job_material: String
|
|||
@onready var job_experience: Label = $MarginContainer/VBoxContainer/HBoxContainer3/PartExperience
|
||||
@onready var job_time_label: Label = $MarginContainer/VBoxContainer/HBoxContainer/TimeLabel
|
||||
@onready var job_material_label: Label = $MarginContainer/VBoxContainer/HBoxContainer2/PartMaterial
|
||||
@onready var skip_job_button: Button = $MarginContainer/VBoxContainer/HBoxContainer/SkipJob
|
||||
|
||||
func _ready() -> void:
|
||||
PlayerData.owned_printers_changed.connect(_on_owned_printers_changed)
|
||||
_on_owned_printers_changed(PlayerData.owned_printers)
|
||||
|
||||
func initialize_job(data: JobData) -> void:
|
||||
job_data = data
|
||||
|
|
@ -37,6 +41,12 @@ func calculate_time() -> String:
|
|||
else:
|
||||
return '%.2f s' % round_time
|
||||
|
||||
func _on_owned_printers_changed(owned_printers: int) -> void:
|
||||
if owned_printers == 0:
|
||||
skip_job_button.disabled = true
|
||||
return
|
||||
skip_job_button.disabled = false
|
||||
|
||||
func _on_accept_job_pressed() -> void:
|
||||
job_accepted.emit(self)
|
||||
GameData.refresh_printer_dropdown.emit()
|
||||
|
|
|
|||
|
|
@ -50,14 +50,14 @@ func _process(delta) -> void:
|
|||
|
||||
func reset_status() -> void:
|
||||
is_printing = false
|
||||
_on_select_job_pressed()
|
||||
set_status()
|
||||
time_left_label.visible = false
|
||||
progress_bar.visible = false
|
||||
progress_bar.value = 0
|
||||
time_left = 0
|
||||
select_job.disabled = false
|
||||
start_button.disabled = false
|
||||
_on_select_job_pressed()
|
||||
set_status()
|
||||
|
||||
func set_status() -> void:
|
||||
if is_printing:
|
||||
|
|
@ -84,6 +84,7 @@ func _on_refresh_printer_dropdown() -> void:
|
|||
|
||||
func _on_sell_button_pressed() -> void:
|
||||
PlayerData.give_money.emit(printer_data.printer_price * PlayerData.sell_multiplier)
|
||||
PlayerData.owned_printers -= 1
|
||||
queue_free()
|
||||
|
||||
func _on_select_job_pressed() -> void:
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ text = "Time left: 15.0"
|
|||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="MarginContainer/MainArea/PrintInfo" unique_id=768246659]
|
||||
layout_mode = 2
|
||||
theme_override_styles/fill = ExtResource("2_dlbos")
|
||||
max_value = 1.0
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="MarginContainer/MainArea" unique_id=248340191]
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ func initialize_printer(data: PrinterData) -> void:
|
|||
printer_data = data
|
||||
printer_name.text = printer_data.printer_manufacturer
|
||||
printer_model.text = printer_data.printer_type
|
||||
printer_speed.text = 'Speed: %d/5' % printer_data.printer_speed
|
||||
printer_quality.text = 'Quality: %d/5' % printer_data.printer_quality
|
||||
printer_speed.text = 'Speed: %d/5' % roundf(printer_data.printer_speed)
|
||||
printer_quality.text = 'Quality: %d/5' % roundf(printer_data.printer_quality)
|
||||
printer_price.text = 'Price: %d €' % printer_data.printer_price
|
||||
|
||||
if PlayerData.money >= printer_data.printer_price:
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ const PRINTER_SCENE = preload("uid://bdpqvwvwmaian")
|
|||
|
||||
func _ready() -> void:
|
||||
generate_printers()
|
||||
generate_printers()
|
||||
|
||||
printer_purchase_requested.connect(GameData._on_shop_printer_purchase_req)
|
||||
|
||||
func generate_printers() -> void:
|
||||
for printer in printers_array:
|
||||
var new_printer = PRINTER_SCENE.instantiate()
|
||||
%PrinterList.add_child(new_printer)
|
||||
new_printer.initialize_printer(printer)
|
||||
new_printer.buy_printer.connect(_buy_printer_pressed)
|
||||
if PlayerData.level >= printer.printer_level_req:
|
||||
var new_printer = PRINTER_SCENE.instantiate()
|
||||
%PrinterList.add_child(new_printer)
|
||||
new_printer.initialize_printer(printer)
|
||||
new_printer.buy_printer.connect(_buy_printer_pressed)
|
||||
|
||||
func _buy_printer_pressed(bought_printer) -> void:
|
||||
printer_purchase_requested.emit(bought_printer.printer_data)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,29 @@
|
|||
extends MarginContainer
|
||||
|
||||
@onready var printers_button: Button = $HBoxContainer/PrintersButton
|
||||
@onready var filaments_button: Button = $HBoxContainer/FilamentsButton
|
||||
|
||||
func _ready() -> void:
|
||||
%Printers.visible = true
|
||||
%Filaments.visible = false
|
||||
disable_buttons("printers")
|
||||
|
||||
func _on_printers_button_pressed() -> void:
|
||||
%Printers.visible = true
|
||||
%Filaments.visible = false
|
||||
disable_buttons("printers")
|
||||
|
||||
func _on_filaments_button_pressed() -> void:
|
||||
%Printers.visible = false
|
||||
%Filaments.visible = true
|
||||
disable_buttons("filaments")
|
||||
|
||||
func disable_buttons(tab: String) -> void:
|
||||
printers_button.disabled = true
|
||||
filaments_button.disabled = true
|
||||
|
||||
match tab:
|
||||
"printers":
|
||||
filaments_button.disabled = false
|
||||
"filaments":
|
||||
printers_button.disabled = false
|
||||
|
|
|
|||
|
|
@ -25,9 +25,13 @@ func _ready() -> void:
|
|||
|
||||
# --- Experience, Level and Money update ---
|
||||
func _on_xp_changed(xp) -> void:
|
||||
%Experience.value = xp
|
||||
var target_xp = PlayerData.xp_required_for_level(PlayerData.level)
|
||||
var required_xp_to_value = (float(PlayerData.xp) / target_xp) * 100
|
||||
%Experience.value = required_xp_to_value
|
||||
|
||||
func _on_level_changed(level) -> void:
|
||||
%Level.text = 'Level: %d' % level
|
||||
|
||||
func _on_money_changed(money) -> void:
|
||||
%Money.text = 'Money: %.2f €' % money
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ bg_color = Color(0.6, 0.6, 0.6, 0)
|
|||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qru7b"]
|
||||
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mmlst"]
|
||||
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||
|
||||
[node name="UI" type="Control" unique_id=256887379]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
|
@ -213,7 +216,6 @@ theme_override_constants/separation = 8
|
|||
|
||||
[node name="ShopTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=23859514]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_vqjbf")
|
||||
|
||||
|
|
@ -243,6 +245,7 @@ text = "Filaments"
|
|||
|
||||
[node name="Printers" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer" unique_id=1896524960]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_qru7b")
|
||||
|
|
@ -271,6 +274,26 @@ theme_override_constants/separation = 8
|
|||
[node name="Filaments" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer" unique_id=1891341317]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mmlst")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Filaments" unique_id=1087434821]
|
||||
layout_mode = 2
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Filaments/ScrollContainer" unique_id=1350479691]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
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="FilamentList" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Filaments/ScrollContainer/MarginContainer" unique_id=1017092781]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="MenuTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=526907583]
|
||||
unique_name_in_owner = true
|
||||
|
|
@ -288,5 +311,3 @@ autostart = true
|
|||
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons/MenuTabButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher" method="_on_menu_tab_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/PrintersButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_printers_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/FilamentsButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_filaments_button_pressed"]
|
||||
[connection signal="printer_purchase_requested" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Printers" to="." method="_on_printers_printer_purchase_requested"]
|
||||
[connection signal="timeout" from="JobSpawner" to="." method="_on_job_spawner_timeout"]
|
||||
|
|
|
|||
|
|
@ -1,21 +1,45 @@
|
|||
extends MarginContainer
|
||||
|
||||
@onready var jobs_tab_button: Button = $TabButtons/JobsTabButton
|
||||
@onready var shop_tab_button: Button = $TabButtons/ShopTabButton
|
||||
@onready var menu_tab_button: Button = $TabButtons/MenuTabButton
|
||||
|
||||
func _ready() -> void:
|
||||
%JobsTab.visible = true
|
||||
%ShopTab.visible = false
|
||||
%MenuTab.visible = false
|
||||
disable_buttons("jobs")
|
||||
|
||||
func _on_jobs_tab_button_pressed() -> void:
|
||||
%JobsTab.visible = true
|
||||
%ShopTab.visible = false
|
||||
%MenuTab.visible = false
|
||||
disable_buttons("jobs")
|
||||
|
||||
func _on_shop_tab_button_pressed() -> void:
|
||||
%JobsTab.visible = false
|
||||
%ShopTab.visible = true
|
||||
%MenuTab.visible = false
|
||||
disable_buttons("shop")
|
||||
|
||||
func _on_menu_tab_button_pressed() -> void:
|
||||
%JobsTab.visible = false
|
||||
%ShopTab.visible = false
|
||||
%MenuTab.visible = true
|
||||
disable_buttons("menu")
|
||||
|
||||
func disable_buttons(tab: String) -> void:
|
||||
jobs_tab_button.disabled = true
|
||||
shop_tab_button.disabled = true
|
||||
menu_tab_button.disabled = true
|
||||
|
||||
match tab:
|
||||
"jobs":
|
||||
shop_tab_button.disabled = false
|
||||
menu_tab_button.disabled = false
|
||||
"shop":
|
||||
jobs_tab_button.disabled = false
|
||||
menu_tab_button.disabled = false
|
||||
"menu":
|
||||
jobs_tab_button.disabled = false
|
||||
shop_tab_button.disabled = false
|
||||
|
|
|
|||
Loading…
Reference in a new issue