1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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();
- }
- }
- }
|