@chiyou/minigame-framework 1.0.2 → 1.0.3

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.
Files changed (114) hide show
  1. package/assets/Scripts/index.ts +2 -5
  2. package/package.json +5 -10
  3. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +0 -78
  4. package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +0 -230
  5. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +0 -31
  6. package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +0 -224
  7. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +0 -34
  8. package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +0 -524
  9. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +0 -34
  10. package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +0 -631
  11. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +0 -33
  12. package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +0 -460
  13. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +0 -31
  14. package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +0 -227
  15. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +0 -33
  16. package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +0 -458
  17. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +0 -35
  18. package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +0 -770
  19. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +0 -33
  20. package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +0 -519
  21. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +0 -33
  22. package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +0 -492
  23. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +0 -33
  24. package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +0 -695
  25. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +0 -34
  26. package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +0 -597
  27. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +0 -33
  28. package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +0 -458
  29. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +0 -51
  30. package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +0 -17
  31. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +0 -45
  32. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +0 -555
  33. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +0 -44
  34. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +0 -148
  35. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +0 -48
  36. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +0 -715
  37. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +0 -44
  38. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +0 -296
  39. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +0 -45
  40. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +0 -284
  41. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +0 -44
  42. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +0 -283
  43. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +0 -43
  44. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +0 -406
  45. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +0 -43
  46. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +0 -248
  47. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +0 -44
  48. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +0 -517
  49. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +0 -44
  50. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +0 -295
  51. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +0 -55
  52. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +0 -964
  53. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +0 -44
  54. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +0 -295
  55. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +0 -44
  56. package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +0 -393
  57. package/dist/Framework/Definition/AdDefinition.d.ts +0 -130
  58. package/dist/Framework/Definition/AdDefinition.js +0 -208
  59. package/dist/Framework/Definition/FrameworkBase.d.ts +0 -13
  60. package/dist/Framework/Definition/FrameworkBase.js +0 -23
  61. package/dist/Framework/Definition/PrivacyDefinition.d.ts +0 -51
  62. package/dist/Framework/Definition/PrivacyDefinition.js +0 -70
  63. package/dist/Framework/Definition/SocialDefinition.d.ts +0 -16
  64. package/dist/Framework/Definition/SocialDefinition.js +0 -2
  65. package/dist/Framework/Definition/SystemDefinition.d.ts +0 -43
  66. package/dist/Framework/Definition/SystemDefinition.js +0 -28
  67. package/dist/Framework/Definition/UIDefinition.d.ts +0 -6
  68. package/dist/Framework/Definition/UIDefinition.js +0 -7
  69. package/dist/Framework/Definition/UserDefinition.d.ts +0 -14
  70. package/dist/Framework/Definition/UserDefinition.js +0 -10
  71. package/dist/Framework/Manager/AdMgr.d.ts +0 -57
  72. package/dist/Framework/Manager/AdMgr.js +0 -684
  73. package/dist/Framework/Manager/AudioMgr.d.ts +0 -28
  74. package/dist/Framework/Manager/AudioMgr.js +0 -265
  75. package/dist/Framework/Manager/BaseMgr.d.ts +0 -18
  76. package/dist/Framework/Manager/BaseMgr.js +0 -114
  77. package/dist/Framework/Manager/EventMgr.d.ts +0 -18
  78. package/dist/Framework/Manager/EventMgr.js +0 -90
  79. package/dist/Framework/Manager/ExcelMgr.d.ts +0 -24
  80. package/dist/Framework/Manager/ExcelMgr.js +0 -156
  81. package/dist/Framework/Manager/LifeCycleMgr.d.ts +0 -20
  82. package/dist/Framework/Manager/LifeCycleMgr.js +0 -110
  83. package/dist/Framework/Manager/NodePoolMgr.d.ts +0 -53
  84. package/dist/Framework/Manager/NodePoolMgr.js +0 -279
  85. package/dist/Framework/Manager/PrivacyMgr.d.ts +0 -15
  86. package/dist/Framework/Manager/PrivacyMgr.js +0 -176
  87. package/dist/Framework/Manager/ResMgr.d.ts +0 -49
  88. package/dist/Framework/Manager/ResMgr.js +0 -337
  89. package/dist/Framework/Manager/SocialMgr.d.ts +0 -23
  90. package/dist/Framework/Manager/SocialMgr.js +0 -220
  91. package/dist/Framework/Manager/SystemMgr.d.ts +0 -24
  92. package/dist/Framework/Manager/SystemMgr.js +0 -222
  93. package/dist/Framework/Manager/TimerMgr.d.ts +0 -11
  94. package/dist/Framework/Manager/TimerMgr.js +0 -63
  95. package/dist/Framework/Manager/UIMgr.d.ts +0 -33
  96. package/dist/Framework/Manager/UIMgr.js +0 -223
  97. package/dist/Framework/Manager/UserMgr.d.ts +0 -15
  98. package/dist/Framework/Manager/UserMgr.js +0 -148
  99. package/dist/Framework/Utils/BezierUtils.d.ts +0 -49
  100. package/dist/Framework/Utils/BezierUtils.js +0 -247
  101. package/dist/Framework/Utils/CSVUtils.d.ts +0 -35
  102. package/dist/Framework/Utils/CSVUtils.js +0 -341
  103. package/dist/Framework/Utils/LogUtils.d.ts +0 -7
  104. package/dist/Framework/Utils/LogUtils.js +0 -32
  105. package/dist/Framework/Utils/NumberUtils.d.ts +0 -16
  106. package/dist/Framework/Utils/NumberUtils.js +0 -44
  107. package/dist/Framework/Utils/TaskUtils.d.ts +0 -10
  108. package/dist/Framework/Utils/TaskUtils.js +0 -24
  109. package/dist/Framework/Utils/TimeUtils.d.ts +0 -19
  110. package/dist/Framework/Utils/TimeUtils.js +0 -33
  111. package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +0 -12
  112. package/dist/Framework/Utils/WXBizDataCryptUtils.js +0 -37
  113. package/dist/index.d.ts +0 -30
  114. package/dist/index.js +0 -35
@@ -1,684 +0,0 @@
1
- import { math, randomRangeInt, view } from 'cc';
2
- import { LogUtils } from '../Utils/LogUtils';
3
- import { AudioMgr } from './AudioMgr';
4
- import { AdCallback, Ad_Record, InterstitialAd_Callback_Status, InterstitialAd_Record, RewardedVideoAd_Callback_Status, RewardedVideoAd_Record, AdSwitchType, AdType, AdDefinition } from '../Definition/AdDefinition';
5
- import { PlatformID } from '../Definition/SystemDefinition';
6
- import { UserMgr } from './UserMgr';
7
- import { BaseMgr } from './BaseMgr';
8
- import { AdAdapterWeiXin } from '../Adapter/AdAdapter/AdAdapterWeiXin';
9
- import { AdAdapterBilibili } from '../Adapter/AdAdapter/AdAdapterBilibili';
10
- import { AdAdapterDouYin } from '../Adapter/AdAdapter/AdAdapterDouYin';
11
- import { AdAdapterHonor } from '../Adapter/AdAdapter/AdAdapterHonor';
12
- import { AdAdapterHuaWei } from '../Adapter/AdAdapter/AdAdapterHuaWei';
13
- import { AdAdapterJingDong } from '../Adapter/AdAdapter/AdAdapterJingDong';
14
- import { AdAdapterKuaiShou } from '../Adapter/AdAdapter/AdAdapterKuaiShou';
15
- import { AdAdapterOppo } from '../Adapter/AdAdapter/AdAdapterOppo';
16
- import { AdAdapterTapTap } from '../Adapter/AdAdapter/AdAdapterTapTap';
17
- import { AdAdapterVivo } from '../Adapter/AdAdapter/AdAdapterVivo';
18
- import { AdAdapterXiaoMi } from '../Adapter/AdAdapter/AdAdapterXiaoMi';
19
- import { AdAdapterZhiFuBao } from '../Adapter/AdAdapter/AdAdapterZhiFuBao';
20
- export class AdMgr extends BaseMgr {
21
- onLoad() {
22
- if (AdMgr.Instance === null) {
23
- AdMgr.Instance = this;
24
- }
25
- else {
26
- this.destroy();
27
- return;
28
- }
29
- }
30
- init(contentHeight, adPlatformUnitMap, adPlatformSettingMap) {
31
- let currentPlatformID = this.getCurrentPlatformID();
32
- if (adPlatformUnitMap === null ||
33
- adPlatformUnitMap.get(currentPlatformID) === null) {
34
- return 0;
35
- }
36
- if (adPlatformSettingMap === null ||
37
- adPlatformSettingMap.get(currentPlatformID) === null) {
38
- return 0;
39
- }
40
- if (this.getPlatformAdapter() === null) {
41
- return 0;
42
- }
43
- AdMgr.adPlatformUnitMap = adPlatformUnitMap;
44
- AdMgr.adPlatformSettingMap = adPlatformSettingMap;
45
- let adAdapterImpl = null;
46
- switch (BaseMgr.Instance.getCurrentPlatformID()) {
47
- case PlatformID.ID_MiniGame_WeiXin:
48
- adAdapterImpl = this.node.addComponent(AdAdapterWeiXin);
49
- break;
50
- case PlatformID.ID_MiniGame_DouYin:
51
- adAdapterImpl = this.node.addComponent(AdAdapterDouYin);
52
- break;
53
- case PlatformID.ID_MiniGame_KuaiShou:
54
- adAdapterImpl = this.node.addComponent(AdAdapterKuaiShou);
55
- break;
56
- case PlatformID.ID_MiniGame_ZhiFuBao:
57
- adAdapterImpl = this.node.addComponent(AdAdapterZhiFuBao);
58
- break;
59
- case PlatformID.ID_MiniGame_Bilibili:
60
- adAdapterImpl = this.node.addComponent(AdAdapterBilibili);
61
- break;
62
- case PlatformID.ID_MiniGame_TapTap:
63
- adAdapterImpl = this.node.addComponent(AdAdapterTapTap);
64
- break;
65
- case PlatformID.ID_MiniGame_JingDong:
66
- adAdapterImpl = this.node.addComponent(AdAdapterJingDong);
67
- break;
68
- case PlatformID.ID_QuickGame_XiaoMi:
69
- adAdapterImpl = this.node.addComponent(AdAdapterXiaoMi);
70
- break;
71
- case PlatformID.ID_QuickGame_Oppo:
72
- adAdapterImpl = this.node.addComponent(AdAdapterOppo);
73
- break;
74
- case PlatformID.ID_QuickGame_Honor:
75
- adAdapterImpl = this.node.addComponent(AdAdapterHonor);
76
- break;
77
- case PlatformID.ID_QuickGame_Vivo:
78
- adAdapterImpl = this.node.addComponent(AdAdapterVivo);
79
- break;
80
- case PlatformID.ID_QuickGame_HuaWei:
81
- adAdapterImpl = this.node.addComponent(AdAdapterHuaWei);
82
- break;
83
- default:
84
- break;
85
- }
86
- if (adAdapterImpl !== null) {
87
- BaseMgr.Instance.setAdAdapter(adAdapterImpl);
88
- }
89
- AdMgr.launchTime = new Date().getTime();
90
- AdMgr.lastInterstitialAdTimestamp = 0;
91
- AdMgr.interstitialAd_nowIntervalCount = 1;
92
- if (this.getAdAdapter() === null) {
93
- return 0;
94
- }
95
- if (!this.adSwithOn()) {
96
- return 0;
97
- }
98
- this.clearAdRecord();
99
- AdMgr.nowRunningBannerAd = "";
100
- AdMgr.nowRunningCustomAd = "";
101
- AdMgr.isPermanentAdShowing = false;
102
- AdMgr.nowInterstitialAdScene = "InterstitialAd_Scene.Scene_Invalid";
103
- AdMgr.adRecord.intersitialAdRecord.set(AdMgr.nowInterstitialAdScene, new InterstitialAd_Record());
104
- AdMgr.interstitialAds = new Map();
105
- AdMgr.interstitialAdCallback = function (res) {
106
- LogUtils.Instance.log(AdMgr.TAG, "interstitialAdCallback");
107
- LogUtils.Instance.log("", "scene=" + AdMgr.nowInterstitialAdScene + ",res=" + InterstitialAd_Callback_Status[res]);
108
- if (res === InterstitialAd_Callback_Status.Status_Watching) {
109
- AdMgr.Instance.hideAllPermanentAd();
110
- }
111
- else if (res === InterstitialAd_Callback_Status.Status_Close ||
112
- res === InterstitialAd_Callback_Status.Status_Error) {
113
- AdMgr.Instance.showAllPermanentAd();
114
- }
115
- if (res === InterstitialAd_Callback_Status.Status_Close) {
116
- AdMgr.lastInterstitialAdTimestamp = new Date().getTime();
117
- AdMgr.interstitialAd_nowIntervalCount = 1;
118
- }
119
- if (AdMgr.adRecord.intersitialAdRecord !== null &&
120
- AdMgr.adRecord.intersitialAdRecord.has(AdMgr.nowInterstitialAdScene) &&
121
- AdMgr.adRecord.intersitialAdRecord.get(AdMgr.nowInterstitialAdScene) !== null) {
122
- let record = AdMgr.adRecord.intersitialAdRecord.get(AdMgr.nowInterstitialAdScene);
123
- if (res === InterstitialAd_Callback_Status.Status_Watching) {
124
- record.viewCount++;
125
- }
126
- else if (res === InterstitialAd_Callback_Status.Status_Error) {
127
- record.errorCount++;
128
- }
129
- else if (res === InterstitialAd_Callback_Status.Status_Close) {
130
- record.completeCount++;
131
- }
132
- AdMgr.adRecord.intersitialAdRecord.set(AdMgr.nowInterstitialAdScene, record);
133
- }
134
- if (AdMgr.interstitialAds !== null &&
135
- AdMgr.interstitialAds.has(AdMgr.nowInterstitialAdScene) &&
136
- AdMgr.interstitialAds.get(AdMgr.nowInterstitialAdScene) !== null) {
137
- let adCallback = AdMgr.interstitialAds.get(AdMgr.nowInterstitialAdScene);
138
- if (adCallback.callback && adCallback.target) {
139
- adCallback.callback.apply(adCallback.target, [res]);
140
- }
141
- }
142
- if (res !== InterstitialAd_Callback_Status.Status_Watching) {
143
- AdMgr.nowInterstitialAdScene = "InterstitialAd_Scene.Scene_Invalid";
144
- }
145
- };
146
- AdMgr.nowRewardedVideoAdScene = "RewardedVideoAd_Scene.Scene_Invalid";
147
- AdMgr.adRecord.rewardedVideoAdRecord.set(AdMgr.nowRewardedVideoAdScene, new RewardedVideoAd_Record());
148
- AdMgr.rewardedVideoAds = new Map();
149
- AdMgr.rewardedVideoAdCallback = function (res) {
150
- LogUtils.Instance.log(AdMgr.TAG, "rewardedVideoAdCallback");
151
- LogUtils.Instance.log("", "scene=" + AdMgr.nowRewardedVideoAdScene + ",res=" + RewardedVideoAd_Callback_Status[res]);
152
- if (res === RewardedVideoAd_Callback_Status.Status_Watching) {
153
- AudioMgr.Instance.pauseMusic();
154
- AdMgr.Instance.hideAllPermanentAd();
155
- }
156
- else if (res === RewardedVideoAd_Callback_Status.Status_Complete ||
157
- res === RewardedVideoAd_Callback_Status.Status_Giveup ||
158
- res === RewardedVideoAd_Callback_Status.Status_Error) {
159
- AudioMgr.Instance.resumeMusic();
160
- AdMgr.Instance.showAllPermanentAd();
161
- }
162
- if (res === RewardedVideoAd_Callback_Status.Status_Complete) {
163
- AdMgr.interstitialAd_nowIntervalCount++;
164
- }
165
- if (AdMgr.adRecord.rewardedVideoAdRecord !== null &&
166
- AdMgr.adRecord.rewardedVideoAdRecord.has(AdMgr.nowRewardedVideoAdScene) &&
167
- AdMgr.adRecord.rewardedVideoAdRecord.get(AdMgr.nowRewardedVideoAdScene) !== null) {
168
- let record = AdMgr.adRecord.rewardedVideoAdRecord.get(AdMgr.nowRewardedVideoAdScene);
169
- if (res === RewardedVideoAd_Callback_Status.Status_Watching) {
170
- record.viewCount++;
171
- }
172
- else if (res === RewardedVideoAd_Callback_Status.Status_Complete) {
173
- record.completeCount++;
174
- }
175
- else if (res === RewardedVideoAd_Callback_Status.Status_Giveup) {
176
- record.giveupCount++;
177
- }
178
- else if (res === RewardedVideoAd_Callback_Status.Status_Error) {
179
- record.errorCount++;
180
- }
181
- AdMgr.adRecord.rewardedVideoAdRecord.set(AdMgr.nowRewardedVideoAdScene, record);
182
- }
183
- if (AdMgr.rewardedVideoAds !== null &&
184
- AdMgr.rewardedVideoAds.has(AdMgr.nowRewardedVideoAdScene) &&
185
- AdMgr.rewardedVideoAds.get(AdMgr.nowRewardedVideoAdScene) !== null) {
186
- let adCallback = AdMgr.rewardedVideoAds.get(AdMgr.nowRewardedVideoAdScene);
187
- if (adCallback.callback && adCallback.target) {
188
- adCallback.callback.apply(adCallback.target, [res]);
189
- }
190
- }
191
- if (res !== RewardedVideoAd_Callback_Status.Status_Watching) {
192
- AdMgr.nowRewardedVideoAdScene = "RewardedVideoAd_Scene.Scene_Invalid";
193
- }
194
- };
195
- this.getAdAdapter().onInit(this.getPlatformAdapter().getScreenInfo(), this, AdMgr.adPlatformUnitMap.get(currentPlatformID).intersitialAd, AdMgr.interstitialAdCallback, AdMgr.adPlatformUnitMap.get(currentPlatformID).rewardedVideoAd, AdMgr.rewardedVideoAdCallback);
196
- LogUtils.Instance.log(AdMgr.TAG, "init() finished.");
197
- return this.adjustSuitableUIConfig(contentHeight);
198
- }
199
- createAds() {
200
- this.createInterstitialAd();
201
- this.createRewardedVideoAd();
202
- this.createPortalAd();
203
- this.createAllPermanentAd();
204
- }
205
- isPermanentAdShowing() {
206
- return AdMgr.isPermanentAdShowing;
207
- }
208
- adSwithOn() {
209
- let currentPlatformID = this.getCurrentPlatformID();
210
- if (!AdMgr.adPlatformUnitMap.has(currentPlatformID) ||
211
- AdMgr.adPlatformUnitMap.get(currentPlatformID) === null ||
212
- AdMgr.adPlatformUnitMap.get(currentPlatformID).switchType === AdSwitchType.Off) {
213
- return false;
214
- }
215
- return true;
216
- }
217
- supportAdType(adType) {
218
- if (!this.adSwithOn()) {
219
- return false;
220
- }
221
- let adPlatformUnitInfo = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID());
222
- if (adPlatformUnitInfo === null) {
223
- return false;
224
- }
225
- switch (adType) {
226
- case AdType.Type_Banner:
227
- let bannerAd = adPlatformUnitInfo.bannerAd;
228
- if (bannerAd !== null && bannerAd.length > 0) {
229
- return true;
230
- }
231
- return false;
232
- case AdType.Type_Custom:
233
- let customAd = adPlatformUnitInfo.customAd;
234
- if (customAd !== null && customAd.length > 0) {
235
- return true;
236
- }
237
- return false;
238
- case AdType.Type_Interstitial:
239
- let intersitialAd = adPlatformUnitInfo.intersitialAd;
240
- if (intersitialAd !== null && intersitialAd.length > 0) {
241
- return true;
242
- }
243
- return false;
244
- case AdType.Type_RewardedVideo:
245
- let rewardedVideoAd = adPlatformUnitInfo.rewardedVideoAd;
246
- if (rewardedVideoAd !== null && rewardedVideoAd.length > 0) {
247
- return true;
248
- }
249
- return false;
250
- case AdType.Type_Portal:
251
- let portalAd = adPlatformUnitInfo.portalAd;
252
- if (portalAd !== null && portalAd.length > 0) {
253
- return true;
254
- }
255
- default:
256
- return false;
257
- }
258
- }
259
- createBannerAd() {
260
- AdMgr.nowRunningBannerAd = "";
261
- if (!this.supportAdType(AdType.Type_Banner)) {
262
- return;
263
- }
264
- if (this.getAdAdapter() === null) {
265
- return;
266
- }
267
- let bannerAd_Info = AdDefinition.AdInfoConfig.BannerAd_Info;
268
- if (bannerAd_Info === null || !bannerAd_Info.shouldShow) {
269
- return;
270
- }
271
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).bannerAd;
272
- let result = this.getAdAdapter().createBannerAd(adUnitId);
273
- if (result) {
274
- AdMgr.nowRunningBannerAd = adUnitId;
275
- }
276
- }
277
- destroyBannerAd() {
278
- if (!this.supportAdType(AdType.Type_Banner)) {
279
- return;
280
- }
281
- if (this.getAdAdapter() === null) {
282
- return;
283
- }
284
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).bannerAd;
285
- this.getAdAdapter().destroyBannerAd(adUnitId);
286
- AdMgr.nowRunningBannerAd = "";
287
- }
288
- showBannerAd() {
289
- if (!this.supportAdType(AdType.Type_Banner)) {
290
- return;
291
- }
292
- if (this.getAdAdapter() === null) {
293
- return;
294
- }
295
- if (AdMgr.nowRunningBannerAd !== "") {
296
- this.getAdAdapter().showBannerAd(AdMgr.nowRunningBannerAd);
297
- }
298
- }
299
- hideBannerAd() {
300
- if (!this.supportAdType(AdType.Type_Banner)) {
301
- return;
302
- }
303
- if (this.getAdAdapter() === null) {
304
- return;
305
- }
306
- if (AdMgr.nowRunningBannerAd !== "") {
307
- this.getAdAdapter().hideBannerAd(AdMgr.nowRunningBannerAd);
308
- }
309
- }
310
- createInterstitialAd() {
311
- if (!this.supportAdType(AdType.Type_Interstitial)) {
312
- return;
313
- }
314
- if (this.getAdAdapter() === null) {
315
- return;
316
- }
317
- this.getAdAdapter().createInterstitialAd();
318
- }
319
- showInterstitialAd(scene, callback, target) {
320
- if (AdMgr.Instance.isIntersititialAdShowing()) {
321
- return;
322
- }
323
- if (scene === "" || scene === "InterstitialAd_Scene.Scene_Invalid") {
324
- return;
325
- }
326
- AdMgr.nowInterstitialAdScene = scene;
327
- if (!AdMgr.adRecord.intersitialAdRecord.has(AdMgr.nowInterstitialAdScene) ||
328
- AdMgr.adRecord.intersitialAdRecord.get(AdMgr.nowInterstitialAdScene) === null) {
329
- AdMgr.adRecord.intersitialAdRecord.set(AdMgr.nowInterstitialAdScene, new InterstitialAd_Record());
330
- }
331
- if (!this.supportAdType(AdType.Type_Interstitial)) {
332
- AdMgr.interstitialAdCallback(InterstitialAd_Callback_Status.Status_NotSupport);
333
- return;
334
- }
335
- let launchNoAdInterval = 0;
336
- let interstitialAdIntervalBase = 60000;
337
- if (AdMgr.adPlatformSettingMap.has(this.getCurrentPlatformID())) {
338
- let adPlatformSettingInfo = AdMgr.adPlatformSettingMap.get(this.getCurrentPlatformID());
339
- launchNoAdInterval = adPlatformSettingInfo.launchNoAdInterval_interstitialAd;
340
- interstitialAdIntervalBase = adPlatformSettingInfo.registerUser_interstitialAd_IntervalBase;
341
- if (UserMgr.Instance.isNewUser()) {
342
- interstitialAdIntervalBase = adPlatformSettingInfo.registerUser_interstitialAd_IntervalBase;
343
- }
344
- }
345
- let interstitialAdInterval = interstitialAdIntervalBase * AdMgr.interstitialAd_nowIntervalCount;
346
- let now = new Date().getTime();
347
- if (now - AdMgr.launchTime < launchNoAdInterval) {
348
- AdMgr.interstitialAdCallback(InterstitialAd_Callback_Status.Status_InsufficientInterval);
349
- return;
350
- }
351
- if (now - AdMgr.lastInterstitialAdTimestamp < interstitialAdInterval) {
352
- AdMgr.interstitialAdCallback(InterstitialAd_Callback_Status.Status_InsufficientInterval);
353
- return;
354
- }
355
- if (!AdMgr.interstitialAds.has(scene) ||
356
- (AdMgr.interstitialAds.get(scene).callback !== callback && AdMgr.interstitialAds.get(scene).target !== target)) {
357
- AdMgr.interstitialAds.set(scene, new AdCallback(callback, target));
358
- }
359
- this.getAdAdapter().showInterstitialAd();
360
- }
361
- destroyInterstitialAd() {
362
- if (!this.supportAdType(AdType.Type_Interstitial)) {
363
- return;
364
- }
365
- if (this.getAdAdapter() === null) {
366
- return;
367
- }
368
- this.getAdAdapter().destroyInterstitialAd();
369
- }
370
- isIntersititialAdShowing() {
371
- if (!this.supportAdType(AdType.Type_Interstitial)) {
372
- return false;
373
- }
374
- if (this.getAdAdapter() === null) {
375
- return false;
376
- }
377
- return this.getAdAdapter().isIntersititialAdShowing();
378
- }
379
- createRewardedVideoAd() {
380
- if (!this.supportAdType(AdType.Type_RewardedVideo)) {
381
- return;
382
- }
383
- if (this.getAdAdapter() === null) {
384
- return;
385
- }
386
- this.getAdAdapter().createRewardedVideoAd();
387
- }
388
- showRewardedVideoAd(scene, callback, target) {
389
- if (AdMgr.Instance.isRewardedVideoAdShowing()) {
390
- return;
391
- }
392
- if (this.getAdAdapter() === null) {
393
- return;
394
- }
395
- if (scene === "" || scene === "RewardedVideoAd_Scene.Scene_Invalid") {
396
- return;
397
- }
398
- AdMgr.nowRewardedVideoAdScene = scene;
399
- if (!this.supportAdType(AdType.Type_RewardedVideo)) {
400
- AdMgr.rewardedVideoAdCallback(RewardedVideoAd_Callback_Status.Status_NotSupport);
401
- return;
402
- }
403
- if (!AdMgr.adRecord.rewardedVideoAdRecord.has(AdMgr.nowRewardedVideoAdScene) ||
404
- AdMgr.adRecord.rewardedVideoAdRecord.get(AdMgr.nowRewardedVideoAdScene) === null) {
405
- AdMgr.adRecord.rewardedVideoAdRecord.set(AdMgr.nowRewardedVideoAdScene, new RewardedVideoAd_Record());
406
- }
407
- let record = AdMgr.adRecord.rewardedVideoAdRecord.get(AdMgr.nowRewardedVideoAdScene);
408
- record.clickCount++;
409
- AdMgr.adRecord.rewardedVideoAdRecord.set(AdMgr.nowRewardedVideoAdScene, record);
410
- if (!AdMgr.rewardedVideoAds.has(scene) ||
411
- (AdMgr.rewardedVideoAds.get(scene).callback !== callback && AdMgr.rewardedVideoAds.get(scene).target !== target)) {
412
- AdMgr.rewardedVideoAds.set(scene, new AdCallback(callback, target));
413
- }
414
- let adPlatformUnitInfo = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID());
415
- if (adPlatformUnitInfo.switchType === AdSwitchType.On_Debug) {
416
- let ranNumber = randomRangeInt(0, 100);
417
- if (ranNumber <= 33) {
418
- AdMgr.rewardedVideoAdCallback(RewardedVideoAd_Callback_Status.Status_Error);
419
- }
420
- else if (33 < ranNumber && ranNumber <= 66) {
421
- AdMgr.rewardedVideoAdCallback(RewardedVideoAd_Callback_Status.Status_Giveup);
422
- }
423
- else {
424
- AdMgr.rewardedVideoAdCallback(RewardedVideoAd_Callback_Status.Status_Complete);
425
- }
426
- }
427
- else {
428
- this.getAdAdapter().showRewardedVideoAd();
429
- }
430
- }
431
- destroyRewardedVideoAd() {
432
- if (!this.supportAdType(AdType.Type_RewardedVideo)) {
433
- return;
434
- }
435
- if (this.getAdAdapter() === null) {
436
- return;
437
- }
438
- this.getAdAdapter().destroyRewardedVideoAd();
439
- }
440
- isRewardedVideoAdShowing() {
441
- if (this.getAdAdapter() === null) {
442
- return false;
443
- }
444
- return this.getAdAdapter().isRewardedVideoAdShowing();
445
- }
446
- isRewardedVideoAdLoaded() {
447
- if (this.getAdAdapter() === null) {
448
- return false;
449
- }
450
- return this.getAdAdapter().isRewardedVideoAdLoaded();
451
- }
452
- createCustomAd() {
453
- AdMgr.nowRunningCustomAd = "";
454
- if (!this.supportAdType(AdType.Type_Custom)) {
455
- return;
456
- }
457
- if (this.getAdAdapter() === null) {
458
- return;
459
- }
460
- let customAd_Info = AdDefinition.AdInfoConfig.CustomAd_Info;
461
- if (customAd_Info === null || !customAd_Info.shouldShow) {
462
- return;
463
- }
464
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).customAd;
465
- let result = this.getAdAdapter().createCustomAd(adUnitId);
466
- if (result) {
467
- AdMgr.nowRunningCustomAd = adUnitId;
468
- }
469
- }
470
- destroyCustomAd() {
471
- if (!this.supportAdType(AdType.Type_Custom)) {
472
- return;
473
- }
474
- if (this.getAdAdapter() === null) {
475
- return;
476
- }
477
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).customAd;
478
- this.getAdAdapter().destroyCustomAd(adUnitId);
479
- AdMgr.nowRunningCustomAd = "";
480
- }
481
- showCustomAd() {
482
- if (!this.supportAdType(AdType.Type_Custom)) {
483
- return;
484
- }
485
- if (this.getAdAdapter() === null) {
486
- return;
487
- }
488
- if (AdMgr.nowRunningCustomAd !== "") {
489
- this.getAdAdapter().showCustomAd(AdMgr.nowRunningCustomAd);
490
- }
491
- }
492
- hideCustomAd() {
493
- if (!this.supportAdType(AdType.Type_Custom)) {
494
- return;
495
- }
496
- if (this.getAdAdapter() === null) {
497
- return;
498
- }
499
- if (AdMgr.nowRunningCustomAd !== "") {
500
- this.getAdAdapter().hideCustomAd(AdMgr.nowRunningCustomAd);
501
- }
502
- }
503
- createPortalAd() {
504
- if (!this.supportAdType(AdType.Type_Portal)) {
505
- return;
506
- }
507
- if (this.getAdAdapter() === null) {
508
- return;
509
- }
510
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).portalAd;
511
- this.getAdAdapter().createPortalAd(adUnitId);
512
- }
513
- destoryPortalAd() {
514
- if (!this.supportAdType(AdType.Type_Portal)) {
515
- return;
516
- }
517
- if (this.getAdAdapter() === null) {
518
- return;
519
- }
520
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).portalAd;
521
- this.getAdAdapter().destroyPortalAd(adUnitId);
522
- }
523
- showPortalAd() {
524
- if (!this.supportAdType(AdType.Type_Portal)) {
525
- return;
526
- }
527
- if (this.getAdAdapter() === null) {
528
- return;
529
- }
530
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).portalAd;
531
- this.getAdAdapter().showPortalAd(adUnitId);
532
- }
533
- hidePortalAd() {
534
- if (!this.supportAdType(AdType.Type_Custom)) {
535
- return;
536
- }
537
- if (this.getAdAdapter() === null) {
538
- return;
539
- }
540
- let adUnitId = AdMgr.adPlatformUnitMap.get(this.getCurrentPlatformID()).portalAd;
541
- this.getAdAdapter().hidePortalAd(adUnitId);
542
- }
543
- createAllPermanentAd() {
544
- this.createBannerAd();
545
- this.createCustomAd();
546
- }
547
- showAllPermanentAd() {
548
- let delay = 0;
549
- let currentPlatformID = this.getCurrentPlatformID();
550
- if (AdMgr.adPlatformSettingMap.has(currentPlatformID)) {
551
- let launchNoAdInterval = AdMgr.adPlatformSettingMap.get(currentPlatformID).launchNoAdInterval_permanentAd;
552
- let now = new Date().getTime();
553
- if (now - AdMgr.launchTime < launchNoAdInterval) {
554
- delay = Math.floor((launchNoAdInterval - (now - AdMgr.launchTime)) / 1000);
555
- }
556
- }
557
- if (!AdMgr.isPermanentAdShowing) {
558
- LogUtils.Instance.log(AdMgr.TAG, "showAllPermanentAd, delay=" + delay);
559
- this.scheduleOnce(() => {
560
- AdMgr.isPermanentAdShowing = true;
561
- this.showBannerAd();
562
- this.showCustomAd();
563
- }, delay);
564
- }
565
- }
566
- hideAllPermanentAd() {
567
- LogUtils.Instance.log(AdMgr.TAG, "hideAllPermanentAd");
568
- AdMgr.isPermanentAdShowing = false;
569
- this.hideBannerAd();
570
- this.hideCustomAd();
571
- }
572
- getAdRecord() {
573
- return AdMgr.adRecord;
574
- }
575
- clearAdRecord() {
576
- AdMgr.adRecord.intersitialAdRecord.clear();
577
- AdMgr.adRecord.rewardedVideoAdRecord.clear();
578
- }
579
- // [0] bannerAd_shouldShow
580
- // [1] customAd_shouldShow
581
- // [2] yOffset
582
- adjustSuitableUIConfig(contentHeight) {
583
- LogUtils.Instance.log(AdMgr.TAG, "adjustSuitableUIConfig() contentHeight=" + contentHeight);
584
- LogUtils.Instance.log(AdMgr.TAG, "screen");
585
- LogUtils.Instance.log("", screen);
586
- let screenSize = new math.Size(0, 0);
587
- if (screen["width"] && screen["height"]) {
588
- screenSize.width = screen.width;
589
- screenSize.height = screen.height;
590
- }
591
- else if (screen["availWidth"] && screen["availHeight"]) {
592
- screenSize.width = screen.availWidth;
593
- screenSize.height = screen.availHeight;
594
- }
595
- let designSize = view.getDesignResolutionSize();
596
- LogUtils.Instance.log(AdMgr.TAG, "designSize=" + designSize + ", screenSize=" + screenSize);
597
- let screenDisplayWidth = designSize.width;
598
- let screenDisplayHeight = designSize.width * screenSize.y / screenSize.x;
599
- LogUtils.Instance.log("", "screenDisplayWidth=" + screenDisplayWidth + ", screenDisplayHeight=" + screenDisplayHeight);
600
- let bannerAdHeight = 0;
601
- let bannerAdYMargin = 0;
602
- let bannerAdDisplayHeight = 0;
603
- let bannerAdYMarginDisplayHeight = 0;
604
- let currentPlatformID = this.getCurrentPlatformID();
605
- if (AdDefinition.BannerAdStyleConfig.has(currentPlatformID)) {
606
- let bannerAd_PlatformInfo = AdDefinition.BannerAdStyleConfig.get(currentPlatformID);
607
- bannerAdHeight = bannerAd_PlatformInfo.height;
608
- bannerAdYMargin = bannerAd_PlatformInfo.yMargin;
609
- if (bannerAd_PlatformInfo.scaleRatio > 0) {
610
- bannerAdHeight *= bannerAd_PlatformInfo.scaleRatio;
611
- }
612
- }
613
- bannerAdDisplayHeight = bannerAdHeight * designSize.height / screenSize.y;
614
- bannerAdYMarginDisplayHeight = bannerAdYMargin * designSize.height / screenSize.y;
615
- LogUtils.Instance.log("", "bannerAdDisplayHeight=" + bannerAdDisplayHeight);
616
- let customAdHeight = 0;
617
- let customAdYMargin = 0;
618
- let customAdDisplayHeight = 0;
619
- let customAdYMarginDisplayHeight = 0;
620
- if (AdDefinition.CustomAdStyleConfig.has(currentPlatformID)) {
621
- let customAd_PlatformInfo = AdDefinition.CustomAdStyleConfig.get(currentPlatformID);
622
- customAdHeight = customAd_PlatformInfo.height;
623
- customAdYMargin = customAd_PlatformInfo.yMargin;
624
- if (customAd_PlatformInfo.scaleRatio > 0) {
625
- customAdHeight *= customAd_PlatformInfo.scaleRatio;
626
- }
627
- }
628
- customAdDisplayHeight = customAdHeight * designSize.height / screenSize.y;
629
- customAdYMarginDisplayHeight = customAdYMargin * designSize.height / screenSize.y;
630
- LogUtils.Instance.log("", "customAdDisplayHeight=" + customAdDisplayHeight);
631
- let height_1 = bannerAdDisplayHeight + bannerAdYMarginDisplayHeight + 30;
632
- let height_2 = bannerAdDisplayHeight + bannerAdYMarginDisplayHeight + customAdDisplayHeight + customAdYMarginDisplayHeight + 50;
633
- LogUtils.Instance.log("", "height_1=" + height_1);
634
- LogUtils.Instance.log("", "height_2=" + height_2);
635
- let solution = 0;
636
- if (height_2 <= screenDisplayHeight - contentHeight) {
637
- solution = 2;
638
- }
639
- else if (height_1 <= screenDisplayHeight - contentHeight) {
640
- solution = 1;
641
- }
642
- LogUtils.Instance.log("", "solution=" + solution);
643
- let yOffset = 0;
644
- if (solution === 0) {
645
- AdDefinition.AdInfoConfig.BannerAd_Info.shouldShow = false;
646
- AdDefinition.AdInfoConfig.CustomAd_Info.shouldShow = false;
647
- yOffset = 0;
648
- }
649
- else if (solution === 1) {
650
- AdDefinition.AdInfoConfig.BannerAd_Info.shouldShow = true;
651
- AdDefinition.AdInfoConfig.CustomAd_Info.shouldShow = false;
652
- yOffset = bannerAdDisplayHeight / 2;
653
- }
654
- else if (solution === 2) {
655
- AdDefinition.AdInfoConfig.BannerAd_Info.shouldShow = true;
656
- AdDefinition.AdInfoConfig.CustomAd_Info.shouldShow = true;
657
- yOffset = (bannerAdDisplayHeight - customAdDisplayHeight) / 2;
658
- }
659
- LogUtils.Instance.log("", "yOffset=" + yOffset);
660
- AdMgr.contentTop = designSize.y - (designSize.y - contentHeight) / 2 + yOffset;
661
- AdMgr.contentBottom = (designSize.y - contentHeight) / 2 + yOffset;
662
- LogUtils.Instance.log(AdMgr.TAG, "contentTop=" + AdMgr.contentTop + ",contentBottom=" + AdMgr.contentBottom);
663
- return yOffset;
664
- }
665
- }
666
- AdMgr.Instance = null;
667
- AdMgr.TAG = "AudioMgr";
668
- AdMgr.adPlatformUnitMap = null;
669
- AdMgr.adPlatformSettingMap = null;
670
- AdMgr.launchTime = 0;
671
- AdMgr.interstitialAd_nowIntervalCount = 0;
672
- AdMgr.interstitialAds = new Map();
673
- AdMgr.nowInterstitialAdScene = "InterstitialAd_Scene.Scene_Invalid";
674
- AdMgr.interstitialAdCallback = null;
675
- AdMgr.lastInterstitialAdTimestamp = 0;
676
- AdMgr.rewardedVideoAds = new Map();
677
- AdMgr.nowRewardedVideoAdScene = "";
678
- AdMgr.rewardedVideoAdCallback = null;
679
- AdMgr.nowRunningBannerAd = "";
680
- AdMgr.nowRunningCustomAd = "";
681
- AdMgr.isPermanentAdShowing = false;
682
- AdMgr.adRecord = new Ad_Record();
683
- AdMgr.contentTop = 0;
684
- AdMgr.contentBottom = 0;