Reworked failure condition while printin. Added filaments
This commit is contained in:
parent
5562774716
commit
55afdc4b33
11 changed files with 117 additions and 24 deletions
13
Resources/Filaments/filament_abs.tres
Normal file
13
Resources/Filaments/filament_abs.tres
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="FilamentData" format=3 uid="uid://gmby6rjd07wi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cim8peoxip2si" path="res://Resources/filament_data.gd" id="1_uvxfr"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_uvxfr")
|
||||
material = "ABS - Small"
|
||||
reward_multiplier = 1.0
|
||||
xp_multiplier = 1.0
|
||||
amount = 200.0
|
||||
price = 4.18
|
||||
description = "ABS filament for industrial applications"
|
||||
metadata/_custom_type_script = "uid://cim8peoxip2si"
|
||||
14
Resources/Filaments/filament_asa-cf.tres
Normal file
14
Resources/Filaments/filament_asa-cf.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_resource type="Resource" script_class="FilamentData" format=3 uid="uid://gm0cqq0ggri"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cim8peoxip2si" path="res://Resources/filament_data.gd" id="1_ws0fq"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ws0fq")
|
||||
material = "ASA-CF - Small"
|
||||
reward_multiplier = 1.0
|
||||
xp_multiplier = 1.0
|
||||
amount = 200.0
|
||||
price = 7.74
|
||||
description = "Carbon fibre-reinforced ASA to withstand extreme performance"
|
||||
level_req = 3
|
||||
metadata/_custom_type_script = "uid://cim8peoxip2si"
|
||||
13
Resources/Filaments/filament_asa.tres
Normal file
13
Resources/Filaments/filament_asa.tres
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_resource type="Resource" script_class="FilamentData" format=3 uid="uid://cwtaryim1yjnu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cim8peoxip2si" path="res://Resources/filament_data.gd" id="1_02q3j"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_02q3j")
|
||||
material = "ASA - Small"
|
||||
reward_multiplier = 1.0
|
||||
xp_multiplier = 1.0
|
||||
amount = 200.0
|
||||
price = 5.3
|
||||
description = "Weather and UV resistant ASA filament"
|
||||
metadata/_custom_type_script = "uid://cim8peoxip2si"
|
||||
14
Resources/Filaments/filament_petg.tres
Normal file
14
Resources/Filaments/filament_petg.tres
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_resource type="Resource" script_class="FilamentData" format=3 uid="uid://vuby4u37cu42"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cim8peoxip2si" path="res://Resources/filament_data.gd" id="1_w3dqi"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_w3dqi")
|
||||
material = "PETG - Small"
|
||||
reward_multiplier = 1.0
|
||||
xp_multiplier = 1.0
|
||||
amount = 200.0
|
||||
price = 5.23
|
||||
description = "PETG filament for robust & precise prints"
|
||||
level_req = 2
|
||||
metadata/_custom_type_script = "uid://cim8peoxip2si"
|
||||
|
|
@ -95,7 +95,6 @@ func generate_random_job() -> JobData:
|
|||
new_job.job_difficulty = random_job.job_difficulty
|
||||
new_job.job_amount = roundf(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:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ var sell_multiplier: float = 0.5:
|
|||
set(value):
|
||||
sell_multiplier = value
|
||||
|
||||
var failure_chance: float = 0.2:
|
||||
var failure_chance: float = 0.6:
|
||||
set(value):
|
||||
failure_chance = value
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ var printer_data: PrinterData
|
|||
var selected_job: JobData
|
||||
var selected_job_index: int
|
||||
var is_printing: bool = false
|
||||
var print_failed: bool = false
|
||||
var time_left: float
|
||||
var failure_points: Array
|
||||
|
||||
# Variables - Failure calculations
|
||||
var print_failed: bool = false
|
||||
var failure_points: Array
|
||||
var failure_point_amount: float = 5
|
||||
var print_quality: float = 1.0
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -46,8 +48,12 @@ func _process(delta) -> void:
|
|||
reward_label.visible = true
|
||||
set_status()
|
||||
|
||||
quality_label.text = 'Quality: [color=%s]%.0f%%[/color]' % [GameData.hex_green, (print_quality * 100)]
|
||||
reward_label.text = 'Reward: [color=%s]%.2f €[/color]' % [GameData.hex_green, (selected_job.job_reward * print_quality)]
|
||||
var text_color = GameData.hex_green
|
||||
if print_quality < 1.0:
|
||||
text_color = GameData.hex_red
|
||||
|
||||
quality_label.text = 'Quality: [color=%s]%.0f%%[/color]' % [text_color, (print_quality * 100)]
|
||||
reward_label.text = 'Reward: [color=%s]%.2f €[/color]' % [text_color, (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
|
||||
|
|
@ -57,16 +63,25 @@ func _process(delta) -> void:
|
|||
time_left_label.text = 'Time left: %s' % calculate_time_left(time_left)
|
||||
|
||||
if time_left <= 0:
|
||||
PlayerData.give_money.emit(selected_job.job_reward * print_quality)
|
||||
PlayerData.give_experience.emit(selected_job.job_experience * print_quality)
|
||||
var end_reward = selected_job.job_reward * print_quality
|
||||
var end_xp = selected_job.job_experience * print_quality
|
||||
PlayerData.give_money.emit(end_reward)
|
||||
PlayerData.give_experience.emit(end_xp)
|
||||
GameData.display_msg('Print completed! Got %.2f €' % end_reward, GameData.hex_green)
|
||||
reset_status()
|
||||
|
||||
# Old print failure condition - 1st Fail, 2nd + 3rd Quality decrease
|
||||
#if failure_points.has(roundf(progress_bar.value * 100)):
|
||||
#if failure_points[0] == roundf(progress_bar.value * 100):
|
||||
#if check_failure(roundf(progress_bar.value * 100)):
|
||||
#print_failed = true
|
||||
#reset_status()
|
||||
#elif check_failure(roundf(progress_bar.value * 100)):
|
||||
#print_quality -= 0.1
|
||||
|
||||
# New print failure condition - Only quality decrease
|
||||
if failure_points.has(roundf(progress_bar.value * 100)):
|
||||
if failure_points[0] == roundf(progress_bar.value * 100):
|
||||
if check_failure(roundf(progress_bar.value * 100)):
|
||||
print_failed = true
|
||||
reset_status()
|
||||
elif check_failure(roundf(progress_bar.value * 100)):
|
||||
print_quality -= 0.1
|
||||
|
||||
func reset_status() -> void:
|
||||
|
|
@ -99,15 +114,20 @@ func set_status() -> void:
|
|||
else:
|
||||
status = 'Free'
|
||||
color_hex = GameData.hex_green
|
||||
GameData.display_msg('Print completed!',color_hex)
|
||||
|
||||
status_label.text = 'Status: [color=%s]%s[/color]' % [color_hex, status]
|
||||
|
||||
func calculate_fail_thresholds() -> Array:
|
||||
var failure_checkpoints: Array = []
|
||||
failure_checkpoints.append(roundf(randf_range(1,33)))
|
||||
failure_checkpoints.append(roundf(randf_range(34,66)))
|
||||
failure_checkpoints.append(roundf(randf_range(67,90)))
|
||||
var failure_range = roundf(100.0 / failure_point_amount)
|
||||
|
||||
for point in failure_point_amount:
|
||||
var range_min = failure_checkpoints.size() * (failure_range + 1)
|
||||
var range_max = failure_checkpoints.size() * (failure_range + 1) + failure_range
|
||||
failure_checkpoints.append(roundf(randf_range(\
|
||||
range_min, range_max)))
|
||||
|
||||
print('Failure points: ', failure_checkpoints)
|
||||
return failure_checkpoints
|
||||
|
||||
func check_failure(value: float) -> bool:
|
||||
|
|
@ -131,7 +151,6 @@ func calculate_time_left(time) -> String:
|
|||
func _on_refresh_printer_dropdown() -> void:
|
||||
if is_printing:
|
||||
return
|
||||
|
||||
_on_select_job_pressed()
|
||||
|
||||
func _on_sell_button_pressed() -> void:
|
||||
|
|
@ -147,7 +166,8 @@ func _on_select_job_pressed() -> void:
|
|||
else:
|
||||
start_button.disabled = false
|
||||
for job in PlayerData.jobs:
|
||||
var item_text = '%s (XP: %d | %d € | %s)' % [job.job_name, job.job_experience, job.job_reward, calculate_time_left(job.job_time / printer_data.printer_speed)]
|
||||
var item_text = '%s (XP: %.2f | %.2f € | %s)' %\
|
||||
[job.job_name, job.job_experience, job.job_reward, calculate_time_left(job.job_time / printer_data.printer_speed)]
|
||||
select_job.add_item(item_text)
|
||||
|
||||
var current_index = select_job.item_count - 1
|
||||
|
|
@ -174,5 +194,4 @@ func _on_start_button_pressed() -> void:
|
|||
PlayerData.jobs.remove_at(selected_job_index)
|
||||
|
||||
failure_points = calculate_fail_thresholds()
|
||||
print('Failure points: ', failure_points)
|
||||
GameData.refresh_printer_dropdown.emit()
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@ const SHOP_FILAMENTS_CARD = preload("uid://csq76iufxrb4y")
|
|||
func _ready() -> void:
|
||||
generate_filaments()
|
||||
filament_purchase_requested.connect(GameData._on_shop_filament_purchase_req)
|
||||
PlayerData.level_changed.connect(_on_level_changed)
|
||||
|
||||
func generate_filaments() -> void:
|
||||
for child in %FilamentList.get_children():
|
||||
child.queue_free()
|
||||
for filament in filaments_array:
|
||||
if PlayerData.level >= filament.level_req:
|
||||
var new_filament = SHOP_FILAMENTS_CARD.instantiate()
|
||||
|
|
@ -19,4 +22,7 @@ func generate_filaments() -> void:
|
|||
new_filament.buy_filament.connect(_on_buy_filament_pressed)
|
||||
|
||||
func _on_buy_filament_pressed(bought_filament) -> void:
|
||||
filament_purchase_requested.emit(bought_filament)
|
||||
filament_purchase_requested.emit(bought_filament.filament_data)
|
||||
|
||||
func _on_level_changed(_level) -> void:
|
||||
generate_filaments()
|
||||
|
|
@ -5,11 +5,15 @@ signal printer_purchase_requested(printer_data: PrinterData)
|
|||
@export var printers_array: Array[PrinterData]
|
||||
const PRINTER_SCENE = preload("uid://bdpqvwvwmaian")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
generate_printers()
|
||||
printer_purchase_requested.connect(GameData._on_shop_printer_purchase_req)
|
||||
PlayerData.level_changed.connect(_on_level_changed)
|
||||
|
||||
func generate_printers() -> void:
|
||||
for child in %PrinterList.get_children():
|
||||
child.queue_free()
|
||||
for printer in printers_array:
|
||||
if PlayerData.level >= printer.printer_level_req:
|
||||
var new_printer = PRINTER_SCENE.instantiate()
|
||||
|
|
@ -19,3 +23,6 @@ func generate_printers() -> void:
|
|||
|
||||
func _buy_printer_pressed(bought_printer) -> void:
|
||||
printer_purchase_requested.emit(bought_printer.printer_data)
|
||||
|
||||
func _on_level_changed(_level) -> void:
|
||||
generate_printers()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
[ext_resource type="Script" uid="uid://d0sgvbphgssmi" path="res://Scenes/UI/ui.gd" id="1_vqjbf"]
|
||||
[ext_resource type="PackedScene" uid="uid://c4tdg221rvm53" path="res://Scenes/UI/ui_notification.tscn" id="2_s3gqk"]
|
||||
[ext_resource type="Script" uid="uid://bcowlm04qsgqc" path="res://Scenes/UI/shop_filaments.gd" id="9_mbl0m"]
|
||||
[ext_resource type="Script" uid="uid://bcowlm04qsgqc" path="res://Scenes/Shop/Printers/shop_filaments.gd" id="9_mbl0m"]
|
||||
[ext_resource type="Script" uid="uid://cim8peoxip2si" path="res://Resources/filament_data.gd" id="10_vy225"]
|
||||
[ext_resource type="Resource" uid="uid://dvu3hbx3tn0nx" path="res://Resources/Filaments/filament_pla.tres" id="11_fy0us"]
|
||||
[ext_resource type="Resource" uid="uid://vuby4u37cu42" path="res://Resources/Filaments/filament_petg.tres" id="12_fy0us"]
|
||||
[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/shop_printers.gd" id="15_vqjbf"]
|
||||
|
|
@ -215,6 +218,7 @@ theme_override_constants/margin_bottom = 10
|
|||
|
||||
[node name="JobsTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=859027615]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_cqvjp")
|
||||
|
||||
|
|
@ -238,6 +242,9 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="JobCard" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/JobsTab/JobScroll/MarginContainer/JobContainer" unique_id=1714388686 instance_placeholder="res://Scenes/Job/job_card.tscn"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ShopTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=23859514]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
|
@ -301,6 +308,7 @@ layout_mode = 2
|
|||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mmlst")
|
||||
script = ExtResource("9_mbl0m")
|
||||
filaments_array = Array[ExtResource("10_vy225")]([ExtResource("11_fy0us"), ExtResource("12_fy0us")])
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Filaments" unique_id=1087434821]
|
||||
layout_mode = 2
|
||||
|
|
|
|||
Loading…
Reference in a new issue