@chiyou/minigame-framework 1.0.0
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/README.md +66 -0
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +78 -0
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +230 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +31 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +224 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +34 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +524 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +34 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +631 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +460 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +31 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +227 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +458 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +35 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +770 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +519 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +492 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +695 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +34 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +597 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +458 -0
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +51 -0
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +17 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +45 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +555 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +148 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +48 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +715 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +296 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +45 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +284 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +283 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +43 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +406 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +43 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +248 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +517 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +295 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +55 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +964 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +295 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +393 -0
- package/dist/Framework/Definition/AdDefinition.d.ts +130 -0
- package/dist/Framework/Definition/AdDefinition.js +208 -0
- package/dist/Framework/Definition/FrameworkBase.d.ts +13 -0
- package/dist/Framework/Definition/FrameworkBase.js +23 -0
- package/dist/Framework/Definition/PrivacyDefinition.d.ts +51 -0
- package/dist/Framework/Definition/PrivacyDefinition.js +70 -0
- package/dist/Framework/Definition/SocialDefinition.d.ts +16 -0
- package/dist/Framework/Definition/SocialDefinition.js +2 -0
- package/dist/Framework/Definition/SystemDefinition.d.ts +43 -0
- package/dist/Framework/Definition/SystemDefinition.js +28 -0
- package/dist/Framework/Definition/UIDefinition.d.ts +6 -0
- package/dist/Framework/Definition/UIDefinition.js +7 -0
- package/dist/Framework/Definition/UserDefinition.d.ts +14 -0
- package/dist/Framework/Definition/UserDefinition.js +10 -0
- package/dist/Framework/Manager/AdMgr.d.ts +57 -0
- package/dist/Framework/Manager/AdMgr.js +684 -0
- package/dist/Framework/Manager/AudioMgr.d.ts +28 -0
- package/dist/Framework/Manager/AudioMgr.js +265 -0
- package/dist/Framework/Manager/BaseMgr.d.ts +18 -0
- package/dist/Framework/Manager/BaseMgr.js +114 -0
- package/dist/Framework/Manager/EventMgr.d.ts +18 -0
- package/dist/Framework/Manager/EventMgr.js +90 -0
- package/dist/Framework/Manager/ExcelMgr.d.ts +24 -0
- package/dist/Framework/Manager/ExcelMgr.js +156 -0
- package/dist/Framework/Manager/LifeCycleMgr.d.ts +20 -0
- package/dist/Framework/Manager/LifeCycleMgr.js +110 -0
- package/dist/Framework/Manager/NodePoolMgr.d.ts +53 -0
- package/dist/Framework/Manager/NodePoolMgr.js +279 -0
- package/dist/Framework/Manager/PrivacyMgr.d.ts +15 -0
- package/dist/Framework/Manager/PrivacyMgr.js +176 -0
- package/dist/Framework/Manager/ResMgr.d.ts +49 -0
- package/dist/Framework/Manager/ResMgr.js +337 -0
- package/dist/Framework/Manager/SocialMgr.d.ts +23 -0
- package/dist/Framework/Manager/SocialMgr.js +220 -0
- package/dist/Framework/Manager/SystemMgr.d.ts +24 -0
- package/dist/Framework/Manager/SystemMgr.js +222 -0
- package/dist/Framework/Manager/TimerMgr.d.ts +11 -0
- package/dist/Framework/Manager/TimerMgr.js +63 -0
- package/dist/Framework/Manager/UIMgr.d.ts +33 -0
- package/dist/Framework/Manager/UIMgr.js +223 -0
- package/dist/Framework/Manager/UserMgr.d.ts +15 -0
- package/dist/Framework/Manager/UserMgr.js +148 -0
- package/dist/Framework/Utils/BezierUtils.d.ts +49 -0
- package/dist/Framework/Utils/BezierUtils.js +247 -0
- package/dist/Framework/Utils/CSVUtils.d.ts +35 -0
- package/dist/Framework/Utils/CSVUtils.js +341 -0
- package/dist/Framework/Utils/LogUtils.d.ts +7 -0
- package/dist/Framework/Utils/LogUtils.js +32 -0
- package/dist/Framework/Utils/NumberUtils.d.ts +16 -0
- package/dist/Framework/Utils/NumberUtils.js +44 -0
- package/dist/Framework/Utils/TaskUtils.d.ts +10 -0
- package/dist/Framework/Utils/TaskUtils.js +24 -0
- package/dist/Framework/Utils/TimeUtils.d.ts +19 -0
- package/dist/Framework/Utils/TimeUtils.js +33 -0
- package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +12 -0
- package/dist/Framework/Utils/WXBizDataCryptUtils.js +37 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +35 -0
- package/package.json +40 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { AbsAdAdapter, InterstitialAdStatus, RewardedVideoAdStatus } from './AbsAdAdapter';
|
|
2
|
+
import { LogUtils } from '../../Utils/LogUtils';
|
|
3
|
+
import { AdDefinition, InterstitialAd_Callback_Status, RewardedVideoAd_Callback_Status } from '../../Definition/AdDefinition';
|
|
4
|
+
import { PlatformID } from '../../Definition/SystemDefinition';
|
|
5
|
+
class ZFBBannerAd {
|
|
6
|
+
constructor(adUnitId, ad, isFirstLoad) {
|
|
7
|
+
this.unitId = adUnitId;
|
|
8
|
+
this.ad = ad;
|
|
9
|
+
this.errorListener = null;
|
|
10
|
+
this.loadListener = null;
|
|
11
|
+
this.isRecreating = false;
|
|
12
|
+
this.isFirstLoad = isFirstLoad;
|
|
13
|
+
}
|
|
14
|
+
destroy() {
|
|
15
|
+
if (this.ad !== null) {
|
|
16
|
+
this.errorListener = null;
|
|
17
|
+
this.loadListener = null;
|
|
18
|
+
this.ad.destroy();
|
|
19
|
+
this.ad = null;
|
|
20
|
+
}
|
|
21
|
+
this.isRecreating = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class ZFBInterstitialAd {
|
|
25
|
+
constructor(adUnitId, callback) {
|
|
26
|
+
this.unitId = adUnitId;
|
|
27
|
+
this.ad = null;
|
|
28
|
+
this.status = InterstitialAdStatus.Status_Destroyed;
|
|
29
|
+
this.callback = callback;
|
|
30
|
+
this.errorListener = null;
|
|
31
|
+
this.loadListener = null;
|
|
32
|
+
this.closeListener = null;
|
|
33
|
+
this.isShowImmediately = false;
|
|
34
|
+
}
|
|
35
|
+
destroy() {
|
|
36
|
+
if (this.ad !== null) {
|
|
37
|
+
this.errorListener = null;
|
|
38
|
+
this.loadListener = null;
|
|
39
|
+
this.closeListener = null;
|
|
40
|
+
this.ad = null;
|
|
41
|
+
}
|
|
42
|
+
this.isShowImmediately = false;
|
|
43
|
+
this.status = InterstitialAdStatus.Status_Destroyed;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class ZFBRewardedVideoAd {
|
|
47
|
+
constructor(adUnitId, callback) {
|
|
48
|
+
this.unitId = adUnitId;
|
|
49
|
+
this.ad = null;
|
|
50
|
+
this.status = RewardedVideoAdStatus.Status_Destroyed;
|
|
51
|
+
this.callback = callback;
|
|
52
|
+
this.errorListener = null;
|
|
53
|
+
this.loadListener = null;
|
|
54
|
+
this.closeListener = null;
|
|
55
|
+
this.isShowImmediately = false;
|
|
56
|
+
}
|
|
57
|
+
destroy() {
|
|
58
|
+
if (this.ad !== null) {
|
|
59
|
+
this.errorListener = null;
|
|
60
|
+
this.loadListener = null;
|
|
61
|
+
this.closeListener = null;
|
|
62
|
+
this.ad = null;
|
|
63
|
+
}
|
|
64
|
+
this.isShowImmediately = false;
|
|
65
|
+
this.status = RewardedVideoAdStatus.Status_Destroyed;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class AdAdapterZhiFuBao extends AbsAdAdapter {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.zfbInterstitialAd = null;
|
|
72
|
+
this.zfbRewardedVideoAd = null;
|
|
73
|
+
this.zfbBannerAds = [];
|
|
74
|
+
}
|
|
75
|
+
init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
|
|
76
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "init()");
|
|
77
|
+
this.zfbInterstitialAd = new ZFBInterstitialAd(interstitialAdUnitId, interstitialAdCallback);
|
|
78
|
+
this.zfbRewardedVideoAd = new ZFBRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
|
|
79
|
+
this.zfbBannerAds = [];
|
|
80
|
+
}
|
|
81
|
+
createBannerAd(adUnitId) {
|
|
82
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "createBannerAd()");
|
|
83
|
+
let isFirstLoad = true;
|
|
84
|
+
for (let i = 0; i < this.zfbBannerAds.length; i++) {
|
|
85
|
+
if (this.zfbBannerAds[i].unitId === adUnitId) {
|
|
86
|
+
isFirstLoad = this.zfbBannerAds[i].isFirstLoad;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
this.destroyBannerAd(adUnitId);
|
|
91
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "createBannerAd() adUnitId=" + adUnitId);
|
|
92
|
+
let bannerAdInfo = AdDefinition.AdInfoConfig.BannerAd_Info;
|
|
93
|
+
if (bannerAdInfo === null || !bannerAdInfo.shouldShow) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
let bannerAdPlatformInfo = AdDefinition.BannerAdStyleConfig.get(PlatformID.ID_MiniGame_ZhiFuBao);
|
|
97
|
+
if (bannerAdPlatformInfo === null) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
let bannerAdPosition = this.calcBannerAdPosition(bannerAdInfo, bannerAdPlatformInfo);
|
|
101
|
+
let bannerAdParam = {
|
|
102
|
+
adUnitId: adUnitId,
|
|
103
|
+
style: {
|
|
104
|
+
left: bannerAdPosition.left,
|
|
105
|
+
top: bannerAdPosition.top,
|
|
106
|
+
width: bannerAdPosition.realWidth,
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
if (bannerAdPlatformInfo.canAutoRefresh) {
|
|
110
|
+
bannerAdParam.adIntervals = bannerAdPlatformInfo.refreshInterval;
|
|
111
|
+
}
|
|
112
|
+
let bannerAd = window["my"].createBannerAd(bannerAdParam);
|
|
113
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "my.createBannerAd() " + (bannerAd !== null ? "success" : "fail"));
|
|
114
|
+
LogUtils.Instance.log("", bannerAd);
|
|
115
|
+
if (!bannerAd) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
let zfbBannerAd = new ZFBBannerAd(adUnitId, bannerAd, isFirstLoad);
|
|
119
|
+
this.zfbBannerAds.push(zfbBannerAd);
|
|
120
|
+
zfbBannerAd.errorListener = (err) => {
|
|
121
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbBannerAd.ad.onError()");
|
|
122
|
+
if (err) {
|
|
123
|
+
LogUtils.Instance.log("", err);
|
|
124
|
+
}
|
|
125
|
+
if (!zfbBannerAd.isRecreating) {
|
|
126
|
+
zfbBannerAd.isRecreating = true;
|
|
127
|
+
this.scheduleOnce(() => {
|
|
128
|
+
zfbBannerAd.isRecreating = false;
|
|
129
|
+
this.createBannerAd(adUnitId);
|
|
130
|
+
}, 15);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
zfbBannerAd.ad.onError(zfbBannerAd.errorListener);
|
|
134
|
+
zfbBannerAd.loadListener = () => {
|
|
135
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbBannerAd.ad.onLoad()");
|
|
136
|
+
if (zfbBannerAd.isFirstLoad) {
|
|
137
|
+
zfbBannerAd.isFirstLoad = false;
|
|
138
|
+
}
|
|
139
|
+
if (this.adMgr.isPermanentAdShowing()) {
|
|
140
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbBannerAd.ad.show()");
|
|
141
|
+
zfbBannerAd.ad.show()
|
|
142
|
+
.then(() => {
|
|
143
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbBannerAd.ad.show() success");
|
|
144
|
+
}).catch((err) => {
|
|
145
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbBannerAd.ad.show() error");
|
|
146
|
+
if (err) {
|
|
147
|
+
LogUtils.Instance.log("", err);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
zfbBannerAd.ad.onLoad(zfbBannerAd.loadListener);
|
|
153
|
+
if (!bannerAdPlatformInfo.canAutoRefresh) {
|
|
154
|
+
if (!zfbBannerAd.isRecreating) {
|
|
155
|
+
zfbBannerAd.isRecreating = true;
|
|
156
|
+
this.scheduleOnce(() => {
|
|
157
|
+
zfbBannerAd.isRecreating = false;
|
|
158
|
+
this.createBannerAd(adUnitId);
|
|
159
|
+
}, bannerAdPlatformInfo.refreshInterval);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
destroyBannerAd(adUnitId) {
|
|
165
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "destroyBannerAd(): adUnitId=" + adUnitId);
|
|
166
|
+
let index = -1;
|
|
167
|
+
for (let i = 0; i < this.zfbBannerAds.length; i++) {
|
|
168
|
+
if (this.zfbBannerAds[i].unitId === adUnitId) {
|
|
169
|
+
index = i;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (index >= 0) {
|
|
174
|
+
this.zfbBannerAds[index].destroy();
|
|
175
|
+
this.zfbBannerAds.splice(index, 1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
showBannerAd(adUnitId) {
|
|
179
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "showBannerAd(): adUnitId=" + adUnitId);
|
|
180
|
+
for (let i = 0; i < this.zfbBannerAds.length; i++) {
|
|
181
|
+
if (this.zfbBannerAds[i].unitId === adUnitId) {
|
|
182
|
+
this.zfbBannerAds[i].ad.show();
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
hideBannerAd(adUnitId) {
|
|
188
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "hideBannerAd(): adUnitId=" + adUnitId);
|
|
189
|
+
for (let i = 0; i < this.zfbBannerAds.length; i++) {
|
|
190
|
+
if (this.zfbBannerAds[i].unitId === adUnitId) {
|
|
191
|
+
this.zfbBannerAds[i].ad.hide();
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
createInterstitialAd() {
|
|
197
|
+
this.destroyInterstitialAd();
|
|
198
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "createInterstitialAd() adUnitId=" + this.zfbInterstitialAd.unitId);
|
|
199
|
+
let interstitialAd = window["my"].createInterstitialAd({
|
|
200
|
+
adUnitId: this.zfbInterstitialAd.unitId
|
|
201
|
+
});
|
|
202
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "my.createInterstitialAd() " + (interstitialAd !== null ? "success" : "fail"));
|
|
203
|
+
LogUtils.Instance.log("", interstitialAd);
|
|
204
|
+
if (!interstitialAd) {
|
|
205
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Error;
|
|
206
|
+
this.zfbInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
this.zfbInterstitialAd.ad = interstitialAd;
|
|
210
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Init;
|
|
211
|
+
this.zfbInterstitialAd.errorListener = (err) => {
|
|
212
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.ad.onError()");
|
|
213
|
+
if (err) {
|
|
214
|
+
LogUtils.Instance.log("", err);
|
|
215
|
+
}
|
|
216
|
+
if (this.zfbInterstitialAd.status !== InterstitialAdStatus.Status_Watching) {
|
|
217
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Error;
|
|
218
|
+
this.zfbInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
this.zfbInterstitialAd.ad.onError(this.zfbInterstitialAd.errorListener);
|
|
222
|
+
this.zfbInterstitialAd.loadListener = () => {
|
|
223
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.ad.onLoad()");
|
|
224
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
|
|
225
|
+
if (this.zfbInterstitialAd.isShowImmediately) {
|
|
226
|
+
this.zfbInterstitialAd.isShowImmediately = false;
|
|
227
|
+
this._showInterstitialAd();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
this.zfbInterstitialAd.ad.onLoad(this.zfbInterstitialAd.loadListener);
|
|
231
|
+
this.zfbInterstitialAd.closeListener = () => {
|
|
232
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.ad.onClose()");
|
|
233
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Watched;
|
|
234
|
+
this.zfbInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Close);
|
|
235
|
+
this.createInterstitialAd();
|
|
236
|
+
};
|
|
237
|
+
this.zfbInterstitialAd.ad.onClose(this.zfbInterstitialAd.closeListener);
|
|
238
|
+
}
|
|
239
|
+
showInterstitialAd() {
|
|
240
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "showInterstitialAd()");
|
|
241
|
+
if (this.zfbInterstitialAd.ad === null) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.status=" + InterstitialAdStatus[this.zfbInterstitialAd.status]);
|
|
245
|
+
switch (this.zfbInterstitialAd.status) {
|
|
246
|
+
case InterstitialAdStatus.Status_Destroyed:
|
|
247
|
+
case InterstitialAdStatus.Status_Watching:
|
|
248
|
+
case InterstitialAdStatus.Status_StartToWatch:
|
|
249
|
+
break;
|
|
250
|
+
case InterstitialAdStatus.Status_Loaded:
|
|
251
|
+
this._showInterstitialAd();
|
|
252
|
+
break;
|
|
253
|
+
case InterstitialAdStatus.Status_Watched:
|
|
254
|
+
case InterstitialAdStatus.Status_Error:
|
|
255
|
+
case InterstitialAdStatus.Status_Init:
|
|
256
|
+
this.createInterstitialAd();
|
|
257
|
+
break;
|
|
258
|
+
default:
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
destroyInterstitialAd() {
|
|
263
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "destroyInterstitialAd()");
|
|
264
|
+
this.zfbInterstitialAd.destroy();
|
|
265
|
+
}
|
|
266
|
+
isIntersititialAdShowing() {
|
|
267
|
+
if (this.zfbInterstitialAd.ad === null) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (this.zfbInterstitialAd.status === InterstitialAdStatus.Status_Watching) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
_loadInterstitialAd(isShowImmediately) {
|
|
276
|
+
}
|
|
277
|
+
_showInterstitialAd() {
|
|
278
|
+
if (this.zfbInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_StartToWatch;
|
|
282
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.ad.show()");
|
|
283
|
+
this.zfbInterstitialAd.ad.show()
|
|
284
|
+
.then(() => {
|
|
285
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.ad.show() success");
|
|
286
|
+
if (this.zfbInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
|
|
287
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Watching;
|
|
288
|
+
this.zfbInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Watching);
|
|
289
|
+
}
|
|
290
|
+
}).catch((err) => {
|
|
291
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbInterstitialAd.ad.show() error");
|
|
292
|
+
if (err) {
|
|
293
|
+
LogUtils.Instance.log("", err);
|
|
294
|
+
}
|
|
295
|
+
if (this.zfbInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
|
|
296
|
+
this.zfbInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
createRewardedVideoAd() {
|
|
301
|
+
this.destroyRewardedVideoAd();
|
|
302
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "createRewardedVideoAd() adUnitId=" + this.zfbRewardedVideoAd.unitId);
|
|
303
|
+
let rewardedVideoAd = window["my"].createRewardedAd({
|
|
304
|
+
adUnitId: this.zfbRewardedVideoAd.unitId
|
|
305
|
+
});
|
|
306
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "my.createRewardedAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
|
|
307
|
+
LogUtils.Instance.log("", rewardedVideoAd);
|
|
308
|
+
if (!rewardedVideoAd) {
|
|
309
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
310
|
+
this.zfbRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
this.zfbRewardedVideoAd.ad = rewardedVideoAd;
|
|
314
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
|
|
315
|
+
this.zfbRewardedVideoAd.errorListener = (err) => {
|
|
316
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.onError()");
|
|
317
|
+
if (err) {
|
|
318
|
+
LogUtils.Instance.log("", err);
|
|
319
|
+
}
|
|
320
|
+
if (this.zfbRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
|
|
321
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
322
|
+
this.zfbRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
this.zfbRewardedVideoAd.ad.onError(this.zfbRewardedVideoAd.errorListener);
|
|
326
|
+
this.zfbRewardedVideoAd.loadListener = () => {
|
|
327
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.onLoad()");
|
|
328
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
329
|
+
if (this.zfbRewardedVideoAd.isShowImmediately) {
|
|
330
|
+
this.zfbRewardedVideoAd.isShowImmediately = false;
|
|
331
|
+
this._showRewardedVideoAd();
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
this.zfbRewardedVideoAd.ad.onLoad(this.zfbRewardedVideoAd.loadListener);
|
|
335
|
+
this.zfbRewardedVideoAd.closeListener = (res) => {
|
|
336
|
+
let isEnded = (res !== null) ? res.isEnded : false;
|
|
337
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.onClose()");
|
|
338
|
+
LogUtils.Instance.log("", "isEnded=" + isEnded);
|
|
339
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
|
|
340
|
+
if (isEnded) {
|
|
341
|
+
this.zfbRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
this.zfbRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
|
|
345
|
+
}
|
|
346
|
+
this.scheduleOnce(() => {
|
|
347
|
+
if (this.zfbRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
348
|
+
this._loadRewardedVideoAd(false);
|
|
349
|
+
}
|
|
350
|
+
}, 2);
|
|
351
|
+
};
|
|
352
|
+
this.zfbRewardedVideoAd.ad.onClose(this.zfbRewardedVideoAd.closeListener);
|
|
353
|
+
this.scheduleOnce(() => {
|
|
354
|
+
if (this.zfbRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
355
|
+
this._loadRewardedVideoAd(false);
|
|
356
|
+
}
|
|
357
|
+
}, 2);
|
|
358
|
+
}
|
|
359
|
+
showRewardedVideoAd() {
|
|
360
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "showRewardedVideoAd()");
|
|
361
|
+
if (this.zfbRewardedVideoAd.ad === null) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.status=" + RewardedVideoAdStatus[this.zfbRewardedVideoAd.status]);
|
|
365
|
+
switch (this.zfbRewardedVideoAd.status) {
|
|
366
|
+
case RewardedVideoAdStatus.Status_Destroyed:
|
|
367
|
+
case RewardedVideoAdStatus.Status_Watching:
|
|
368
|
+
case RewardedVideoAdStatus.Status_StartToWatch:
|
|
369
|
+
break;
|
|
370
|
+
case RewardedVideoAdStatus.Status_Loaded:
|
|
371
|
+
this._showRewardedVideoAd();
|
|
372
|
+
break;
|
|
373
|
+
case RewardedVideoAdStatus.Status_Watched:
|
|
374
|
+
case RewardedVideoAdStatus.Status_Error:
|
|
375
|
+
case RewardedVideoAdStatus.Status_Init:
|
|
376
|
+
this._loadRewardedVideoAd(true);
|
|
377
|
+
break;
|
|
378
|
+
default:
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
destroyRewardedVideoAd() {
|
|
383
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "destroyRewardedVideoAd()");
|
|
384
|
+
this.zfbRewardedVideoAd.destroy();
|
|
385
|
+
}
|
|
386
|
+
isRewardedVideoAdLoaded() {
|
|
387
|
+
if (this.zfbRewardedVideoAd.ad === null) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (this.zfbRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
isRewardedVideoAdShowing() {
|
|
396
|
+
if (this.zfbRewardedVideoAd.ad === null) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
if (this.zfbRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
_loadRewardedVideoAd(isShowImmediately) {
|
|
405
|
+
this.zfbRewardedVideoAd.isShowImmediately = isShowImmediately;
|
|
406
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.load()");
|
|
407
|
+
this.zfbRewardedVideoAd.ad.load()
|
|
408
|
+
.then(() => {
|
|
409
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.load() success");
|
|
410
|
+
}).catch((err) => {
|
|
411
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.load() error");
|
|
412
|
+
if (err) {
|
|
413
|
+
LogUtils.Instance.log("", err);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
_showRewardedVideoAd() {
|
|
418
|
+
if (this.zfbRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_StartToWatch;
|
|
422
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.show()");
|
|
423
|
+
this.zfbRewardedVideoAd.ad.show()
|
|
424
|
+
.then(() => {
|
|
425
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.show() success");
|
|
426
|
+
if (this.zfbRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
427
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
|
|
428
|
+
this.zfbRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
|
|
429
|
+
}
|
|
430
|
+
}).catch((err) => {
|
|
431
|
+
LogUtils.Instance.log(AdAdapterZhiFuBao.TAG, "zfbRewardedVideoAd.ad.show() error");
|
|
432
|
+
if (err) {
|
|
433
|
+
LogUtils.Instance.log("", err);
|
|
434
|
+
}
|
|
435
|
+
if (this.zfbRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
436
|
+
this.zfbRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
createCustomAd(adUnitId) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
destroyCustomAd(adUnitId) {
|
|
444
|
+
}
|
|
445
|
+
showCustomAd(adUnitId) {
|
|
446
|
+
}
|
|
447
|
+
hideCustomAd(adUnitId) {
|
|
448
|
+
}
|
|
449
|
+
createPortalAd(adUnitId) {
|
|
450
|
+
}
|
|
451
|
+
destroyPortalAd(adUnitId) {
|
|
452
|
+
}
|
|
453
|
+
showPortalAd(adUnitId) {
|
|
454
|
+
}
|
|
455
|
+
hidePortalAd(adUnitId) {
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
AdAdapterZhiFuBao.TAG = "AdAdapterZhiFuBao";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Component } from "cc";
|
|
2
|
+
import { ScreenInfo } from "../../Definition/SystemDefinition";
|
|
3
|
+
import { SystemMgr } from "../../Manager/SystemMgr";
|
|
4
|
+
export declare abstract class AbsPlatformAdapter extends Component {
|
|
5
|
+
protected coldStartOptions: any;
|
|
6
|
+
protected warmStartOptions: any;
|
|
7
|
+
protected coldStartScene: string;
|
|
8
|
+
protected warmStartScene: string;
|
|
9
|
+
protected systemMgr: SystemMgr;
|
|
10
|
+
protected onLoad(): void;
|
|
11
|
+
onInit(systemMgr: SystemMgr): void;
|
|
12
|
+
abstract init(): void;
|
|
13
|
+
abstract onLoadingStart(): void;
|
|
14
|
+
abstract onLoadingFinish(args: any[]): void;
|
|
15
|
+
abstract exitGame(): void;
|
|
16
|
+
abstract getSDKVersion(): string;
|
|
17
|
+
abstract downloadFile(fileUrl: string, success: Function, fail: Function): void;
|
|
18
|
+
abstract requestGet(url: string, success: Function, fail: Function): void;
|
|
19
|
+
abstract requestPost(url: string, data: string, success: Function, fail: Function): void;
|
|
20
|
+
abstract configPassiveShare(title?: string, desc?: string, imageUrl?: string, templateId?: string, query?: string): void;
|
|
21
|
+
abstract activeShareToFriend(callback: Function, title?: string, desc?: string, imageUrl?: string, templateId?: string, query?: string): void;
|
|
22
|
+
abstract getScreenInfo(): ScreenInfo;
|
|
23
|
+
abstract navigateToMiniProgram(appid: string, path?: string): void;
|
|
24
|
+
abstract reportEvent(eventId: string, data: any): void;
|
|
25
|
+
abstract getScreenBrightness(callback: Function): void;
|
|
26
|
+
abstract setScreenBrightness(value: number): void;
|
|
27
|
+
abstract setKeepScreenOn(keepScreenOn: boolean): void;
|
|
28
|
+
abstract updateColdStartScene(): void;
|
|
29
|
+
abstract updateWarmStartScene(warmStartOptions: any): void;
|
|
30
|
+
abstract onShow(fn: Function): void;
|
|
31
|
+
abstract offShow(fn: Function): void;
|
|
32
|
+
abstract onHide(fn: Function): void;
|
|
33
|
+
abstract offHide(fn: Function): void;
|
|
34
|
+
abstract isNavigateToRecentUseAvailable(callback: Function): void;
|
|
35
|
+
abstract navigateToRecentUse(): void;
|
|
36
|
+
abstract isLaunchFromRecentUse(): boolean;
|
|
37
|
+
abstract isLaunchFromDesktopShortcut(): boolean;
|
|
38
|
+
abstract isLaunchFromAdvertisement(): boolean;
|
|
39
|
+
abstract checkSession(success: Function, fail: Function): void;
|
|
40
|
+
abstract login(success: Function, fail: Function): void;
|
|
41
|
+
abstract requirePrivacyAuthorize(callback: Function): void;
|
|
42
|
+
abstract getSetting(scope: string, callback: Function): void;
|
|
43
|
+
abstract openSetting(scope: string, callback: Function): void;
|
|
44
|
+
abstract authorize(scope: string, callback: Function): void;
|
|
45
|
+
abstract setRankData(args: any[]): void;
|
|
46
|
+
abstract showRankList(args: any[]): void;
|
|
47
|
+
abstract openPortalGame(): void;
|
|
48
|
+
abstract openGameClub(): void;
|
|
49
|
+
abstract openRecommendToFriend(): void;
|
|
50
|
+
abstract openRecommendToGameClub(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Component } from "cc";
|
|
2
|
+
export class AbsPlatformAdapter extends Component {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.coldStartOptions = null;
|
|
6
|
+
this.warmStartOptions = null;
|
|
7
|
+
this.coldStartScene = "";
|
|
8
|
+
this.warmStartScene = "";
|
|
9
|
+
this.systemMgr = null;
|
|
10
|
+
}
|
|
11
|
+
onLoad() {
|
|
12
|
+
}
|
|
13
|
+
onInit(systemMgr) {
|
|
14
|
+
this.systemMgr = systemMgr;
|
|
15
|
+
this.init();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AbsPlatformAdapter } from './AbsPlatformAdapter';
|
|
2
|
+
import { ScreenInfo } from '../../Definition/SystemDefinition';
|
|
3
|
+
export declare class PlatformAdapterBilibili extends AbsPlatformAdapter {
|
|
4
|
+
init(): void;
|
|
5
|
+
onLoadingStart(): void;
|
|
6
|
+
onLoadingFinish(args: any[]): void;
|
|
7
|
+
exitGame(): void;
|
|
8
|
+
getSDKVersion(): string;
|
|
9
|
+
requestGet(url: string, success: Function, fail: Function): void;
|
|
10
|
+
requestPost(url: string, data: string, success: Function, fail: Function): void;
|
|
11
|
+
downloadFile(fileUrl: string, success: Function, fail: Function): void;
|
|
12
|
+
configPassiveShare(title?: string, desc?: string, imageUrl?: string, templateId?: string, query?: string): void;
|
|
13
|
+
activeShareToFriend(callback?: Function, title?: string, desc?: string, imageUrl?: string, templateId?: string, query?: string): void;
|
|
14
|
+
getScreenInfo(): ScreenInfo;
|
|
15
|
+
navigateToMiniProgram(appid: string, path?: string): void;
|
|
16
|
+
reportEvent(eventId: string, data: any): void;
|
|
17
|
+
getScreenBrightness(callback: Function): void;
|
|
18
|
+
setScreenBrightness(value: number): void;
|
|
19
|
+
setKeepScreenOn(keepScreenOn: boolean): void;
|
|
20
|
+
updateColdStartScene(): void;
|
|
21
|
+
updateWarmStartScene(warmStartOptions: any): void;
|
|
22
|
+
onShow(fn: Function): void;
|
|
23
|
+
offShow(fn: Function): void;
|
|
24
|
+
onHide(fn: Function): void;
|
|
25
|
+
offHide(fn: Function): void;
|
|
26
|
+
isNavigateToRecentUseAvailable(callback: Function): void;
|
|
27
|
+
navigateToRecentUse(): void;
|
|
28
|
+
isLaunchFromRecentUse(): boolean;
|
|
29
|
+
isLaunchFromDesktopShortcut(): boolean;
|
|
30
|
+
isLaunchFromAdvertisement(): boolean;
|
|
31
|
+
checkSession(success: Function, fail: Function): void;
|
|
32
|
+
login(success: Function, fail: Function): void;
|
|
33
|
+
requirePrivacyAuthorize(callback: Function): void;
|
|
34
|
+
getSetting(scope: string, callback: Function): void;
|
|
35
|
+
openSetting(scope: string, callback: Function): void;
|
|
36
|
+
authorize(scope: string, callback: Function): void;
|
|
37
|
+
setRankData(args: any[]): void;
|
|
38
|
+
showRankList(args: any[]): void;
|
|
39
|
+
openPortalGame(): void;
|
|
40
|
+
openGameClub(): void;
|
|
41
|
+
openRecommendToFriend(): void;
|
|
42
|
+
openRecommendToGameClub(): void;
|
|
43
|
+
reportScene(sceneId: number, costTime?: number): void;
|
|
44
|
+
addShortcut(): void;
|
|
45
|
+
}
|