366 lines
11 KiB
JavaScript
366 lines
11 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '6f98d4id9NGTapmC3gMvAwU', 'cmp.battle.settle.special');
|
||
|
|
// Scripts/mod/battle/cmp/cmp.battle.settle.special.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var PathTool = require("pathtool");
|
||
|
|
var BattleConst = require("battle_const");
|
||
|
|
var BattleController = require("battle_controller");
|
||
|
|
var BattleEvent = require("battle_event");
|
||
|
|
var RoleController = require("role_controller");
|
||
|
|
var NxExpand = require("nx.fx.sv.expand");
|
||
|
|
var NxSpine = require("nx.fx.spine");
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var StartowerController = require("startower.mod");
|
||
|
|
var BattleDramaController = require("battle_drama_controller");
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
mainSp: {
|
||
|
|
"default": null,
|
||
|
|
type: NxSpine
|
||
|
|
},
|
||
|
|
mainNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
sMvp: {
|
||
|
|
"default": null,
|
||
|
|
type: NxSpine
|
||
|
|
},
|
||
|
|
harmBtn: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
rewardZi: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
btns: {
|
||
|
|
//按鈕組
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
rewardNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
awardList: {
|
||
|
|
"default": null,
|
||
|
|
type: NxExpand
|
||
|
|
},
|
||
|
|
roleNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
roleSp: {
|
||
|
|
"default": null,
|
||
|
|
type: NxSpine
|
||
|
|
},
|
||
|
|
fabHead: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Prefab
|
||
|
|
},
|
||
|
|
timeTxt: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this.ctrl = BattleController.getInstance();
|
||
|
|
this.model = this.ctrl.getModel();
|
||
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
||
|
|
this.vbind([["CloseSpecial", this.delayCloss.bind(this)]]);
|
||
|
|
// this.bindGEvent( BattleEvent.BATTLE_HARM_MVP, this.changeMvpDraw.bind( this ) );
|
||
|
|
},
|
||
|
|
start: function start() {},
|
||
|
|
delayCloss: function delayCloss(_data) {
|
||
|
|
if (!_data) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_data && _data == 1) {
|
||
|
|
this.close();
|
||
|
|
nx.bridge.vset("CloseSpecial", null);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 重载:关闭前
|
||
|
|
onPreClosed: function onPreClosed() {
|
||
|
|
nx.bridge.vset("ResultInfo", {});
|
||
|
|
this.awardList.rebuild([]);
|
||
|
|
this.ctrl.delSpecialRetInfo(this.fight_type);
|
||
|
|
var cur = nx.bridge.plot.vget("id");
|
||
|
|
if (nx.dt.strEmpty(cur)) {
|
||
|
|
nx.bridge.mainui.tryPlot("main");
|
||
|
|
}
|
||
|
|
nx.bridge.mainui.onDramaLevelChanged();
|
||
|
|
// if( this.model.getBattleScene() && this.ctrl.getIsSameBattleType( this.fight_type ) ) {
|
||
|
|
// //只执行一次,防止假战斗被误清除
|
||
|
|
// if( this.is_result ) return;
|
||
|
|
// this.model.result( this.data, null );
|
||
|
|
// this.is_result = true;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// if(this.fight_type == 7){
|
||
|
|
// gcore.GlobalEvent.fire(StartowerEvent.Show_Jump_Sp);
|
||
|
|
// }
|
||
|
|
},
|
||
|
|
onOpenConfigs: function onOpenConfigs(params) {
|
||
|
|
if (!params || !params.data) {
|
||
|
|
this.delayClose();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.data = params.data;
|
||
|
|
this.fight_type = this.data.combat_type;
|
||
|
|
var action1 = "action1_1";
|
||
|
|
var action2 = "action1_2";
|
||
|
|
if (this.fight_type == 7) {
|
||
|
|
//試煉塔
|
||
|
|
this.first_items = this.data.first_award;
|
||
|
|
action1 = "action2_1";
|
||
|
|
action2 = "action2_2";
|
||
|
|
}
|
||
|
|
|
||
|
|
//數據統計
|
||
|
|
if (this.data && this.data.hurt_statistics) {
|
||
|
|
this.harmBtn.active = true;
|
||
|
|
} else {
|
||
|
|
this.harmBtn.active = false;
|
||
|
|
}
|
||
|
|
//返回挂機
|
||
|
|
this.btns.children[0].active = this.fight_type == 3;
|
||
|
|
this.reward_list = this.data.item_rewards || this.data.award || this.data.award_list;
|
||
|
|
this.setInfos(this.data);
|
||
|
|
this.doMainStep(action1, action2);
|
||
|
|
},
|
||
|
|
doMainStep: function doMainStep(start_act, final_act) {
|
||
|
|
var _this = this;
|
||
|
|
this.mainNd.runAction(cc.fadeIn(0.3));
|
||
|
|
var sps = PathTool.getSpinePath("E55312", "action", false);
|
||
|
|
this.mainSp.load(sps, function (_e) {
|
||
|
|
if (!_e) {
|
||
|
|
_this.mainSp.action(start_act, false, function (_key, _name) {
|
||
|
|
if (_key == "t1") {
|
||
|
|
var nd = nx.gui.find(_this.mainNd, String(_this.fight_type));
|
||
|
|
if (nd) {
|
||
|
|
nd.runAction(cc.sequence(cc.fadeIn(0.16), cc.callFunc(function () {
|
||
|
|
_this.setMainPanel(nd);
|
||
|
|
})));
|
||
|
|
}
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_key == "t2") {
|
||
|
|
_this.setRewards();
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_key == "t3_2") {
|
||
|
|
_this.btns.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.16), cc.scaleTo(0.16, 1.1)), cc.scaleTo(0.16, 1)));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_key == "t4") {
|
||
|
|
_this.harmBtn.runAction(cc.fadeIn(0.33));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_key == "mvp") {
|
||
|
|
_this.sMvp.node.active = true;
|
||
|
|
_this.sMvp.action("action1", false, function (_key2, _name2) {
|
||
|
|
if (_key2 == "complete") {
|
||
|
|
_this.sMvp.action("action2", true);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_key == "role") {
|
||
|
|
_this.roleNd.runAction(cc.fadeIn(0.3));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (_key == "complete") {
|
||
|
|
// this.autoNext();
|
||
|
|
_this.mainSp.action(final_act, true, null);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
setMainPanel: function setMainPanel(nd) {
|
||
|
|
if (this.fight_type == 3) {
|
||
|
|
this.setDramaInfo(nd);
|
||
|
|
this.showDramaProgress(nd);
|
||
|
|
} else {
|
||
|
|
this.setStarTowerInfo(nd);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
setDramaInfo: function setDramaInfo(nd) {
|
||
|
|
//等级
|
||
|
|
nx.gui.setString(nd, "lev", cc.js.formatStr("Lv.%d", this.data.new_lev));
|
||
|
|
//名字
|
||
|
|
nx.gui.setString(nd, "name", this.role_vo.name);
|
||
|
|
//设置头像
|
||
|
|
var headNd = nx.gui.find(nd, "head");
|
||
|
|
this.head_icon = cc.instantiate(this.fabHead);
|
||
|
|
var cmp = this.head_icon.getComponent("cmp.common.header");
|
||
|
|
if (this.role_vo) {
|
||
|
|
cmp.rebind(0, this.role_vo);
|
||
|
|
}
|
||
|
|
this.head_icon.parent = headNd;
|
||
|
|
//經驗值
|
||
|
|
var exp = nx.gui.find(nd, "exp");
|
||
|
|
nx.gui.setString(exp, "cur_exp", nx.text.getKey("Exp_") + this.data.exp);
|
||
|
|
nx.gui.setString(exp, "add_exp", " +" + this.data.new_exp);
|
||
|
|
var drama_info = BattleDramaController.getInstance().getModel().getDramaData();
|
||
|
|
var drama_key = game.configs.dungeon_data.data_drama_dungeon_info[drama_info.max_dun_id];
|
||
|
|
nx.gui.setString(nd, "ti", cc.js.formatStr(nx.text.getKey("DramaBatCross"), drama_key.name));
|
||
|
|
},
|
||
|
|
//剧情经验条
|
||
|
|
showDramaProgress: function showDramaProgress(par) {
|
||
|
|
var baseCurMaxExp = game.configs.role_data.data_role_attr[this.data.lev].exp_max;
|
||
|
|
var basePercent = this.data.exp / baseCurMaxExp;
|
||
|
|
var maxPercent = this.data.new_exp / baseCurMaxExp;
|
||
|
|
if (this.data.lev != this.data.new_lev) {
|
||
|
|
//有升级
|
||
|
|
var nextCurMaxExp = game.configs.role_data.data_role_attr[this.data.new_lev].exp_max;
|
||
|
|
if (nextCurMaxExp) {
|
||
|
|
maxPercent = this.data.new_exp / nextCurMaxExp;
|
||
|
|
basePercent = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
var add_bar = nx.gui.getComponent(par, "bar_bg/add", cc.ProgressBar);
|
||
|
|
var normal_bar = nx.gui.getComponent(par, "bar_bg/normal", cc.ProgressBar);
|
||
|
|
normal_bar.progress = basePercent;
|
||
|
|
add_bar.progress = maxPercent;
|
||
|
|
},
|
||
|
|
setStarTowerInfo: function setStarTowerInfo(nd) {
|
||
|
|
var str = cc.js.formatStr(nx.text.getKey("TowerSuccessFloor"), this.data.max_tower);
|
||
|
|
nx.gui.setString(nd, "name", str);
|
||
|
|
StartowerController.getInstance().refrreshNewTower(this.data);
|
||
|
|
},
|
||
|
|
setRewards: function setRewards() {
|
||
|
|
var rewards = [];
|
||
|
|
if (this.first_items) {
|
||
|
|
for (var i in this.first_items) {
|
||
|
|
var v = this.first_items[i];
|
||
|
|
rewards.push({
|
||
|
|
bid: v.item_id,
|
||
|
|
num: v.num
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for (var a = 0; a < this.reward_list.length; a++) {
|
||
|
|
var item = this.reward_list[a];
|
||
|
|
rewards.push({
|
||
|
|
bid: item.bid || item.item_id,
|
||
|
|
num: item.num
|
||
|
|
});
|
||
|
|
}
|
||
|
|
this.awardList.rebuild(rewards);
|
||
|
|
},
|
||
|
|
//設置mvp
|
||
|
|
setInfos: function setInfos(data) {
|
||
|
|
if (nx.dt.arrEmpty(data.hurt_statistics)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var hurt_arr = data.hurt_statistics;
|
||
|
|
var partner_hurt = {};
|
||
|
|
for (var i = 0; i < hurt_arr.length; i++) {
|
||
|
|
var _data2 = hurt_arr[i];
|
||
|
|
if (_data2.type == 1) {
|
||
|
|
//我方數據
|
||
|
|
partner_hurt = _data2.partner_hurts;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (nx.dt.arrEmpty(partner_hurt)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var total_hurt = 0;
|
||
|
|
var mvp_hurt = 0;
|
||
|
|
this.mvp_skin_id = 0;
|
||
|
|
var svp_cure = 0;
|
||
|
|
this.svp_skin_id = 0;
|
||
|
|
for (var v in partner_hurt) {
|
||
|
|
var info = partner_hurt[v];
|
||
|
|
//总伤害
|
||
|
|
total_hurt += info.dps;
|
||
|
|
if (info.dps >= mvp_hurt) {
|
||
|
|
//生成新的dps
|
||
|
|
mvp_hurt = info.dps;
|
||
|
|
this.hurt_mvp = info.bid;
|
||
|
|
for (var key in info.ext_data) {
|
||
|
|
if (info.ext_data[key].key == 5) {
|
||
|
|
this.mvp_skin_id = info.ext_data[key].val;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (info.cure > svp_cure) {
|
||
|
|
svp_cure = info.cure;
|
||
|
|
this.cure_mvp = info.bid;
|
||
|
|
for (var _key3 in info.ext_data) {
|
||
|
|
if (info.ext_data[_key3].key == 5) {
|
||
|
|
this.svp_skin_id = info.ext_data[_key3].val;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.setMvpPartner();
|
||
|
|
},
|
||
|
|
setMvpPartner: function setMvpPartner() {
|
||
|
|
var _this2 = this;
|
||
|
|
var mvp_bid = this.hurt_mvp;
|
||
|
|
var partner_config = game.configs.partner_data.data_partner_base[mvp_bid];
|
||
|
|
var skin_config = game.configs.partner_skin_data.data_skin_info[this.mvp_skin_id];
|
||
|
|
//名称和立绘
|
||
|
|
if (partner_config) {
|
||
|
|
var bustid = partner_config.bustid;
|
||
|
|
if (skin_config) {
|
||
|
|
bustid = skin_config.bustid;
|
||
|
|
}
|
||
|
|
var bust_res = PathTool.getSpinePath(bustid, bustid, false);
|
||
|
|
this.roleSp.load(bust_res, function (_e) {
|
||
|
|
if (!_e) {
|
||
|
|
_this2.roleSp.action("stand2", true);
|
||
|
|
} else {
|
||
|
|
_this2.roleSp.stop();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
//點開統計
|
||
|
|
clickHarm: function clickHarm() {
|
||
|
|
nx.bridge.createPanel("WndSettleDetail", {
|
||
|
|
data: this.data
|
||
|
|
});
|
||
|
|
},
|
||
|
|
//返回挂機
|
||
|
|
clickBackHook: function clickBackHook() {
|
||
|
|
this.ctrl.requestOpenBattleRelevanceWindow(3);
|
||
|
|
this.close();
|
||
|
|
},
|
||
|
|
//開始下一關
|
||
|
|
clickNext: function clickNext() {
|
||
|
|
if (this.fight_type == 3) {
|
||
|
|
BattleDramaController.getInstance().send13003();
|
||
|
|
} else {
|
||
|
|
StartowerController.getInstance().sender11322(this.data.max_tower + 1, 0);
|
||
|
|
}
|
||
|
|
nx.tbox("BatNextStart");
|
||
|
|
this.close();
|
||
|
|
},
|
||
|
|
autoNext: function autoNext() {
|
||
|
|
var _this3 = this;
|
||
|
|
var timer = 10;
|
||
|
|
var str = cc.js.formatStr(nx.text.getKey("BatTimeNext"), timer);
|
||
|
|
nx.gui.setString(this.timeTxt, "", str);
|
||
|
|
this.schedule(function () {
|
||
|
|
var str = cc.js.formatStr(nx.text.getKey("BatTimeNext"), timer);
|
||
|
|
nx.gui.setString(_this3.timeTxt, "", str);
|
||
|
|
timer--;
|
||
|
|
if (timer <= 0) {
|
||
|
|
_this3.clickNext();
|
||
|
|
}
|
||
|
|
}, 1, 9);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|