|
|
|
|
@tool
|
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
@onready var core_item_list: Array[CoreItemSub] = [
|
|
|
|
|
$CoreItemFree/Up, $CoreItemFree/Left, $CoreItemFree/Down, $CoreItemFree/Right,
|
|
|
|
|
$CoreItemLock/Up, $CoreItemLock/Left, $CoreItemLock/Down, $CoreItemLock/Right,
|
|
|
|
|
]
|
|
|
|
|
@onready var core_item_input_list: Array[InputItem] = [
|
|
|
|
|
$CoreItemInput/Up, $CoreItemInput/Left, $CoreItemInput/Down, $CoreItemInput/Right,
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@onready var core_item_free: Control = $CoreItemFree
|
|
|
|
|
@onready var core_item_lock: Control = $CoreItemLock
|
|
|
|
|
|
|
|
|
|
@export var is_switch: bool:
|
|
|
|
|
set(value):
|
|
|
|
|
is_switch = value
|
|
|
|
|
is_switch_animation = true
|
|
|
|
|
|
|
|
|
|
@export var is_lock: bool:
|
|
|
|
|
set(value):
|
|
|
|
|
is_lock = value
|
|
|
|
|
core_item_free.visible = not is_lock
|
|
|
|
|
core_item_lock.visible = is_lock
|
|
|
|
|
|
|
|
|
|
@export var switch_animation_time_max: float = 0.1
|
|
|
|
|
var switch_animation_time: float = 0.0
|
|
|
|
|
var is_switch_animation: bool
|
|
|
|
|
|
|
|
|
|
@export var switch_center_pos1 = Vector2(560, 300)
|
|
|
|
|
@export var switch_center_pos2 = Vector2(480, 280)
|
|
|
|
|
var switch_item_pos1 = [
|
|
|
|
|
Vector2(0, -16), Vector2(-24, 0), Vector2(0, 16), Vector2(24, 0),
|
|
|
|
|
Vector2(0, -16), Vector2(-24, 0), Vector2(0, 16), Vector2(24, 0),
|
|
|
|
|
]
|
|
|
|
|
var switch_item_pos2 = [
|
|
|
|
|
Vector2(0, -32), Vector2(-32, 0), Vector2(0, 32), Vector2(32, 0),
|
|
|
|
|
Vector2(0, -32), Vector2(-32, 0), Vector2(0, 32), Vector2(32, 0),
|
|
|
|
|
]
|
|
|
|
|
var core_item_input_pos1 = Vector2(0, 0)
|
|
|
|
|
var core_item_input_pos2 = [
|
|
|
|
|
Vector2(0, -16), Vector2(-16, 0), Vector2(0, 16), Vector2(16, 0),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
if not is_switch_animation:
|
|
|
|
|
return
|
|
|
|
|
switch_animation_time += delta if is_switch else -delta
|
|
|
|
|
switch_animation_time = max(0, min(switch_animation_time, switch_animation_time_max))
|
|
|
|
|
var rate = switch_animation_time / switch_animation_time_max
|
|
|
|
|
animation_lerp(rate)
|
|
|
|
|
|
|
|
|
|
if switch_animation_time == switch_animation_time_max or switch_animation_time == 0:
|
|
|
|
|
is_switch_animation = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_core_active_list_changed(core_list: Array[CoreCfg]):
|
|
|
|
|
for i in range(len(core_list)):
|
|
|
|
|
var cfg: CoreCfg = core_list[i]
|
|
|
|
|
var item: CoreItemSub = core_item_list[i] as CoreItemSub
|
|
|
|
|
item.set_info(cfg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_is_switch_changed(value: bool):
|
|
|
|
|
is_switch = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func on_is_lock_changed(value: bool):
|
|
|
|
|
is_lock = value
|
|
|
|
|
|
|
|
|
|
func animation_lerp(rate: float):
|
|
|
|
|
position = lerp(switch_center_pos1, switch_center_pos2, rate)
|
|
|
|
|
for i in len(core_item_list):
|
|
|
|
|
var item: CoreItemSub = core_item_list[i] as CoreItemSub
|
|
|
|
|
item.position = lerp(switch_item_pos1[i], switch_item_pos2[i], rate)
|
|
|
|
|
item.detail_rate = rate
|
|
|
|
|
for i in len(core_item_input_list):
|
|
|
|
|
var item: InputItem = core_item_input_list[i] as InputItem
|
|
|
|
|
item.position = lerp(core_item_input_pos1, core_item_input_pos2[i], rate)
|
|
|
|
|
item.detail_rate = rate
|