@chiyou/minigame-framework 1.4.10 → 1.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -54,10 +54,10 @@ export type AdPlatformUnitInfo = {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export type AdPlatformSettingInfo = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
permanentAd_firstShowInterval_registerUser: number;
|
|
58
|
+
permanentAd_firstShowInterval_retainUser: number;
|
|
59
|
+
interstitialAd_showIntervalBase_registerUser: number;
|
|
60
|
+
interstitialAd_showIntervalBase_retainUser: number;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
//BannerAd
|
|
@@ -67,6 +67,9 @@ export class AdMgr extends BaseMgr {
|
|
|
67
67
|
/** 内容区域底部 */
|
|
68
68
|
private static contentBottom: number = 0;
|
|
69
69
|
|
|
70
|
+
private static interstitialAdIntervalBase: number = 60000;
|
|
71
|
+
private static permanentAdFirstShowInterval: number = 60000;
|
|
72
|
+
|
|
70
73
|
private rewardedVideoAdCallbackToBusinessStatusSet: Set<RewardedVideoAd_Callback_Status> = new Set<RewardedVideoAd_Callback_Status>(
|
|
71
74
|
[
|
|
72
75
|
RewardedVideoAd_Callback_Status.Status_LoadError,
|
|
@@ -136,7 +139,7 @@ export class AdMgr extends BaseMgr {
|
|
|
136
139
|
AdMgr.adPlatformSettingMap = adPlatformSettingMap;
|
|
137
140
|
|
|
138
141
|
let adAdapterImpl: AbsAdAdapter = null;
|
|
139
|
-
switch (
|
|
142
|
+
switch (currentPlatformID) {
|
|
140
143
|
case PlatformID.ID_MiniGame_WeiXin:
|
|
141
144
|
adAdapterImpl = this.node.addComponent(AdAdapterWeiXin);
|
|
142
145
|
break;
|
|
@@ -348,6 +351,24 @@ export class AdMgr extends BaseMgr {
|
|
|
348
351
|
|
|
349
352
|
/** 创建所有广告实例 */
|
|
350
353
|
public createAds(): void {
|
|
354
|
+
if (this.userMgr === null) {
|
|
355
|
+
this.userMgr = ServiceLocator.Instance.get<UserMgr>("UserMgr");
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
AdMgr.interstitialAdIntervalBase = 60000;
|
|
359
|
+
AdMgr.permanentAdFirstShowInterval = 60;
|
|
360
|
+
let currentPlatformID: PlatformID = this.getCurrentPlatformID();
|
|
361
|
+
if (AdMgr.adPlatformSettingMap.has(currentPlatformID) && AdMgr.adPlatformSettingMap.get(currentPlatformID) !== null) {
|
|
362
|
+
let adPlatformSettingInfo: AdPlatformSettingInfo = AdMgr.adPlatformSettingMap.get(currentPlatformID);
|
|
363
|
+
AdMgr.interstitialAdIntervalBase = adPlatformSettingInfo.interstitialAd_showIntervalBase_retainUser;
|
|
364
|
+
AdMgr.permanentAdFirstShowInterval = adPlatformSettingInfo.permanentAd_firstShowInterval_retainUser;
|
|
365
|
+
|
|
366
|
+
if (this.userMgr && this.userMgr.isNewUser()) {
|
|
367
|
+
AdMgr.interstitialAdIntervalBase = adPlatformSettingInfo.interstitialAd_showIntervalBase_registerUser;
|
|
368
|
+
AdMgr.permanentAdFirstShowInterval = adPlatformSettingInfo.permanentAd_firstShowInterval_registerUser;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
351
372
|
this.createInterstitialAd();
|
|
352
373
|
this.createRewardedVideoAd();
|
|
353
374
|
this.createPortalAd();
|
|
@@ -535,29 +556,12 @@ export class AdMgr extends BaseMgr {
|
|
|
535
556
|
return;
|
|
536
557
|
}
|
|
537
558
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
if (AdMgr.adPlatformSettingMap.has(this.getCurrentPlatformID())) {
|
|
541
|
-
let adPlatformSettingInfo: AdPlatformSettingInfo = AdMgr.adPlatformSettingMap.get(this.getCurrentPlatformID());
|
|
542
|
-
launchNoAdInterval = adPlatformSettingInfo.launchNoAdInterval_interstitialAd;
|
|
543
|
-
|
|
544
|
-
interstitialAdIntervalBase = adPlatformSettingInfo.retainUser_interstitialAd_IntervalBase;
|
|
545
|
-
|
|
546
|
-
if (this.userMgr === null) {
|
|
547
|
-
this.userMgr = ServiceLocator.Instance.get<UserMgr>("UserMgr");
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (this.userMgr && this.userMgr.isNewUser()) {
|
|
551
|
-
interstitialAdIntervalBase = adPlatformSettingInfo.registerUser_interstitialAd_IntervalBase;
|
|
552
|
-
}
|
|
559
|
+
if (this.userMgr === null) {
|
|
560
|
+
this.userMgr = ServiceLocator.Instance.get<UserMgr>("UserMgr");
|
|
553
561
|
}
|
|
554
|
-
let interstitialAdInterval: number = interstitialAdIntervalBase * AdMgr.interstitialAd_nowIntervalCount;
|
|
555
562
|
|
|
563
|
+
let interstitialAdInterval: number = AdMgr.interstitialAdIntervalBase * AdMgr.interstitialAd_nowIntervalCount;
|
|
556
564
|
let now: number = new Date().getTime();
|
|
557
|
-
if (now - AdMgr.launchTime < launchNoAdInterval) {
|
|
558
|
-
AdMgr.interstitialAdCallback(InterstitialAd_Callback_Status.Status_InsufficientInterval);
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
565
|
if (now - AdMgr.lastInterstitialAdTimestamp < interstitialAdInterval) {
|
|
562
566
|
AdMgr.interstitialAdCallback(InterstitialAd_Callback_Status.Status_InsufficientInterval);
|
|
563
567
|
return;
|
|
@@ -823,14 +827,9 @@ export class AdMgr extends BaseMgr {
|
|
|
823
827
|
/** 显示所有常驻广告 */
|
|
824
828
|
public showAllPermanentAd(): void {
|
|
825
829
|
let delay: number = 0;
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
let launchNoAdInterval: number = AdMgr.adPlatformSettingMap.get(currentPlatformID).launchNoAdInterval_permanentAd;
|
|
830
|
-
let now: number = new Date().getTime();
|
|
831
|
-
if (now - AdMgr.launchTime < launchNoAdInterval) {
|
|
832
|
-
delay = Math.floor((launchNoAdInterval - (now - AdMgr.launchTime)) / 1000);
|
|
833
|
-
}
|
|
830
|
+
let now: number = new Date().getTime();
|
|
831
|
+
if (now - AdMgr.launchTime < AdMgr.permanentAdFirstShowInterval) {
|
|
832
|
+
delay = Math.floor((AdMgr.permanentAdFirstShowInterval - (now - AdMgr.launchTime)) / 1000);
|
|
834
833
|
}
|
|
835
834
|
|
|
836
835
|
if (!AdMgr.isPermanentAdShowing) {
|