2023-06-06 13:35:20 +10:00
|
|
|
class_name Client
|
|
|
|
extends Card
|
|
|
|
|
2023-06-11 02:08:09 +10:00
|
|
|
signal time_slots_selected
|
|
|
|
|
2023-06-06 13:35:20 +10:00
|
|
|
var icon_prefab = preload("res://Scenes/bonus_icon.tscn")
|
2023-06-13 00:59:02 +10:00
|
|
|
var bad_pip_sprite = preload("res://Assets/bad_pip.png")
|
|
|
|
var medium_pip_sprite = preload("res://Assets/medium_pip.png")
|
|
|
|
var good_pip_sprite = preload("res://Assets/good_pip.png")
|
2023-06-06 13:35:20 +10:00
|
|
|
var title = "New Task"
|
|
|
|
var initial_stress = 0
|
|
|
|
var turns_left = 4
|
|
|
|
var time_slots = [true, true, false, true]
|
|
|
|
var icon_list = []
|
2023-06-13 00:59:02 +10:00
|
|
|
var medium_threshold := 5
|
|
|
|
var good_threshold := 8
|
|
|
|
var satisfaction := 1
|
2023-06-13 19:21:13 +10:00
|
|
|
var watch_on := false
|
2023-06-13 00:59:02 +10:00
|
|
|
@export var pip_sprites: Array[TextureRect] = []
|
2023-06-13 19:21:13 +10:00
|
|
|
@export var time_button_sprites: Array[TextureRect] = []
|
|
|
|
@export var time_hovered_sprites: Array[TextureRect] = []
|
2023-07-05 22:19:18 +10:00
|
|
|
@export var watch: TextureRect
|
2023-06-13 00:59:02 +10:00
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
pip_sprites.append($front/pip2)
|
|
|
|
pip_sprites.append($front/pip3)
|
|
|
|
pip_sprites.append($front/pip4)
|
|
|
|
pip_sprites.append($front/pip5)
|
|
|
|
pip_sprites.append($front/pip6)
|
|
|
|
pip_sprites.append($front/pip7)
|
|
|
|
pip_sprites.append($front/pip8)
|
|
|
|
pip_sprites.append($front/pip9)
|
2023-06-13 19:21:13 +10:00
|
|
|
icon_list.append($front/Bonus1)
|
|
|
|
icon_list.append($front/Bonus2)
|
|
|
|
icon_list.append($front/Bonus3)
|
|
|
|
icon_list.append($front/Bonus4)
|
|
|
|
time_button_sprites.append($watch/time1)
|
|
|
|
time_button_sprites.append($watch/time2)
|
|
|
|
time_button_sprites.append($watch/time3)
|
|
|
|
time_button_sprites.append($watch/time4)
|
|
|
|
time_hovered_sprites.append($watch/time_hovered1)
|
|
|
|
time_hovered_sprites.append($watch/time_hovered2)
|
|
|
|
time_hovered_sprites.append($watch/time_hovered3)
|
|
|
|
time_hovered_sprites.append($watch/time_hovered4)
|
2023-06-06 13:35:20 +10:00
|
|
|
|
2023-06-11 02:08:09 +10:00
|
|
|
|
2023-06-06 13:35:20 +10:00
|
|
|
func _process(delta):
|
|
|
|
if sliding:
|
|
|
|
slide(delta)
|
|
|
|
|
2023-06-11 02:08:09 +10:00
|
|
|
|
2023-06-13 19:21:13 +10:00
|
|
|
func setup(_title, _initial_stress, _time_slots, _services):
|
2023-06-06 13:35:20 +10:00
|
|
|
if _title != "":
|
|
|
|
title = _title
|
|
|
|
initial_stress = _initial_stress
|
|
|
|
time_slots = _time_slots
|
|
|
|
services = []
|
|
|
|
if _services != null and _services != []:
|
|
|
|
services.append_array(_services)
|
2023-06-13 19:21:13 +10:00
|
|
|
for x in time_button_sprites.size():
|
|
|
|
if time_slots[x] == true:
|
|
|
|
time_button_sprites[x].visible = true
|
2023-06-11 02:08:09 +10:00
|
|
|
$front/Slice1.visible = false
|
|
|
|
$front/Slice2.visible = false
|
|
|
|
$front/Slice3.visible = false
|
|
|
|
$front/Slice4.visible = false
|
2023-06-06 13:35:20 +10:00
|
|
|
if time_slots[0] == true:
|
2023-06-11 02:08:09 +10:00
|
|
|
$front/Slice1.visible = true
|
2023-06-06 13:35:20 +10:00
|
|
|
if time_slots[1] == true:
|
2023-06-11 02:08:09 +10:00
|
|
|
$front/Slice2.visible = true
|
2023-06-06 13:35:20 +10:00
|
|
|
if time_slots[2] == true:
|
2023-06-11 02:08:09 +10:00
|
|
|
$front/Slice3.visible = true
|
2023-06-06 13:35:20 +10:00
|
|
|
if time_slots[3] == true:
|
2023-06-11 02:08:09 +10:00
|
|
|
$front/Slice4.visible = true
|
|
|
|
$front/Title.text = str(title)
|
|
|
|
$"front/Initial Stress".text = str(initial_stress)
|
2023-06-13 19:21:13 +10:00
|
|
|
for x in services.size():
|
|
|
|
if x == 0:
|
|
|
|
continue
|
|
|
|
icon_list[x - 1].set_service(services[x])
|
|
|
|
icon_list[x - 1].visible = true
|
|
|
|
good_threshold = 10 - (5 - services.size())
|
|
|
|
medium_threshold = 4
|
|
|
|
if time_slots[3] == false:
|
|
|
|
good_threshold -= 1
|
|
|
|
if time_slots[2] == false:
|
|
|
|
good_threshold -= 1
|
|
|
|
if time_slots[1] == false:
|
|
|
|
good_threshold -= 1
|
|
|
|
if time_slots[0] == false:
|
|
|
|
medium_threshold += 1
|
|
|
|
if time_slots[1] == false:
|
|
|
|
medium_threshold += 1
|
|
|
|
if time_slots[2] == false:
|
|
|
|
medium_threshold += 1
|
|
|
|
for x in pip_sprites.size() + 2:
|
|
|
|
if x < 2:
|
|
|
|
continue
|
|
|
|
if x >= good_threshold:
|
|
|
|
pip_sprites[x - 2].texture = good_pip_sprite
|
|
|
|
if x < good_threshold:
|
|
|
|
pip_sprites[x - 2].texture = medium_pip_sprite
|
|
|
|
if x < medium_threshold:
|
|
|
|
pip_sprites[x - 2].texture = bad_pip_sprite
|
2023-06-11 02:08:09 +10:00
|
|
|
|
2023-06-06 13:35:20 +10:00
|
|
|
|
|
|
|
func show_time_selector():
|
2023-06-13 19:21:13 +10:00
|
|
|
watch_on = true
|
2023-07-05 22:19:18 +10:00
|
|
|
watch.visible = true
|
2023-06-06 13:35:20 +10:00
|
|
|
|
2023-06-11 02:08:09 +10:00
|
|
|
|
2023-06-06 13:35:20 +10:00
|
|
|
func update_counter():
|
2023-06-13 19:21:13 +10:00
|
|
|
$"front/Turns Left Counter".text = str(turns_left)
|
2023-06-06 13:35:20 +10:00
|
|
|
|
|
|
|
|
|
|
|
func _on_turn_pressed(num):
|
|
|
|
turns_left = num
|
|
|
|
update_counter()
|
2023-07-05 22:19:18 +10:00
|
|
|
watch.visible = false
|
2023-06-13 19:21:13 +10:00
|
|
|
watch_on = false
|
2023-06-06 13:35:20 +10:00
|
|
|
time_slots_selected.emit()
|
2023-06-11 02:08:09 +10:00
|
|
|
|
|
|
|
|
|
|
|
func turn_front():
|
|
|
|
$back.visible = false
|
|
|
|
$front.visible = true
|
|
|
|
|
|
|
|
|
|
|
|
func turn_back():
|
|
|
|
$back.visible = true
|
|
|
|
$front.visible = false
|
2023-06-13 19:21:13 +10:00
|
|
|
|
|
|
|
|
2023-07-05 22:19:18 +10:00
|
|
|
func set_satisfaction(num):
|
|
|
|
satisfaction = 1 + num
|
|
|
|
$front/ColorRect.position.x = 134 + ((satisfaction - 1) * 20.0)
|
|
|
|
|
|
|
|
|
2023-06-13 19:21:13 +10:00
|
|
|
func _on_watch_segment_mouse_entered(extra_arg_0: int) -> void:
|
|
|
|
if not watch_on or not time_slots[extra_arg_0]:
|
|
|
|
return
|
|
|
|
for x in extra_arg_0 + 1:
|
|
|
|
time_hovered_sprites[x].visible = true
|
|
|
|
|
|
|
|
|
2023-07-05 22:19:18 +10:00
|
|
|
func _on_watch_segment_mouse_exited(_extra_arg_0: int) -> void:
|
2023-06-13 19:21:13 +10:00
|
|
|
for sprite in time_hovered_sprites:
|
|
|
|
sprite.visible = false
|
|
|
|
|
|
|
|
|
2023-07-05 22:19:18 +10:00
|
|
|
func _on_watch_segment_input_event(_viewport: Node, event: InputEvent, _shape_idx: int, extra_arg_0: int) -> void:
|
2023-06-13 19:21:13 +10:00
|
|
|
if event is InputEventMouseButton and event.pressed:
|
|
|
|
_on_turn_pressed(extra_arg_0 + 1)
|