UIGoldenAim.ts
2.78 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
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import { SaveDataManager } from "../../component/SaveDataManager";
import { ADID, tMgr, WindowName } from "../../Global";
import { GamePlayTable, TableName } from "../../kernel/table/TableDefine";
import { UIBase } from "../UIBase";
import { UIManager } from "../UIManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class UIGoldenAim extends UIBase {
@property(cc.Node)
btn_ad: cc.Node = null;
@property(cc.Node)
btn_start: cc.Node = null;
@property(cc.Node)
btn_bonus: cc.Node = null;
openCount: number = 0;
protected onEnable(): void {
let price = (tMgr.getConfig(TableName.GAME_PLAY, 15) as GamePlayTable).Value;
this.node.getChildByName('btnDiamond').getComponentInChildren(cc.Label).string = price.toString();
this.btn_ad.getChildByName('Background').getChildByName('UI_General_Btn_yellow_ckgg').active = true;
this.btn_ad.getChildByName('Background').getChildByName('UI_Finish_kxsx').active = false;
this.openCount++;
if (this.openCount > 1) {
this.BtnPos_Change();
}
}
//按钮位置轮换
BtnPos_Change() {
let tempPos = this.btn_start.position;
this.btn_start.position = this.btn_bonus.position;
this.btn_bonus.position = this.btn_ad.position;
this.btn_ad.position = tempPos;
}
onCloseClick() {
this.close();
}
onBuyClick() {
let price = (tMgr.getConfig(TableName.GAME_PLAY, 15) as GamePlayTable).Value;
// this.node.getChildByName('btnDiamond').getComponentInChildren(cc.Label).string = price
if (SaveDataManager.ins.adjustDiamond(-price)) {
let sec = (tMgr.getConfig(TableName.GAME_PLAY, 31) as GamePlayTable).Value;
let endTime = Date.now() + sec * 1000;
SaveDataManager.ins.runtimeData.goldenAimEndTime = endTime;
SaveDataManager.ins.saveData();
this.close();
}
}
onAdTryClick() {
//AD 放广告,放完后调用 onTry
// HeyGamePlatform.instance.showVideoAd(ADID.ADID_ADDCOIN, (_result) => {
if (true) {
this.onTry();
} else {
console.log('视频播放失败');
}
// });
}
private onTry() {
SaveDataManager.ins.runtimeData.goldenAimTry = true;
this.close();
}
close(): void {
UIManager.ins.closeWindow(WindowName.GOLDEN_AIM);
// HeyGamePlatform.instance.hideGameNativeAd();
}
}