import UIBase from "../fgui/core/UIBase"; import ui_BallRodDisplay from "../fgui/res/game/ui_BallRodDisplay"; import ui_daoJuDisplay from "../fgui/res/game/ui_daoJuDisplay"; import ui_UIShop from "../fgui/res/game/ui_UIShop"; import { xGame } from "../xGame"; import BallRodDisplay from "./item/BallRodDisplay"; import DaoJuDisplay from "./item/DaoJuDisplay"; import MoneyNode from "./item/MoneyNode"; export default class UIShop extends UIBase { protected ui: ui_UIShop; public moneyNode: MoneyNode; public ballRodArr: Array; public daoJuArr: Array; public itemNums: number = 0; public itemNumsForDj: number = 0; public curType: string = ""; public constructor() { super(); } protected onConstructor(): void { this.ui = ui_UIShop.createInstance(); this.contentPane = this.ui; this.isEject = false; this.moneyNode = new MoneyNode(this.ui.moneyNode); // this.addUIClick(this.ui.closeNode.closeBtn, this.closeSelf); this.addUIClick(this.ui.myNode.n_qiuGan, () => this.switchBtn("qiugan")); this.addUIClick(this.ui.myNode.n_daoju, () => this.switchBtn("daoju")); // this.addUIClick(this.ui.btn_qiugan, this.test123); // this.addUIClick(this.ui.btn_daoju, this.test123); this.addUIClick(this.ui, this.interuptSecretary); // console.log('zh:this.renderBallRodthis.renderBallRodthis.renderBallRodthis.renderBallRod = ' + this.renderBallRod) this.ui.myNode.myList.itemRenderer = Laya.Handler.create(this, this.renderBallRod, null, false); this.ballRodArr = []; this.itemNums = Object.keys(cfgTable.ballrodData).length; this.ui.myNode.myList.numItems = this.itemNums; // if (Moyu.isKs) // this.ui.closeNode.closeBtn.x += 100; //道具数据----------------start this.ui.myNode.djList.itemRenderer = Laya.Handler.create(this, this.renderDaoJu, null, false); this.daoJuArr = []; this.itemNumsForDj = Object.keys(cfgTable.daoJuData).length; this.ui.myNode.djList.numItems = this.itemNumsForDj; //道具数据----------------end } public show(type): void { super.show(); console.log('zh:show type = ' + type) //type,0-球杆,1-道具 this.curType = type == 0 ? "qiugan" : "daoju"; this.switchBtn("qiugan"); this.playSecretaryIdle(); this.updateBallRod(); } test123() { console.log('zh:test123 ') } switchBtn(type: string) { console.log('zh:1111切換 sel type=' + type) if (type == "") { type = this.curType; } else { if (this.curType == type) { return; } else { this.curType = type; } } if (type == "qiugan") { this.ui.myNode.n_qiuGan.c1.selectedIndex = 0; this.ui.myNode.n_daoju.c1.selectedIndex = 1; this.ui.myNode.myList.visible = true; this.ui.myNode.djList.visible = false; } else { this.ui.myNode.n_qiuGan.c1.selectedIndex = 1; this.ui.myNode.n_daoju.c1.selectedIndex = 0; this.ui.myNode.myList.visible = false; this.ui.myNode.djList.visible = true; } } updateBallRod() { for (let index = 0; index < this.ballRodArr.length; index++) { this.ballRodArr[index].updateSelf(); } } renderBallRod(sort, obj: ui_BallRodDisplay) { let index = this.getIndexBySort(sort + 1) - 1; let ballRod = new BallRodDisplay(obj, index); this.ballRodArr.push(ballRod); } renderDaoJu(sort, obj: ui_daoJuDisplay) { let index = this.getIndexBySortForDj(sort + 1) - 1; let b = new DaoJuDisplay(obj, index); this.daoJuArr.push(b); } getIndexBySort(sort) { let object = cfgTable.ballrodData; for (const key in object) { if (object[key].sort == sort) { return parseInt(key); } } } getIndexBySortForDj(sort) { let object = cfgTable.daoJuData; for (const key in object) { if (object[key].sort == sort) { return parseInt(key); } } } playSecretaryIdle() { let parent = this.ui.secretary.displayObject; parent.destroyChildren(); let xx = this.ui.secretary.width / 2 let yy = this.ui.secretary.height; let scale = xGame.common.getSecretaryScale(); let data = { x: xx, y: yy, scaleX: scale, scaleY: scale }; // xGame.common.secretary.play(data, 1, true, parent); xGame.common.secretary.play(data, 0, true, parent); } interuptSecretary() { Laya.timer.clearAll(this); this.playSecretaryRandomSound(); } //主界面和技能选择界面3-7秒未操作随机播放秘书音效 playSecretaryRandomSound() { if (this.isHide) return; let time = xGame.common.randomNum(45000, 60000); Laya.timer.once(time, this, () => { if (this.isHide) return; let index = xGame.common.randomNum(4, 7); xGame.soundMgr.playSound("s_main0" + index); let words = 1; switch (index) { case 4: words = 5; break; case 5: words = 3; break; case 6: words = 6; break; case 7: words = 7; break; default: break; } xGame.common.showGirlTalkPop(words, this.ui.talkNode, this.ui.talkNode.womanTxt); // this.playSecretaryRandomSound(); }) } closeSelf() { this.hide(); } } UIShop.uiName = "UIShop";