123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { sys } from "cc";
- import { WeChatAdManager } from "./WeChatAdManager";
- import { DouYinAdManager } from "./DouYinAdManager";
- import { KuaiShouAdManager } from "./KuaiShouAdManager";
- export class AdManager {
- private static _instance: AdManager;
- public static getInstance(): AdManager {
- if (!AdManager._instance) {
- if ((sys.platform == sys.Platform.WECHAT_GAME) && window.ks) {
- AdManager._instance = new AdManager('kuaihsou');
- } else if (sys.platform == sys.Platform.WECHAT_GAME) {
- AdManager._instance = new AdManager('wechat');
- } else if (sys.platform == sys.Platform.BYTEDANCE_MINI_GAME) {
- AdManager._instance = new AdManager('douyin');
- } else {
- AdManager._instance = new AdManager('wechat');
- }
- }
- return AdManager._instance;
- }
- private currentAdManager: WeChatAdManager | DouYinAdManager | KuaiShouAdManager;
- constructor(platform: string) {
- sys.Platform.WECHAT_GAME
- switch (platform) {
- case 'wechat':
- this.currentAdManager = new WeChatAdManager();
- break;
- case 'douyin':
- this.currentAdManager = new DouYinAdManager();
- break;
- case 'kuaihsou':
- this.currentAdManager = new KuaiShouAdManager();
- break;
- default:
- console.log('Unsupported platform');
- }
- }
- public showBannerAd() {
- if (this.currentAdManager) {
- this.currentAdManager.showBannerAd();
- }
- }
- public showRewardVideoAd(successCallback: (res) => void) {
- if (this.currentAdManager) {
- this.currentAdManager.showRewardVideoAd(successCallback);
- }
- }
- public showInterstitialAd() {
- if (this.currentAdManager) {
- this.currentAdManager.showInterstitialAd();
- }
- }
- }
|