mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(武器系统): 添加武器位置交换功能
- 在ArrayTool中添加swap方法用于数组元素交换 - 为武器卡片添加左右移动按钮 - 实现武器位置交换逻辑,包括UI更新和数组同步
This commit is contained in:
@@ -30,6 +30,8 @@ class_name Weapon
|
||||
@onready var extractBtn: Button = $"%extractBtn"
|
||||
@onready var inlayBtn: Button = $"%inlayBtn"
|
||||
@onready var sounds: Node2D = $"%sounds"
|
||||
@onready var moveLeftBtn: Button = $"%moveleft"
|
||||
@onready var moveRightBtn: Button = $"%moveright"
|
||||
|
||||
var cooldownTimer: CooldownTimer = null
|
||||
var originalStore: Dictionary = {}
|
||||
@@ -62,6 +64,20 @@ func _ready():
|
||||
updateStore(level, UIState.player)
|
||||
rebuildInfo()
|
||||
)
|
||||
moveLeftBtn.pressed.connect(
|
||||
func():
|
||||
var myIndex = get_index()
|
||||
var leftIndex = max(myIndex - 1, 0)
|
||||
get_parent().move_child(self, leftIndex)
|
||||
ArrayTool.swap(UIState.player.weapons, myIndex, leftIndex)
|
||||
UIState.player.rebuildWeaponIcons()
|
||||
)
|
||||
moveRightBtn.pressed.connect(
|
||||
func():
|
||||
var myIndex = get_index()
|
||||
var rightIndex = min(myIndex + 1, get_parent().get_child_count() - 1)
|
||||
get_parent().move_child(self, rightIndex)
|
||||
)
|
||||
for i in sounds.get_children():
|
||||
i.process_mode = ProcessMode.PROCESS_MODE_ALWAYS
|
||||
rebuildInfo()
|
||||
|
||||
Reference in New Issue
Block a user