Changes to JobData class. Added random job generation and difficulty variable
This commit is contained in:
parent
c291ae9259
commit
f057bd2c2c
10 changed files with 58 additions and 8 deletions
|
|
@ -6,7 +6,8 @@
|
||||||
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 = 25.0
|
job_experience = 30.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 = 250.0
|
job_reward = 5.0
|
||||||
job_experience = 250.0
|
job_experience = 8.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,5 +8,6 @@ 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,5 +8,6 @@ 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,5 +8,6 @@ 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,5 +8,6 @@ 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,5 +8,6 @@ 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,6 +14,14 @@ 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"
|
||||||
|
|
@ -22,6 +30,7 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ func _ready() -> void:
|
||||||
|
|
||||||
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():
|
func generate_job():
|
||||||
if not current_job_count >= MAX_JOBS:
|
if not current_job_count >= MAX_JOBS:
|
||||||
|
|
@ -43,6 +44,32 @@ func generate_job():
|
||||||
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():
|
||||||
|
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):
|
func _on_job_accepted_pressed(accepted_job):
|
||||||
print("Job accepted")
|
print("Job accepted")
|
||||||
PlayerData.jobs.append(accepted_job.job_data)
|
PlayerData.jobs.append(accepted_job.job_data)
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,36 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
@export var xp: float = 0:
|
var xp: float = 0:
|
||||||
set(value):
|
set(value):
|
||||||
xp = value
|
xp = value
|
||||||
xp_changed.emit(xp)
|
xp_changed.emit(xp)
|
||||||
|
|
||||||
@export var money: float = 500:
|
var money: float = 500:
|
||||||
set(value):
|
set(value):
|
||||||
money = value
|
money = value
|
||||||
money_changed.emit(money)
|
money_changed.emit(money)
|
||||||
|
|
||||||
@export var level: int = 0:
|
var level: int = 0:
|
||||||
set(value):
|
set(value):
|
||||||
level = value
|
level = value
|
||||||
level_changed.emit(level)
|
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]
|
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)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue