979 lines
32 KiB
JavaScript
979 lines
32 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '59eaaHdFQtGRb4M9GDQoAQQ', 'cmp.battle.view');
|
|
// Scripts/mod/battle/cmp/cmp.battle.view.js
|
|
|
|
"use strict";
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var PathTool = require("pathtool");
|
|
var BattleConst = require("battle_const");
|
|
var BattleEvent = require("battle_event");
|
|
var EndlessEvent = require("endless_trail_event");
|
|
var RoleController = require("role_controller");
|
|
var ELC = require("endless_trail_controller");
|
|
var BTC = require("battle_controller");
|
|
var BDC = require("battle_drama_controller");
|
|
var STARC = require("startower.mod");
|
|
var NxSpine = require("nx.fx.spine");
|
|
var NxBGM = require("nx.fx.BGM");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
uiNd: {
|
|
//ui层
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
camSp: {
|
|
//演示的特效
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
left_name: {
|
|
"default": null,
|
|
type: cc.Label
|
|
},
|
|
right_name: {
|
|
"default": null,
|
|
type: cc.Label
|
|
},
|
|
hero_info_list: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
round: {
|
|
"default": null,
|
|
type: cc.RichText
|
|
},
|
|
speed_txt: {
|
|
"default": null,
|
|
type: cc.Label
|
|
},
|
|
total_hurt: {
|
|
"default": null,
|
|
type: cc.RichText
|
|
},
|
|
pass_btn: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
exit_btn: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
out_btn: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
result_btn: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
//技能演出
|
|
LBSkill: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
Lrole_sp: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
Lbig: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
LSmall: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
RBSkill: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
Rrole_sp: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
Rbig: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
RSmall: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
fabHeroView: {
|
|
"default": null,
|
|
type: cc.Prefab
|
|
},
|
|
skill_view: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
LeftSkill: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
LRole: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
LName: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
RightSkill: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
RRole: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
RName: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
endlessInfo: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
LHallow: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
RHallow: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
bgnCmp: {
|
|
"default": null,
|
|
type: NxBGM
|
|
}
|
|
},
|
|
// LIFE-CYCLE CALLBACKS:
|
|
onLoad: function onLoad() {
|
|
var _this$skill_speed;
|
|
this.skill_speed = (_this$skill_speed = {}, _this$skill_speed[1] = 3, _this$skill_speed[2] = 6, _this$skill_speed[3] = 9, _this$skill_speed);
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_SETSPEED, this.setSpeed.bind(this));
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_UPROUND, this.updateRound.bind(this));
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_TOTALHURT, this.addTotalHurt.bind(this));
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_UPNEXTMON, this.updateBaseInfo.bind(this));
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_SHOWSKILL, this.showActiveSkillName.bind(this));
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_GUILDBOSS, this.addTotalHurt.bind(this));
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_SELFDMG, this.showSelfDmgEff.bind(this));
|
|
// this.bindGEvent( BattleEvent.BATTLE_FORM_VIEW_UPBUFF, this.updateSelfBuff.bind( this ) );
|
|
this.bindGEvent(BattleEvent.BATTLE_FORM_VIEW_HALLOW, this.upHallowStatus.bind(this));
|
|
// this.bindGEvent( BattleEvent.BATTLE_FORM_VIEW_CLOSE, this.goClose.bind( this ) );
|
|
|
|
//无尽试炼相关信息更新
|
|
this.bindGEvent(EndlessEvent.UPDATA_ENDLESSBATTLE_DATA, this.upEndlessInfo.bind(this));
|
|
},
|
|
upHallowStatus: function upHallowStatus(is_open, attacker, is_friend, val, max) {
|
|
if (!attacker.role_data || attacker.role_data.object_type != BattleConst.Unit_Type.Hallows) return;
|
|
if (is_open) {
|
|
//打開星艦
|
|
if (is_friend) {
|
|
this.LHallow.active = true;
|
|
nx.gui.setSpriteFrame(this.LHallow, "sp", cc.js.formatStr("prefab/battle/ui/plane0%s", attacker.role_data.object_bid));
|
|
} else {
|
|
this.RHallow.active = true;
|
|
nx.gui.setSpriteFrame(this.RHallow, "sp", cc.js.formatStr("prefab/battle/ui/plane0%s", attacker.role_data.object_bid));
|
|
}
|
|
}
|
|
if (is_friend) {
|
|
var LBar = nx.gui.getComponent(this.LHallow, "", cc.ProgressBar);
|
|
if (val == 0 || val == null) {
|
|
LBar.progress = 0;
|
|
} else {
|
|
if (max == 0 || max == null) {
|
|
max = 3;
|
|
}
|
|
var per1 = Math.min(1, Math.max(val / max));
|
|
LBar.progress = per1;
|
|
}
|
|
} else {
|
|
var RBar = nx.gui.getComponent(this.RHallow, "", cc.ProgressBar);
|
|
if (val == 0 || val == null) {
|
|
RBar.progress = 0;
|
|
} else {
|
|
if (max == 0 || max == null) {
|
|
max = 3;
|
|
}
|
|
var per2 = Math.min(1, Math.max(val / max));
|
|
RBar.progress = per2;
|
|
}
|
|
}
|
|
},
|
|
//------------无尽试炼相关
|
|
upEndlessInfo: function upEndlessInfo(data) {
|
|
this.endlessInfo.active = true;
|
|
var final_data = data || ELC.getInstance().getModel().getEndlessBattleData();
|
|
if (!nx.dt.objEmpty(final_data)) {
|
|
var str = cc.js.formatStr(nx.text.getKey("lab_endless_trail_battle_node_num"), final_data.round);
|
|
var str_2 = nx.text.getKey("lab_endless_trail_battle_buff");
|
|
if (final_data.buff_list && Utils.next(final_data.buff_list || {}) != null) {
|
|
for (var i in final_data.buff_list) {
|
|
var v = final_data.buff_list[i];
|
|
if (game.configs.endless_data.data_buff_data[v.group_id] && game.configs.endless_data.data_buff_data[v.group_id][v.id]) {
|
|
var config = game.configs.endless_data.data_buff_data[v.group_id][v.id];
|
|
if (config) {
|
|
str_2 = str_2 + config.battle_desc;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
str_2 = str_2 + nx.text.getKey("lab_endless_trail_battle_no_data");
|
|
}
|
|
nx.gui.setString(this.endlessInfo, "lev", str);
|
|
nx.gui.setString(this.endlessInfo, "buff/desc", str_2);
|
|
}
|
|
},
|
|
openEndlessBuffDesc: function openEndlessBuffDesc() {
|
|
var _this = this;
|
|
if (this.is_endbuff_show) return;
|
|
this.is_endbuff_show = true;
|
|
nx.gui.setActive(this.endlessInfo, "buff", true);
|
|
this.scheduleOnce(function () {
|
|
_this.is_endbuff_show = false;
|
|
nx.gui.setActive(_this.endlessInfo, "buff", false);
|
|
}, 3);
|
|
},
|
|
//------------无尽试炼相关
|
|
goClose: function goClose() {
|
|
nx.bridge.vset("BatBreak", false);
|
|
this.close();
|
|
},
|
|
updateSelfBuff: function updateSelfBuff(object_bid, buff_list) {
|
|
this.clearFriendBuff(object_bid);
|
|
this.addFriendBuff(object_bid, buff_list);
|
|
},
|
|
start: function start() {},
|
|
onOpenConfigs: function onOpenConfigs(params) {
|
|
//ui启动完成,通知真战斗开始
|
|
if (params.finish_cb) {
|
|
nx.dt.fnInvoke(params.finish_cb);
|
|
}
|
|
var combat_type = params.combat_type;
|
|
this.combat_type = params.combat_type;
|
|
this.arena_notice_num = 0; // 竞技场挑战次数达到才可以跳过
|
|
this.my_hero_list = {};
|
|
this.total_my_hurt = 0;
|
|
this.bind_attack_num = 0;
|
|
|
|
// 更新回合数
|
|
if (this.update_round_num) {
|
|
this.updateRound(this.update_round_num);
|
|
this.update_round_num = null;
|
|
}
|
|
|
|
// 重置一些特殊显示
|
|
this.initExtendShowStatus();
|
|
|
|
// 区分观战以及战斗状态等
|
|
if (!BTC.getInstance().getWatchReplayStatus()) {
|
|
if (combat_type == BattleConst.Fight_Type.GuildDun) {
|
|
this.addTotalHurt(0, true);
|
|
} else if (combat_type == BattleConst.Fight_Type.PK || combat_type == BattleConst.Fight_Type.HeroTestWar) {
|
|
this.result_btn.active = true;
|
|
} else if (combat_type == BattleConst.Fight_Type.Endless) {
|
|
ELC.getInstance().send23902();
|
|
this.addExitBtnUI();
|
|
this.out_btn.active = true;
|
|
} else if (combat_type == BattleConst.Fight_Type.Default) {
|
|
if (nx.bridge.plot && !nx.bridge.plot.isDoing()) {
|
|
this.addExitBtnUI();
|
|
}
|
|
} else if (combat_type == BattleConst.Fight_Type.newRole) {
|
|
var show_id = BTC.getInstance().getShowBatID();
|
|
if (show_id && show_id > 1) {
|
|
this.uiNd.active = true;
|
|
this.hero_info_list.active = true;
|
|
} else {
|
|
this.uiNd.active = false;
|
|
this.setCamEft();
|
|
}
|
|
} else if (combat_type == BattleConst.Fight_Type.newHeroUse) {
|
|
this.result_btn.active = true;
|
|
} else if (combat_type == BattleConst.Fight_Type.StarTower) {
|
|
var switch_star = game.configs.star_tower_data.data_tower_const.quit_switch;
|
|
var max_tower = STARC.getInstance().getNowTowerId();
|
|
if (max_tower >= switch_star.val[1]) {
|
|
this.addExitBtnUI();
|
|
}
|
|
} else if (combat_type == BattleConst.Fight_Type.Darma) {
|
|
var switch_info = game.configs.dungeon_data.data_drama_const.quit_switch;
|
|
var drama_data = BDC.getInstance().getModel().getDramaData();
|
|
if (drama_data.dun_id >= switch_info.val[1]) {
|
|
this.addExitBtnUI();
|
|
}
|
|
}
|
|
} else {
|
|
this.out_btn.active = true;
|
|
}
|
|
|
|
// 设置跳过按钮状态
|
|
this.updatePassBtnStatus(combat_type);
|
|
|
|
// 初始化显示,包括名字,阵容等数据,这个中途不会变化只做一次判断
|
|
this.hero_info_list.active = combat_type != 44;
|
|
this.updateBaseInfo();
|
|
|
|
// 显示初始速率
|
|
var speed = BTC.getInstance().getModel().getSpeed();
|
|
this.setSpeed(speed);
|
|
this.changeBattleMusic(combat_type);
|
|
},
|
|
setCamEft: function setCamEft() {
|
|
var _this2 = this;
|
|
this.scheduleOnce(function () {
|
|
_this2.camSp.node.active = true;
|
|
_this2.hero_info_list.active = true;
|
|
var res_path = PathTool.getSpinePath("E80053", "action", false);
|
|
_this2.camSp.load(res_path, function (_e) {
|
|
if (!_e) {
|
|
_this2.camSp.action("action", true);
|
|
} else {
|
|
_this2.camSp.stop();
|
|
}
|
|
});
|
|
}, 3);
|
|
},
|
|
onPreClosed: function onPreClosed() {
|
|
nx.bridge.NodeChidrenDestroy(this.hero_info_list);
|
|
this.my_hero_list = {};
|
|
var ChatController = require("chat_controller");
|
|
ChatController.getInstance().closeChatPanel();
|
|
gcore.GlobalEvent.fire(BattleEvent.EXIT_FIGHT);
|
|
},
|
|
changeBattleMusic: function changeBattleMusic(combat_type) {
|
|
var _this3 = this;
|
|
var base_config = game.configs.battle_bg_data.data_info[combat_type];
|
|
if (combat_type != 3) {
|
|
base_config = game.configs.battle_bg_data.data_info[BattleConst.Fight_Type.Default];
|
|
} else {
|
|
var chapterId = BDC.getInstance().getModel().getDramaData().chapter_id;
|
|
if (chapterId) {
|
|
var cfgs = game.configs.battle_bg_data.data_info2[combat_type];
|
|
base_config = cfgs[chapterId];
|
|
}
|
|
if (base_config == null) {
|
|
base_config = game.configs.battle_bg_data.data_info[BattleConst.Fight_Type.Default];
|
|
}
|
|
}
|
|
this.scheduleOnce(function () {
|
|
var res_key = cc.path.join("audios/bgms", base_config.bg_music);
|
|
_this3.bgnCmp.bgmRK = res_key;
|
|
_this3.bgnCmp.reActive();
|
|
}, 0.5);
|
|
},
|
|
// 改变速率
|
|
setSpeed: function setSpeed(speed) {
|
|
if (speed == null) {
|
|
speed = 1;
|
|
}
|
|
var role = RoleController.getInstance().getRoleVo();
|
|
var touch = nx.storage.get("touch" + role.rid);
|
|
if (!touch || touch == 0) {
|
|
nx.gui.setActive(this.speed_txt.node.parent, "sp", speed == 1);
|
|
} else {
|
|
nx.gui.setActive(this.speed_txt.node.parent, "sp", false);
|
|
}
|
|
this.speed_txt.string = "X" + speed;
|
|
// 设置场景上的模型和特效的速率
|
|
if (speed == 2) {
|
|
BTC.getInstance().getModel().setBattleTimeScale(false);
|
|
nx.storage.set("touch" + role.rid, speed);
|
|
} else if (speed == 3) {
|
|
BTC.getInstance().getModel().setBattleTimeScale(false);
|
|
nx.storage.set("touch" + role.rid, speed);
|
|
} else {
|
|
BTC.getInstance().getModel().setBattleTimeScale(true);
|
|
}
|
|
this.LeftSkill.setTimeScale(this.skill_speed[speed]);
|
|
this.RightSkill.setTimeScale(this.skill_speed[speed]);
|
|
this.LBSkill.setTimeScale(this.skill_speed[speed]);
|
|
this.RBSkill.setTimeScale(this.skill_speed[speed]);
|
|
},
|
|
onClickOpenbuffView: function onClickOpenbuffView() {
|
|
var battle_data = BTC.getInstance().getModel().getCurBattleData();
|
|
var left_name = battle_data.actor_role_name;
|
|
var right_name = battle_data.target_role_name;
|
|
var group = BTC.getInstance().getModel().getGroup();
|
|
if (group == BattleConst.BattleGroupTypeConf.TYPE_GROUP_ENEMY && !BTC.getInstance().getWatchReplayStatus()) {
|
|
left_name = data.target_role_name;
|
|
right_name = data.actor_role_name;
|
|
}
|
|
BTC.getInstance().openBattleBuffInfoView(true, left_name, right_name);
|
|
},
|
|
// 初始化一些特殊战斗需要显示的东西
|
|
initExtendShowStatus: function initExtendShowStatus() {
|
|
this.exit_btn.active = false;
|
|
},
|
|
// 当前回合数
|
|
updateRound: function updateRound(round) {
|
|
// if (this.round_label1 == null){
|
|
this.update_round_num = round;
|
|
// }else{
|
|
var combat_type = BTC.getInstance().getModel().getCombatType();
|
|
if (combat_type == null || combat_type == BattleConst.Fight_Type.Nil) return;
|
|
var config = game.configs.combat_type_data.data_fight_list[combat_type];
|
|
if (!config) return;
|
|
var total_round = config.max_action_count;
|
|
this.round.string = cc.js.formatStr("<color=#176f9d>%s</color>/%s", round, total_round);
|
|
gcore.GlobalEvent.fire(BattleEvent.UPDATE_ROUND_NUM);
|
|
// }
|
|
},
|
|
|
|
//更新基础数据,不过在无尽试炼的时候需要额外调用一次 每波可能都不一样
|
|
updateBaseInfo: function updateBaseInfo() {
|
|
var _this4 = this;
|
|
var battle_data = BTC.getInstance().getModel().getCurBattleData();
|
|
if (!battle_data) return;
|
|
// if (battle_data.formation){ //更新左右阵法
|
|
// this.updateFormIcon(battle_data.formation);
|
|
// }
|
|
if (battle_data.extra_args && nx.dt.arrNEmpty(battle_data.extra_args)) {
|
|
var dungen = battle_data.extra_args[0].param;
|
|
var dfg = game.configs.dungeon_data.data_drama_dungeon_info[dungen];
|
|
if (dfg) {
|
|
nx.gui.setString(this.endlessInfo.parent, "nowdungon", dfg.name);
|
|
}
|
|
}
|
|
nx.gui.setActive(this.endlessInfo, "", BTC.getInstance().getModel().combat_type == BattleConst.Fight_Type.Endless);
|
|
nx.gui.setActive(this.endlessInfo.parent, "nowdungon", battle_data.extra_args && nx.dt.arrNEmpty(battle_data.extra_args));
|
|
if (battle_data.halo_list) {
|
|
// 更新左右阵营
|
|
this.updateHaloIcon(battle_data.halo_list);
|
|
}
|
|
if (battle_data.fight_object_list) {
|
|
//更新英雄响应序列
|
|
var my_list = [];
|
|
for (var i in battle_data.fight_object_list) {
|
|
if (battle_data.fight_object_list[i].group == 1) {
|
|
my_list.push(battle_data.fight_object_list[i]);
|
|
}
|
|
}
|
|
this.scheduleOnce(function () {
|
|
_this4.initMyHeroList(my_list);
|
|
}, 1);
|
|
}
|
|
|
|
// 判断左边是不是队友
|
|
var left_is_friend = BTC.getInstance().getModel().isFriend(BattleConst.Group_Type.Friend);
|
|
if (left_is_friend == true) {
|
|
this.left_name.string = battle_data.actor_role_name;
|
|
this.right_name.string = battle_data.target_role_name;
|
|
} else {
|
|
this.left_name.string = battle_data.target_role_name;
|
|
this.right_name.string = battle_data.actor_role_name;
|
|
}
|
|
// this.buff_btn.opacity = 0;
|
|
// this.buff_btn.runAction(cc.fadeIn(0.7))
|
|
},
|
|
|
|
initMyHeroList: function initMyHeroList(data) {
|
|
if (!data) return;
|
|
nx.bridge.NodeChidrenDestroy(this.hero_info_list);
|
|
for (var i = 0; i < data.length; i++) {
|
|
var partner_bid = 0;
|
|
if (data[i].object_type == BattleConst.Unit_Type.Monster) {
|
|
var config = Utils.getUnitConfig(data[i].object_bid);
|
|
if (config) {
|
|
partner_bid = Number(config.head_icon);
|
|
data[i].star == 0 ? data[i].object_id = partner_bid : data[i].object_id = data[i].object_id;
|
|
}
|
|
} else {
|
|
partner_bid = data[i].object_bid;
|
|
}
|
|
var partner_data = gdata("partner_data", "data_partner_base", partner_bid);
|
|
if (partner_data && partner_data.bid) {
|
|
var pre = cc.instantiate(this.fabHeroView);
|
|
pre.parent = this.hero_info_list;
|
|
var cmp = nx.gui.getComponent(pre, "", "cmp.item.battle.hero");
|
|
cmp.setData(data[i]);
|
|
this.my_hero_list[partner_bid] = cmp;
|
|
}
|
|
|
|
// data[i].object_bid = data[i].object_bid;
|
|
}
|
|
},
|
|
|
|
// addFriendBuff(object_bid,buff_data_list){
|
|
// for(let i in this.my_hero_list){
|
|
// let hero = this.my_hero_list[i];
|
|
// if(hero.object_bid == object_bid){
|
|
// hero.addBuffList(buff_data_list);
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// clearFriendBuff(bid){
|
|
// for(let i in this.my_hero_list){
|
|
// let hero = this.my_hero_list[i];
|
|
// if(hero.object_bid == bid){
|
|
// hero.removeBuffList();
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// 更新阵营
|
|
updateHaloIcon: function updateHaloIcon(data_list) {
|
|
if (data_list == null || Object.keys(data_list).length < 2) return;
|
|
var left_camp = null;
|
|
var right_camp = null;
|
|
for (var key in data_list) {
|
|
var info = data_list[key];
|
|
if (info.group == 1) {
|
|
left_camp = info.type;
|
|
} else if (info.group == 2) {
|
|
right_camp = info.type;
|
|
}
|
|
}
|
|
var left_halo_id_list = [];
|
|
if (left_camp < 100) {
|
|
left_halo_id_list = BattleConst.Old_Halo_Id_Change[left_camp] || [];
|
|
} else {
|
|
if (left_camp >= 10000) {
|
|
var left_1 = Math.floor(left_camp / 10000);
|
|
var left_2 = Math.floor(left_camp / 100) % 100;
|
|
var left_3 = left_camp % 100;
|
|
if (left_1 > 0) {
|
|
left_halo_id_list.push(left_1);
|
|
}
|
|
if (left_2 > 0) {
|
|
left_halo_id_list.push(left_2);
|
|
}
|
|
if (left_3 > 0) {
|
|
left_halo_id_list.push(left_3);
|
|
}
|
|
} else {
|
|
var left_id_1 = Math.floor(left_camp / 100);
|
|
var left_id_2 = left_camp % 100;
|
|
if (left_id_1 > 0) {
|
|
left_halo_id_list.push(left_id_1);
|
|
}
|
|
if (left_id_2 > 0) {
|
|
left_halo_id_list.push(left_id_2);
|
|
}
|
|
}
|
|
}
|
|
left_halo_id_list.sort(function (a, b) {
|
|
return a < b;
|
|
});
|
|
this.left_halo_id = left_halo_id_list;
|
|
var right_halo_id_list = [];
|
|
if (right_camp < 100) {
|
|
right_halo_id_list = BattleConst.Old_Halo_Id_Change[right_camp] || [];
|
|
} else {
|
|
if (right_camp >= 10000) {
|
|
var right_1 = Math.floor(right_camp / 10000);
|
|
var right_2 = Math.floor(right_camp / 100) % 100;
|
|
var right_3 = right_camp % 100;
|
|
if (right_1 > 0) {
|
|
right_halo_id_list.push(right_1);
|
|
}
|
|
if (right_2 > 0) {
|
|
right_halo_id_list.push(right_2);
|
|
}
|
|
if (right_3 > 0) {
|
|
right_halo_id_list.push(right_3);
|
|
}
|
|
} else {
|
|
var right_id_1 = Math.floor(right_camp / 100);
|
|
var right_id_2 = right_camp % 100;
|
|
if (right_id_1 > 0) {
|
|
right_halo_id_list.push(right_id_1);
|
|
}
|
|
if (right_id_2 > 0) {
|
|
right_halo_id_list.push(right_id_2);
|
|
}
|
|
}
|
|
}
|
|
right_halo_id_list.sort(function (a, b) {
|
|
return a < b;
|
|
});
|
|
this.right_halo_id = right_halo_id_list;
|
|
},
|
|
//统计通用伤害
|
|
addTotalHurt: function addTotalHurt(total_hurt, is_my_hurt) {
|
|
if (!is_my_hurt) {
|
|
this.total_hurt.string = "";
|
|
this.total_my_hurt = 0;
|
|
var fade = cc.fadeOut(0.1);
|
|
var sca = cc.scaleTo(0.1, 0, 1).easing(cc.easeIn(0.2));
|
|
this.total_hurt.node.runAction(cc.spawn(fade, sca));
|
|
} else {
|
|
if (this.total_hurt.node.scaleX == 0) {
|
|
var _fade = cc.fadeIn(0.1);
|
|
var _sca = cc.scaleTo(0.1, 1).easing(cc.easeIn(0.2));
|
|
this.total_hurt.node.runAction(cc.spawn(_fade, _sca));
|
|
}
|
|
this.total_my_hurt += total_hurt;
|
|
var dmg_str = Math.abs(this.total_my_hurt) + "";
|
|
var total_str = "<img src='harm' />";
|
|
for (var index = 0; index < dmg_str.length; index++) {
|
|
var desc = dmg_str[index];
|
|
total_str = total_str + cc.js.formatStr("<img src='%s'/>", desc);
|
|
}
|
|
this.total_hurt.string = total_str;
|
|
}
|
|
},
|
|
// 观战等退出
|
|
addExitBtnUI: function addExitBtnUI() {
|
|
this.exit_btn.active = true;
|
|
},
|
|
// 跳过按钮状态
|
|
updatePassBtnStatus: function updatePassBtnStatus(combat_type) {
|
|
this.arena_notice_num = 0;
|
|
if (combat_type == null || BTC.getInstance().getWatchReplayStatus()) {
|
|
this.pass_btn.active = false;
|
|
return;
|
|
}
|
|
var _config = game.configs.combat_type_data.data_fight_list[combat_type];
|
|
if (_config == null || _config.is_skip != "true") {
|
|
this.pass_btn.active = false;
|
|
return;
|
|
}
|
|
// 如果是竞技场,则判断次数
|
|
if (combat_type == BattleConst.Fight_Type.Arena) {
|
|
var count = require("arena_controller").getInstance().getModel().getHadCombatNum(); // 当前已经挑战过的次数
|
|
var arena_config = game.configs.arena_data.data_const.arena_skip_count;
|
|
if (arena_config == null) {
|
|
this.pass_btn.active = false;
|
|
return;
|
|
} else {
|
|
if (count < arena_config.val) {
|
|
// 这种情况下也需要显示,但是保留计算判断
|
|
this.arena_notice_num = arena_config.val;
|
|
}
|
|
}
|
|
}
|
|
this.pass_btn.active = true;
|
|
},
|
|
//小技能播报
|
|
setSelfSkillItem: function setSelfSkillItem(is_friend, name, cfg, end_call) {
|
|
var _this5 = this;
|
|
if (is_friend) {
|
|
if (this.LeftSkill.node) {
|
|
this.LeftSkill.node.x = -cc.winSize.width / 2 + 20;
|
|
this.LeftSkill.node.active = true;
|
|
nx.gui.setString(this.LName, "", name);
|
|
var Partner_res = PathTool.getIconPath("models/" + cfg.res_id + "/play", "action");
|
|
nx.gui.setSpriteFrame(this.LRole, "", Partner_res);
|
|
this.LeftSkill.action("action1", false, function (_key, _name) {
|
|
if (_key == "done") {
|
|
_this5.LeftSkill.node.active = false;
|
|
return end_call();
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
if (this.RightSkill.node) {
|
|
this.RightSkill.node.x = cc.winSize.width / 2 - 20;
|
|
this.RightSkill.node.active = true;
|
|
nx.gui.setString(this.RName, "", name);
|
|
var _Partner_res = PathTool.getIconPath("models/" + cfg.res_id + "/play", "action");
|
|
nx.gui.setSpriteFrame(this.RRole, "", _Partner_res);
|
|
this.RightSkill.action("action2", false, function (_key, _name) {
|
|
if (_key == "done") {
|
|
_this5.RightSkill.node.active = false;
|
|
return end_call();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
},
|
|
// 单位主动技能喊招
|
|
showActiveSkillName: function showActiveSkillName(attacker, callback) {
|
|
var _this6 = this;
|
|
var self = this;
|
|
// if (callback) {
|
|
// callback();
|
|
// }
|
|
if (attacker == null || !attacker.isValid || attacker.skill_data == null) {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
return;
|
|
}
|
|
var battle_role = attacker.getRoleData();
|
|
if (battle_role == null) {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
return;
|
|
}
|
|
if (attacker.temp_skill_bid != attacker.attacker_info.skill_bid) {
|
|
attacker.temp_skill_bid = attacker.attacker_info.skill_bid;
|
|
|
|
// 获取头像资源id,以及加载头像
|
|
var object_type = battle_role.object_type;
|
|
var object_bid = battle_role.object_bid;
|
|
var head_icon = battle_role.face_id;
|
|
if (battle_role.face_id == 0) {
|
|
head_icon = battle_role.object_bid;
|
|
}
|
|
var key;
|
|
var is_useskin = false;
|
|
var skin_id = 0;
|
|
if (object_type == BattleConst.Unit_Type.Monster) {
|
|
var config = Utils.getUnitConfig(object_bid);
|
|
if (config) {
|
|
head_icon = config.head_icon;
|
|
var p_id = Number(config.head_icon);
|
|
var p_config = game.configs.partner_data.data_partner_base[p_id];
|
|
if (p_config) {
|
|
key = p_config.bid + "_" + p_config.init_star;
|
|
}
|
|
}
|
|
} else {
|
|
key = object_bid + "_" + battle_role.star;
|
|
var extras = battle_role.extra_data;
|
|
for (var e in extras) {
|
|
if (5 == extras[e].extra_key) {
|
|
//使用皮肤
|
|
skin_id = extras[e].extra_value;
|
|
if (skin_id != 0) {
|
|
is_useskin = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var cfg = gdata("partner_data", "data_partner_star", key);
|
|
if (is_useskin) {
|
|
cfg = game.configs.partner_skin_data.data_skin_info[skin_id];
|
|
}
|
|
if (!cfg.res_id) {
|
|
cfg = {};
|
|
cfg.res_id = attacker.base_spine_name;
|
|
}
|
|
|
|
//大技能动画
|
|
var skill_func = function skill_func() {
|
|
if (attacker.is_friend) {
|
|
var big_res = PathTool.getIconPath("models/" + cfg.res_id + "/play", "b1");
|
|
nx.gui.setSpriteFrame(self.Lbig, "", big_res);
|
|
var role_res = cc.js.formatStr("resDB/models/%s/play/action1", cfg.res_id);
|
|
nx.gui.setSpriteFrame(_this6.Lrole_sp, "", role_res);
|
|
_this6.LBSkill.node.active = true;
|
|
_this6.LBSkill.node.x = -cc.winSize.width / 2;
|
|
_this6.LBSkill.action("action1", false, function (_key, _name) {
|
|
if (_key == "role_a") {
|
|
_this6.Lbig.opacity = 255;
|
|
_this6.LSmall.opacity = 255;
|
|
_this6.Lrole_sp.stopAllActions();
|
|
_this6.Lrole_sp.runAction(cc.fadeIn(0.16));
|
|
return;
|
|
}
|
|
if (_key == "role_b") {
|
|
_this6.Lrole_sp.stopAllActions();
|
|
_this6.Lrole_sp.runAction(cc.fadeOut(0.16));
|
|
return;
|
|
}
|
|
if (_key == "zi1") {
|
|
_this6.Lbig.stopAllActions();
|
|
_this6.Lbig.runAction(cc.fadeOut(0.2));
|
|
return;
|
|
}
|
|
if (_key == "zi2") {
|
|
_this6.LSmall.stopAllActions();
|
|
_this6.LSmall.runAction(cc.fadeOut(0.2));
|
|
return;
|
|
}
|
|
if (_key == "done") {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
return;
|
|
}
|
|
if (_key == "complete") {
|
|
_this6.LBSkill.node.active = false;
|
|
return;
|
|
}
|
|
});
|
|
} else {
|
|
var _big_res = PathTool.getIconPath("models/" + cfg.res_id + "/play", "b2");
|
|
nx.gui.setSpriteFrame(self.Rbig, "", _big_res);
|
|
var _role_res = cc.js.formatStr("resDB/models/%s/play/action1", cfg.res_id);
|
|
nx.gui.setSpriteFrame(_this6.Rrole_sp, "", _role_res);
|
|
_this6.RBSkill.node.active = true;
|
|
_this6.RBSkill.node.x = cc.winSize.width / 2;
|
|
_this6.RBSkill.action("action2", false, function (_key, _name) {
|
|
if (_key == "role_a") {
|
|
_this6.Rbig.opacity = 255;
|
|
_this6.RSmall.opacity = 255;
|
|
_this6.Rrole_sp.stopAllActions();
|
|
_this6.Rrole_sp.runAction(cc.fadeIn(0.16));
|
|
return;
|
|
}
|
|
if (_key == "role_b") {
|
|
_this6.Rrole_sp.stopAllActions();
|
|
_this6.Rrole_sp.runAction(cc.fadeOut(0.16));
|
|
return;
|
|
}
|
|
if (_key == "zi1") {
|
|
_this6.Rbig.stopAllActions();
|
|
_this6.Rbig.runAction(cc.fadeOut(0.2));
|
|
return;
|
|
}
|
|
if (_key == "zi2") {
|
|
_this6.RSmall.stopAllActions();
|
|
_this6.RSmall.runAction(cc.fadeOut(0.2));
|
|
return;
|
|
}
|
|
if (_key == "done") {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
return;
|
|
}
|
|
if (_key == "complete") {
|
|
_this6.RBSkill.node.active = false;
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
};
|
|
var end_call = cc.callFunc(function () {
|
|
if (attacker.skill_data && attacker.skill_data.skill_cartoon == 1) {
|
|
// 播放音效
|
|
if (attacker.skill_data.skill2_play_sound && attacker.skill_data.skill2_play_sound != "") {
|
|
nx.audio.playSFX("audios/combats/" + attacker.skill_data.skill2_play_sound, false, function () {
|
|
skill_func();
|
|
});
|
|
} else {
|
|
skill_func();
|
|
}
|
|
// skill_func();
|
|
} else {
|
|
//小技能动画
|
|
if (attacker && attacker.skill_data) {
|
|
self.setSelfSkillItem(attacker.is_friend, attacker.skill_data.name, cfg, callback);
|
|
} else {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
if (attacker.is_friend) {
|
|
//头像动作
|
|
|
|
var info_fun = function info_fun() {
|
|
var hero = self.my_hero_list[cfg.bid];
|
|
if (hero) {
|
|
//英雄施法
|
|
var skill_delay = attacker.skill_data.skill_cartoon == 1 ? 0.6 : 0.2;
|
|
hero.useSkill(end_call, skill_delay);
|
|
} else {}
|
|
};
|
|
|
|
// 设置头像以及播放动作
|
|
info_fun();
|
|
} else {
|
|
// // 设置头像以及播放动作
|
|
// info_fun();
|
|
|
|
if (attacker.skill_data && attacker.skill_data.skill_cartoon == 1) {
|
|
if (attacker.skill_data && attacker.skill_data.skill_cartoon == 1) {
|
|
// 播放音效
|
|
if (attacker.skill_data.skill2_play_sound && attacker.skill_data.skill2_play_sound != "") {
|
|
nx.audio.playSFX("audios/combats/" + attacker.skill_data.skill2_play_sound, false, function () {
|
|
skill_func();
|
|
});
|
|
} else {
|
|
skill_func();
|
|
}
|
|
}
|
|
} else {
|
|
//小技能动画
|
|
// let call = cc.callFunc(()=>{
|
|
// if (callback) {
|
|
// callback();
|
|
// }
|
|
// });
|
|
if (attacker && attacker.skill_data) {
|
|
this.setSelfSkillItem(attacker.is_friend, attacker.skill_data.name, cfg, callback);
|
|
} else {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
}
|
|
},
|
|
//播放受击特效
|
|
showSelfDmgEff: function showSelfDmgEff(attacker) {
|
|
var targets = attacker.attacker_info.target_list;
|
|
for (var i in targets) {
|
|
var tar = targets[i];
|
|
for (var j in this.my_hero_list) {
|
|
var my = this.my_hero_list[j].data;
|
|
if (tar.target == my.pos) {
|
|
var hero = this.my_hero_list[j];
|
|
//受到攻击
|
|
hero.getEncountor();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
onClickExit: function onClickExit() {
|
|
BTC.getInstance().requestCutOutBattle(function (_data) {
|
|
if (_data) {
|
|
BTC.getInstance().setUIFightType(0);
|
|
nx.bridge.cleanPanels();
|
|
}
|
|
});
|
|
},
|
|
onCclickR3esult: function onCclickR3esult() {
|
|
if (this.combat_type == BattleConst.Fight_Type.Endless) {
|
|
var str = nx.text.getKey("msg_endless_trail_battle_tip1");
|
|
nx.mbox(str, ["btn_endless_trail_battle_continue", "btn_endless_trail_battle_out"], function (_key, _box) {
|
|
_box.close();
|
|
if (_key == "btn_endless_trail_battle_out") {
|
|
BTC.getInstance().csFightExit();
|
|
}
|
|
});
|
|
} else {
|
|
BTC.getInstance().csFightExit();
|
|
}
|
|
},
|
|
onClickOutResult: function onClickOutResult() {
|
|
BTC.getInstance().OutResult();
|
|
},
|
|
onClickCamp: function onClickCamp() {
|
|
if (!this.right_halo_id) return;
|
|
BTC.getInstance().openBattleCampView(true, this.right_halo_id);
|
|
},
|
|
onClickSelfCamp: function onClickSelfCamp() {
|
|
if (!this.left_halo_id) return;
|
|
BTC.getInstance().openBattleCampView(true, this.left_halo_id);
|
|
},
|
|
onClickPass: function onClickPass() {
|
|
if (this.arena_notice_num == 0) {
|
|
BTC.getInstance().send20062();
|
|
if (nx.bridge.plot && nx.bridge.plot.isDoing()) {
|
|
nx.bridge.plot.next();
|
|
}
|
|
} else {
|
|
nx.tbox(cc.js.formatStr(nx.text.getKey("msg_battle_form_fight_num"), this.arena_notice_num));
|
|
}
|
|
},
|
|
onClickSpeed: function onClickSpeed() {
|
|
if (BTC.getInstance().getModel().checkIsCanChangeBattleSpeed()) {
|
|
BTC.getInstance().getModel().changeSpeed();
|
|
}
|
|
},
|
|
touchChat: function touchChat() {
|
|
var ChatCtrl = require("chat_controller");
|
|
ChatCtrl.getInstance().openChatPanel();
|
|
} // update (dt) {},
|
|
});
|
|
|
|
cc._RF.pop(); |