import { ui } from "./ui/layaMaxUI"; import AdManager from "./sdk/AdManager"; import { AppSdk } from "./sdk/AppSdk"; import ShakeModel from "./sdk/model/ShakeModel"; import RedpacketModel from "./sdk/model/RedpacketModel"; export default class TestScene extends ui.TestSceneUI { constructor() { super(); //关闭多点触控,否则就无敌了 Laya.MouseManager.multiTouchEnabled = false; console.log('---------------TestScene-------') this.NativeAD.visible = false; } onEnable(): void { this.btnServer.on(Laya.Event.CLICK, this, this.openServer); this.btnDrawal.on(Laya.Event.CLICK, this, this.openPersonal); this.btnInvite.on(Laya.Event.CLICK, this, this.invitation); this.btn_shake.on(Laya.Event.CLICK, this, this.touchShake); this.btnPreloadAD.on(Laya.Event.CLICK, this, this.preloadAD); this.btnShowBanner.on(Laya.Event.CLICK, this, this.showBanner); this.btnShowFullAd.on(Laya.Event.CLICK, this, this.showFullAd); this.btnShowNativeAd.on(Laya.Event.CLICK, this, this.showNativeAd); this.btnShowInterAd.on(Laya.Event.CLICK, this, this.showInterAd); this.btnRewardAd.on(Laya.Event.CLICK, this, this.showRewardAd); this.btnRedpacket.on(Laya.Event.CLICK, this, this.openRedpacket); } /**预加载广告 */ async preloadAD() { console.log('---------------preloadAD-------') await AdManager.I.init(); } /**显示全屏广告 */ showFullAd() { console.log('---------------showFullAd-------') AdManager.I.showFullAd(); } /**显示banner */ showBanner() { console.log('---------------showBanner-------') AdManager.I.showBanner(); } /**信息流广告 */ showNativeAd() { console.log('---------------showNativeAd-------') this.NativeAD.visible = true; } /**插屏广告 */ showInterAd() { console.log('---------------showInterAd-------') AdManager.I.showInterAd(); } /**激励视频广告 */ async showRewardAd() { console.log('---------------showRewardAd-------') await AdManager.I.showRewardAd(); /**成功后执行对应的奖励 */ } /**意见反馈 */ openServer() { console.log('---------------openServer-------') AppSdk.I.feedback(); } openRedpacket() { RedpacketModel.I.checkRedpacket(); console.log('红包获取结果:curRedpacket' + RedpacketModel.I.curRedpacket) // console.log('红包获取结果:' + JSON.stringify(data)) // ViewManager.I.openPopwin(RedpacketPopwin, 0); } /**打开个人中心 */ openPersonal() { console.log('---------------openServer-------') AppSdk.I.personal(0); } /**邀请好友 */ invitation() { AppSdk.I.invitation(); } /** * 1 金币 2 激励视频后金币 3 4 5 6 7 游戏中对应的道具 8 空 */ touchShake() { console.log('---------------touchShake-------') // this.skin.btnShakeAni.play(0); AppSdk.I.vibrate(); // ViewManager.I.showModal(HintModal, ' 今⽇次数已⽤完,请明⽇再来'); // this.skin.handAni.stop(); /** * 1.回去星星 道具 * 2.红包 直接获得⾦币;或者直接弹激励视频后,获得⾦币 * 3.无道具 * 直接展⽰插屏 * */ let data = ShakeModel.I.getShakeType(); console.log('摇一摇获取结果:' + JSON.stringify(data)) if (!data) return; let type = data.type; switch (type) { case 8: /** '谢谢参与,下次好运!'*/; AdManager.I.showInterAd(); break; case 1: this.getCoin(); break; case 2: this.watchADCoin(); break; case 3: case 4: case 5: case 6: case 7: this.getProps(data); break; } } getProps(data) { let booster; let rewardNum = data.num; let type = data.type; /** * 处理游戏中的道具显示 */ // switch (type) { // case 4: // booster = BoosterType.Remove; // break; // case 6: // booster = BoosterType.Change; // break; // case 5: // booster = BoosterType.Refresh; // break; // case 7: // booster = BoosterType.RandRemove; // break; // case 3: // booster = BoosterType.Star; // break; // } // ViewManager.I.openPopwin(ReceivePropsPopwin, booster, rewardNum); } /** * 看广告获得红包 */ async watchADCoin() { await AdManager.I.showRewardAd(); this.getCoin(); } /**直接获得红包 */ getCoin() { //刷新总金币 // AppManager.I.redpacket.getRepacket() // ViewManager.I.openPopwin(RedPacketReward, 2); } }