feat: 创建 upgrade 数据resource,编写upgrade_panel.gd动态生成升级卡片

This commit is contained in:
luke358
2026-05-21 16:04:27 +08:00
parent ce3813c5dc
commit 1796d9e47d
14 changed files with 170 additions and 17 deletions
+16 -6
View File
@@ -1,11 +1,21 @@
extends Panel
class_name UpgradePanel
# Called when the node enters the scene tree for the first time.
const UPGRADE_CARD_SCENE = preload("uid://bfohai4xgom8w")
@export var upgrade_list: Array[ItemUpgrade]
@onready var items_container: HBoxContainer = %ItemsContainer
func _ready() -> void:
pass # Replace with function body.
load_upgrades()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func load_upgrades() -> void:
for child in items_container.get_children():
child.queue_free()
for i in 4:
var random_upg := upgrade_list.pick_random() as ItemUpgrade
var card_instance := UPGRADE_CARD_SCENE.instantiate() as UpgradeCard
items_container.add_child(card_instance)
card_instance.item_data = random_upg