| | |
| | | import { SdkDefault } from "./SdkDefault"; |
| | | |
| | | |
| | | var rewardCallback = null; |
| | | export class SdkHuawei { |
| | | export class SdkHuawei extends SdkDefault { |
| | | |
| | | private lastShowInterAdTime: number = 0; |
| | | |
| | | private static interstitialAd = null; |
| | | private static rewardedVideoAd = null; |
| | | private static interstitialAdLoaded: boolean = false; |
| | | private interstitialAd = null; |
| | | private rewardedVideoAd = null; |
| | | private interstitialAdLoaded: boolean = false; |
| | | |
| | | /** |
| | | * 开始游戏 |
| | | * @param cb |
| | | */ |
| | | static startGame(cb?: Function): void { |
| | | startGame(cb?: Function): void { |
| | | cc.log('SdkHuawei startGame.'); |
| | | |
| | | qg.gameLoginWithReal({ |
| | |
| | | if (code == 7004 || code == 2012) { |
| | | console.log("玩家取消登录,返回游戏界面让玩家重新登录。"); |
| | | cc.director.loadScene('logo'); |
| | | }else |
| | | //状态码为7021表示玩家取消实名认证。 |
| | | //在中国大陆的情况下,此时需要禁止玩家进入游戏。 |
| | | if (code == 7021) { |
| | | console.log("The player has canceled identity verification. Forbid the player from entering the game.") |
| | | cc.director.loadScene('logo'); |
| | | }else{ |
| | | cc.game.end(); |
| | | } |
| | | } else |
| | | //状态码为7021表示玩家取消实名认证。 |
| | | //在中国大陆的情况下,此时需要禁止玩家进入游戏。 |
| | | if (code == 7021) { |
| | | console.log("The player has canceled identity verification. Forbid the player from entering the game.") |
| | | cc.director.loadScene('logo'); |
| | | } else { |
| | | cc.game.end(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | static getOAID() { |
| | | getOAID() { |
| | | "function" == typeof qg.getOAID && qg.getOAID({ |
| | | success: function (ret) { |
| | | console.log("qg.getOAID success :" + JSON.stringify(ret)); |
| | |
| | | } |
| | | |
| | | //Ads |
| | | static showInterAd() { |
| | | showInterAd() { |
| | | cc.log('show InterAd'); |
| | | // if (Date.now() - this.lastShowInterAdTime > 30000) {//最少间隔30秒 |
| | | // this.lastShowInterAdTime = Date.now(); |
| | |
| | | |
| | | } |
| | | |
| | | static loadInterAd() { |
| | | loadInterAd() { |
| | | if (this.interstitialAd) { |
| | | this.interstitialAd.destroy(); |
| | | } |
| | | this.interstitialAd = qg.createInterstitialAd({ |
| | | adUnitId: |
| | | "g2tz5d4wkv" //测试ID |
| | | //"q5m5hlquus"//正式ID |
| | | // "g2tz5d4wkv" //测试ID |
| | | "q5m5hlquus"//正式ID |
| | | }); |
| | | this.interstitialAd.load({ |
| | | "channelExtras": { |
| | |
| | | }); |
| | | } |
| | | |
| | | static reLoadVideo() { |
| | | reLoadVideo() { |
| | | this.rewardedVideoAd = qg.createRewardedVideoAd({ |
| | | adUnitId: |
| | | "testx9dtjwj8hp" //测试ID |
| | | //"v1gtsb1ga8" //正式ID |
| | | // "testx9dtjwj8hp" //测试ID |
| | | "v1gtsb1ga8" //正式ID |
| | | , |
| | | success: (code) => { |
| | | cc.log("ad demo : loadAndShowVideoAd createRewardedVideoAd success"); |
| | |
| | | this.rewardedVideoAd.load() |
| | | } |
| | | |
| | | static showVideoAd(cb?: (result: boolean) => void) { |
| | | showVideoAd(cb?: (result: boolean) => void) { |
| | | cc.log('show VideoAd'); |
| | | // cb && cb(true); |
| | | |
| | |
| | | this.rewardedVideoAd.load(); |
| | | } |
| | | |
| | | isPaymentReady(cb?: (result: boolean) => void) { |
| | | cb && cb(false); |
| | | } |
| | | |
| | | } |