58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import AudioUtil from "../core/AudioUtil";
|
|
import FGUtil from "../gear_2.3.4/fgui/FGUtil";
|
|
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
|
|
import ItemUtil from "../core/ItemUtil";
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class xwItemList extends cc.Component {
|
|
/**
|
|
* 信物面板單例實例
|
|
*/
|
|
public static Instance: xwItemList = null;
|
|
/**
|
|
* 信物列表面板
|
|
*/
|
|
private listPanel: fgui.GComponent = null;
|
|
/**
|
|
* 需要加載的預製體
|
|
*/
|
|
prefabObject: any = {};
|
|
|
|
onLoad() {
|
|
if (xwItemList.Instance === null) {
|
|
xwItemList.Instance = this;
|
|
this.loadPrefab();
|
|
} else {
|
|
this.destroy();
|
|
return;
|
|
}
|
|
}
|
|
|
|
loadPrefab() {
|
|
// 加載所需的預製體
|
|
var prefabList = [
|
|
// { url: "Prefabs/UIRole", name: "UIRole" },
|
|
]
|
|
this.prefabObject = {}
|
|
for (let item of prefabList) {
|
|
cc.loader.loadRes(item.url, cc.Prefab, (err, prefab) => {
|
|
if (err)
|
|
console.warn(err);
|
|
else {
|
|
this.prefabObject[item.name] = prefab;
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
openXWList() {
|
|
if (!this.listPanel || (this.listPanel && !this.listPanel.node && !SKUIUtil.isValid(this.listPanel.node))) {
|
|
this.listPanel = FGUtil.create("main_ui", "bagua_my_posinfo");
|
|
FGUtil.root().addChild(this.listPanel);
|
|
FGUtil.fitScreen(this.listPanel)
|
|
}
|
|
}
|
|
}
|
|
|