Compare commits
No commits in common. "a2978f4beea67396933bff23896c4a8ee0c0c8ed" and "c291ae92594e266df69b9e0799f0081ad80944ee" have entirely different histories.
a2978f4bee
...
c291ae9259
12 changed files with 31 additions and 90 deletions
|
|
@ -6,8 +6,7 @@
|
||||||
script = ExtResource("1_5jvwy")
|
script = ExtResource("1_5jvwy")
|
||||||
job_name = "Action figure (D&D)"
|
job_name = "Action figure (D&D)"
|
||||||
job_reward = 25.0
|
job_reward = 25.0
|
||||||
job_experience = 30.0
|
job_experience = 25.0
|
||||||
job_amount = 1
|
job_amount = 1
|
||||||
job_difficulty = 3
|
|
||||||
job_description = "Local D&D player needs a custom action figure for his upcoming session"
|
job_description = "Local D&D player needs a custom action figure for his upcoming session"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_uaqmk")
|
script = ExtResource("1_uaqmk")
|
||||||
job_name = "Ad keychain with logo"
|
job_name = "Ad keychain with logo"
|
||||||
job_reward = 5.0
|
job_reward = 250.0
|
||||||
job_experience = 8.0
|
job_experience = 250.0
|
||||||
job_amount = 50
|
job_amount = 50
|
||||||
job_description = "Local company needs keychains with their logo for the local fair"
|
job_description = "Local company needs keychains with their logo for the local fair"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,5 @@ job_name = "Cookiestamp with logo"
|
||||||
job_reward = 80.0
|
job_reward = 80.0
|
||||||
job_experience = 75.0
|
job_experience = 75.0
|
||||||
job_amount = 3
|
job_amount = 3
|
||||||
job_difficulty = 2
|
|
||||||
job_description = "Cafe wants to stamp their cookies with their own logo"
|
job_description = "Cafe wants to stamp their cookies with their own logo"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,5 @@ job_name = "Electronic control box"
|
||||||
job_reward = 120.0
|
job_reward = 120.0
|
||||||
job_experience = 110.0
|
job_experience = 110.0
|
||||||
job_amount = 5
|
job_amount = 5
|
||||||
job_difficulty = 3
|
|
||||||
job_description = "College student group needs control boxes for their prototype project"
|
job_description = "College student group needs control boxes for their prototype project"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,5 @@ job_name = "Cupholder-adapter"
|
||||||
job_reward = 55.0
|
job_reward = 55.0
|
||||||
job_experience = 50.0
|
job_experience = 50.0
|
||||||
job_amount = 1
|
job_amount = 1
|
||||||
job_difficulty = 2
|
|
||||||
job_description = "Car enthusiast wants a custom cupholder-adapter for his project car"
|
job_description = "Car enthusiast wants a custom cupholder-adapter for his project car"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,5 @@ job_name = "Prototype drone chassis"
|
||||||
job_reward = 190.0
|
job_reward = 190.0
|
||||||
job_experience = 180.0
|
job_experience = 180.0
|
||||||
job_amount = 1
|
job_amount = 1
|
||||||
job_difficulty = 5
|
|
||||||
job_description = "Anonymous client needs a complex prototype chassis"
|
job_description = "Anonymous client needs a complex prototype chassis"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,5 @@ job_name = "RC-car front control arm"
|
||||||
job_reward = 35.0
|
job_reward = 35.0
|
||||||
job_experience = 35.0
|
job_experience = 35.0
|
||||||
job_amount = 2
|
job_amount = 2
|
||||||
job_difficulty = 4
|
|
||||||
job_description = "Hobbyist crashed his rc-car on a race and needs new control arms quickly"
|
job_description = "Hobbyist crashed his rc-car on a race and needs new control arms quickly"
|
||||||
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
metadata/_custom_type_script = "uid://bp1c3unpg2ndn"
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,6 @@ extends Resource
|
||||||
set(value):
|
set(value):
|
||||||
job_amount = value
|
job_amount = value
|
||||||
_generate_job_time()
|
_generate_job_time()
|
||||||
|
|
||||||
# - Difficulty from 1 to 5: Easy, Medium, Hard, Pain, Torture
|
|
||||||
@export var job_difficulty: int = 1:
|
|
||||||
set(value):
|
|
||||||
clamp(value, 1, 5)
|
|
||||||
job_difficulty = value
|
|
||||||
_generate_job_time()
|
|
||||||
|
|
||||||
@export var job_description: String
|
@export var job_description: String
|
||||||
var job_time: float
|
var job_time: float
|
||||||
var job_material: String = "PLA"
|
var job_material: String = "PLA"
|
||||||
|
|
@ -30,7 +22,6 @@ var job_material: String = "PLA"
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
_generate_job_time()
|
_generate_job_time()
|
||||||
|
|
||||||
# Generate printing time
|
|
||||||
func _generate_job_time() -> void:
|
func _generate_job_time() -> void:
|
||||||
var print_time: float = sqrt(job_experience + job_reward) * job_amount
|
var print_time: float = sqrt(job_experience + job_reward) * job_amount
|
||||||
var round_time: float = round(print_time * 100) / 100
|
var round_time: float = round(print_time * 100) / 100
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,14 @@ extends Node
|
||||||
# - Signals
|
# - Signals
|
||||||
signal job_generated(job: Node)
|
signal job_generated(job: Node)
|
||||||
signal job_interact
|
signal job_interact
|
||||||
signal printer_bought(printer: Node)
|
|
||||||
|
|
||||||
# - Variables - Code managed
|
# - Variables - Code managed
|
||||||
var job_spawn_timer: Timer
|
var job_spawn_timer: Timer
|
||||||
var jobs_array: Array[JobData]
|
var jobs_array: Array[JobData]
|
||||||
var current_job_count: int = 0
|
var current_job_count: int = 0
|
||||||
|
|
||||||
# - Scenes
|
# Scenes
|
||||||
const JOB_CARD = preload("uid://dvfcie8hqcb0")
|
const JOB_CARD = preload("uid://dvfcie8hqcb0")
|
||||||
const PRINTER = preload("uid://33ctlyrpibs3")
|
|
||||||
|
|
||||||
# - Constants - Settings
|
# - Constants - Settings
|
||||||
# Jobs
|
# Jobs
|
||||||
|
|
@ -31,20 +29,11 @@ func _ready() -> void:
|
||||||
job_spawn_timer.timeout.connect(_on_job_spawn_timer_timeout)
|
job_spawn_timer.timeout.connect(_on_job_spawn_timer_timeout)
|
||||||
job_spawn_timer.start()
|
job_spawn_timer.start()
|
||||||
|
|
||||||
func _on_shop_printer_purchase_req(printer_data: PrinterData) -> void:
|
|
||||||
if PlayerData.try_purchase(printer_data.printer_price):
|
|
||||||
var new_printer = PRINTER.instantiate()
|
|
||||||
printer_bought.emit(new_printer)
|
|
||||||
new_printer.initialize_printer(printer_data)
|
|
||||||
|
|
||||||
|
|
||||||
#region Job generation
|
|
||||||
func _on_job_spawn_timer_timeout() -> void:
|
func _on_job_spawn_timer_timeout() -> void:
|
||||||
print("Spawn timer over")
|
print("Spawn timer over")
|
||||||
#generate_job()
|
generate_job()
|
||||||
draw_job()
|
|
||||||
|
|
||||||
func generate_job() -> void:
|
func generate_job():
|
||||||
if not current_job_count >= MAX_JOBS:
|
if not current_job_count >= MAX_JOBS:
|
||||||
var random_job: JobData = jobs_array.pick_random()
|
var random_job: JobData = jobs_array.pick_random()
|
||||||
current_job_count += 1
|
current_job_count += 1
|
||||||
|
|
@ -54,41 +43,15 @@ func generate_job() -> void:
|
||||||
new_job.job_accepted.connect(_on_job_accepted_pressed)
|
new_job.job_accepted.connect(_on_job_accepted_pressed)
|
||||||
job_interact.emit()
|
job_interact.emit()
|
||||||
|
|
||||||
func draw_job() -> void:
|
func _on_job_accepted_pressed(accepted_job):
|
||||||
if not current_job_count >= MAX_JOBS:
|
|
||||||
var job: JobData = generate_random_job()
|
|
||||||
current_job_count += 1
|
|
||||||
var new_job = JOB_CARD.instantiate()
|
|
||||||
job_generated.emit(new_job)
|
|
||||||
new_job.initialize_job(job)
|
|
||||||
new_job.job_accepted.connect(_on_job_accepted_pressed)
|
|
||||||
job_interact.emit()
|
|
||||||
|
|
||||||
func generate_random_job() -> JobData:
|
|
||||||
var new_job = JobData.new()
|
|
||||||
var random_job: JobData = jobs_array.pick_random()
|
|
||||||
var amount = randf_range(1, PlayerData.max_order_amount)
|
|
||||||
|
|
||||||
new_job.job_name = random_job.job_name
|
|
||||||
new_job.job_reward = random_job.job_reward * amount
|
|
||||||
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])
|
|
||||||
return new_job
|
|
||||||
|
|
||||||
func _on_job_accepted_pressed(accepted_job) -> void:
|
|
||||||
print("Job accepted")
|
print("Job accepted")
|
||||||
PlayerData.jobs.append(accepted_job.job_data)
|
PlayerData.jobs.append(accepted_job.job_data)
|
||||||
print(PlayerData.jobs[0].job_name)
|
print(PlayerData.jobs[0].job_name)
|
||||||
GameData.current_job_count -= 1
|
GameData.current_job_count -= 1
|
||||||
accepted_job.queue_free()
|
accepted_job.queue_free()
|
||||||
job_interact.emit()
|
job_interact.emit()
|
||||||
#endregion
|
|
||||||
#region Utility - Load job resources
|
#region Load job resources
|
||||||
func load_all_jobs(path: String) -> void:
|
func load_all_jobs(path: String) -> void:
|
||||||
var dir = DirAccess.open(path)
|
var dir = DirAccess.open(path)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,28 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var xp: float = 0:
|
@export var xp: float = 0:
|
||||||
set(value):
|
set(value):
|
||||||
xp = value
|
xp = value
|
||||||
xp_changed.emit(xp)
|
xp_changed.emit(xp)
|
||||||
|
|
||||||
var money: float = 500:
|
@export var money: float = 500:
|
||||||
set(value):
|
set(value):
|
||||||
money = value
|
money = value
|
||||||
money_changed.emit(money)
|
money_changed.emit(money)
|
||||||
|
|
||||||
var level: int = 0:
|
@export var level: int = 0:
|
||||||
set(value):
|
set(value):
|
||||||
level = value
|
level = value
|
||||||
level_changed.emit(level)
|
level_changed.emit(level)
|
||||||
|
|
||||||
var max_order_amount: int = 5:
|
@export var sell_multiplier: float = 0.5
|
||||||
set(value):
|
|
||||||
max_order_amount = value
|
|
||||||
max_order_amount_changed.emit(max_order_amount)
|
|
||||||
|
|
||||||
var sell_multiplier: float = 0.5
|
|
||||||
|
|
||||||
var jobs: Array[JobData]
|
var jobs: Array[JobData]
|
||||||
|
|
||||||
# Signal - player stats
|
|
||||||
signal xp_changed(new_xp)
|
signal xp_changed(new_xp)
|
||||||
signal money_changed(new_money)
|
signal money_changed(new_money)
|
||||||
signal level_changed(new_level)
|
signal level_changed(new_level)
|
||||||
signal max_order_amount_changed(new_max_order_amount)
|
|
||||||
|
|
||||||
# Signal - functions
|
|
||||||
signal give_experience(xp_amount)
|
signal give_experience(xp_amount)
|
||||||
signal give_money(money_amount)
|
signal give_money(money_amount)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,5 @@ func _ready() -> void:
|
||||||
new_printer.initialize_printer(printer)
|
new_printer.initialize_printer(printer)
|
||||||
new_printer.buy_printer.connect(_buy_printer_pressed)
|
new_printer.buy_printer.connect(_buy_printer_pressed)
|
||||||
|
|
||||||
printer_purchase_requested.connect(GameData._on_shop_printer_purchase_req)
|
func _buy_printer_pressed(bought_printer):
|
||||||
|
|
||||||
func _buy_printer_pressed(bought_printer) -> void:
|
|
||||||
printer_purchase_requested.emit(bought_printer.printer_data)
|
printer_purchase_requested.emit(bought_printer.printer_data)
|
||||||
|
|
|
||||||
|
|
@ -14,33 +14,36 @@ const PRINTER = preload("uid://33ctlyrpibs3")
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
check_debug()
|
check_debug()
|
||||||
|
|
||||||
_on_xp_changed(PlayerData.xp)
|
%Money.text = "Money: " + str(PlayerData.money) + " €"
|
||||||
_on_level_changed(PlayerData.level)
|
%Experience.value = PlayerData.xp
|
||||||
_on_money_changed(PlayerData.money)
|
%Level.text = "Level: " + str(PlayerData.level)
|
||||||
|
|
||||||
PlayerData.xp_changed.connect(_on_xp_changed)
|
PlayerData.xp_changed.connect(_on_xp_changed)
|
||||||
PlayerData.level_changed.connect(_on_level_changed)
|
PlayerData.level_changed.connect(_on_level_changed)
|
||||||
PlayerData.money_changed.connect(_on_money_changed)
|
PlayerData.money_changed.connect(_on_money_changed)
|
||||||
GameData.job_generated.connect(_on_job_generated)
|
GameData.job_generated.connect(_on_job_generated)
|
||||||
GameData.job_interact.connect(_on_job_interact)
|
GameData.job_interact.connect(_on_job_interact)
|
||||||
GameData.printer_bought.connect(_on_printer_bought)
|
|
||||||
|
|
||||||
# --- Experience, Level and Money update ---
|
# --- Experience, Level and Money update ---
|
||||||
func _on_xp_changed(xp) -> void:
|
func _on_xp_changed(xp):
|
||||||
%Experience.value = xp
|
%Experience.value = xp
|
||||||
func _on_level_changed(level) -> void:
|
func _on_level_changed(level):
|
||||||
%Level.text = 'Level: %d' % level
|
%Level.text = "Level: " + str(level)
|
||||||
func _on_money_changed(money) -> void:
|
func _on_money_changed(money):
|
||||||
%Money.text = 'Money: %.2f €' % money
|
%Money.text = "Money: " + str(money) + "€"
|
||||||
|
|
||||||
func _on_job_generated(job: Node) -> void:
|
func _on_job_generated(job: Node):
|
||||||
%JobContainer.add_child(job)
|
%JobContainer.add_child(job)
|
||||||
|
|
||||||
func _on_job_interact() -> void:
|
func _on_job_interact() -> void:
|
||||||
jobs_tab_button.text = 'Jobs (%d / %d)' % [GameData.current_job_count, GameData.MAX_JOBS]
|
jobs_tab_button.text = "Jobs (" + str(GameData.current_job_count) + "/" + str(GameData.MAX_JOBS) + ")"
|
||||||
|
|
||||||
func _on_printer_bought(new_printer: Node) -> void:
|
func _on_printers_printer_purchase_requested(printer_data: PrinterData) -> void:
|
||||||
%PrinterContainer.add_child(new_printer)
|
if PlayerData.try_purchase(printer_data.printer_price):
|
||||||
|
%Money.text = "Money: " + str(PlayerData.money) + "€"
|
||||||
|
var new_printer = PRINTER.instantiate()
|
||||||
|
%PrinterContainer.add_child(new_printer)
|
||||||
|
new_printer.initialize_printer(printer_data)
|
||||||
|
|
||||||
#region Debug
|
#region Debug
|
||||||
func check_debug() -> void:
|
func check_debug() -> void:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue