import { _decorator, Component, Button, ScrollView } from 'cc'; import { GameManager } from '../core/GameManager'; const { ccclass, property } = _decorator; /** * BagScene 背包/仓库/装备槽 UI。 */ @ccclass('BagScene') export class BagScene extends Component { @property({ type: Button }) public backButton: Button | null = null; @property({ type: ScrollView }) public inventoryScroll: ScrollView | null = null; onLoad() { this.backButton?.node.on(Button.EventType.CLICK, this.onBack, this); this.loadInventory(); } private async loadInventory() { // TODO: 查询 inventories / equipments 并渲染列表 } public onUseItem(inventoryId: string) { // TODO: 使用物品或上架交易行 console.log('use item', inventoryId); } private onBack() { GameManager.getInstance().switchScene('LobbyScene'); } onDestroy() { this.backButton?.node.off(Button.EventType.CLICK, this.onBack, this); } }