Fixes for multiple printer interaction and job selections
This commit is contained in:
parent
7450dd39cb
commit
72a25238d3
6 changed files with 40 additions and 43 deletions
|
|
@ -4,6 +4,8 @@ extends Node
|
|||
signal job_generated(job: Node)
|
||||
signal job_interact
|
||||
signal printer_bought(printer: Node)
|
||||
@warning_ignore("unused_signal")
|
||||
signal print_started
|
||||
|
||||
# - Variables - Code managed
|
||||
var job_spawn_timer: Timer
|
||||
|
|
@ -17,7 +19,7 @@ const PRINTER = preload("uid://33ctlyrpibs3")
|
|||
# - Constants - Settings
|
||||
# Jobs
|
||||
const JOB_SPAWN_WAIT: float = 2.0
|
||||
const MAX_JOBS: int = 4
|
||||
var max_jobs: int = PlayerData.max_order_amount
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -40,12 +42,12 @@ func _on_shop_printer_purchase_req(printer_data: PrinterData) -> void:
|
|||
|
||||
#region Job generation
|
||||
func _on_job_spawn_timer_timeout() -> void:
|
||||
print("Spawn timer over")
|
||||
#print("Spawn timer over")
|
||||
#generate_job()
|
||||
draw_job()
|
||||
|
||||
func generate_job() -> void:
|
||||
if not current_job_count >= MAX_JOBS:
|
||||
if not current_job_count >= max_jobs:
|
||||
var random_job: JobData = jobs_array.pick_random()
|
||||
current_job_count += 1
|
||||
var new_job = JOB_CARD.instantiate()
|
||||
|
|
@ -55,7 +57,7 @@ func generate_job() -> void:
|
|||
job_interact.emit()
|
||||
|
||||
func draw_job() -> void:
|
||||
if not current_job_count >= MAX_JOBS:
|
||||
if not current_job_count >= max_jobs:
|
||||
var job: JobData = generate_random_job()
|
||||
current_job_count += 1
|
||||
var new_job = JOB_CARD.instantiate()
|
||||
|
|
@ -75,15 +77,13 @@ func generate_random_job() -> JobData:
|
|||
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('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])
|
||||
return new_job
|
||||
|
||||
func _on_job_accepted_pressed(accepted_job) -> void:
|
||||
print("Job accepted")
|
||||
PlayerData.jobs.append(accepted_job.job_data)
|
||||
print(PlayerData.jobs[0].job_name)
|
||||
GameData.current_job_count -= 1
|
||||
accepted_job.queue_free()
|
||||
job_interact.emit()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ var level: int = 0:
|
|||
level = value
|
||||
level_changed.emit(level)
|
||||
|
||||
var max_order_amount: int = 5:
|
||||
var max_order_amount: int = 10:
|
||||
set(value):
|
||||
max_order_amount = value
|
||||
max_order_amount_changed.emit(max_order_amount)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ func calculate_time() -> String:
|
|||
|
||||
func _on_accept_job_pressed() -> void:
|
||||
job_accepted.emit(self)
|
||||
GameData.print_started.emit()
|
||||
|
||||
func _on_skip_job_pressed() -> void:
|
||||
queue_free()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ var selected_job_index: int
|
|||
var is_printing: bool = false
|
||||
var time_left: float
|
||||
|
||||
func _ready() -> void:
|
||||
GameData.print_started.connect(_on_print_started)
|
||||
|
||||
func initialize_printer(data: PrinterData) -> void:
|
||||
printer_data = data
|
||||
printer_name_label.text = printer_data.printer_manufacturer
|
||||
|
|
@ -27,7 +30,7 @@ func initialize_printer(data: PrinterData) -> void:
|
|||
|
||||
func _process(delta) -> void:
|
||||
if is_printing:
|
||||
select_job.disabled = true
|
||||
select_job.visible = false
|
||||
progress_bar.visible = true
|
||||
time_left_label.visible = true
|
||||
set_status()
|
||||
|
|
@ -40,10 +43,7 @@ func _process(delta) -> void:
|
|||
if time_left <= 0:
|
||||
PlayerData.give_money.emit(selected_job.job_reward)
|
||||
PlayerData.give_experience.emit(selected_job.job_experience)
|
||||
if PlayerData.jobs.size() == 1:
|
||||
PlayerData.jobs.clear()
|
||||
else:
|
||||
PlayerData.jobs.remove_at(selected_job_index)
|
||||
select_job.visible = true
|
||||
reset_status()
|
||||
|
||||
func reset_status() -> void:
|
||||
|
|
@ -72,14 +72,15 @@ func calculate_time_left(time) -> String:
|
|||
else:
|
||||
return '%.2f s' % time
|
||||
|
||||
func _on_print_started() -> void:
|
||||
print("Refresh dropdown")
|
||||
_on_select_job_pressed()
|
||||
|
||||
func _on_sell_button_pressed() -> void:
|
||||
PlayerData.give_money.emit(printer_data.printer_price * PlayerData.sell_multiplier)
|
||||
queue_free()
|
||||
|
||||
func _on_select_job_pressed() -> void:
|
||||
#if selected_job != null:
|
||||
#PlayerData.jobs.append(selected_job)
|
||||
|
||||
select_job.clear()
|
||||
if PlayerData.jobs.is_empty():
|
||||
select_job.add_item("No jobs accepted")
|
||||
|
|
@ -95,17 +96,19 @@ func _on_select_job_pressed() -> void:
|
|||
selected_job = select_job.get_item_metadata(0)
|
||||
selected_job_index = 0
|
||||
|
||||
func _on_select_job_item_selected(index: int) -> void:
|
||||
selected_job = select_job.get_item_metadata(index)
|
||||
selected_job_index = index
|
||||
|
||||
func _on_start_button_pressed() -> void:
|
||||
if select_job.get_item_text(0) == "No jobs accepted":
|
||||
print("No job selected")
|
||||
else:
|
||||
if not select_job.get_item_text(0) == "No jobs accepted":
|
||||
time_left = selected_job.job_time / printer_data.printer_speed
|
||||
progress_bar.value = 0
|
||||
is_printing = true
|
||||
|
||||
_on_select_job_pressed()
|
||||
if PlayerData.jobs.size() == 1:
|
||||
PlayerData.jobs.clear()
|
||||
else:
|
||||
PlayerData.jobs.remove_at(selected_job_index)
|
||||
|
||||
func _on_select_job_item_selected(index: int) -> void:
|
||||
selected_job = select_job.get_item_metadata(index)
|
||||
selected_job_index = index
|
||||
#PlayerData.jobs.remove_at(index)
|
||||
GameData.print_started.emit()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
extends Control
|
||||
|
||||
@export var jobs_array: Array[JobData]
|
||||
@export var job_limit: int = 5
|
||||
@export var debug: bool = false
|
||||
|
||||
@onready var debug_xp: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugXP
|
||||
|
|
@ -34,7 +32,7 @@ func _on_money_changed(money) -> void:
|
|||
%Money.text = 'Money: %.2f €' % money
|
||||
|
||||
func _on_job_interact() -> void:
|
||||
jobs_tab_button.text = 'Jobs (%d / %d)' % [GameData.current_job_count, GameData.MAX_JOBS]
|
||||
jobs_tab_button.text = 'Jobs (%d / %d)' % [GameData.current_job_count, GameData.max_jobs]
|
||||
|
||||
func _on_job_generated(job: Node) -> void:
|
||||
%JobContainer.add_child(job)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,6 @@
|
|||
[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://bp1c3unpg2ndn" path="res://Resources/job_data.gd" id="2_cqvjp"]
|
||||
[ext_resource type="Resource" uid="uid://0gyhxwe47tby" path="res://Resources/Jobs/job_action_figure.tres" id="3_hfaco"]
|
||||
[ext_resource type="Resource" uid="uid://cuff7udubpjgk" path="res://Resources/Jobs/job_ad_keychain.tres" id="4_1eb8u"]
|
||||
[ext_resource type="Resource" uid="uid://ceck7mpy7qnae" path="res://Resources/Jobs/job_cafe_cookie_stamp.tres" id="5_vhchw"]
|
||||
[ext_resource type="Resource" uid="uid://5ag48elqtpg7" path="res://Resources/Jobs/job_college_electronic_box.tres" id="6_jx4bj"]
|
||||
[ext_resource type="Resource" uid="uid://dg2ffm3feksrm" path="res://Resources/Jobs/job_cup_holder_seat.tres" id="7_rdq6y"]
|
||||
[ext_resource type="Resource" uid="uid://c3l3haowyo1yc" path="res://Resources/Jobs/job_drone_chassis.tres" id="8_l5iwa"]
|
||||
[ext_resource type="Resource" uid="uid://0wacf77o0vq1" path="res://Resources/Jobs/job_headphone_stand_tableside.tres" id="9_3h0f6"]
|
||||
[ext_resource type="Resource" uid="uid://dt1hgcy140fpt" path="res://Resources/Jobs/job_modern_cabinet_handle.tres" id="10_unbrw"]
|
||||
[ext_resource type="Resource" uid="uid://b0akomrm6gavw" path="res://Resources/Jobs/job_rc_car_control_arm.tres" id="11_i1f3g"]
|
||||
[ext_resource type="Resource" uid="uid://dy48odm1apexk" path="res://Resources/Jobs/job_zipper_pull_tab.tres" id="12_cnm7j"]
|
||||
[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"]
|
||||
|
|
@ -28,9 +17,15 @@ corner_radius_bottom_right = 6
|
|||
corner_radius_bottom_left = 6
|
||||
corner_detail = 6
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cqvjp"]
|
||||
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqjbf"]
|
||||
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)
|
||||
|
||||
[node name="UI" type="Control" unique_id=256887379]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
|
|
@ -39,8 +34,6 @@ anchor_bottom = 1.0
|
|||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_vqjbf")
|
||||
jobs_array = Array[ExtResource("2_cqvjp")]([ExtResource("3_hfaco"), ExtResource("4_1eb8u"), ExtResource("5_vhchw"), ExtResource("6_jx4bj"), ExtResource("7_rdq6y"), ExtResource("8_l5iwa"), ExtResource("9_3h0f6"), ExtResource("10_unbrw"), ExtResource("11_i1f3g"), ExtResource("12_cnm7j")])
|
||||
job_limit = 4
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1634044894]
|
||||
layout_mode = 1
|
||||
|
|
@ -195,8 +188,8 @@ 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")
|
||||
|
||||
[node name="JobScroll" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/JobsTab" unique_id=1046443254]
|
||||
layout_mode = 2
|
||||
|
|
@ -220,6 +213,7 @@ 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")
|
||||
|
||||
|
|
@ -251,6 +245,7 @@ text = "Filaments"
|
|||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_qru7b")
|
||||
script = ExtResource("15_vqjbf")
|
||||
printers_array = Array[ExtResource("16_rdojl")]([ExtResource("17_llrls"), ExtResource("18_8rt22"), ExtResource("19_1ohgd")])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue