58c2d9ab-bfe0-4c89-952c-d49d68efd726.js
17.8 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
"use strict";
cc._RF.push(module, '58c2dmrv+BMiZUs1J1o79cm', 'UIBattle');
// scripts/ui/uiView/UIBattle.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 SoundManager_1 = require("../../component/SoundManager");
var Global_1 = require("../../Global");
var BattleConst_1 = require("../../kernel/battle/BattleConst");
var BattleManager_1 = require("../../kernel/battle/BattleManager");
var MapUtil_1 = require("../../kernel/battle/map/MapUtil");
var UserSkillShurikenData_1 = require("../../kernel/battle/userSkill/UserSkillShurikenData");
var UIBase_1 = require("../UIBase");
var UIManager_1 = require("../UIManager");
var UIBattleUserSkillBtn_1 = require("./UIBattleUserSkillBtn");
var UICommonNoticeEnableParam_1 = require("./UICommonNoticeEnableParam");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var UIBattle = /** @class */ (function (_super) {
__extends(UIBattle, _super);
function UIBattle() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._starList = [];
return _this;
//#endregion
}
// private _collecting: boolean = false;
//#region LIFE-CYCLE CALLBACKS:
UIBattle.prototype.onLoad = function () {
this._useCloseEffect = false;
this._usePopUpEffect = false;
this._cancelNode = this.node.getChildByName('bottom').getChildByName('nodeCancel');
this._skillNode = this.node.getChildByName('bottom').getChildByName('skillNode');
this._roundingNode = this.node.getChildByName('bottom').getChildByName('roundingNode');
this._roundingNode.active = false;
this._pauseNode = this.node.getChildByName('pauseNode');
this._pauseNode.active = false;
for (var i = 1; i <= 3; ++i) {
this._starList.push(this.node.getChildByName('top').getChildByName('prgStar').getChildByName('star' + i.toString()));
}
this._noticeParam = new UICommonNoticeEnableParam_1.UICommonNoticeEnableParam();
this._noticeParam.desc = '您想重新开始游戏吗?';
this._noticeParam.callBackThisObj = this;
this._noticeParam.doneCallBack = this.onNoticeRestartDoneClick;
BattleManager_1.BattleManager.ins.eventNode.once(BattleConst_1.BattleEvent.BATTLE_START, this.onBattleStart, this);
BattleManager_1.BattleManager.ins.eventNode.on(BattleConst_1.BattleEvent.BLOCK_COMBO, this.onBlockCombo, this);
BattleManager_1.BattleManager.ins.eventNode.on(BattleConst_1.BattleEvent.ROUND_END, this.onRoundEnd, this);
BattleManager_1.BattleManager.ins.eventNode.on(BattleConst_1.BattleEvent.ROUND_START, this.onRoundStart, this);
BattleManager_1.BattleManager.ins.eventNode.on(BattleConst_1.BattleEvent.SKILL_START, this.onSkillStart, this);
};
UIBattle.prototype.start = function () {
this.node.getComponent(cc.Widget).updateAlignment(); //必须先根据舞台调整尺寸
var dis = this.node.height / 2 + this.node.getChildByName('bottom').y;
var nodeRounding = this.node.getChildByName('bottom').getChildByName('roundingNode');
nodeRounding.y -= (nodeRounding.height + dis);
nodeRounding.active = true;
};
UIBattle.prototype.onEnable = function () {
// this.schedule(this.onLazyUpdate, 1 / 20);
};
UIBattle.prototype.onDisable = function () {
// this.unschedule(this.onLazyUpdate);
};
UIBattle.prototype.onDestroy = function () {
// cc.Tween.stopAllByTarget(this._tobj);
this.unschedule(this.onLazyUpdate);
// BattleManager.ins.eventNode.off(BattleEvent.BATTLE_START, this.onBattleStart, this);
// BattleManager.ins.eventNode.off(BattleEvent.BLOCK_COMBO, this.onBlockCombo, this);
// BattleManager.ins.eventNode.off(BattleEvent.ROUND_START, this.onRoundStart, this);
// BattleManager.ins.eventNode.off(BattleEvent.ROUND_END, this.onRoundEnd, this);
BattleManager_1.BattleManager.ins.eventNode.targetOff(this);
};
//#endregion
//#region public method
UIBattle.prototype.setCancelNodeVisible = function (value) {
this._cancelNode.active = value;
};
UIBattle.prototype.setCancelNodeHit = function (value) {
this._cancelNode.opacity = (value ? 255 : 153);
};
//#endregion
//#region private method
UIBattle.prototype.onLazyUpdate = function () {
var battle = BattleManager_1.BattleManager.ins.curBattle;
if (battle) {
var rate = (battle.doubleShoot ? 2 : 1);
this.node.getChildByName('bottom').getChildByName('txtMarblesNum').getComponent(cc.Label).string = "弹球:" + (battle.marblesNum * rate).toString();
if (battle.mapData) {
this.node.getChildByName('top').getChildByName('nodeScore').getComponentInChildren(cc.Label).string = battle.mapData.curScore.toString();
this.node.getChildByName('top').getChildByName('prgStar').getComponent(cc.ProgressBar).progress = battle.mapData.curScore / MapUtil_1.MapUtil.getThreeStarScore(battle.mapData);
var starRate = MapUtil_1.MapUtil.getStarRate(battle.mapData);
var _loop_1 = function (i) {
var get = (i + 1 <= starRate);
var enableNode = this_1._starList[i].getChildByName('enable');
if (enableNode.active == false && get) {
enableNode.active = get;
var spine_1 = enableNode.getComponent(sp.Skeleton);
spine_1.setAnimation(0, 'animation2', false);
spine_1.setCompleteListener(function () {
spine_1.setAnimation(0, 'animation3', true);
});
SoundManager_1.SoundManager.ins.playEffect(Global_1.SoundName.GET_STAR);
}
else {
enableNode.active = get;
}
};
var this_1 = this;
for (var i = 0; i < 3; ++i) {
_loop_1(i);
}
}
var nodeSpeedUp = this.node.getChildByName('nodeSpeedUp');
if (battle.roundRunning && battle.speedUp) {
if (nodeSpeedUp.active == false) {
nodeSpeedUp.active = true;
nodeSpeedUp.getComponentInChildren(cc.Animation).play();
}
}
else {
nodeSpeedUp.getComponentInChildren(cc.Animation).stop();
nodeSpeedUp.active = false;
}
var now = Date.now();
var goldenAimLeftTime = SaveDataManager_1.SaveDataManager.ins.runtimeData.goldenAimEndTime - Date.now();
var txtGoldenAim = cc.find('top/btnGoldenAim/txtTime', this.node);
if (goldenAimLeftTime > 0) {
txtGoldenAim.active = true;
var timeStr = slib.StringUtil.formatTimeBySecs(goldenAimLeftTime / 1000);
timeStr = timeStr.slice(3, timeStr.length);
txtGoldenAim.getComponent(cc.Label).string = timeStr;
}
else {
txtGoldenAim.active = false;
}
}
};
UIBattle.prototype.tweenTarget = function (node, up) {
var dis = this.node.height / 2 - Math.abs(this.node.getChildByName('bottom').y);
// if (node == this.node.getChildByName('bottom').getChildByName('roundingNode') && !up) {
// //回收栏下降时 添加额外的回调
// cc.tween(node).to(0.3, { position: cc.v3(node.x, up ? 0 : -dis - 200, node.z) }, { easing: 'backOut' }).call(() => { this._collecting = false; })
// .start();
// }
// else {
cc.tween(node).to(0.3, { position: cc.v3(node.x, up ? 0 : -dis - 200, node.z) }, { easing: 'backOut' })
.start();
// }
};
//#endregion
//#region events
UIBattle.prototype.onBattleStart = function () {
var spineNode = this.node.getChildByName('spineGameStart');
spineNode.active = true;
var spine = spineNode.getComponent(sp.Skeleton);
spine.setCompleteListener(function () { spineNode.active = false; BattleManager_1.BattleManager.ins.shootTouchEnable = true; });
spine.setAnimation(0, 'animation', false);
for (var i = 0; i < 4; ++i) {
this._skillNode.getChildByName('skill' + (i + 1).toString()).getComponent(UIBattleUserSkillBtn_1.default).setId(i + 1);
// this._skillNode.getChildByName('skill' + (i + 1).toString()).getComponent(UIBattleUserSkillBtn).setLock(false);
}
this.schedule(this.onLazyUpdate, 1 / 20);
};
// private _tobj = { progress: 0 };
UIBattle.prototype.onBlockCombo = function (combo) {
var nodeCombo = this.node.getChildByName('nodeCombo');
var txtNum = nodeCombo.getChildByName('txtNum').getComponent(cc.Label);
if (nodeCombo.active == false) {
nodeCombo.active = true;
}
txtNum.string = combo.toString();
nodeCombo.getComponent(cc.Animation).play();
//连击描述
var nodeComboTip = this.node.getChildByName('nodeComboTip');
var frame = nodeComboTip.getChildByName('UI_fx_bksy').getChildByName('UI_fx_bksy02').getComponent(cc.Sprite);
var showTip = true;
if (combo == 5) {
//很棒
cc.resources.load('ui/battle/UI_yxz_hb', cc.SpriteFrame, function (error, asset) { frame.spriteFrame = asset; });
}
else if (combo == 10) {
//了不起
cc.resources.load('ui/battle/UI_yxz_lbq', cc.SpriteFrame, function (error, asset) { frame.spriteFrame = asset; });
}
else if (combo == 15) {
//真了不起
cc.resources.load('ui/battle/UI_yxz_zlbq', cc.SpriteFrame, function (error, asset) { frame.spriteFrame = asset; });
}
else if (combo == 20) {
//完美
cc.resources.load('ui/battle/UI_yxz_wm', cc.SpriteFrame, function (error, asset) { frame.spriteFrame = asset; });
}
else if (combo == 25) {
//太疯狂了
cc.resources.load('ui/battle/UI_yxz_tfkl', cc.SpriteFrame, function (error, asset) { frame.spriteFrame = asset; });
}
else if (combo == 30) {
//不可思议
cc.resources.load('ui/battle/UI_yxz_bksy', cc.SpriteFrame, function (error, asset) { frame.spriteFrame = asset; });
}
else {
showTip = false;
}
if (showTip) {
// cc.Tween.stopAllByTarget(this._tobj);
nodeComboTip.active = true;
nodeComboTip.getChildByName('UI_fx_bksy').getComponent(cc.Animation).once('finished', function () { nodeComboTip.active = false; }, this);
nodeComboTip.getChildByName('UI_fx_bksy').getComponent(cc.Animation).play('UI_fx_bksy');
// this._tobj.progress = 0.618;
// nodeComboTip.setScale(0.618, 0.618);
// cc.tween(this._tobj).to(0.2, { progress: 1 }, {
// onUpdate: (target: { progress: number }) => {
// nodeComboTip.setScale(target.progress, target.progress);
// },
// }).delay(1).to(0.2, { progress: 0 }, {
// onUpdate: (target: { progress: number }) => {
// nodeComboTip.setScale(target.progress, target.progress);
// },
// }).call(() => { nodeComboTip.active = false; }).start();
}
};
UIBattle.prototype.onRoundStart = function () {
var nodeSkill = this.node.getChildByName('bottom').getChildByName('skillNode');
var nodeRounding = this.node.getChildByName('bottom').getChildByName('roundingNode');
this.tweenTarget(nodeSkill, false);
this.tweenTarget(nodeRounding, true);
};
UIBattle.prototype.onRoundEnd = function () {
var nodeCombo = this.node.getChildByName('nodeCombo');
nodeCombo.active = false;
var nodeSkill = this.node.getChildByName('bottom').getChildByName('skillNode');
var nodeRounding = this.node.getChildByName('bottom').getChildByName('roundingNode');
this.tweenTarget(nodeSkill, true);
this.tweenTarget(nodeRounding, false);
};
UIBattle.prototype.onSkillStart = function (skillId) {
var _this = this;
if (skillId == BattleConst_1.UserSkill.BOMB) {
var spNode_1 = this.node.getChildByName('userSkillBombSpine');
spNode_1.active = true;
spNode_1.getComponent(sp.Skeleton).setCompleteListener(function () { spNode_1.active = false; });
spNode_1.getComponent(sp.Skeleton).setAnimation(0, 'animation', false);
}
else if (skillId == BattleConst_1.UserSkill.SHURIKEN) {
var spNode_2 = this.node.getChildByName('userSkillShuriken');
spNode_2.active = true;
spNode_2.getComponent(sp.Skeleton).setCompleteListener(function () {
if (spNode_2.getComponent(sp.Skeleton).animation == 'in') {
spNode_2.getComponent(sp.Skeleton).setAnimation(0, 'att', false);
//调整位置
var p = BattleManager_1.BattleManager.ins.curBattle.mapData.getPixelPosByGridPos(cc.v2(0, UserSkillShurikenData_1.UserSkillShurikenData.maxY));
BattleManager_1.BattleManager.ins.curBattle.mapView.convertToWorldSpaceAR(p, p);
_this.node.convertToNodeSpaceAR(p, p);
spNode_2.setPosition(0, p.y);
}
else {
spNode_2.active = false;
}
});
spNode_2.getComponent(sp.Skeleton).setAnimation(0, 'in', false);
}
};
UIBattle.prototype.onBtnPauseClick = function () {
// BattleManager.ins.leaveBattle();
// UIManager.ins.openScene('Main');
// UIManager.ins.openWindow(WindowName.PAUSE);
this._pauseNode.active = true;
BattleManager_1.BattleManager.ins.paused = true;
this.refreshSoundBtn();
};
UIBattle.prototype.onBtnCollectClick = function () {
// if (!this._collecting) {
// this._collecting = true;
BattleManager_1.BattleManager.ins.curBattle.collectAll();
// }
};
UIBattle.prototype.onBtnPauseCloseClick = function () {
this._pauseNode.active = false;
BattleManager_1.BattleManager.ins.paused = false;
};
UIBattle.prototype.onBtnMusicClick = function () {
SaveDataManager_1.SaveDataManager.ins.setMusicMute(!SaveDataManager_1.SaveDataManager.ins.runtimeData.musicMute);
this.refreshSoundBtn();
if (SaveDataManager_1.SaveDataManager.ins.runtimeData.musicMute) {
SoundManager_1.SoundManager.ins.stopMusic();
}
else {
SoundManager_1.SoundManager.ins.playMusic();
}
};
UIBattle.prototype.onBtnMuteClick = function () {
SaveDataManager_1.SaveDataManager.ins.setSoundEffectMute(!SaveDataManager_1.SaveDataManager.ins.runtimeData.SEMute);
this.refreshSoundBtn();
};
UIBattle.prototype.onBtnRestartClick = function () {
UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.COMMON_NOTICE, this._noticeParam);
};
UIBattle.prototype.onGoldenAimClick = function () {
UIManager_1.UIManager.ins.openWindow(Global_1.WindowName.GOLDEN_AIM);
};
UIBattle.prototype.onNoticeRestartDoneClick = function () {
// this.leave();
BattleManager_1.BattleManager.ins.leaveBattle();
UIManager_1.UIManager.ins.openScene('Battle');
// UIManager.ins.closeWindow(WindowName.PAUSE, () => {
// BattleManager.ins.leaveBattle();
// UIManager.ins.openScene('Main');
// });
};
UIBattle.prototype.refreshSoundBtn = function () {
cc.find('New Layout/btnMusic/Background/disable', this._pauseNode).active = SaveDataManager_1.SaveDataManager.ins.runtimeData.musicMute;
cc.find('New Layout/btnVol/Background/disable', this._pauseNode).active = SaveDataManager_1.SaveDataManager.ins.runtimeData.SEMute;
};
UIBattle.prototype.onBtnHomeClick = function () {
BattleManager_1.BattleManager.ins.leaveBattle();
UIManager_1.UIManager.ins.openScene('Main');
};
UIBattle = __decorate([
ccclass
], UIBattle);
return UIBattle;
}(UIBase_1.UIBase));
exports.default = UIBattle;
cc._RF.pop();