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