@chiyou/minigame-framework 1.0.0 → 1.0.2
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/assets/AssetsPackage/GUI/Images/Block.png +0 -0
- package/assets/AssetsPackage/GUI/Images/Block.png.meta +134 -0
- package/assets/AssetsPackage/GUI/Images.meta +9 -0
- package/assets/AssetsPackage/GUI/UIPrefabs/ChessBoard_Card.prefab +509 -0
- package/assets/AssetsPackage/GUI/UIPrefabs/ChessBoard_Card.prefab.meta +13 -0
- package/assets/AssetsPackage/GUI/UIPrefabs.meta +9 -0
- package/assets/AssetsPackage/GUI.meta +11 -0
- package/assets/AssetsPackage/SpriteAtlas/Card_Pattern.plist +1106 -0
- package/assets/AssetsPackage/SpriteAtlas/Card_Pattern.plist.meta +3329 -0
- package/assets/AssetsPackage/SpriteAtlas/Card_Pattern.png +0 -0
- package/assets/AssetsPackage/SpriteAtlas/Card_Pattern.png.meta +134 -0
- package/assets/AssetsPackage/SpriteAtlas/SA_Card.plist +1196 -0
- package/assets/AssetsPackage/SpriteAtlas/SA_Card.plist.meta +3605 -0
- package/assets/AssetsPackage/SpriteAtlas/SA_Card.png +0 -0
- package/assets/AssetsPackage/SpriteAtlas/SA_Card.png.meta +134 -0
- package/assets/AssetsPackage/SpriteAtlas.meta +11 -0
- package/assets/AssetsPackage/SpriteFrame/Card_PatternType_Back.png +0 -0
- package/assets/AssetsPackage/SpriteFrame/Card_PatternType_Back.png.meta +134 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Back_BG.png +0 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Back_BG.png.meta +134 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Back_FG.png +0 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Back_FG.png.meta +134 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Front_BG.png +0 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Front_BG.png.meta +134 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Front_FG.png +0 -0
- package/assets/AssetsPackage/SpriteFrame/Card_TowardType_Front_FG.png.meta +134 -0
- package/assets/AssetsPackage/SpriteFrame.meta +11 -0
- package/assets/AssetsPackage.meta +9 -0
- package/assets/Scenes/Game.scene +831 -0
- package/assets/Scenes/Game.scene.meta +11 -0
- package/assets/Scenes.meta +9 -0
- package/assets/Scripts/Biz.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AbsAdAdapter.ts +312 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AbsAdAdapter.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterBilibili.ts +294 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterBilibili.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterDouYin.ts +650 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterDouYin.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterHonor.ts +782 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterHonor.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterHuaWei.ts +582 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterHuaWei.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterJingDong.ts +298 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterJingDong.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.ts +575 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterOppo.ts +946 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterOppo.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterTapTap.ts +643 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterTapTap.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterVivo.ts +616 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterVivo.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterWeiXin.ts +847 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterWeiXin.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.ts +747 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.ts +579 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/AdAdapter.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.ts +102 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.ts +660 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.ts +224 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.ts +827 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.ts +378 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.ts +363 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.ts +368 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.ts +498 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.ts +323 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.ts +617 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.ts +377 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.ts +1136 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.ts +377 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.ts +483 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.ts.meta +9 -0
- package/assets/Scripts/Framework/Adapter/PlatformAdapter.meta +9 -0
- package/assets/Scripts/Framework/Adapter.meta +9 -0
- package/assets/Scripts/Framework/Definition/AdDefinition.ts +284 -0
- package/assets/Scripts/Framework/Definition/AdDefinition.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition/FrameworkBase.ts +15 -0
- package/assets/Scripts/Framework/Definition/FrameworkBase.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition/PrivacyDefinition.ts +95 -0
- package/assets/Scripts/Framework/Definition/PrivacyDefinition.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition/SocialDefinition.ts +21 -0
- package/assets/Scripts/Framework/Definition/SocialDefinition.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition/SystemDefinition.ts +58 -0
- package/assets/Scripts/Framework/Definition/SystemDefinition.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition/UIDefinition.ts +10 -0
- package/assets/Scripts/Framework/Definition/UIDefinition.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition/UserDefinition.ts +17 -0
- package/assets/Scripts/Framework/Definition/UserDefinition.ts.meta +9 -0
- package/assets/Scripts/Framework/Definition.meta +9 -0
- package/assets/Scripts/Framework/Manager/AdMgr.ts +812 -0
- package/assets/Scripts/Framework/Manager/AdMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/AudioMgr.ts +296 -0
- package/assets/Scripts/Framework/Manager/AudioMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/BaseMgr.ts +130 -0
- package/assets/Scripts/Framework/Manager/BaseMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/EventMgr.ts +102 -0
- package/assets/Scripts/Framework/Manager/EventMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/ExcelMgr.ts +188 -0
- package/assets/Scripts/Framework/Manager/ExcelMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/LifeCycleMgr.ts +142 -0
- package/assets/Scripts/Framework/Manager/LifeCycleMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/NodePoolMgr.ts +385 -0
- package/assets/Scripts/Framework/Manager/NodePoolMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/PrivacyMgr.ts +189 -0
- package/assets/Scripts/Framework/Manager/PrivacyMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/ResMgr.ts +420 -0
- package/assets/Scripts/Framework/Manager/ResMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/SocialMgr.ts +250 -0
- package/assets/Scripts/Framework/Manager/SocialMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/SystemMgr.ts +264 -0
- package/assets/Scripts/Framework/Manager/SystemMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/TimerMgr.ts +80 -0
- package/assets/Scripts/Framework/Manager/TimerMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/UIMgr.ts +267 -0
- package/assets/Scripts/Framework/Manager/UIMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager/UserMgr.ts +162 -0
- package/assets/Scripts/Framework/Manager/UserMgr.ts.meta +9 -0
- package/assets/Scripts/Framework/Manager.meta +9 -0
- package/assets/Scripts/Framework/Utils/BezierUtils.ts +273 -0
- package/assets/Scripts/Framework/Utils/BezierUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils/CSVUtils.ts +396 -0
- package/assets/Scripts/Framework/Utils/CSVUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils/LogUtils.ts +32 -0
- package/assets/Scripts/Framework/Utils/LogUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils/NumberUtils.ts +51 -0
- package/assets/Scripts/Framework/Utils/NumberUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils/TaskUtils.ts +27 -0
- package/assets/Scripts/Framework/Utils/TaskUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils/TimeUtils.ts +38 -0
- package/assets/Scripts/Framework/Utils/TimeUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils/WXBizDataCryptUtils.ts +54 -0
- package/assets/Scripts/Framework/Utils/WXBizDataCryptUtils.ts.meta +9 -0
- package/assets/Scripts/Framework/Utils.meta +9 -0
- package/assets/Scripts/Framework.meta +9 -0
- package/assets/Scripts/index.ts +39 -0
- package/assets/Scripts.meta +9 -0
- package/package.json +2 -4
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { Component } from "cc";
|
|
2
|
+
import { BannerAd_Info, BannerAd_PlatformInfo, BannerAd_XPosition, BannerAd_YPosition, CustomAd_Info, CustomAd_PlatformInfo, CustomAd_XPosition, CustomAd_YPosition, PortalAd_PlatformInfo } from "../../Definition/AdDefinition";
|
|
3
|
+
import { ScreenInfo } from "../../Definition/SystemDefinition";
|
|
4
|
+
import { AdMgr } from "../../Manager/AdMgr";
|
|
5
|
+
import { AbsPlatformAdapter } from "../PlatformAdapter/AbsPlatformAdapter";
|
|
6
|
+
import { BaseMgr } from "../../Manager/BaseMgr";
|
|
7
|
+
|
|
8
|
+
export enum InterstitialAdStatus {
|
|
9
|
+
Status_Error = -1,
|
|
10
|
+
Status_Init = 0,
|
|
11
|
+
Status_Loaded = 1,
|
|
12
|
+
Status_StartToWatch = 2,
|
|
13
|
+
Status_Watching = 3,
|
|
14
|
+
Status_Watched = 4,
|
|
15
|
+
Status_Destroyed = 5,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export enum RewardedVideoAdStatus {
|
|
19
|
+
Status_Error = -1,
|
|
20
|
+
Status_Init = 0,
|
|
21
|
+
Status_Loaded = 1,
|
|
22
|
+
Status_StartToWatch = 2,
|
|
23
|
+
Status_Watching = 3,
|
|
24
|
+
Status_Watched = 4,
|
|
25
|
+
Status_Destroyed = 5,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type BannerAdPosition = {
|
|
29
|
+
realWidth: number,
|
|
30
|
+
realHeight: number,
|
|
31
|
+
left: number,
|
|
32
|
+
top: number,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type CustomAdPosition = {
|
|
36
|
+
realWidth: number,
|
|
37
|
+
realHeight: number,
|
|
38
|
+
left: number,
|
|
39
|
+
top: number,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type PortalAdPosition = {
|
|
43
|
+
realWidth: number,
|
|
44
|
+
realHeight: number,
|
|
45
|
+
left: number,
|
|
46
|
+
top: number,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export abstract class AbsAdAdapter extends Component {
|
|
50
|
+
protected static TAG: string = "AbsAdAdapter";
|
|
51
|
+
|
|
52
|
+
protected screenInfo: ScreenInfo = null;
|
|
53
|
+
protected adMgr: AdMgr = null;
|
|
54
|
+
|
|
55
|
+
protected platformAdapter: AbsPlatformAdapter = null;
|
|
56
|
+
|
|
57
|
+
protected onLoad(): void {
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public onInit(screenInfo: ScreenInfo, adMgr: AdMgr,
|
|
62
|
+
interstitialAdUnitId: string, interstitialAdCallback: Function,
|
|
63
|
+
rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void {
|
|
64
|
+
this.screenInfo = screenInfo;
|
|
65
|
+
this.adMgr = adMgr;
|
|
66
|
+
this.platformAdapter = BaseMgr.Instance.getPlatformAdapter();
|
|
67
|
+
|
|
68
|
+
this.init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
abstract init(interstitialAdUnitId: string, interstitialAdCallback: Function,
|
|
72
|
+
rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void;
|
|
73
|
+
|
|
74
|
+
abstract createBannerAd(adUnitId: string): boolean;
|
|
75
|
+
abstract destroyBannerAd(adUnitId: string): void;
|
|
76
|
+
abstract showBannerAd(adUnitId: string): void;
|
|
77
|
+
abstract hideBannerAd(adUnitId: string): void;
|
|
78
|
+
|
|
79
|
+
abstract createInterstitialAd(): void;
|
|
80
|
+
abstract showInterstitialAd(): void;
|
|
81
|
+
abstract destroyInterstitialAd(): void;
|
|
82
|
+
abstract isIntersititialAdShowing(): boolean;
|
|
83
|
+
protected abstract _loadInterstitialAd(isShowImmediately: boolean): void;
|
|
84
|
+
protected abstract _showInterstitialAd(): void;
|
|
85
|
+
|
|
86
|
+
abstract createRewardedVideoAd(): void;
|
|
87
|
+
abstract showRewardedVideoAd(): void;
|
|
88
|
+
abstract destroyRewardedVideoAd(): void;
|
|
89
|
+
abstract isRewardedVideoAdLoaded(): boolean;
|
|
90
|
+
abstract isRewardedVideoAdShowing(): boolean;
|
|
91
|
+
protected abstract _loadRewardedVideoAd(isShowImmediately: boolean): void;
|
|
92
|
+
protected abstract _showRewardedVideoAd(): void;
|
|
93
|
+
|
|
94
|
+
abstract createCustomAd(adUnitId: string): boolean;
|
|
95
|
+
abstract destroyCustomAd(adUnitId: string): void;
|
|
96
|
+
abstract showCustomAd(adUnitId: string): void;
|
|
97
|
+
abstract hideCustomAd(adUnitId: string): void;
|
|
98
|
+
|
|
99
|
+
abstract createPortalAd(adUnitId: string): void;
|
|
100
|
+
abstract destroyPortalAd(adUnitId: string): void;
|
|
101
|
+
abstract showPortalAd(adUnitId: string): void;
|
|
102
|
+
abstract hidePortalAd(adUnitId: string): void;
|
|
103
|
+
|
|
104
|
+
public calcBannerAdPosition(bannerAdInfo: BannerAd_Info, bannerAdPlatformInfo: BannerAd_PlatformInfo): BannerAdPosition {
|
|
105
|
+
let xPosition: BannerAd_XPosition = bannerAdInfo.xPosition;
|
|
106
|
+
let yPosition: BannerAd_YPosition = bannerAdInfo.yPosition;
|
|
107
|
+
|
|
108
|
+
let xMargin: number = bannerAdPlatformInfo.xMargin;
|
|
109
|
+
let yMargin: number = bannerAdPlatformInfo.yMargin;
|
|
110
|
+
let width: number = bannerAdPlatformInfo.width;
|
|
111
|
+
let height: number = bannerAdPlatformInfo.height;
|
|
112
|
+
let adScaleRatio: number = bannerAdPlatformInfo.scaleRatio;
|
|
113
|
+
|
|
114
|
+
let left: number = 0;
|
|
115
|
+
let top: number = 0;
|
|
116
|
+
let realWidth: number = 0;
|
|
117
|
+
let realHeight: number = 0;
|
|
118
|
+
|
|
119
|
+
if (adScaleRatio === 0) {
|
|
120
|
+
realWidth = width;
|
|
121
|
+
if (this.screenInfo !== null) {
|
|
122
|
+
realWidth = this.screenInfo.windowWidth - xMargin * 2;
|
|
123
|
+
}
|
|
124
|
+
realHeight = height * realWidth / width;
|
|
125
|
+
|
|
126
|
+
left = xMargin;
|
|
127
|
+
switch(yPosition) {
|
|
128
|
+
case BannerAd_YPosition.Top:
|
|
129
|
+
top = yMargin;
|
|
130
|
+
break;
|
|
131
|
+
case BannerAd_YPosition.Center:
|
|
132
|
+
top = yMargin;
|
|
133
|
+
if (this.screenInfo !== null) {
|
|
134
|
+
top = this.screenInfo.windowHeight / 2 - realHeight / 2;
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
case BannerAd_YPosition.Bottom:
|
|
138
|
+
top = yMargin;
|
|
139
|
+
if (this.screenInfo !== null) {
|
|
140
|
+
top = this.screenInfo.windowHeight - realHeight - yMargin;
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
} else {
|
|
145
|
+
realWidth = width * adScaleRatio;
|
|
146
|
+
realHeight = height * adScaleRatio;
|
|
147
|
+
|
|
148
|
+
switch(yPosition) {
|
|
149
|
+
case BannerAd_YPosition.Top:
|
|
150
|
+
top = yMargin;
|
|
151
|
+
break;
|
|
152
|
+
case BannerAd_YPosition.Center:
|
|
153
|
+
top = yMargin;
|
|
154
|
+
if (this.screenInfo !== null) {
|
|
155
|
+
top = this.screenInfo.windowHeight / 2 - realHeight / 2;
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case BannerAd_YPosition.Bottom:
|
|
159
|
+
top = yMargin;
|
|
160
|
+
if (this.screenInfo !== null) {
|
|
161
|
+
top = this.screenInfo.windowHeight - realHeight - yMargin;
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
switch (xPosition) {
|
|
167
|
+
case BannerAd_XPosition.Left:
|
|
168
|
+
left = xMargin;
|
|
169
|
+
break;
|
|
170
|
+
case BannerAd_XPosition.Center:
|
|
171
|
+
left = xMargin;
|
|
172
|
+
if (this.screenInfo !== null) {
|
|
173
|
+
left = this.screenInfo.windowWidth / 2 - realWidth / 2;
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case BannerAd_XPosition.Right:
|
|
177
|
+
left = xMargin;
|
|
178
|
+
if (this.screenInfo !== null) {
|
|
179
|
+
left = this.screenInfo.windowWidth - realWidth - xMargin;
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let posInfo: BannerAdPosition = {
|
|
186
|
+
realWidth: realWidth,
|
|
187
|
+
realHeight: realHeight,
|
|
188
|
+
left: left,
|
|
189
|
+
top: top,
|
|
190
|
+
};
|
|
191
|
+
return posInfo;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public calcCustomAdPosition(customAdInfo: CustomAd_Info, customAdPlatformInfo: CustomAd_PlatformInfo): CustomAdPosition {
|
|
195
|
+
let xPosition: CustomAd_XPosition = customAdInfo.xPostion;
|
|
196
|
+
let yPosition: CustomAd_YPosition = customAdInfo.yPostion;
|
|
197
|
+
|
|
198
|
+
let xMargin: number = customAdPlatformInfo.xMargin;
|
|
199
|
+
let yMargin: number = customAdPlatformInfo.yMargin;
|
|
200
|
+
let width: number = customAdPlatformInfo.width;
|
|
201
|
+
let height: number = customAdPlatformInfo.height;
|
|
202
|
+
let adScaleRatio: number = customAdPlatformInfo.scaleRatio;
|
|
203
|
+
|
|
204
|
+
let top: number = 0;
|
|
205
|
+
let left: number = 0;
|
|
206
|
+
let realWidth: number = 0;
|
|
207
|
+
let realHeight: number = 0;
|
|
208
|
+
|
|
209
|
+
if (adScaleRatio === 0) {
|
|
210
|
+
realWidth = width;
|
|
211
|
+
if (this.screenInfo !== null) {
|
|
212
|
+
realWidth = this.screenInfo.windowWidth - xMargin * 2;
|
|
213
|
+
}
|
|
214
|
+
realHeight = height * realWidth / width;
|
|
215
|
+
|
|
216
|
+
left = xMargin;
|
|
217
|
+
switch(yPosition) {
|
|
218
|
+
case CustomAd_YPosition.Top:
|
|
219
|
+
top = yMargin;
|
|
220
|
+
break;
|
|
221
|
+
case CustomAd_YPosition.Center:
|
|
222
|
+
top = yMargin;
|
|
223
|
+
if (this.screenInfo !== null) {
|
|
224
|
+
top = this.screenInfo.windowHeight / 2 - realHeight / 2;
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
case CustomAd_YPosition.Bottom:
|
|
228
|
+
top = yMargin;
|
|
229
|
+
if (this.screenInfo !== null) {
|
|
230
|
+
top = this.screenInfo.windowHeight - realHeight - yMargin;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
realWidth = width * adScaleRatio;
|
|
236
|
+
realHeight = height * adScaleRatio;
|
|
237
|
+
|
|
238
|
+
switch (yPosition) {
|
|
239
|
+
case CustomAd_YPosition.Top:
|
|
240
|
+
top = yMargin;
|
|
241
|
+
break;
|
|
242
|
+
case CustomAd_YPosition.Center:
|
|
243
|
+
top = 0;
|
|
244
|
+
if (this.screenInfo !== null) {
|
|
245
|
+
top = this.screenInfo.windowHeight / 2 - realHeight / 2;
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case CustomAd_YPosition.Bottom:
|
|
249
|
+
top = 0;
|
|
250
|
+
if (this.screenInfo !== null) {
|
|
251
|
+
top = this.screenInfo.windowHeight - realHeight - yMargin;
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
switch (xPosition) {
|
|
257
|
+
case CustomAd_XPosition.Left:
|
|
258
|
+
left = xMargin;
|
|
259
|
+
break;
|
|
260
|
+
case CustomAd_XPosition.Center:
|
|
261
|
+
left = 0;
|
|
262
|
+
if (this.screenInfo !== null) {
|
|
263
|
+
left = this.screenInfo.windowWidth / 2 - realWidth / 2;
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
266
|
+
case CustomAd_XPosition.Right:
|
|
267
|
+
left = 0;
|
|
268
|
+
if (this.screenInfo !== null) {
|
|
269
|
+
left = this.screenInfo.windowWidth - realWidth - xMargin;
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let posInfo: CustomAdPosition = {
|
|
276
|
+
realWidth: realWidth,
|
|
277
|
+
realHeight: realHeight,
|
|
278
|
+
left: left,
|
|
279
|
+
top: top,
|
|
280
|
+
};
|
|
281
|
+
return posInfo;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public calcPortalAdPosition(portalAdPlatformInfo: PortalAd_PlatformInfo): PortalAdPosition {
|
|
285
|
+
let width: number = portalAdPlatformInfo.width;
|
|
286
|
+
let height: number = portalAdPlatformInfo.height;
|
|
287
|
+
let adScaleRatio: number = portalAdPlatformInfo.scaleRatio;
|
|
288
|
+
|
|
289
|
+
let top: number = 0;
|
|
290
|
+
let left: number = 0;
|
|
291
|
+
let realWidth: number = 0;
|
|
292
|
+
let realHeight: number = 0;
|
|
293
|
+
|
|
294
|
+
realWidth = width * adScaleRatio;
|
|
295
|
+
realHeight = height * adScaleRatio;
|
|
296
|
+
|
|
297
|
+
top = 0;
|
|
298
|
+
left = 0;
|
|
299
|
+
if (this.screenInfo !== null) {
|
|
300
|
+
left = this.screenInfo.windowWidth / 2 - realWidth / 2;
|
|
301
|
+
top = this.screenInfo.windowHeight / 2 - realHeight / 2;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let posInfo: PortalAdPosition = {
|
|
305
|
+
realWidth: realWidth,
|
|
306
|
+
realHeight: realHeight,
|
|
307
|
+
left: left,
|
|
308
|
+
top: top,
|
|
309
|
+
};
|
|
310
|
+
return posInfo;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { RewardedVideoAd_Callback_Status } from "../../Definition/AdDefinition";
|
|
2
|
+
import { LogUtils } from "../../Utils/LogUtils";
|
|
3
|
+
import { AbsAdAdapter, RewardedVideoAdStatus } from "./AbsAdAdapter";
|
|
4
|
+
|
|
5
|
+
class BLRewardedVideoAd {
|
|
6
|
+
unitId: string;
|
|
7
|
+
ad: any;
|
|
8
|
+
status: RewardedVideoAdStatus;
|
|
9
|
+
callback: Function;
|
|
10
|
+
errorListener: Function;
|
|
11
|
+
loadListener: Function;
|
|
12
|
+
closeListener: Function;
|
|
13
|
+
isShowImmediately: boolean;
|
|
14
|
+
|
|
15
|
+
constructor(adUnitId: string, callback: Function) {
|
|
16
|
+
this.unitId = adUnitId;
|
|
17
|
+
this.ad = null;
|
|
18
|
+
this.status = RewardedVideoAdStatus.Status_Destroyed;
|
|
19
|
+
this.callback = callback;
|
|
20
|
+
this.errorListener = null;
|
|
21
|
+
this.loadListener = null;
|
|
22
|
+
this.closeListener = null;
|
|
23
|
+
this.isShowImmediately = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public destroy(): void {
|
|
27
|
+
if (this.ad !== null) {
|
|
28
|
+
if (this.errorListener !== null) {
|
|
29
|
+
this.ad.offError(this.errorListener);
|
|
30
|
+
this.errorListener = null;
|
|
31
|
+
}
|
|
32
|
+
if (this.loadListener !== null) {
|
|
33
|
+
this.ad.offLoad(this.loadListener);
|
|
34
|
+
this.loadListener = null;
|
|
35
|
+
}
|
|
36
|
+
if (this.closeListener !== null) {
|
|
37
|
+
this.ad.offClose(this.closeListener);
|
|
38
|
+
this.closeListener = null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.ad.destroy();
|
|
42
|
+
this.ad = null;
|
|
43
|
+
}
|
|
44
|
+
this.isShowImmediately = false;
|
|
45
|
+
this.status = RewardedVideoAdStatus.Status_Destroyed;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class AdAdapterBilibili extends AbsAdAdapter {
|
|
50
|
+
static TAG: string = "AdAdapterBilibili";
|
|
51
|
+
|
|
52
|
+
private blRewardedVideoAd: BLRewardedVideoAd = null;
|
|
53
|
+
|
|
54
|
+
public init(interstitialAdUnitId: string, interstitialAdCallback: Function, rewardedVideoAdUnitId: string, rewardedVideoAdCallback: Function): void {
|
|
55
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "init()");
|
|
56
|
+
|
|
57
|
+
this.blRewardedVideoAd = new BLRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public createBannerAd(adUnitId: string): boolean {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public destroyBannerAd(adUnitId: string): void {
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public showBannerAd(adUnitId: string): void {
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public hideBannerAd(adUnitId: string): void {
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public createInterstitialAd(): void {
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public showInterstitialAd(): void {
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public destroyInterstitialAd(): void {
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public isIntersititialAdShowing(): boolean {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected _loadInterstitialAd(isShowImmediately: boolean): void {
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
protected _showInterstitialAd(): void {
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public createRewardedVideoAd(): void {
|
|
101
|
+
this.destroyRewardedVideoAd();
|
|
102
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "createRewardedVideoAd() adUnitId=" + this.blRewardedVideoAd.unitId);
|
|
103
|
+
|
|
104
|
+
let rewardedVideoAd: any = window["bl"].createRewardedVideoAd({
|
|
105
|
+
adUnitId: this.blRewardedVideoAd.unitId
|
|
106
|
+
});
|
|
107
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "bl.createRewardedVideoAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
|
|
108
|
+
LogUtils.Instance.log("", rewardedVideoAd);
|
|
109
|
+
if (!rewardedVideoAd) {
|
|
110
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
111
|
+
this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.blRewardedVideoAd.ad = rewardedVideoAd;
|
|
116
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
|
|
117
|
+
|
|
118
|
+
this.blRewardedVideoAd.errorListener = (err) => {
|
|
119
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.onError()");
|
|
120
|
+
if (err) {
|
|
121
|
+
LogUtils.Instance.log("", err);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
|
|
125
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
126
|
+
this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
this.blRewardedVideoAd.ad.onError(this.blRewardedVideoAd.errorListener);
|
|
130
|
+
|
|
131
|
+
this.blRewardedVideoAd.loadListener = () => {
|
|
132
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.onLoad()");
|
|
133
|
+
|
|
134
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
135
|
+
|
|
136
|
+
if (this.blRewardedVideoAd.isShowImmediately) {
|
|
137
|
+
this.blRewardedVideoAd.isShowImmediately = false;
|
|
138
|
+
this._showRewardedVideoAd();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
this.blRewardedVideoAd.ad.onLoad(this.blRewardedVideoAd.loadListener);
|
|
142
|
+
|
|
143
|
+
this.blRewardedVideoAd.closeListener = (res) => {
|
|
144
|
+
let isEnded: boolean = (res !== null) ? res.isEnded : false;
|
|
145
|
+
|
|
146
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.onClose()");
|
|
147
|
+
LogUtils.Instance.log("", "isEnded=" + isEnded);
|
|
148
|
+
|
|
149
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
|
|
150
|
+
if (isEnded) {
|
|
151
|
+
this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
|
|
152
|
+
} else {
|
|
153
|
+
this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
this.scheduleOnce(() => {
|
|
157
|
+
if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
158
|
+
this._loadRewardedVideoAd(false);
|
|
159
|
+
}
|
|
160
|
+
}, 2);
|
|
161
|
+
};
|
|
162
|
+
this.blRewardedVideoAd.ad.onClose(this.blRewardedVideoAd.closeListener);
|
|
163
|
+
|
|
164
|
+
this.scheduleOnce(() => {
|
|
165
|
+
if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
166
|
+
this._loadRewardedVideoAd(false);
|
|
167
|
+
}
|
|
168
|
+
}, 2);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public showRewardedVideoAd(): void {
|
|
172
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "showRewardedVideoAd()");
|
|
173
|
+
|
|
174
|
+
if (this.blRewardedVideoAd.ad === null) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.status=" + RewardedVideoAdStatus[this.blRewardedVideoAd.status]);
|
|
179
|
+
switch(this.blRewardedVideoAd.status) {
|
|
180
|
+
case RewardedVideoAdStatus.Status_Destroyed:
|
|
181
|
+
case RewardedVideoAdStatus.Status_Watching:
|
|
182
|
+
case RewardedVideoAdStatus.Status_StartToWatch:
|
|
183
|
+
break;
|
|
184
|
+
case RewardedVideoAdStatus.Status_Loaded:
|
|
185
|
+
this._showRewardedVideoAd();
|
|
186
|
+
break;
|
|
187
|
+
case RewardedVideoAdStatus.Status_Watched:
|
|
188
|
+
case RewardedVideoAdStatus.Status_Error:
|
|
189
|
+
case RewardedVideoAdStatus.Status_Init:
|
|
190
|
+
this._loadRewardedVideoAd(true);
|
|
191
|
+
break;
|
|
192
|
+
default:
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public destroyRewardedVideoAd(): void {
|
|
198
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "destroyRewardedVideoAd()");
|
|
199
|
+
this.blRewardedVideoAd.destroy();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public isRewardedVideoAdLoaded(): boolean {
|
|
203
|
+
if (this.blRewardedVideoAd.ad === null) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public isRewardedVideoAdShowing(): boolean {
|
|
213
|
+
if (this.blRewardedVideoAd.ad === null) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
protected _loadRewardedVideoAd(isShowImmediately: boolean): void {
|
|
223
|
+
this.blRewardedVideoAd.isShowImmediately = isShowImmediately;
|
|
224
|
+
|
|
225
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.load()");
|
|
226
|
+
this.blRewardedVideoAd.ad.load().then(() => {
|
|
227
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.load() success");
|
|
228
|
+
}).catch((err) => {
|
|
229
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.load() error");
|
|
230
|
+
if (err) {
|
|
231
|
+
LogUtils.Instance.log("", err);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
protected _showRewardedVideoAd(): void {
|
|
237
|
+
if (this.blRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_StartToWatch;
|
|
242
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.show()");
|
|
243
|
+
this.blRewardedVideoAd.ad.show()
|
|
244
|
+
.then(() => {
|
|
245
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.show() success");
|
|
246
|
+
|
|
247
|
+
if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
248
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
|
|
249
|
+
this.blRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
|
|
250
|
+
}
|
|
251
|
+
}).catch((err) => {
|
|
252
|
+
LogUtils.Instance.log(AdAdapterBilibili.TAG, "blRewardedVideoAd.ad.show() error");
|
|
253
|
+
if (err) {
|
|
254
|
+
LogUtils.Instance.log("", err);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (this.blRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
258
|
+
this.blRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public createCustomAd(adUnitId: string): boolean {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public destroyCustomAd(adUnitId: string): void {
|
|
268
|
+
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
public showCustomAd(adUnitId: string): void {
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public hideCustomAd(adUnitId: string): void {
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public createPortalAd(adUnitId: string): void {
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public destroyPortalAd(adUnitId: string): void {
|
|
284
|
+
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public showPortalAd(adUnitId: string): void {
|
|
288
|
+
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public hidePortalAd(adUnitId: string): void {
|
|
292
|
+
|
|
293
|
+
}
|
|
294
|
+
}
|