declare module 'phaser-ads' { export = PhaserAds ; } module PhaserAds { export interface IAdGame extends Phaser . Game { ads : AdManager ; } export enum AdEvent { start , firstQuartile , midPoint , thirdQuartile , complete } export enum AdType { interstitial , rewarded , banner , video } export class AdManager extends Phaser . Plugin { public onContentPaused : Phaser . Signal = new Phaser . Signal ( ) ; public onContentResumed : Phaser . Signal = new Phaser . Signal ( ) ; public onAdProgression : Phaser . Signal = new Phaser . Signal ( ) ; public onAdsDisabled : Phaser . Signal = new Phaser . Signal ( ) ; public onAdClicked : Phaser . Signal = new Phaser . Signal ( ) ; public onAdRewardGranted : Phaser . Signal = new Phaser . Signal ( ) ; public onAdLoaded : Phaser . Signal = new Phaser . Signal ( ) ; public onBannerShown : Phaser . Signal = new Phaser . Signal ( ) ; public onBannerHidden : Phaser . Signal = new Phaser . Signal ( ) ; public bannerActive : boolean = false ; private provider : AdProvider . IProvider = null ; private wasMuted : boolean = false ; constructor ( game , pluginManager ) { super ( game , pluginManager ) ; Object . defineProperty ( game , 'ads' , { value : this } ) ; } param provider public setAdProvider ( provider ) { this . provider = provider ; this . provider . setManager ( this ) ; } param args public showAd ( ... args ) { if ( null === this . provider ) { throw new Error ( 'Can not request an ad without an provider, please attach an ad provider!' ) ; } if ( args [ 0 ] !== AdType . banner ) { this . wasMuted = this . game . sound . mute ; this . game . sound . mute = true ; } this . provider . showAd . apply ( this . provider , args ) ; } public loadBanner ( ... args ) { return this . provider . loadBanner . apply ( this . provider , args ) ; } public isRewardedAvailable ( ) { return this . provider . hasRewarded ; } param args public preloadAd ( ... args ) { if ( null === this . provider ) { throw new Error ( 'Can not preload an ad without an provider, please attach an ad provider!' ) ; } this . provider . preloadAd . apply ( this . provider , args ) ; } param args public destroyAd ( ... args ) { if ( null === this . provider ) { throw new Error ( 'Can not destroy an ad without an provider, please attach an ad provider!' ) ; } this . provider . destroyAd . apply ( this . provider , args ) ; } param args public hideAd ( ... args ) { if ( null === this . provider ) { throw new Error ( 'Can not hide an ad without an provider, please attach an ad provider!' ) ; } this . unMuteAfterAd ( ) ; this . provider . hideAd . apply ( this . provider , args ) ; } param args public adsEnabled ( ) { return this . provider . adsEnabled ; } /**
         * Should be called after ad was(n't) shown, demutes the game so we can peacefully continue
         */ public unMuteAfterAd ( ) { if ( ! this . wasMuted ) { this . game . sound . mute = false ; } } } }