9db7e33d-7da2-42ba-8891-ec592a521616.js
8.03 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
"use strict";
cc._RF.push(module, '9db7eM9faJCuoiR7FkqUhYW', 'UIShop');
// scripts/ui/uiView/UIShop.ts
"use strict";
// 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
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var SaveDataManager_1 = require("../../component/SaveDataManager");
var Global_1 = require("../../Global");
var TableDefine_1 = require("../../kernel/table/TableDefine");
var UIBase_1 = require("../UIBase");
var UIManager_1 = require("../UIManager");
var UITitle_1 = require("./UITitle");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var UIShop = /** @class */ (function (_super) {
__extends(UIShop, _super);
function UIShop() {
var _this = _super.call(this) || this;
_this.txtPackDiamond = null;
_this.txtAdDiamond = null;
_this.adNode = null;
_this.btn_ad = null;
_this._useCloseEffect = false;
_this._usePopUpEffect = false;
return _this;
}
//#region lifecycle
UIShop.prototype.onLoad = function () {
this.txtPackDiamond.getComponent(cc.Label).string = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 20).Value.toString();
this.txtAdDiamond.getComponent(cc.Label).string = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 14).Value.toString();
var content = cc.find('scrollView/view/content', this.node);
for (var i = 1; i <= 4; ++i) {
var item = content.getChildByName('itemSkill' + i.toString());
item.getChildByName('btnGet').getComponentInChildren(cc.Label).string = Global_1.tMgr.getConfig(TableDefine_1.TableName.USER_SKILL, i).Cost.toString();
item.getChildByName('icon').getComponentInChildren(cc.Label).string = Global_1.tMgr.getConfig(TableDefine_1.TableName.USER_SKILL, i).BuyNum.toString();
}
};
UIShop.prototype.onEnable = function () {
this.refresh();
this.setAD();
};
UIShop.prototype.setAD = function () {
// this.adNode.getComponent(CustomNativeAdView).showNativeAd((result) => {
// if (result) {
// this.btn_ad.active = true;
// } else {
// this.btn_ad.active = false;
// }
// });
this.btn_ad.getChildByName('Background').getChildByName('UI_General_Btn_yellow_ckgg').active = true;
this.btn_ad.getChildByName('Background').getChildByName('UI_Finish_kxsx').active = false;
};
UIShop.prototype.onDestroy = function () {
UIManager_1.UIManager.ins.cache.delete(Global_1.WindowName.SHOP); // 此界面添加在场景中,会随场景一起销毁,将UIManager中的缓存也删除,避免后续取到被销毁的缓存
};
UIShop.prototype.hide_btn_ad = function () {
this.btn_ad.active = false;
};
//#endregion
//#region public method
//#endregion
//#region event
UIShop.prototype.onGetClick = function (e, customData) {
if (customData == 'pack') {
//AD 放广告,放完后调 getPack()
// HeyGamePlatform.instance.showVideoAd(ADID.ADID_ADDCOIN, (_result) => {
if (true) {
this.getPack();
}
else {
console.log('视频播放失败');
}
// });
}
else if (customData == 'diamond') {
//AD 放广告,放完后调 getDiamond()
// HeyGamePlatform.instance.showVideoAd(ADID.ADID_ADDCOIN, (_result) => {
if (true) {
this.getDiamond();
}
else {
console.log('视频播放失败');
}
// });
}
else if (customData == 'ad') {
//AD 纯看广告
}
else if (customData.includes('skill')) {
var skillId = Number(customData.slice(5));
var config = Global_1.tMgr.getConfig(TableDefine_1.TableName.USER_SKILL, skillId);
var wpos = e.target.convertToWorldSpaceAR(cc.Vec3.ZERO);
if (SaveDataManager_1.SaveDataManager.ins.adjustDiamond(-config.Cost, true, wpos)) {
//扣钱成功
SaveDataManager_1.SaveDataManager.ins.setUserSkillNumDelta(skillId, config.BuyNum);
}
}
};
UIShop.prototype.onCloseClick = function () {
var titleNode = cc.find('Canvas/UITitle', cc.director.getScene());
titleNode.getComponent(UITitle_1.default).onShopCloseClick();
};
//#endregion
//#region private method
UIShop.prototype.refresh = function () {
var btnPackGet = cc.find('bg/pack/btnBuy', this.node);
var btnPackBg = btnPackGet.getChildByName('Background');
var valid = (Date.now() > SaveDataManager_1.SaveDataManager.ins.runtimeData.shopDailyPackRefreshTime);
btnPackGet.getComponent(cc.Button).interactable = valid;
btnPackBg.getChildByName('txtFree').active = valid;
btnPackBg.getChildByName('iconAd').active = valid;
btnPackBg.getChildByName('txtGeted').active = !valid;
};
UIShop.prototype.getPack = function () {
var valid = (Date.now() > SaveDataManager_1.SaveDataManager.ins.runtimeData.shopDailyPackRefreshTime);
if (valid) {
var config = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 20); //礼包钻石数量
SaveDataManager_1.SaveDataManager.ins.adjustDiamond(config.Value, true);
SaveDataManager_1.SaveDataManager.ins.setUserSkillNumDelta(1, 1);
SaveDataManager_1.SaveDataManager.ins.setUserSkillNumDelta(2, 1);
SaveDataManager_1.SaveDataManager.ins.setUserSkillNumDelta(3, 1);
SaveDataManager_1.SaveDataManager.ins.setUserSkillNumDelta(4, 1);
var endTime = new Date();
endTime.setHours(23, 59, 59);
SaveDataManager_1.SaveDataManager.ins.runtimeData.shopDailyPackRefreshTime = endTime.getTime();
SaveDataManager_1.SaveDataManager.ins.saveData();
this.refresh();
}
};
UIShop.prototype.getDiamond = function () {
var config = Global_1.tMgr.getConfig(TableDefine_1.TableName.GAME_PLAY, 14);
SaveDataManager_1.SaveDataManager.ins.adjustDiamond(config.Value, true);
};
__decorate([
property(cc.Node)
], UIShop.prototype, "txtPackDiamond", void 0);
__decorate([
property(cc.Node)
], UIShop.prototype, "txtAdDiamond", void 0);
__decorate([
property(cc.Node)
], UIShop.prototype, "adNode", void 0);
__decorate([
property(cc.Node)
], UIShop.prototype, "btn_ad", void 0);
UIShop = __decorate([
ccclass
], UIShop);
return UIShop;
}(UIBase_1.UIBase));
exports.default = UIShop;
cc._RF.pop();