import { AwardType, EAdType, Prop } from "../data/Define"; import UIBase from "../fgui/core/UIBase"; import ui_AwardItem from "../fgui/res/game/ui_AwardItem"; import ui_UIGetAward from "../fgui/res/game/ui_UIGetAward"; import PlatMgr from "../game/PlatMgr"; import { xGame } from "../xGame"; import GlobalManager from "../utils/GlobalManager"; import JSBridgeUtils from "../utils/JSBridgeUtils"; export default class UIGetAward extends UIBase { public ui: ui_UIGetAward; // public awardArr: Array; public showTriple: boolean = true; public callback: Function; public constructor() { super(); } protected onConstructor(): void { this.ui = ui_UIGetAward.createInstance(); this.contentPane = this.ui; this.isEject = false; this.addUIClick(this.ui.btnNode.tripleBtn, this.tripleGetAward); this.addUIClick(this.ui.btnNode.normalBtn, this.normalGetAward); // this.ui.myList.itemRenderer = Laya.Handler.create(this, this.renderItem, null, false); } public show(arr: Array, showTriple, callback): void { super.show(); this.ui.t0.play(); this.ui.eftNode.visible = true; this.ui.eftNode.t0.play(Laya.Handler.create(this, () => { this.ui.eftNode.visible = false; }), 1, 0, 0, 0.9); // this.awardArr = arr; this.showTriple = showTriple; this.callback = callback; // this.ui.btnNode.c1.selectedIndex = this.showTriple ? 0 : 1; this.ui.myList.numItems = arr.length; // xGame.soundMgr.playSound("getaward"); } updateSelf(index, obj: ui_AwardItem) { let temp: AwardType = this.awardArr[index]; let icon = this.getIcon(temp.type); let str = icon; if (temp.type > 2) { str = "s" + icon; } obj.myIcon.url = xGame.common.getGameIconUrl(str); obj.myIcon.rotation = 0; obj.numTxt.text = temp.num + ""; obj.numTxt.visible = temp.type > 2 ? false : true; obj.nameTxt.text = this.getNameStr(temp.type); } renderItem(index, obj: ui_AwardItem) { this.updateSelf(index, obj); } public tripleGetAward() { console.log('zh:qjff_AD_for_uigetAward') // GlobalManager.instance.registerMethod('xxxxx',this.xxxxx); // JSBridgeUtils.instance.showRewardAd('xxxxx'); if (Laya.Browser.onAndroid) { let boo = JSBridgeUtils.instance.getNetworkAvailable(); if (!boo) { JSBridgeUtils.instance.showToast2("Network error, reward unavailable"); return; } } if (JSBridgeUtils.instance.showRewardAd('qjff_AD_for_uigetAward')) { } else { console.log('zh:AD 失败,直接发放奖励') this.qjff_AD_for_uigetAward(); } // Moyu.showVideoAd(() => { // this.getAward(3); // }, EAdType.triple) } public qjff_AD_for_uigetAward() { this.getAward(3); } public normalGetAward() { if (PlatMgr.isMisVideo()) this.tripleGetAward() else this.getAward(); } public getAward(times = 1) { this.hide(); for (let index = 0; index < this.awardArr.length; index++) { this.awardArr[index].num *= times; } this.callback && this.callback(times != 1); } public getIcon(type) { switch (type) { case Prop.diamond: return "ty_zs"; case Prop.coin: return "ty_jb"; case Prop.gan1: return "qg1"; case Prop.gan2: return "qg2"; case Prop.gan3: return "qg3"; case Prop.gan4: return "qg4"; default: break; } } public getNameStr(type) { switch (type) { case Prop.diamond: return "Diamond"; case Prop.coin: return "Coins"; case Prop.gan1: case Prop.gan2: case Prop.gan3: case Prop.gan4: return cfgTable.ballrodData[type - 1].name; default: break; } } } UIGetAward.uiName = "UIGetAward"