123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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<AwardType>;
- 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<AwardType>, 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"
|