import { _decorator} from 'cc'; import { Constants } from '../data/Constants'; import MsgHints from '../utils/MsgHints'; import { settingData } from '../data/SettingData'; import { audioMgr } from '../core/manager/AudioManager'; const { ccclass, property } = _decorator; class PlatformBrowser { adInstance: any = null; gtag: any = null; openAd: boolean = true; public initialize(): void { this.initilizeWindow(); this.adInstance = (window as any)['adInstance']; try { window["__woso"]?.["TopCallback"]?.(); } catch (error) { } console.log('web ads sdk初始化'); } private initilizeWindow() { window["youxi"] = { SoundManager: { pauseAll: () => { settingData.data.soundFx = false; settingData.data.bgMusic = false; settingData.saveToCache(); audioMgr.stop(Constants.audios.BGM); }, resumeAll: () => { settingData.data.soundFx = true; settingData.data.bgMusic = true; audioMgr.play(Constants.audios.BGM,true); settingData.saveToCache(); } }, GameManager: { pauseAll: () => { // console.log(`暂停游戏`); }, resumeAll: () => { // console.log(`开始游戏`); } }, TargetedAds: { open: () => { console.log("开启广告"); }, clos: () => { console.log("关闭广告"); } }, Fps: { setfps: (value) => { // GlobalMgr.instance.setfps(value); } } }; } /**显示插屏广告*/ public showInterstitialAd(cb?:Function): void { if(Constants.isDebug){ console.log('模拟显示插屏广告回调'); cb?.(); return } try { window['showAd']('interstitial').then(() => { console.log("rewarded11111") }).catch(() => { // GtagMgr.inst.doGameDot(GtagType.ad_error); }); } catch (error) { // tgxUITips.show('The ad failed to load') } } /** 显示激励广告*/ public showRewardVideo(cb:Function): void { if(Constants.isDebug){ console.log('模拟激励广告回调'); cb?.(true); return } try { window["showAd"]('rewarded') .then(() => { cb?.(true) }) .catch(() => { //上报信息 // GtagMgr.inst.doGameDot(GtagType.ad_error); // cb && cb(); }) return } catch (error) { } //tgxUITips.show('The ads failed to load'); } /** 显示激励广告*/ public hideBannerAd(): void { } public showBannerAd(): void { } public vibrateShort(): void { } } export default new PlatformBrowser();