TestScene.ts
6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import { ui } from "./ui/layaMaxUI";
import AdManager from "./sdk/AdManager";
import ShakeModel from "./sdk/model/ShakeModel";
import RedpacketModel from "./sdk/model/RedpacketModel";
import PcSdk from "./sdk/PcSdk";
import NativeAd from "./sdk/NativeAd";
import Util from "./uitl/Util";
export default class TestScene extends ui.TestSceneUI {
private isLongVibrate: boolean = false;
constructor() {
super();
//关闭多点触控,否则就无敌了
Laya.MouseManager.multiTouchEnabled = false;
console.log('---------------TestScene-------')
// this.NativeAD.visible = false;
}
onEnable(): void {
this.btnServer.on(Laya.Event.CLICK, this, this.openServer);
this.btnVibrate.on(Laya.Event.CLICK, this, () => {
PcSdk.I.vibrate(this.isLongVibrate ? 0 : 1);
this.isLongVibrate = !this.isLongVibrate;
});
this.btnDrawal.on(Laya.Event.CLICK, this, this.openPersonal);
this.btnInvite.on(Laya.Event.CLICK, this, this.invitation);
this.btn_shake.on(Laya.Event.CLICK, this, this.touchShake);
this.btnPreloadAD.on(Laya.Event.CLICK, this, this.preloadAD);
this.btnShowBanner.on(Laya.Event.CLICK, this, this.showBanner);
this.btnShowFullAd.on(Laya.Event.CLICK, this, this.showFullAd);
this.btnShowNativeAd.on(Laya.Event.CLICK, this, this.showNativeAd);
this.btnShowInterAd.on(Laya.Event.CLICK, this, this.showInterAd);
this.btnRewardAd.on(Laya.Event.CLICK, this, this.showRewardAd);
this.btnRedpacket.on(Laya.Event.CLICK, this, this.openRedpacket);
this.btnPreVideo.on(Laya.Event.CLICK, this, this.preloadRewardAd);
this.btnPreFull.on(Laya.Event.CLICK, this, this.preloadFull);
this.btnPreInsert.on(Laya.Event.CLICK, this, this.preloadInterAd);
this.btnPreNative.on(Laya.Event.CLICK, this, this.preloadNativeAd);
this.btnCloseBanner.on(Laya.Event.CLICK, this, this.closeAdBanner);
this.btnCloseNative.on(Laya.Event.CLICK, this, this.closeAdverDialog);
this.btnMinWithDrawal.on(Laya.Event.CLICK, this, this.minWithDrawal);
}
/**预加载广告 */
async preloadAD() {
console.log('---------------preloadAD-------')
await AdManager.I.preloadBanner();
}
preloadRewardAd() {
AdManager.I.preloadRewardAd();
}
preloadFull() {
AdManager.I.preloadFullAd();
}
preloadInterAd() {
AdManager.I.preloadInterAd();
}
preloadNativeAd() {
this.NativeAD.getComponent(NativeAd).initNativeAd(1);
}
closeAdverDialog() {
AdManager.I.closeAdverDialog()
}
closeAdBanner() {
AdManager.I.closeAdBanner()
}
/**显示全屏广告 */
showFullAd() {
console.log('---------------showFullAd-------')
AdManager.I.showFullAd();
}
/**显示banner */
showBanner() {
console.log('---------------showBanner-------')
AdManager.I.showBanner();
}
/**信息流广告 */
showNativeAd() {
this.NativeAD.getComponent(NativeAd).initNativeAd();
}
/**插屏广告 */
showInterAd() {
console.log('---------------showInterAd-------')
AdManager.I.showInterAd();
}
/**激励视频广告 */
async showRewardAd() {
console.log('---------------showRewardAd-------')
await AdManager.I.showRewardAd();
/**成功后执行对应的奖励 */
}
/**意见反馈 */
openServer() {
console.log('---------------openServer-------')
PcSdk.I.feedback();
}
async openRedpacket() {
RedpacketModel.I.checkRedpacket()
}
async minWithDrawal() {
let money = await PcSdk.I.minWithDrawal()
this.minWithDrawalLab.text = '最低提现:' + money;
}
/**打开个人中心 */
openPersonal() {
console.log('---------------openServer-------')
PcSdk.I.personal(0);
}
/**邀请好友 */
invitation() {
PcSdk.I.invitation();
}
/**
* 1 金币
2 激励视频后金币
3 4 5 6 7 游戏中对应的道具
8 空
*/
touchShake() {
console.log('---------------touchShake-------')
PcSdk.I.vibrate();
/**
* 1.回去星星 道具
* 2.红包 直接获得⾦币;或者直接弹激励视频后,获得⾦币
* 3.无道具
* 直接展⽰插屏
* */
let data = ShakeModel.I.getShakeType();
console.log('摇一摇获取结果:' + JSON.stringify(data))
if (!data) return;
let type = data.type;
switch (type) {
case 8:
/** '谢谢参与,下次好运!'*/;
AdManager.I.showInterAd();
break;
case 1:
this.getCoin();
break;
case 2:
this.watchADCoin();
break;
case 3:
case 4:
case 5:
case 6:
case 7:
this.getProps(data);
break;
}
}
getProps(data) {
let booster;
let rewardNum = data.num;
let type = data.type;
/**
* 处理游戏中的道具显示
*/
// switch (type) {
// case 4:
// booster = BoosterType.Remove;
// break;
// case 6:
// booster = BoosterType.Change;
// break;
// case 5:
// booster = BoosterType.Refresh;
// break;
// case 7:
// booster = BoosterType.RandRemove;
// break;
// case 3:
// booster = BoosterType.Star;
// break;
// }
// ViewManager.I.openPopwin(ReceivePropsPopwin, booster, rewardNum);
}
/**
* 看广告获得红包
*/
async watchADCoin() {
await AdManager.I.showRewardAd();
this.getCoin();
}
/**直接获得红包 */
getCoin() {
//刷新总金币
// AppManager.I.redpacket.getRepacket()
// ViewManager.I.openPopwin(RedPacketReward, 2);
}
}