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