Files
fc/dev/project/library/imports/04/046a3bf4-5c12-474d-a3cf-8d7dc83ddd10.js
T

3303 lines
117 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '046a3v0XBJHTaPPjX3IPd0Q', 'battle_model');
// Scripts/mod/battle/battle_model.js
"use strict";
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 战战斗数据控制器,其中包括了战斗场景的创建
// flyItem attack hideUI showUI fadeOut fadeIn moveBack moveTo noActAttack 暂时实现的播报动作只有这一些
// blackScreen blackScreen2 blackScreen3 hide show shadow 这一些已经废弃的
// <br/>Create: 2018-11-28 19:19:19
// --------------------------------------------------------------------
var BattleData = require("battle_data");
var BattleConst = require("battle_const");
var BattleEvent = require("battle_event");
var DramaEvent = require("battle_drama_event");
var PathTool = require("pathtool");
var _require = require("define"),
SCREEN_WIDTH = _require.SCREEN_WIDTH,
SCREEN_HEIGHT = _require.SCREEN_HEIGHT,
PlayerAction = _require.PlayerAction;
var RoleController = require("role_controller");
var AniRes = ["hit_effect_list",
// 受击点特效
"area_effect_list",
// 范围特效
"act_effect_list",
// 出手点特效
"bact_effect_list",
// 施法特效
"trc_effect_list" // 弹道特效
];
var BattleModel = cc.Class({
ctor: function ctor() {},
properties: {
init_fight_status: false
},
initConfig: function initConfig() {
this.battle_controller = require("battle_controller").getInstance();
this.hook_model = this.battle_controller.getHookModel();
this.skill_act = require("skill_act");
this.battle_pools = require("battle_role_pool").getInstance(); // 现在这个对象池主要是存放buff飘字以及主动技能飘字等,退出战斗没有移除掉这个对象池
this.battle_dmg_cache_list = {}; // 战斗伤害数字的缓存纹理数据,现在退出战斗没有移除掉
this.battle_effect_list = {}; // 当前战斗存在的非挂接角色的特效,这里存放的,退出战斗就会移除掉
this.battle_effect_pool = {}; // 已经播放过的特效缓存对象,退出战斗就会移除掉
this.role_time_scale = 1; // 二倍速下面的模型动作速率
this.battle_speed = 1; // 当前战斗速率,服务端速率
this.button_list_panel_time = 0; // 假战斗详情面板关闭的时间戳
this.form_panel_time = 0; // 真战斗对战面板关闭的时间戳
this.is_clear = true;
this.batEftMgr = Utils.createClass("battle_effect_mgr");
this.batEftMgr.initConfig();
this.batEftMgr.loadFab();
this.batRoleMgr = Utils.createClass("battle_role_mgr");
this.batRoleMgr.initConfig();
this.batRoleMgr.loadFab();
this.resetInitData();
},
getEftMgr: function getEftMgr() {
if (this.batEftMgr) {
return this.batEftMgr;
}
},
getRoleMgr: function getRoleMgr() {
if (this.batRoleMgr) {
return this.batRoleMgr;
}
},
// 重设初始化数据
resetInitData: function resetInitData() {
//重連需要手動清楚角色
this.clearRealRole();
this.my_group = 0; // 战斗中我自己的分组,主要区分是否是己方
this.init_fight_status = false; // 是否是初始化进詹欧的,主要是做进场
this.alive_num = 0; // 存活单位
this.create_over_num = 0; // 已经创建完成的单位数量
this.skill_plays_order_list = []; // 当前播放列表
this.round_data_temp = {};
this.order_list = [];
this.round_data = {};
this.cur_round_data = {};
this.actor_sum = 0;
this.actor_play_sum = 0;
this.act_playing = false;
this.is_play_round_start = false;
this.cur_round = null;
this.next_round = null;
this.battle_data = null;
this.combat_type = BattleConst.Fight_Type.Nil; // 当前战斗类型
this.real_role_list = {}; // 真是战斗单位列表
this.cur_fight_type = 0; // 当前战斗类型,如果是0:没有战斗 1:假战斗 2:真战斗
this.buffs = {}; // 重连buff
this.hallows_list = {}; // 神器数据
this.scene_buff_effect_list = {}; // 场景buff特效缓存对象
this.action_count = 0;
this.allow_talk_objs = {}; // 允许说话的对象
this.allow_lens_role = {};
this.is_ready_fight = false;
},
// 创建一个场景特效,主要是群攻之类的,这类特效在退出战斗的时候会移除掉
addBattleEfffect: function addBattleEfffect(parent, scene_pos, reverse, effect_id, action_name, is_bg_effect) {
if (is_bg_effect === void 0) {
is_bg_effect = 0;
}
// var BattleEffect = require("battle_effect");
// var battle_effect = null;
// var effect_key = Utils.getNorKey(effect_id, action_name)
// if (this.battle_effect_pool[effect_key] != null){
// if (this.battle_effect_pool[effect_key].length > 0)
// {
// battle_effect = this.battle_effect_pool[effect_key].shift(); // 从头取出一个
// }
// }
// //全屏技能缓速
// let base_config = 150;
// let reduce_speed = null;
// if(this.battle_speed == 1){
// base_config = game.configs.battle_act_data.data_get_act_data.base_speed_scale;
// reduce_speed = game.configs.battle_act_data.data_get_act_data.reduce_speed;
// }else if(this.battle_speed == 2){
// base_config = game.configs.battle_act_data.data_get_act_data.speed_scale;
// reduce_speed = game.configs.battle_act_data.data_get_act_data.reduce_speed1;
// }else if(this.battle_speed == 3){
// base_config = game.configs.battle_act_data.data_get_act_data.speed_scale_2;
// reduce_speed = game.configs.battle_act_data.data_get_act_data.reduce_speed2;
// }
// let scale = this.role_time_scale+1;
// if(is_bg_effect && is_bg_effect > 0){
// scale = (base_config.val - reduce_speed.val) * 0.01;
// }
// if(battle_effect == null){
// battle_effect = new BattleEffect();
// battle_effect.createEffect(parent, scene_pos, reverse, effect_id, scale);
// } else {
// battle_effect.resetScenePos(scene_pos);
// battle_effect.resetReverse(reverse);
// battle_effect.setTimeScale(scale);
// battle_effect.setActiveEffect(true);
// }
// if (this.battle_effect_list[effect_key] == null){
// this.battle_effect_list[effect_key] = []
// }
// this.battle_effect_list[effect_key].push(battle_effect);
// return battle_effect;
var battle_effect = null;
if (!this.batEftMgr) {
return;
}
var effect_key = Utils.getNorKey(effect_id, action_name);
//全屏技能缓速
var base_config = 150;
var reduce_speed = null;
if (this.battle_speed == 1) {
base_config = game.configs.battle_act_data.data_get_act_data.base_speed_scale;
reduce_speed = game.configs.battle_act_data.data_get_act_data.reduce_speed;
} else if (this.battle_speed == 2) {
base_config = game.configs.battle_act_data.data_get_act_data.speed_scale;
reduce_speed = game.configs.battle_act_data.data_get_act_data.reduce_speed1;
} else if (this.battle_speed == 3) {
base_config = game.configs.battle_act_data.data_get_act_data.speed_scale_2;
reduce_speed = game.configs.battle_act_data.data_get_act_data.reduce_speed2;
}
var scale = this.role_time_scale + 1;
if (is_bg_effect && is_bg_effect > 0) {
scale = (base_config.val - reduce_speed.val) * 0.01;
}
battle_effect = this.batEftMgr.findEft(effect_key);
if (battle_effect == null) {
battle_effect = this.batEftMgr.createEft(effect_key, parent, scene_pos, reverse, effect_id, scale);
} else {
battle_effect.resetScenePos(scene_pos);
battle_effect.resetReverse(reverse);
battle_effect.setTimeScale(scale);
battle_effect.setActiveEffect(true);
}
return battle_effect;
},
// 移除一个场景战斗特效
delBattleEffect: function delBattleEffect(battle_effect) {
// var effect_key = battle_effect.getEffectKey();
// if (effect_key == "_") return;
// if (this.battle_effect_pool[effect_key] == null){
// this.battle_effect_pool[effect_key] = []
// }
// var array = this.battle_effect_list[effect_key];
// for (let index = 0; index < array.length; index++) {
// const element = array[index];
// if (element == battle_effect){
// array.splice(index, 1);
// battle_effect.setActiveEffect(false);
// this.battle_effect_pool[effect_key].push(battle_effect);
// break;
// }
// }
var effect_key = battle_effect.getEffectKey();
if (effect_key == "_") return;
if (!this.batEftMgr) return;
var eft = this.batEftMgr.findEft(effect_key);
eft.setActiveEffect(false);
},
// 获取伤害数字的缓存纹理数据
getDmgFontCacheObject: function getDmgFontCacheObject(type, callback) {
var res_path = PathTool.getPlistPath("harmnum", "type" + type);
// var res_object = this.battle_dmg_cache_list[res_path];
// if(res_object == null){
nx.res.loadRes(res_path, cc.SpriteAtlas, function (err, res_object) {
if (!err) {
// this.battle_dmg_cache_list[res_path] = res_object;
callback(res_object);
} else {
callback(null);
}
});
// }else{
// callback(res_object);
// }
},
getDiedEffectObj: function getDiedEffectObj(call) {
var res_path = PathTool.getSpinePath("E65010", "action", false);
nx.res.loadRes(res_path, sp.SkeletonData, function (err, res) {
if (err) {
if (call) {
return call(null);
}
return false;
}
return call(res);
});
},
// 释放掉战斗资源,退出战斗场景之后释放掉吧,但是这里可能存在一个问题就是退出战斗场景是即时的,但是伤害数字还在处于动作中,这个时候还是释放不掉,战斗艺术字不是特别大,暂时考虑不清除
releaseDmgFont: function releaseDmgFont() {
this.battle_dmg_cache_list = {};
},
// 获取一个普通文字.带背景的,暂时退出战斗没有移除对象池
getNormalFont: function getNormalFont() {
var pools = this.battle_pools.getFontPools();
var node = null;
if (pools.size() > 0) {
node = pools.get();
} else {
node = new cc.Node();
node.setAnchorPoint(0.5, 0.5);
node.width = 180;
node.height = 50;
node.addComponent(cc.Sprite);
var _sp = node.getComponent(cc.Sprite);
_sp.trim = false;
_sp.sizeMode = cc.Sprite.SizeMode.RAW;
}
return node;
},
/**
* 回收对象池
* @param {*} font
*/
pushBackBattleFont: function pushBackBattleFont(font) {
this.battle_pools.pushBackFont(font);
},
/**
* 真是战斗的初始化数据.战斗单位可能存在hp为0的时候,这个时候需要特殊处理
*/
updateCurBattleData: function updateCurBattleData(data, is_init) {
this.deleteCurBattleData();
this.init_fight_status = is_init;
if (this.battle_data == null) {
this.battle_data = new BattleData();
}
this.battle_data.updateData(data);
// 保存战斗速度
this.saveSpeed(data.play_speed);
// 更新神器数据
for (var index = 0; index < data.hallows_list.length; index++) {
var element = data.hallows_list[index];
this.hallows_list[element.group] = element;
}
// 先判断对战列表中是否有自己的
var RoleController = require("role_controller");
var role_vo = RoleController.getInstance().getRoleVo();
for (var key in this.battle_data.fight_object_list) {
var role_data = this.battle_data.fight_object_list[key];
if (Utils.getNorKey(role_data.owner_id, role_data.owner_srv_id) == Utils.getNorKey(role_vo.rid, role_vo.srv_id) && this.my_group == 0) {
this.my_group = role_data.group;
}
if (role_data.hp > 0 && key < 40) {
this.alive_num += 1;
}
// 处理神器的
if (role_data.object_type == BattleConst.Unit_Type.Hallows) {
var hallows_data = this.hallows_list[role_data.group];
hallows_data.pos = role_data.pos;
role_data.hallows_val = hallows_data.val;
role_data.hallows_max = hallows_data.max;
}
}
if (this.my_group == 0) {
this.my_group = 1;
}
},
/**
* 创建完成之后通知服务端准备报了
*/
addReadySum: function addReadySum() {
this.create_over_num += 1;
if (this.create_over_num >= this.alive_num) {
this.is_ready_fight = true;
this.battle_controller.csReadyFightStart();
}
},
isReadyFight: function isReadyFight() {
return this.is_ready_fight;
},
// 获取所有战斗单位
getAllObject: function getAllObject() {
return this.real_role_list;
},
// 设置战斗场景可见与否
handleBattleSceneStatus: function handleBattleSceneStatus(status) {
if (this.battle_scene) {
this.battle_scene.changeVisible(status);
// this.battle_scene.setVisible(status)
}
},
// 是否在战斗中
getFightStatus: function getFightStatus() {
return this.is_real_combat;
},
// 返回战斗场景
getBattleScene: function getBattleScene() {
return this.battle_scene;
},
// 是否在真战斗中
isInRealBattle: function isInRealBattle() {
return this.is_real_combat;
},
/**
* 创建战斗场景,这里是唯一的入口,这里需要判断真假战斗切换,等
* @param {*} in_fight_type 0:没有战斗 1:假战斗 2:真战斗
*/
createBattleScene: function createBattleScene(in_fight_type, combat_type) {
var _this = this;
// 不同类的战斗或者不同类的战斗状态类型,都清掉单位
if (this.combat_type != combat_type || this.cur_fight_type != in_fight_type || in_fight_type == 1) {
// 假战斗也移除掉单位重新创建吧
this.clearRealRole();
this.hook_model.clearRealRole();
}
this.combat_type = combat_type; // 储存当前战斗类型
this.cur_fight_type = in_fight_type; // 保存当前之战斗状态类型
this.is_real_combat = in_fight_type == BattleConst.Battle_In_Type.Real;
// 只有剧情战斗的时候才需要显示战斗ui,新项目全部不展示
var is_show = combat_type == BattleConst.Fight_Type.Darma;
// this.battle_controller.openDramaFightUI(is_show && !this.is_real_combat);
var self = this;
if (this.battle_scene == null) {
// this.battle_scene = Utils.createClass("battle_scene");
this.openBattleScene(true, function (battle_scene) {
self.battle_scene = battle_scene;
_this.battle_controller.openDramaFightUI(is_show && !_this.is_real_combat);
if (self.is_real_combat) {
//真戰鬥
_this.openFormViewUI(self.is_real_combat, combat_type, function () {
_this.battle_controller.setIsNormaBattle(self.is_real_combat);
_this.battle_scene.updateBattleScene(self.is_real_combat);
});
} else {
//假战斗
_this.battle_controller.setIsNormaBattle(self.is_real_combat);
_this.battle_scene.updateBattleScene(self.is_real_combat);
}
});
} else {
this.battle_controller.openDramaFightUI(is_show && !this.is_real_combat);
if (self.is_real_combat) {
//真戰鬥
this.openFormViewUI(self.is_real_combat, combat_type, function () {
_this.battle_controller.setIsNormaBattle(self.is_real_combat);
_this.battle_scene.updateBattleScene(self.is_real_combat);
});
} else {
//假战斗
this.battle_controller.setIsNormaBattle(self.is_real_combat);
this.battle_scene.updateBattleScene(self.is_real_combat);
}
}
// 只有真战斗才需要显示
nx.bridge.vset("BatBreak", true);
this.is_clear = false;
},
setBattleListPanelTime: function setBattleListPanelTime(val) {
if (val) {
this.button_list_panel_time = 0;
} else {
this.button_list_panel_time = client.socket.getTime();
}
},
openBattleScene: function openBattleScene(status, finish_cb) {
if (!status) {
window.game.runMainScene();
} else {
window.game.runBattleScene({
finish_cb: finish_cb
});
}
},
// 真战斗中的阵型以及其他相关显示部分
openFormViewUI: function openFormViewUI(status, combat_type, _cb) {
if (!status) {
//直接返回通知假战斗
nx.dt.fnInvoke(_cb);
// nx.bridge.closePanel("WndFormView");
this.form_panel_time = client.socket.getTime();
} else {
nx.bridge.createPanel("WndFormView", {
combat_type: combat_type,
finish_cb: _cb
});
this.form_panel_time = 0;
}
this.startCountDownToDelete();
},
closeFormView: function closeFormView() {
// gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_CLOSE);
nx.bridge.vset("BatBreak", false);
nx.bridge.closePanel("WndFormView");
},
setFromPanelTime: function setFromPanelTime(val) {
if (val) {
this.form_panel_time = val;
} else {
this.form_panel_time = client.socket.getTime();
}
},
// 关闭面板的倒计时
startCountDownToDelete: function startCountDownToDelete() {
if (this.form_panel_time == 0 && this.button_list_panel_time == 0) {
if (this.close_panel_timer) {
gcore.Timer.del(this.close_panel_timer);
this.close_panel_timer = null;
}
} else {
if (this.close_panel_timer == null) {
this.close_panel_timer = gcore.Timer.set(function () {
this.waitDeletePanel();
}.bind(this), 1000, -1);
}
}
},
// 倒计时准备清楚面板
waitDeletePanel: function waitDeletePanel() {
if (this.form_panel_time == 0 && this.button_list_panel_time == 0) {
this.startCountDownToDelete(); // 移除掉定时器
} else {
if (this.button_list_panel_time != 0) {
var button_pass_time = client.socket.getTime() - this.button_list_panel_time;
if (button_pass_time > 100) {
if (this.drama_fight_ui) {
this.drama_fight_ui.deleteMe();
this.drama_fight_ui = null;
}
this.button_list_panel_time = 0;
}
}
if (this.form_panel_time != 0) {
var form_pass_time = client.socket.getTime() - this.form_panel_time;
if (form_pass_time > 100) {
this.form_panel_time = 0;
}
}
}
},
// 引导需要
getDramaFightUI: function getDramaFightUI() {
if (this.drama_fight_ui) return this.drama_fight_ui.root_wnd;
return null;
},
/**
* 彻底移除一个战斗场景,比如说切换出战斗,或者非剧情战斗结束,这个结束
*/
clearBattleScene: function clearBattleScene() {
if (this.battle_scene && !this.is_clear) {
// 先移除掉单位定时器
var role_list = this.getAllBattleRoleList();
for (var pos in role_list) {
gcore.Timer.del("attackerActTimeout" + pos);
}
this.combat_type = BattleConst.Fight_Type.Nil;
this.cur_fight_type = BattleConst.Battle_In_Type.Nil; // 移除掉战斗类型
this.is_real_combat = false; // 战斗
// 清楚掉场景单位
this.clearRealRole();
this.hook_model.clearRealRole(); // 假战斗模型资源
// 移除掉所有的战斗特效--,群攻类和子弹类
this.cleanAllBattleEffect();
this.releaseAllAssets();
this.battle_controller.openDramaFightUI(false);
this.closeFormView(false);
// 移除真实战斗场景的数据
this.deleteCurBattleData();
//清楚战斗场景
this.openBattleScene(false);
this.battle_scene = null;
this.is_clear = true;
}
},
clearBattleNd: function clearBattleNd() {
// 清楚掉场景单位
this.clearRealRole();
this.hook_model.clearRealRole(); // 假战斗模型资源
// 移除掉所有的战斗特效--,群攻类和子弹类
this.cleanAllBattleEffect();
},
releaseAllAssets: function releaseAllAssets() {
this.batRoleMgr.releaseResAssets();
this.batEftMgr.releaseResAssets();
},
// 清空所有的场景战斗特效
cleanAllBattleEffect: function cleanAllBattleEffect() {
// // 回收掉场景特效资源
// for (var key in this.battle_effect_list) {
// var array = this.battle_effect_list[key]
// for (let index = 0; index < array.length; index++) {
// const element = array[index];
// element.deleEffect();
// }
// delete this.battle_effect_list[key];
// console.log("del3=====>",array);
// }
// this.battle_effect_list = {};
// // 回收掉场景特效资源
// for (var key in this.battle_effect_pool) {
// var array = this.battle_effect_pool[key]
// for (let index = 0; index < array.length; index++) {
// const element = array[index];
// element.deleEffect();
// }
// delete this.battle_effect_list[key];
// console.log("del4=====>",array);
// }
// this.battle_effect_pool = {};\
this.batEftMgr.resetAll();
},
/**
* 假战斗定帧移动地图处理,现在卸载gamestart 的update里面
*/
mapMovescheduleUpdate: function mapMovescheduleUpdate(dt) {
if (this.battle_scene) {
this.battle_scene.mapMovescheduleUpdate(dt);
}
},
/**
* 切换战斗移动状态,比如真实剧情战斗切换到假战斗的时候,就需要开启地图移动
* @param {*} status Bool
*/
changeMoveMapStatus: function changeMoveMapStatus(status) {
if (this.battle_scene) {
this.battle_scene.changeMoveMapStatus(status);
}
},
/**
* 进入真实战斗时,是否需要播放进场动作,中途切进去的不需要处理,这个值针对初始化单位的时候需要,战斗创建一个单位不需要
*/
needPlayEnterAction: function needPlayEnterAction() {
return this.init_fight_status;
},
/**
* 真实战斗中的单位是否是友方判断
* @param {*} group BattleRoleData.group
*/
isFriend: function isFriend(group) {
return group == this.my_group;
},
/**
* 当前真实战斗的初始化数据
*/
getCurBattleData: function getCurBattleData() {
return this.battle_data;
},
// 获取当前战斗类型
getCombatType: function getCombatType() {
return this.combat_type;
},
/**
* 退出战斗,清空战斗数据,针对真实战斗
*/
deleteCurBattleData: function deleteCurBattleData() {
this.resetInitData();
},
// 判断是否可以改变战斗速度
checkIsCanChangeBattleSpeed: function checkIsCanChangeBattleSpeed() {
if (this.battle_data == null) {
return false;
}
var role_vo = require("role_controller").getInstance().getRoleVo();
if (role_vo == null) {
return false;
}
var next_speed = 1;
if (this.battle_speed == 1) {
next_speed = 2;
} else if (this.battle_speed == 2) {
next_speed = 3;
}
var speed_config = game.configs.combat_type_data.data_combat_speed[next_speed];
if (speed_config == null) {
return false;
}
if (speed_config.limit_lev > role_vo.lev) {
if (this.battle_speed == 1 && next_speed == 2) {
var desc = cc.js.formatStr(nx.text.getKey("lab_battle_model_tip1"), speed_config.limit_lev);
nx.tbox(desc);
return false;
} else if (this.battle_speed == 2 && next_speed == 3) {
this.battle_speed = 3;
} else {
this.battle_speed = 3;
}
// var desc = cc.js.formatStr(nx.text.getKey("lab_battle_model_tip1"), speed_config.limit_lev);
// nx.tbox(desc);
return true;
}
var fight_config = game.configs.combat_type_data.data_fight_list[this.battle_data.combat_type];
if (fight_config == null) {
return false;
}
if (fight_config.is_pvp == 1) {
nx.tbox(cc.js.formatStr(nx.text.getKey("lab_battle_model_tip2"), fight_config.desc));
return false;
}
return true;
},
/**
* 修改一下当前战斗速度
*/
changeSpeed: function changeSpeed() {
if (this.battle_speed == 1) {
this.saveSpeed(2);
this.battle_controller.csFightSpeed(2);
} else if (this.battle_speed == 2) {
this.saveSpeed(3);
this.battle_controller.csFightSpeed(3);
} else {
this.saveSpeed(1);
this.battle_controller.csFightSpeed(1);
}
},
/**
* 当前战斗速度
*/
getTimeScale: function getTimeScale() {
var time_scale = 1;
if (this.isInRealBattle() == true) {
time_scale = this.role_time_scale;
}
// time_scale = 1.5
// 要根据当前帧频调整播放速度
return time_scale;
},
// 设置当前动作速度
setBattleTimeScale: function setBattleTimeScale(is_reset) {
if (this.battle_time_status == is_reset) return;
this.battle_time_status = is_reset;
var base_config = null;
if (is_reset == true) {
// 这个时候是1倍速
base_config = game.configs.battle_act_data.data_get_act_data.base_speed_scale;
} else {
base_config = game.configs.battle_act_data.data_get_act_data.speed_scale;
if (this.battle_speed == 1) {
base_config = game.configs.battle_act_data.data_get_act_data.base_speed_scale;
} else if (this.battle_speed == 2) {
base_config = game.configs.battle_act_data.data_get_act_data.speed_scale;
} else if (this.battle_speed == 3) {
base_config = game.configs.battle_act_data.data_get_act_data.speed_scale_2;
}
}
if (base_config) {
this.role_time_scale = base_config.val * 0.01;
}
this.setRoleTimeScale();
},
// 保存速率之后马上设置模型动作
setRoleTimeScale: function setRoleTimeScale() {
if (this.real_role_list) {
for (var key in this.real_role_list) {
var object = this.real_role_list[key];
if (object) {
object.setTimeScale(this.role_time_scale);
}
}
}
// 设置场景特效
if (this.batEftMgr) {
var efts = this.batEftMgr.getEfts();
for (var i in efts) {
if (efts[i]) {
efts[i].setTimeScale(this.role_time_scale);
}
}
}
},
// 保存当前战斗速度,这个速度只是为了改变显示
saveSpeed: function saveSpeed(speed) {
if (this.battle_speed == speed) return;
this.battle_speed = speed;
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_SETSPEED, speed);
// if(this.form_fight_ui){
// this.form_fight_ui.setSpeed(speed);
// }
},
// 获取当前速度
getSpeed: function getSpeed() {
return this.battle_speed;
},
/**
* 一个回合播报的动作计数,最后保证值为0就表示播完了当前动作
* @param {*} attacker
*/
actStart: function actStart(attacker) {
// 如果结算面板已经出来了,就不需要播报了
if (this.checkoutIsRightFight(attacker)) {
attacker.wait_act += 1;
gcore.Timer.del("attackerActTimeout" + attacker.pos);
gcore.Timer.set(function () {
this.actTimeout(attacker);
}.bind(this), 3600 / this.role_time_scale, 1, "attackerActTimeout" + attacker.pos);
}
},
/**
* 某一个动作播放完成之后,计数 -1,当为0的时候,就表示当前小回合播报结束
* @param {*} attacker
*/
actFinish: function actFinish(attacker) {
var _this2 = this;
if (this.checkoutIsRightFight(attacker)) {
if (attacker.wait_act > 0) {
attacker.wait_act -= 1;
if (attacker.wait_act <= 0) {
if (attacker.is_real) {
var actF_timer = setTimeout(function () {
clearTimeout(actF_timer);
_this2.playOrder(attacker);
}, 100);
gcore.Timer.del("attackerActTimeout" + attacker.pos);
} else {
this.hook_model.playOrder(attacker);
}
}
}
}
},
//异常动作处理结束
forceActFinish: function forceActFinish(pos) {
var attacker = this.real_role_list[pos];
if (attacker) {
attacker.wait_act = 0;
this.actFinish(attacker);
}
},
/**
* 判断是都是正式战斗
*
*/
checkoutIsRightFight: function checkoutIsRightFight(attacker) {
if (attacker.is_real == true) {
if (this.battle_data && this.cur_round_data && this.battle_data.combat_type == this.cur_round_data.combat_type) {
return true;
}
} else {
var battle_data = this.hook_model.getUnrealBattleData();
if (battle_data && battle_data.combat_type == BattleConst.Fight_Type.Darma) {
return true;
}
}
return false;
},
/**
* 小回合播报超时处理
* @param {*} attacker
*/
actTimeout: function actTimeout(attacker) {
if (attacker == null || !attacker.isValid) return;
attacker.wait_act = 1;
this.actFinish(attacker);
},
/**
* 回合开始的播报,包括站位的初始化等,因为有一些是需要在回合开始的时候播放的播报 包含回合开始的buff
* @param {*} data 协议 20002 的数据
*/
playRoundStart: function playRoundStart(data) {
var _this3 = this;
if (this.getBattleScene() == null || this.battle_data == null || this.battle_data.combat_type != data.combat_type) {
return;
}
this.is_play_round_start = true;
this.is_ready_fight = false;
this.allow_lens_role = {};
//定义援护不打断动作
for (var key in this.real_role_list) {
var role = this.real_role_list[key];
if (role && role.role_data && role.role_data.object_type != BattleConst.Unit_Type.Hallows && role.role_data.object_type != BattleConst.Unit_Type.Elfin) {
role.is_not_hide = false;
}
}
// 处理回合buff
this.dealRoundBuff(data.round_buff);
// 处理神器的回合进度
if (data && data.hallows_list) {
for (var index = 0; index < data.hallows_list.length; index++) {
var element = data.hallows_list[index];
if (element) {
var hallows = this.hallows_list[element.group];
if (hallows && hallows.pos) {
var role = this.real_role_list[hallows.pos];
if (role) {
// role.setHallowsRound(element.val);
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_HALLOW, false, role, role.is_friend, element.val);
}
}
}
}
}
// 回合开始也处理掉那些假死的模型
if (data && data.all_alive) {
var temp_list = {};
for (var _index = 0; _index < data.all_alive.length; _index++) {
var _element = data.all_alive[_index];
if (_element) {
temp_list[_element.pos] = true;
}
}
for (var key in this.real_role_list) {
if (!temp_list[key]) {
var role = this.real_role_list[key];
if (role && !role.is_die && role.role_data && role.role_data.object_type != BattleConst.Unit_Type.Hallows && role.role_data.object_type != BattleConst.Unit_Type.Elfin) {
role.doDied();
}
}
}
//筛选进行镜头活动的角色
this.sortLernsRole(data.all_alive);
}
// 没有技能播报列表,直接通知服务端结束
if (data == null || data.skill_plays.length == 0) {
var start_timer = setTimeout(function () {
clearTimeout(start_timer);
_this3.battle_controller.csRoundFightEnd();
}, 200);
// 初始化位置层级等相关信息
this.handlePlayRoundStart(data);
} else {
this.addRoundData(data);
}
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_UPROUND, data.action_count);
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_TOTALHURT, 0);
},
sortLernsRole: function sortLernsRole(all_alive) {
var my = [];
var oth = [];
for (var i in all_alive) {
if (all_alive[i].pos < 10) {
my.push(all_alive[i].pos);
} else {
oth.push(all_alive[i].pos);
}
}
var lorder = Math.floor(Math.random() * my.length);
this.allow_lens_role[my[lorder]] = true;
var rorder = Math.floor(Math.random() * oth.length);
this.allow_lens_role[oth[rorder]] = true;
},
checkIsLens: function checkIsLens(pos) {
if (this.allow_lens_role[pos]) {
return true;
}
return false;
},
/**
* 正常回合播报,回合开始播报结束之后,进入正常回合播报 包含回合结束buff和效果播报的buff
* @param {*} data 协议 20004 的数据
*/
playRoundIn: function playRoundIn(data) {
this.is_play_round_start = false;
this.allow_talk_objs = {}; //每回合中先置空数据
// 回合结束后的buff可能需要处理的
if (data.round_buff && data.round_buff.length > 0) {
this.act_after_buff_list = data.round_buff;
} else {
this.act_after_buff_list = null;
}
this.addRoundData(data);
},
// 更新buff
setBuffsList: function setBuffsList(data) {
this.buffs = data;
},
/**
* 更新下一波怪物的数据
* @param {*} data
*/
upDateNextMon: function upDateNextMon(data) {
if (this.real_role_list == null || data == null) return;
// 清掉上一回合的死亡对象
for (var key in this.real_role_list) {
var role = this.real_role_list[key];
if (role) {
//&& role.is_die
role.deleteRole();
this.real_role_list[key] = null;
}
}
// 更新战斗基本数据
if (this.battle_data) {
this.battle_data.updateData(data);
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_UPNEXTMON);
}
this.setBuffsList(data.buffs);
this.dealRoundBuff(data.buffs);
if (this.getBattleScene()) {
for (var index = 0; index < data.objects.length; index++) {
var element = data.objects[index];
var role = this.real_role_list[element.pos];
if (this.isFriend(element.group) && role) {
role.updataNextBattleRole(element);
} else {
this.createRole(element, true, null, true);
}
}
}
},
/**addReConnectReadySum
*
* 处理回合开始的数据
* @param {*} data 协议 20002 的数据
*/
handlePlayRoundStart: function handlePlayRoundStart(data) {
if (this.battle_data == null || this.battle_data.combat_type != data.combat_type) {
return;
}
if (this.battle_scene == null) {
return;
}
this.resetBattleRoleBaseInfo();
},
// 处理回合buff
dealRoundBuff: function dealRoundBuff(buff_list, attacker) {
if (buff_list == null || buff_list.length == 0) return;
for (var index = 0; index < buff_list.length; index++) {
var element = buff_list[index];
var battle_role = this.real_role_list[element.target];
var buff_config = gskilldata('data_get_buff', element.buff_bid);
if (battle_role && buff_config) {
this.playRoundBuff(battle_role, element, attacker);
}
}
},
/**
* 回合中的播报,这个是播报的主入口
* @param {*} data 协议 20004 的数据
*/
addRoundData: function addRoundData(data) {
if (this.getBattleScene() == null || this.battle_data == null || this.battle_data.combat_type != data.combat_type) {
return;
}
this.action_count = data.action_count;
// 更新当前回合数
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_UPROUND, data.action_count);
// 更新精靈的技能cd狀態
if (data.sprite_cd_info && this.real_role_list && Utils.next(this.real_role_list || {}) != null) {
for (var i in data.sprite_cd_info) {
var v = data.sprite_cd_info[i];
var obj = this.real_role_list[v.pos];
if (obj && obj.spine_renderer) {
obj.updateElfinSkillState(v.cd_info);
}
}
}
// 播报数据
this.cur_round = null;
this.next_round = null;
this.cur_round_data = data;
this.skill_plays_order_list = [];
this.round_data_temp = {};
// 技能播报数据, 解析技能数据
for (var j = 0; j < data.skill_plays.length; j++) {
var skill_element = data.skill_plays[j];
for (var _i = 0; _i < skill_element.effect_play.length; _i++) {
var effect_element = skill_element.effect_play[_i];
if (this.round_data_temp[skill_element.order] == null) {
this.round_data_temp[skill_element.order] = [];
this.skill_plays_order_list.push({
skill_order: skill_element.order,
priority: skill_element.order * 1000 + j
});
}
effect_element.skill_bid = effect_element.skill_bid_of_effect;
effect_element.talk_pos = skill_element.talk_pos;
effect_element.talk_content = skill_element.talk_content;
effect_element.index = _i;
effect_element.skill_order = skill_element.order;
effect_element.priority = effect_element.order * 10000 + j * 100 + _i;
this.round_data_temp[skill_element.order].push(effect_element);
}
}
// 对出手进行排序
this.skill_plays_order_list.sort(function (a, b) {
return a.priority - b.priority;
});
// this.preloadBattleRes(data, function() {
this.analyseTempRoundData();
// }.bind(this));
},
// 分析当前播报数据
analyseTempRoundData: function analyseTempRoundData() {
this.order_list = [];
this.round_data = {};
if (Object.keys(this.round_data_temp).length > 0) {
for (var index = 0; index < this.skill_plays_order_list.length; index++) {
var element = this.skill_plays_order_list[index];
var temp = this.round_data_temp[element.skill_order];
for (var i = 0; i < temp.length; i++) {
var one_temp = temp[i];
if (this.round_data[one_temp.order] == null) {
this.round_data[one_temp.order] = {};
this.order_list.push({
order: one_temp.order,
priority: one_temp.priority
});
}
if (this.round_data[one_temp.order][one_temp.actor] == null) {
this.round_data[one_temp.order][one_temp.actor] = {
order: one_temp.order,
actor: one_temp.actor,
skill_bid: one_temp.skill_bid,
talk_content: one_temp.talk_content,
talk_pos: one_temp.talk_pos,
index: one_temp.index,
target_list: []
};
}
//聊天配置
if (!this.allow_talk_objs[one_temp.actor]) {
if (one_temp.talk_pos == one_temp.actor) {
this.allow_talk_objs[one_temp.actor] = true; //允许说话
} else {
this.allow_talk_objs[one_temp.actor] = false; //不允许说话
}
}
var object = this.round_data[one_temp.order][one_temp.actor];
object.target_list.push(one_temp);
}
}
// 对出售惊醒排序
this.order_list.sort(function (a, b) {
return a.priority - b.priority;
});
this.round_data_temp = {};
}
this.round();
},
// 回合播报
round: function round() {
var _this4 = this;
if (this.round_num && this.round_num > 0) return;
this.round_num = 0;
this.actor_sum = 0;
this.actor_play_sum = 0;
this.cur_round = null;
this.next_round = null;
// 回合播报之前重置掉所有单位受击状态
if (this.battle_scene) {
var role_list = this.getAllBattleRoleList();
for (var key in role_list) {
var role = role_list[key];
if (role) {
role.dmg_index = 0;
role.dmg_aid_y_offset = 0;
role.is_hurt_play = false;
role.is_big_play = false;
}
}
}
if (this.order_list.length == 0) {
this.cancleBlackScreen();
// 回合后的buff处理
if (this.act_after_buff_list && this.act_after_buff_list.length > 0) {
this.dealRoundBuff(this.act_after_buff_list);
this.act_after_buff_list = null;
}
// 重置一些状态,可能是一些数值类的
if (this.real_role_list) {
for (var key in this.real_role_list) {
var battle_role = this.real_role_list[key];
if (battle_role) {
battle_role.temp_skill_bid = 0;
}
}
}
// 通知服务端播报完成,区分回合开始和中间回合播报
if (this.is_play_round_start == true) {
this.battle_controller.csRoundFightEnd();
} else {
var round_timer = setTimeout(function () {
_this4.battle_controller.csSkillPlayEnd();
clearTimeout(round_timer);
}, 200);
}
// 这个时候设置所有的单位初始状态
} else {
var first_data = this.order_list.shift();
var round_data = this.round_data[first_data.order];
if (this.order_list.length > 0) {
var second_order = this.order_list[0].order;
var second_data = this.round_data[second_order];
// 找到下一个回合播报,于当前回合播报做比较判断是不是多段攻击,从而在当前播报结束之后,是否需要重置
for (var actor in second_data) {
if (this.next_round == null) {
this.next_round = second_data[actor];
break;
}
}
}
this.round_num = Object.keys(round_data).length;
for (var actor in round_data) {
this.round_num -= 1;
var round_one_temp = round_data[actor];
if (this.cur_round == null) {
this.cur_round = round_one_temp;
}
if (round_one_temp.target_list.length > 0) {
var attacker = this.getBattleRoleByPos(round_one_temp.actor);
if (attacker) {
this.actor_sum = this.actor_sum + 1;
this.initOrder(attacker, round_one_temp);
} else {
this.round();
}
} else {
this.round();
}
}
}
},
// 播放回合buff,可能是回合开始,效果播报结束,也可能是回合结束, 这个buff是协议数据来的
playRoundBuff: function playRoundBuff(target, buff, attacker, effect_hit) {
if (target == null || buff == null) return;
this.addBuff(attacker, target, buff);
if (buff.change_type == 1) {
// 血量变化的时候
this.battleRoleHPChange(target, buff.change_value, buff.is_dead, effect_hit, true);
}
},
// buff类的气血上号
battleRoleHPChange: function battleRoleHPChange(target, value, is_dead, effect_hit, is_buff, camp_restrain) {
if (target == null) return;
target.updateHP(value, is_dead, true, 0);
this.mutiHurtNum(target, value, effect_hit, is_buff, camp_restrain);
},
//回合中错位重置
roundResetScenePos: function roundResetScenePos() {
var all_roles = this.getAllBattleRoleList();
for (var i in all_roles) {
if (all_roles[i]) {
all_roles[i].checkIsScenePos();
}
}
},
// 初始化动作列表,准备开战了,初始化一些数据
initOrder: function initOrder(attacker, one) {
one.target_list.sort(function (a, b) {
return a.priority - b.priority;
});
//镜头重置
nx.bridge.camBattle.reset(0, null);
//错位重置
// if(this.last_round_actor != this.cur_round.actor){
// this.roundResetScenePos();
// }
// 这个后续再看看要不要动态设置层级
if (this.cur_round && this.last_round_actor && this.cur_round.actor == this.last_round_actor) {} else {
attacker.resetZOrder();
attacker.targe_zorder = 9999;
}
var list = one.target_list;
var col_target = list[0].target;
if (col_target > BattleConst.GIRD_POS_OFFSET) {
col_target = col_target - BattleConst.GIRD_POS_OFFSET;
}
var col = BattleConst.Pos_To_Col[col_target - 1];
var target = this.getBattleRoleByPos(col_target);
if (target) {
target.resetZOrder();
attacker.targe_zorder = target.getLocalZOrder();
}
attacker.col = col;
attacker.is_round = false;
attacker.attacker_info = one;
attacker.skill_data = gskilldata('data_get_skill', one.skill_bid);
attacker.target_pos = attacker.grid_pos;
attacker.play_order_index = one.target_list[0].effect_bid;
this.calcTargetPos(attacker);
// 如果没有效果id则不处理,所有播报驱动都是效果驱动
if (attacker.play_order_index == null || attacker.play_order_index == 0) {
this.actor_play_sum += 1;
var effect_play = one.target_list[0];
if (effect_play) {
if (effect_play.sub_effect_play_list && effect_play.sub_effect_play_list.length > 0) {
this.handleSubEffectPlaylist(effect_play, attacker);
}
this.dealRoundBuff(effect_play.buff_list, attacker);
}
this.round();
return;
}
var effect_config = gskilldata('data_get_effect', attacker.play_order_index);
//皮肤需要更换技能组
if (attacker.is_use_skill) {
var skin_eft = attacker.fashion_id + "_" + attacker.play_order_index;
var new_eftid = game.configs.partner_skin_data.data_skilltoeffect[skin_eft];
var Seffect_config = gskilldata('data_get_effect', new_eftid);
if (Seffect_config) {
effect_config = Seffect_config;
}
}
if (effect_config) {
attacker.play_order = nx.dt.objClone(effect_config.action_list); // 动作列表
attacker.shake_id = effect_config.shake_id; // 震屏ID
attacker.effect_type = effect_config.effect_type; // 效果类型
attacker.play_stand = effect_config.play_stand; // 是否收招
attacker.anime_res = effect_config.anime_res; // 攻击动作资源
attacker.split_hurt = effect_config.split_hurt;
attacker.hit_action = effect_config.hit_action; // 受击处理
attacker.effect_desc = effect_config.effect_desc; // 效果飘字
attacker.is_must_die = effect_config.is_must_die; // 死亡的时候是否移除,这个主要是判断连击中的时候
attacker.is_bg_effect = effect_config.is_bg_effect; // 全屏技能一倍速播放
attacker.anime_user_atk = effect_config.anime_user_atk; // 攻击动作名
attacker.attack_sound = effect_config.attack_sound; // 攻击音效
attacker.buff_sound = effect_config.buff_sound;
attacker.ready_sound = effect_config.ready_sound; // 准备音效
attacker.shout_trick = effect_config.shout_trick; // 喊招音效
attacker.hit_sound = effect_config.hit_sound; // 受击音效
attacker.hit_effect_list = nx.dt.objClone(this.getCurEffectList(effect_config.hit_effect_list)); // 记录打击特效列表
attacker.area_effect_list = nx.dt.objClone(this.getCurEffectList(effect_config.area_effect_list)); // 记录范围人物特效
attacker.act_effect_list = nx.dt.objClone(this.getCurEffectList(effect_config.act_effect_list)); // 记录出手点特效
attacker.bact_effect_list = nx.dt.objClone(this.getCurEffectList(effect_config.bact_effect_list)); // 记录施法特效
attacker.trc_effect_list = nx.dt.objClone(this.getCurEffectList(effect_config.trc_effect_list)); // 记录弹道特效
attacker.bg_effect_list = nx.dt.objClone(this.getCurEffectList(effect_config.bg_effect)); //全屏演出特效
attacker.hurt_effect_list = effect_config.hurt_effect_list; // 记录弹道特效
}
// 是否有群攻
if (attacker.area_effect_list.length > 0) {
attacker.attacker_info.is_calc = false;
attacker.in_area_effect = true;
attacker.area_hit_num = 1;
attacker.area_hit_time = 0;
} else {
attacker.in_area_effect = false;
}
var start_attack = function () {
this.playOrder(attacker);
}.bind(this);
// 主动技能和被动技能喊招处理
var show_skill_nme = function () {
var skill_type = attacker.skill_data.type;
if (skill_type == BattleConst.BattleSkillTypeConf.PASSIVE_SKILL && attacker.skill_data.passive_skill_show == 1) {
// this.playFontMessage(attacker, attacker.skill_data.name, null, null, null, null, null, function(){
start_attack();
// }.bind(this))
} else if (skill_type == BattleConst.BattleSkillTypeConf.ACTIVE_SKILL) {
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_SHOWSKILL, attacker, function () {
start_attack();
});
} else {
start_attack();
}
}.bind(this);
// 精靈的技能效果
var show_elfin_ani = function () {
if (this.battle_scene) {
this.battle_scene.showElfinSkillAni(attacker, start_attack, this.act_playing);
}
}.bind(this);
if (attacker.object_type == BattleConst.BattleObjectType.Elfin) {
// 精靈單獨處理
this.talk(attacker, show_elfin_ani);
} else if (attacker.skill_data == null) {
this.talk(attacker, start_attack);
} else {
this.talk(attacker, show_skill_nme);
}
this.act_playing = true;
},
/**
* 计算目标点
* @param {*} attacker
* @param {*} object_list
*/
calcTargetPos: function calcTargetPos(attacker, object_list) {
if (attacker == null || attacker.attacker_info == null || !attacker.isValid) {
return;
}
var target_list = attacker.attacker_info.target_list;
var target = null;
for (var index = 0; index < target_list.length; index++) {
var element = target_list[index];
if (object_list) {
target = object_list[element.target];
} else {
target = this.getBattleRoleByPos(element.target);
}
if (target && target.obj_type != attacker.obj_type) {
break;
}
}
if (target) {
attacker.target_pos = target.grid_pos;
attacker.target_pos_base = target.grid_pos;
attacker.target_name = target.role_data.object_name;
}
},
// 效果列表
getCurEffectList: function getCurEffectList(list) {
var effect_list = [];
for (var index = 0; index < list.length; index++) {
var element = list[index];
var effect_data = game.configs.skill_data.data_get_effect_data[element];
effect_list.push(effect_data);
}
return effect_list;
},
// 单位喊话
talk: function talk(attacker, callback) {
var msg = attacker.attacker_info.talk_content || "";
var actor = attacker.attacker_info.talk_pos;
if (msg == "") {
if (callback) {
callback();
}
return;
}
// 然后播放气泡.....
if (actor > 0) {
if (this.allow_talk_objs[actor]) {
this.allow_talk_objs[actor] = false;
this.battle_scene.talkOne(msg, attacker.scene_pos, attacker.is_friend, callback);
} else {
if (callback) {
callback();
}
}
} else {
if (callback) {
callback();
}
}
},
// 获取播报动作
singleAct: function singleAct(act_data, attacker) {
if (act_data instanceof Array) {
return this.mutiAct(act_data, attacker);
} else {
var act_config = nx.dt.objClone(game.configs.skill_data.data_get_act_data[act_data]);
if (act_config) {
var args = act_config.act_args;
var funname = args[0];
if (funname == null || this[funname] == null) {
return;
}
if (this[funname] instanceof Function) {
var params = args[1] || [];
params.unshift(attacker);
return this[funname].apply(this, params);
} else {
nx.warn("动作错误,动作BID:" + act_data);
}
}
}
},
// 获取多段播报动作
mutiAct: function mutiAct(args, attacker) {
var acts = [];
for (var index = 0; index < args.length; index++) {
var element = args[index];
var act = this.singleAct(element, attacker);
if (act) {
acts.push(act);
}
}
if (acts.length == 1) {
return acts[0];
} else {
return cc.spawn.apply(null, acts);
}
},
/**
* 技能动作附带糊掉函数
* @param {*} attacker
* @param {*} args
*/
callfun: function callfun(attacker, args) {
var funname = "";
var params = null;
if (args instanceof Array) {
funname = args[0];
params = args[1] || [];
} else {
funname = args;
}
if (funname == "") {
return;
}
if (this[funname] instanceof Function) {
if (params == null) {
params = [];
}
params.unshift(attacker);
this[funname].apply(this, params);
} else if (typeof funname == "number") {
var act = this.singleAct(funname, attacker);
attacker.runAction(act);
}
},
skillMusic: function skillMusic(attacker, delay_time) {
return this.skill_act.skillMusic(attacker, delay_time);
},
/**
* 普通近战攻击
* @param {*} attack
* @param {*} delay_time
* @param {*} hit_fun
* @param {*} start_fun 攻击开始动作
* @param {*} is_reverse 是否是移动到背面
*/
attack: function attack(attacker, delay_time, hit_fun, start_fun, is_reverse) {
if (attacker && attacker.anime_user_atk) {
delay_time = delay_time || 0;
is_reverse = is_reverse == 1;
var start_callback = function () {
this.callfun(attacker, start_fun);
}.bind(this);
var hit_callback = function () {
this.callfun(attacker, hit_fun);
}.bind(this);
//设计变身问题
var act_res = attacker.anime_res;
if (attacker.is_change_status) {
act_res = attacker.change_spine_res;
}
return this.skill_act.attack(attacker, delay_time, attacker.anime_user_atk, hit_callback, start_callback, is_reverse, null, act_res);
}
},
/**
* 远程攻击子弹
* @param {*} attacker
* @param {*} delay_time
* @param {*} move_time
* @param {*} is_back
* @param {*} funname
* @param {*} start_height
*/
flyItem: function flyItem(attacker, delay_time, move_time, is_back, funname, start_height, i, j, finish_delay) {
if (this.checkIsInBattle(attacker) == false) {
return;
}
var effect_list = attacker.trc_effect_list; // 这个效果可能有多个,这个时候主要取第一个吧
if (effect_list == null || effect_list.length == 0) {
nx.warn("播放远程攻击效果失败,不存在远程的效果,效果id为: " + attacker.play_order_index);
this.actStart(attacker);
return;
}
var effect_object = effect_list[0]; // 主要第一个
var is_friend = attacker.is_friend; // 是否是友方
var res_up = effect_object.res_up; //
if (is_friend == true && effect_object.spec_res_up != "") {
res_up = effect_object.spec_res_up;
}
var scale = effect_object.scale * 0.001;
var x_fix = effect_object.x_fix * attacker.obj_type;
var y_fix = effect_object.y_fix == 0 ? 50 : effect_object.y_fix;
var anima_name = attacker.anime_user_atk || PlayerAction.action_2;
var attack_func = function () {
var target_list = attacker.attacker_info.target_list;
if (target_list.length <= 1) {
// 只有一个攻击对象的时候
var target_pos = this.center_pos(attacker, y_fix);
//假战斗需要弹道
if (!this.is_real_combat) {
var t = this.hook_model.getBattleRoleByPos(target_list[0].target);
if (t) {
target_pos = cc.v2(t.scene_pos.x, t.scene_pos.y + 50);
} else {
target_pos = cc.v2(640, 220);
}
}
return this.item(attacker, delay_time, res_up, move_time, funname, start_height, target_pos, scale, effect_object.bid, x_fix, y_fix, finish_delay);
} else {
this.playSelfEffect();
var act_list = []; // 动作列表
var array = attacker.attacker_info.target_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
var target = this.getBattleRoleByPos(element.target);
//有可能是不需要攻擊的技能
var ef_data = gskilldata('data_get_effect', element.effect_bid);
if (ef_data.hit_action != "no-hurt" || ef_data.parallel_passive_skill.length == 0) {
//需要攻擊動作
if (target) {
// 目标
var target_pos = {
x: target.scene_pos.x,
y: target.scene_pos.y + y_fix
};
if (target.group != attacker.group) {
var func = this.getItem(attacker, delay_time, res_up, move_time, "hurtOne", start_height, target_pos, scale, effect_object.bid, x_fix, y_fix);
act_list.push(func);
}
}
}
}
// 关键数据
var finish_func = cc.callFunc(function () {
if (attacker.attacker_info.last_effect) {
for (var _index2 = 0; _index2 < attacker.attacker_info.last_effect.length; _index2++) {
var _element2 = attacker.attacker_info.last_effect[_index2];
if (attacker.is_real) {
this.playMagic(attacker, _element2);
} else {
this.hook_model.playMagic(attacker, _element2);
}
}
}
}.bind(this));
if (act_list.length > 1) {
var act_start = this.skill_act.normalStart(attacker);
var act_finish = this.skill_act.normalFinish(attacker);
var act = cc.sequence(act_start, cc.spawn.apply(null, act_list), act_finish);
attacker.runAction(act);
} else {
if (act_list.length == 0) return; //列表為空
//動作列表只有一個
var act_start2 = this.skill_act.normalStart(attacker);
var act_finish2 = this.skill_act.normalFinish(attacker);
var act2 = cc.sequence(act_start2, act_list[0], act_finish2);
attacker.runAction(act2);
}
}
}.bind(this);
return this.skill_act.attack(attacker, delay_time, anima_name, null, null, false, attack_func, attacker.anime_res);
},
// 渐隐掉的播报
fadeOut: function fadeOut(attacker, delay_time, time) {
time = time || 10;
return this.skill_act.fadeOut(attacker, delay_time, time);
},
// 渐现出来
fadeIn: function fadeIn(attacker, delay_time, time) {
time = time || 1;
return this.skill_act.fadeIn(attacker, delay_time, time);
},
// 处理友方特效
playSelfEffect: function playSelfEffect(attacker) {
if (attacker == null || !attacker.isValid || attacker.attacker_info == null || attacker.attacker_info.target_list == null) return;
var last_effect = [];
var target = null;
for (var index = 0; index < attacker.attacker_info.target_list.length; index++) {
var element = attacker.attacker_info.target_list[index];
target = this.getBattleRoleByPos(element.target);
if (target && attacker.group == target.group) {
last_effect.push(element);
}
}
attacker.attacker_info.effect_play = last_effect;
attacker.attacker_info.last_effect = last_effect;
},
// 回合播报结束设置施法者战力动作
resetAttackerStandStatus: function resetAttackerStandStatus(attacker) {
if (this.battle_scene == null || attacker == null || !attacker.isValid) {
return;
}
var next_round_actor = 0;
if (this.next_round) {
next_round_actor = this.next_round.actor;
}
if (this.cur_round) {
this.last_round_actor = this.cur_round.actor;
}
if (next_round_actor == 0 || this.cur_round && this.cur_round.actor != next_round_actor) {
this.skill_act.setAnimation(attacker, PlayerAction.battle_stand, true);
// this.cancelRoleBlackScreen();
this.cancleBlackScreen();
attacker.resetZOrder();
}
},
/**
* 实例化远程子弹动作
* @param {*} attacker
* @param {*} delay_time
* @param {*} effect_name
* @param {*} move_time
* @param {*} funname
* @param {*} start_height
* @param {*} target_pos
* @param {*} scale
* @param {*} bid
* @param {*} x_fix
* @param {*} y_fix
*/
item: function item(attacker, delay_time, effect_name, move_time, funname, start_height, target_pos, scale, bid, x_fix, y_fix, finish_delay) {
if (attacker == null || !attacker.isValid || this.battle_scene == null) {
return;
}
start_height = (start_height || 0) * attacker.model_height * 0.01;
move_time = move_time || 10;
var hit_callback = function () {
this.callfun(attacker, funname);
// 这里暂时注释掉不知道有没有问题
// if(attacker.attacker_info.target_list.length > 0){
// attacker.attacker_info.target_list.unshift();
// }
}.bind(this);
// if (!attacker.is_real){
// // hit_callback();
// }else{
attacker.runAction(this.skill_act.flyItem(attacker, delay_time, effect_name, move_time, hit_callback, start_height, target_pos, scale, bid, x_fix, y_fix, finish_delay));
// }
},
/**
* 获取移动动作
* @param {*} attacker
* @param {*} delay_time
* @param {*} effect_name
* @param {*} move_time
* @param {*} funname
* @param {*} start_height
* @param {*} target_pos
* @param {*} scale
* @param {*} bid
* @param {*} x_fix
* @param {*} y_fix
*/
getItem: function getItem(attacker, delay_time, effect_name, move_time, funname, start_height, target_pos, scale, bid, x_fix, y_fix) {
start_height = start_height || 60;
move_time = move_time || 10;
var hit_callback = function () {
this.callfun(attacker, funname);
// 这里暂时注释掉不知道有没有问题
// if(attacker.attacker_info.target_list.length > 0){
// attacker.attacker_info.target_list.unshift();
// }
}.bind(this);
var act = this.skill_act.flyItem(attacker, delay_time, effect_name, move_time, hit_callback, start_height, target_pos, scale, bid, x_fix, y_fix);
return act;
},
// 播报,动作施法者
playOrder: function playOrder(attacker) {
if (attacker == null || !attacker.isValid) return;
if (attacker.wait_act && attacker.wait_act != 0) return;
// 没有技能效果的时候,直接移除掉
if (attacker.play_order_index == null || attacker.play_order_index == 0) return;
// 每个动作的计数器,当一个动作开始之后开始计数,为0标识这个动作做完了
attacker.wait_act = 0;
if (attacker.play_order == null || attacker.play_order.length == 0) {
this.actor_play_sum += 1;
if (!attacker.is_die) {
this.resetAttackerStandStatus(attacker);
}
if (!attacker.is_round) {
this.act_playing = false;
if (this.actor_play_sum >= this.actor_sum) {
this.round();
}
}
} else {
var index = attacker.play_order.shift();
var act = this.singleAct(index, attacker);
if (act) {
attacker.runAction(act);
}
}
},
// 处理群攻效果,比如说音效不要播太多
batchPlayHurt: function batchPlayHurt(attacker) {
if (attacker == null || !attacker.isValid || attacker.attacker_info == null || attacker.attacker_info.target_list == null) {
return;
}
var target_list = attacker.attacker_info.target_list;
if (target_list.length == 0) {
return;
}
var had_play = false; // 多个受击音效只需要播放一次
for (var index = 0; index < target_list.length; index++) {
var element = target_list[index];
if (attacker.is_real) {
var play_effect = false;
if (element.hp_changed && element.hp_changed < 0 && had_play == false) {
had_play = true;
play_effect = true;
}
this.playMagic(attacker, element, play_effect);
} else {
this.hook_model.playMagic(attacker, element, play_effect);
}
}
},
/**
* 播放普通战斗飘字
* @param {*} target 战斗目标单位
* @param {*} desc 当前文本
* @param {*} parent 父节点,如果没有,则默认是战斗场景特效层1
* @param {*} x x方向的偏移值
* @param {*} y y方向的偏移值
* @param {*} color 文字颜色
* @param {*} outline 文字描边色
*/
playFontMessage: function playFontMessage(target, desc, parent, x, y, color, outline, callback) {
if (this.checkIsInBattle(target) == false) {
return;
}
if (parent == null) {
parent = this.battle_scene.getBattleEffectLayer(1); // 默认放在特效1层上面
}
x = x || 0;
y = y || 0;
var target_x = target.scene_pos.x + x;
var target_y = target.scene_pos.y + y + target.model_height / 2;
if (color == null) {
color = 217;
}
if (outline == null) {
outline = 218;
}
// 设置字体默认颜色
var normal_node = this.getNormalFont();
if (normal_node && normal_node.isValid) {
normal_node.setPosition(target_x, target_y);
nx.gui.setSpriteFrame(normal_node, "", cc.js.formatStr("locals/%s/images/bufftxt/%s", nx.getLocLanguage(), desc));
parent.addChild(normal_node);
if (target.buff_show_index == null) {
target.buff_show_index = 0;
}
target.buff_show_index = target.buff_show_index + 1;
var show = cc.show();
var delay = cc.delayTime(0.3 * target.buff_show_index);
var delay_over = cc.callFunc(function () {
target.buff_show_index -= 1;
}.bind(this));
var scale_to_1 = cc.scaleTo(0.2, 1.2);
var move_by_1 = cc.moveBy(0.2, 0, 50);
var fade_in = cc.fadeIn(0.2);
var scale_to_2 = cc.scaleTo(0.4, 1);
var fade_out = cc.fadeOut(0.4);
var move_by_2 = cc.moveBy(0.4, 0, 25);
var hide = cc.hide();
normal_node.runAction(cc.sequence(show, delay, delay_over, cc.spawn(scale_to_1, move_by_1, fade_in), cc.delayTime(0.5), cc.spawn(scale_to_2, fade_out, move_by_2), hide, cc.callFunc(function () {
if (callback) {
callback();
}
this.pushBackBattleFont(normal_node);
normal_node.destroy();
}.bind(this))));
}
},
/**
* 播放魔法特效
* @param {*} attacker
* @param {*} effect_play
* @param {*} no_die
* @param {*} play_effect
*/
playMagic: function playMagic(attacker, effect_play, play_effect) {
if (this.battle_scene == null) {
return;
}
if (effect_play.target == null) {
return;
}
if (attacker == null || !attacker.isValid) {
return;
}
if (effect_play.play_num != null && effect_play.play_num <= 0) {
return;
}
if (effect_play.play_num == null && attacker.split_hurt) {
effect_play.play_num = attacker.split_hurt || 1;
if (effect_play.play_num > 1) {
effect_play.avg_hp_changed = Math.ceil(effect_play.hp_changed / effect_play.play_num);
}
}
effect_play.play_num = effect_play.play_num || 1;
effect_play.play_num -= 1;
var effect_hit = 1;
var is_selfdmg = false;
var target = this.getBattleRoleByPos(effect_play.target);
if (target) {
if (effect_play.is_hit == 0 || effect_play.is_blind == 1) {
// 闪躲或者未命中
effect_hit = 0;
var desc = nx.text.getKey("lab_battle_model_tip3");
if (effect_play.is_blind == 1) {
desc = nx.text.getKey("lab_battle_model_tip4");
}
if (effect_play.is_dead == 0) {
// 非死亡情况下才飘字
this.playFontMessage(target, desc, null, null, null, 227, 228);
}
}
var hp_changed = effect_play.avg_hp_changed || effect_play.hp_changed || 0;
var dmg = Math.floor(hp_changed);
if (effect_play.is_crit == 1) {
// 暴击
effect_hit = 2;
is_selfdmg = true;
}
var is_dead = effect_play.is_dead;
if (effect_play.play_num > 0) {
// 多次伤害的话第一次不能死
is_dead = 0;
is_selfdmg = true;
}
if (dmg < 0) {
is_selfdmg = true;
}
// 处理召唤列表
if (effect_play.summon_list.length > 0) {
this.addRoleList(effect_play.summon_list, attacker);
}
// 处理子效果
if (effect_play.sub_effect_play_list.length > 0) {
this.handleSubEffectPlaylist(effect_play, attacker);
}
// 副本中需要的特殊处理
var is_my_hurt = false;
if (attacker.is_friend) {
is_my_hurt = true;
}
this.handleExtendDungeon(effect_play, is_my_hurt);
// 处理援护
if (effect_play.aid_actor != 0) {
this.handleAidActor(effect_play, attacker, effect_hit, target);
}
// 播放受击处理
this.playBattleRoleHurt(attacker, target, dmg, play_effect);
// 飘字处理
if (attacker.effect_desc != "" && effect_play.is_hit != 0 && effect_play.play_num <= 0) {
this.showbuffName(target, attacker.effect_desc, 229, 230, attacker.play_order_index);
}
//头像受击特效
if (is_selfdmg && !attacker.is_friend) {
this.handleSelfDmgEffect(attacker);
}
// 把扣血放到最后,因为有死亡动作
this.updateTargetHp(attacker, target, dmg, is_dead, effect_hit, effect_play);
// 处理buff列表,非死亡的时候才处理,如果上面播报已经说死了,不需要处理buff了
if (effect_play.play_num <= 0 && effect_play.buff_list.length > 0) {
this.handleBufflist(attacker, effect_play.buff_list, 1);
}
}
},
// 播放受击处理
playBattleRoleHurt: function playBattleRoleHurt(attacker, target, dmg, play_effect) {
if (attacker == null || !attacker.isValid || target == null) return;
if (target.is_hurt_play == true) return;
target.is_hurt_play = true;
if (!target.is_big_play) {
target.is_big_play = true;
if (!target.is_not_hide) {
this.playHurtEffect(attacker, target);
}
}
if (attacker.pos != target.pos && dmg < 0 && attacker.group != target.group) {
// 播放受击动作
if (attacker.hit_action != "no-hurt") {
this.skill_act.hurt(attacker, target, attacker.hit_action, play_effect);
}
}
},
/**
* 更新血条处理
* @param {*} attacker
* @param {*} target
* @param {*} dmg
* @param {*} is_die
* @param {*} effect_hit 1是是普通, 2是暴击
* @param {*} is_yuanhu
* @param {*} is_normal
* @param {*} effect_play
*/
updateTargetHp: function updateTargetHp(attacker, target, dmg, is_die, effect_hit, effect_play) {
if (target == null) return;
if (attacker == null || !attacker.isValid) return;
if (dmg == 0) return;
effect_hit = effect_hit || 1;
this.mutiHurtNum(target, dmg, effect_hit, false, effect_play.camp_restrain);
// 储存具体数据
target.updateHP(dmg, is_die, false, attacker.is_must_die);
},
/**
* 播放伤害飘血
* @param {*} tatget
* @param {*} dmg
* @param {*} effect_hit 1是是普通, 2是暴击
* @param {*} is_normal
* @param {*} is_buff
* @param {*} camp_restrain
*/
mutiHurtNum: function mutiHurtNum(target, dmg, effect_hit, is_buff, camp_restrain) {
if (this.checkIsInBattle(target) == false || dmg == 0 || target.is_real == false) {
return;
}
if (target.type == BattleConst.BattleObjectType.Elfin) return; // 精靈不處理飄血
// 这个数值用于处理飘血高度的...放置叠加到一起
if (target.dmg_index == null) {
target.dmg_index = 0;
}
target.dmg_index += 1;
this.skill_act.playDmgMessage(target, dmg, effect_hit, is_buff, camp_restrain);
},
/**
* 处理buff效果
* @param {*} attacker
* @param {*} list
* @param {*} effect_hit 是否是暴击
*/
handleBufflist: function handleBufflist(attacker, list, effect_hit) {
if (this.checkIsInBattle(attacker) == false) {
return;
}
for (var index = 0; index < list.length; index++) {
var buff = list[index];
var target = this.getBattleRoleByPos(buff.target);
if (target) {
this.playRoundBuff(target, buff, attacker, effect_hit);
}
}
},
/**
* 添加一个buf
* @param {*} attacker buff的发起者.可能没有
* @param {*} target
* @param {*} buff
*/
addBuff: function addBuff(attacker, target, buff) {
if (target == null || buff == null) return;
var buff_data = gskilldata('data_get_buff', buff.buff_bid); //game.configs.skill_data.data_get_buff[buff.buff_bid];
if (buff_data == null) return;
if (buff.action_type == 7) return; // 這類buff不做任何處理,直接跳出去
if (buff_data.is_passive == 1) {
this.playBuffEffect(attacker, target, buff, buff_data);
}
if (buff.action_type == 4) return;
if (buff.action_type == 2 || buff.action_type == 6) {
this.removeBuff(target, buff, buff_data);
} else {}
if (buff_data.is_passive == 1 || buff_data.group == 3211) {
// 不可复活组的buff额外处理
if (buff.action_type == 1 || buff.action_type == 3 || buff.action_type == 5) {
// 主处理新增或者是展示的buff
if (buff_data.group != 3211) {
if (buff_data.buff_spine && buff_data.buff_spine != "" && !target.is_die) {
// 存在变身的buff
target.changeSpine(true, buff_data.buff_spine, PlayerAction.battle_stand);
}
if (buff_data.group == 3703) {
// 隐身buff
target.setOpacity(true, 155);
}
if (buff_data.group == 128 || buff_data.group == 1285) {
attacker.is_not_hide = true;
}
}
if (buff.action_type != 3 && buff.remain_round != 0) {
// 新增buff才处理,这里主要是开始增加血条下面的bufficon
target.updateBuffList(buff, buff_data);
}
}
}
},
// 移除一个buff,包含移除一个对象的特效和移除一个buff图标
removeBuff: function removeBuff(target, buff, buff_data) {
if (this.getBattleScene() == null || target == null) return;
if (buff == null || buff_data == null) return;
var had_buff = target.hadBuff(buff.id);
if (had_buff == true) {
target.removeBuffList(buff.id); // 移除一个buff,并且包含移除buff图标
if (buff_data.group == 3703) {
// 隐身buff
target.setOpacity(false);
}
if (target.is_die) {
if (target.is_change_status && buff_data.buff_spine && buff_data.buff_spine != "") {
// 移除变身效果
target.changeSpine(false);
}
} else {
if (buff.remain_round == 0) {
if (target.is_change_status && buff_data.buff_spine && buff_data.buff_spine != "") {
// 移除变身效果
target.changeSpine(false);
}
}
}
// 如果是场景buff,则移除
var effect_config = game.configs.skill_data.data_get_effect_data[buff_data.res];
if (effect_config && effect_config.play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
this.removeSceneBuffEffect(target.group, effect_config.bid);
}
// 移除buff存在的特效绑在自身上的
if (effect_config) {
this.removeBattleSpineEffect(target, effect_config);
}
}
},
// 添加一个场景buff特效
addSceneBuffEffect: function addSceneBuffEffect(group, bid, effect_res, effect) {
if (group == null || bid == null || effect_res == null || effect == null) return;
var key = Utils.getNorKey(group, bid);
if (this.scene_buff_effect_list[key] == null) {
this.scene_buff_effect_list[key] = {};
}
// 如果存在的话,先丢到对象池里面去
if (this.scene_buff_effect_list[key][effect_res]) {
this.delBattleEffect(this.scene_buff_effect_list[key][effect_res]);
}
this.scene_buff_effect_list[key][effect_res] = effect;
},
// 移除一个场景buff特效
removeSceneBuffEffect: function removeSceneBuffEffect(group, effect_bid) {
if (group == null || effect_bid == null) {
if (this.scene_buff_effect_list) {
for (var key in this.scene_buff_effect_list) {
for (var res in this.scene_buff_effect_list[key]) {
var effect = this.scene_buff_effect_list[key][res];
this.delBattleEffect(this.scene_buff_effect_list[key][effect]);
}
}
this.scene_buff_effect_list = {};
}
} else {
var key = Utils.getNorKey(group, effect_bid);
var effect_list = this.scene_buff_effect_list[key];
if (effect_list) {
for (var key in effect_list) {
this.delBattleEffect(effect_list[key]);
}
}
this.scene_buff_effect_list[key] = null;
}
},
// 移除一个绑在单位身上的buff特效,这里会根据特效配置去判断上下层特效资源
removeBattleSpineEffect: function removeBattleSpineEffect(target, effect_config) {
if (target == null || effect_config == null) return;
var action_name = PlayerAction.action;
if (effect_config.up_action_name != "") {
action_name = effect_config.up_action_name;
}
target.delBattleEffect(effect_config.res_up, action_name); // 移除上层特效
action_name = PlayerAction.action;
if (effect_config.down_action_name != "") {
action_name = effect_config.down_action_name;
}
target.delBattleEffect(effect_config.res_down, action_name); // 移除下层特效
},
// 播放buff效果,以及添加bufficon等
playBuffEffect: function playBuffEffect(attacker, target, buff, buff_data) {
if (buff == null || buff_data == null) return;
var text_color = null;
var outline_color = null;
if (buff_data.client_desc != "") {
if (buff.action_type == 1 || buff.action_type == 4) {
// 增益
if (buff_data.positive_or_negative == 1) {
text_color = 221;
outline_color = 222;
} else if (buff_data.positive_or_negative == 2) {
// 减益
text_color = 223;
outline_color = 224;
} else if (buff_data.positive_or_negative == 3) {
// 控制
text_color = 225;
outline_color = 226;
}
this.showbuffName(target, buff_data.client_desc, text_color, outline_color, buff.buff_bid);
}
}
if (attacker == null || !attacker.isValid) return;
var hadbuff = target.hadBuff(buff.id);
if (!hadbuff && buff.action_type == 1 && buff_data.res != 0) {
// 不存在的buff才需要处理
var config = game.configs.skill_data.data_get_effect_data[buff_data.res];
if (config) {
if (config.play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
var key = Utils.getNorKey(target.group, buff_data.res);
if (this.scene_buff_effect_list[key] == null || Utils.next(this.scene_buff_effect_list[key]) == false) {
this.effectArea(attacker, [config.res_up, config.res_down], 0, null, config.play_type, config.x_fix, config.y_fix, buff_data.res, config.is_col_effect, false);
}
} else {
this.effectSpineUser(attacker, buff_data.is_release == 1, config.x_fix * target.obj_type, config.y_fix, [config.res_up, config.res_down], target, 1, null, buff_data.bid, buff_data.res);
}
}
}
// 一次效果
if (buff.action_type == 3 && buff_data.efftive_effect != 0) {
var config = game.configs.skill_data.data_get_effect_data[buff_data.efftive_effect];
if (config) {
this.effectSpineUser(attacker, true, config.x_fix * target.obj_type, config.y_fix, [config.res_up, config.res_down], target, 1, null, buff_data.bid, buff_data.res);
}
}
},
// 播放buff描述文字,这里需要对这个对象做判断,如果bid的飘字存在,则不处理了...
showbuffName: function showbuffName(target, desc, color, outline_color, bid) {
if (target == null || bid == null) return;
if (target.tips_list[bid]) return;
target.addTips(bid);
var callback = function () {
target.removeTips(bid);
}.bind(this);
this.playFontMessage(target, desc, null, null, null, color, outline_color, callback);
},
/**
* 添加召唤列表
* @param {*} list
* @param {*} attacker
*/
addRoleList: function addRoleList(list, attacker) {
if (list == null || list.length == 0) return;
},
/**
* 处理子效果
* @param {*} effect_play
* @param {*} attacker
*/
handleSubEffectPlaylist: function handleSubEffectPlaylist(effect_play, attacker) {
if (effect_play == null || effect_play.sub_effect_play_list == null || effect_play.sub_effect_play_list.length == 0) return;
for (var index = 0; index < effect_play.sub_effect_play_list.length; index++) {
var element = effect_play.sub_effect_play_list[index];
var sub_target = this.real_role_list[element.sub_target];
if (sub_target) {
// 播放气血变化的
this.battleRoleHPChange(sub_target, element.sub_hp_changed, false, 1, true);
if (element.extra_effect && element.extra_effect.length > 0) {
for (var n = 0; n < element.extra_effect.length; n++) {
var extra = element.extra_effect[n];
if (extra.extra_key == 2) {
// 护盾吸收
this.skill_act.playBuffAbsorbHurt(sub_target, extra.extra_param);
}
}
}
// 技能效果是否飘字
var effect_config = gskilldata('data_get_effect', element.sub_effect_id);
if (effect_config && effect_config.effect_desc != "" && element.sub_is_hit != 0) {
this.showbuffName(sub_target, effect_config.effect_desc, 229, 230, element.sub_effect_id);
}
// 被动技能是否飘字
var skill_config = gskilldata('data_get_skill', element.sub_skill_id);
if (skill_config && skill_config.passive_skill_show == 1) {
this.showbuffName(sub_target, skill_config.name, 281, 2, element.sub_skill_id);
}
// 闪躲处理
if (element.sub_is_hit == 0 && effect_play.is_dead == 0) {
this.showbuffName(sub_target, nx.text.getKey("lab_battle_miss"), 280, 2, element.sub_effect_id);
}
}
}
},
/**
* 副本数据特殊处理
* @param {*} effect_play
*/
handleExtendDungeon: function handleExtendDungeon(effect_play, is_my_hurt) {
//总伤害统计
if (this.battle_data == null) return;
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_TOTALHURT, effect_play.hp_changed, is_my_hurt);
// if(this.form_fight_ui){
// this.form_fight_ui.addTotalHurt(effect_play.hp_changed,is_my_hurt);
// }
if (this.battle_data == null || this.battle_data.combat_type != BattleConst.Fight_Type.GuildDun) return;
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_GUILDBOSS, effect_play.total_hurt, true);
// if(this.form_fight_ui){
// this.form_fight_ui.addGuildBossUI(effect_play.total_hurt)
// }
},
/**
* 副本数据特殊处理
* @param {*} attacker
*/
handleSelfDmgEffect: function handleSelfDmgEffect(attacker) {
gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_SELFDMG, attacker);
// if(this.form_fight_ui){
// this.form_fight_ui.showSelfDmgEff(attacker);
// }
},
//添加己方buff
handleSelfFriendBuff: function handleSelfFriendBuff(object_bid, buff_data_list) {
// gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_UPBUFF,object_bid,buff_data_list);
// if(this.form_fight_ui){
// this.form_fight_ui.clearFriendBuff();
// this.form_fight_ui.addFriendBuff(object_bid,buff_data_list)
// }
},
/**
* 处理援护
* @param {*} effect_play
* @param {*} attacker
* @param {*} effect_hit 是否暴击
* @param {*} target
*/
handleAidActor: function handleAidActor(effect_play, attacker, effect_hit, target) {
if (effect_play == null || effect_play.aid_actor == 0) return;
var aid_target = this.real_role_list[effect_play.aid_actor];
if (aid_target) {
var aid_dmg = effect_play.actor_hp_changed; // 援护者血量变化
var friend_pos = target.scene_pos; //
var role_width = target.model_width * target.obj_type;
var camp_restrain = effect_play.camp_restrain; // 是否是阵营压制
aid_target.setLocalZOrder(target.getLocalZOrder() + 1); // 层级放到上面来
aid_target.setScenePos(cc.v2(friend_pos.x + role_width, friend_pos.y)); // 设置援护坐标
this.actStart(attacker);
//下个施法对象是否为当前对象,来应对受击特效
// aid_target.is_aid = true;
// if(this.next_round){
// aid_target.is_doing_aid = this.cur_round.actor == this.next_round.actor;//当前正在援护
// }else{
// aid_target.is_doing_aid = false;
// }
this.skill_act.aid_hurt(attacker, aid_target, "hurt");
this.battleRoleHPChange(aid_target, aid_dmg, effect_play.actor_is_dead, effect_hit, false, camp_restrain);
if (!aid_target.is_doing_aid) {
this.playHurtEffect(attacker, aid_target);
}
}
},
/**
* 播放伤害特效
* @param {*} attacker
* @param {*} target
*/
playHurtEffect: function playHurtEffect(attacker, target) {
if (this.battle_scene == null || attacker == null || !attacker.isValid || attacker.hit_effect_list == null || attacker.hit_effect_list.length == 0) {
return;
}
var array = attacker.hit_effect_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
this.effectSpineUser(attacker, true, element.x_fix * attacker.obj_type, element.y_fix, [element.res_up, element.res_down], target, element.scale * 0.001, null, element.bid);
}
},
/**
* 出手前动作
* @param {*} attacker
*/
attackReady: function attackReady(attacker) {
if (attacker == null || !attacker.isValid) {
return;
}
if (attacker.bact_effect_list == null || attacker.bact_effect_list.length == 0) {
return;
}
// 播放出手前音效
if (attacker.ready_sound && attacker.ready_sound != "" && attacker.is_real == true) {
nx.audio.playSFX("audios/combats/" + attacker.ready_sound);
}
var array = attacker.bact_effect_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (element && element.play_type == BattleConst.Effect_Play_Type.ROLE) {
if (element.res_up != "" || element.res_down != "") {
this.effectSpineUser(attacker, true, element.x_fix * attacker.obj_type, element.y_fix, [element.res_up, element.res_down], attacker, element.scale * 0.001, null, element.bid);
}
}
}
},
/**
* 创建单位跟随特效
* @param {*} attacker
* @param {*} is_release
* @param {*} x_fix
* @param {*} height
* @param {*} effect_list
* @param {*} target 目标对象,也可能是自己,也可能是被攻击者
* @param {*} scale
* @param {*} callback
* @param {*} bid
* @param {*} buff_bid 如果这个值不为0,即最终值
*/
effectSpineUser: function effectSpineUser(attacker, is_release, x_fix, height, effect_list, target, scale, callback, bid, buff_bid) {
if (buff_bid && buff_bid != 0) {
bid = buff_bid;
}
var obj_type = BattleConst.Battle_Type_Conf.TYPE_ROLE;
if (attacker) {
obj_type = attacker.obj_type;
}
this.skill_act.effectSpineUser(attacker, is_release, x_fix, height, effect_list, target, scale, callback, bid, obj_type);
},
// 群攻
areaHurt: function areaHurt(attacker) {
var hurt_func = function () {
if (this.battle_scene) {
var role_list = this.getAllBattleRoleList();
for (var key in role_list) {
var role = role_list[key];
if (role) {
role.is_hurt_play = false;
role.is_big_play = false;
}
}
}
this.batchPlayHurt(attacker);
}.bind(this);
this.playSceneAreaEffect(attacker, hurt_func);
},
// 播放范围特效
playSceneAreaEffect: function playSceneAreaEffect(attacker, callback) {
if (attacker == null || !attacker.isValid || attacker.play_order_index == null || attacker.area_effect_list == null || attacker.area_effect_list.length == 0) {
return;
}
var array = attacker.area_effect_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (element && (element.res_down != "" || element.res_up != "")) {
this.effectArea(attacker, [element.res_up, element.res_down], 0, callback, element.play_type, element.x_fix, element.y_fix, element.bid, element.is_col_effect);
}
}
},
// 播放全屏范围演出特效
playSceneGroundEffect: function playSceneGroundEffect(attacker) {
if (attacker == null || !attacker.isValid || attacker.play_order_index == null || attacker.bg_effect_list == null || attacker.bg_effect_list.length == 0) {
return;
}
var array = attacker.bg_effect_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
if (element && (element.res_down != "" || element.res_up != "")) {
this.effectGroundArea(attacker, [element.res_up, element.res_down], 0, element.play_type, element.x_fix, element.y_fix, element.bid, element.is_col_effect);
}
}
},
effectGroundArea: function effectGroundArea(attacker, effect_list, height, play_type, x_fix, y_fix, bid, is_col_effect, is_release) {
height = height || 0;
var reverse = attacker.obj_type;
var is_left = attacker.is_friend;
var scene_pos = null;
if (is_col_effect == 1) {
var temp_list = null;
if (is_left) {
temp_list = [{
x: 34,
y: 17
}, {
x: 34,
y: 23
}, {
x: 34,
y: 29
}];
} else {
temp_list = [{
x: 44,
y: 17
}, {
x: 44,
y: 23
}, {
x: 44,
y: 29
}];
}
var pos = temp_list[attacker.col];
if (pos) {
var temp_pos = this.skill_act.gridPosToScreenPos(pos);
scene_pos = {
x: temp_pos.x + x_fix,
y: temp_pos.y + y_fix
};
}
} else {
if (play_type == BattleConst.Effect_Play_Type.SCENE) {
// 暂时看到是作废的
scene_pos = {
x: SCREEN_WIDTH * 0.5,
y: SCREEN_HEIGHT * 0.5
};
} else if (play_type == BattleConst.Effect_Play_Type.ROLE_SCENE || play_type == BattleConst.Effect_Play_Type.ENEMY_SCENE) {
x_fix = attacker.obj_type * x_fix;
if (is_left) {
if (play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
// 友方阵型
scene_pos = {
x: SCREEN_WIDTH * 22 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
} else {
// 敌方阵型
scene_pos = {
x: SCREEN_WIDTH * 78 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
}
} else {
if (play_type == BattleConst.Effect_Play_Type.ENEMY_SCENE) {
scene_pos = {
x: SCREEN_WIDTH * 22 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
} else {
scene_pos = {
x: SCREEN_WIDTH * 78 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
}
}
} else {
scene_pos = this.center_pos(attacker);
}
}
if (scene_pos) {
scene_pos.y = scene_pos.y + height;
this.skill_act.effectGroundArea(attacker, effect_list, reverse, is_release, scene_pos, bid);
}
},
/**
* 播放范围特效
* @param {*} attacker
* @param {*} effect_list
* @param {*} height
* @param {*} is_reverse
* @param {*} hit_callback
* @param {*} play_type
* @param {*} x_fix
* @param {*} y_fix
* @param {*} bid
* @param {*} is_col_effect
* @param {*} is_release 播完是否释放
*/
effectArea: function effectArea(attacker, effect_list, height, hit_callback, play_type, x_fix, y_fix, bid, is_col_effect, is_release) {
height = height || 0;
var reverse = attacker.obj_type;
var is_left = attacker.is_friend;
var scene_pos = null;
if (is_col_effect == 1) {
var temp_list = null;
if (is_left) {
temp_list = [{
x: 34,
y: 17
}, {
x: 34,
y: 23
}, {
x: 34,
y: 29
}];
} else {
temp_list = [{
x: 44,
y: 17
}, {
x: 44,
y: 23
}, {
x: 44,
y: 29
}];
}
var pos = temp_list[attacker.col];
if (pos) {
var temp_pos = this.skill_act.gridPosToScreenPos(pos);
scene_pos = {
x: temp_pos.x + x_fix,
y: temp_pos.y + y_fix
};
}
} else {
if (play_type == BattleConst.Effect_Play_Type.SCENE) {
// 暂时看到是作废的
scene_pos = {
x: SCREEN_WIDTH * 0.5,
y: SCREEN_HEIGHT * 0.5
};
} else if (play_type == BattleConst.Effect_Play_Type.ROLE_SCENE || play_type == BattleConst.Effect_Play_Type.ENEMY_SCENE) {
x_fix = attacker.obj_type * x_fix;
if (is_left) {
if (play_type == BattleConst.Effect_Play_Type.ROLE_SCENE) {
// 友方阵型
scene_pos = {
x: SCREEN_WIDTH * 22 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
} else {
// 敌方阵型
scene_pos = {
x: SCREEN_WIDTH * 78 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
}
} else {
if (play_type == BattleConst.Effect_Play_Type.ENEMY_SCENE) {
scene_pos = {
x: SCREEN_WIDTH * 22 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
} else {
scene_pos = {
x: SCREEN_WIDTH * 78 / 100 + x_fix,
y: SCREEN_HEIGHT * 1 / 4 + y_fix
};
}
}
} else if (play_type == BattleConst.Effect_Play_Type.ROLE) {
if (attacker.node && attacker.node.position) {
x_fix = attacker.obj_type * x_fix;
scene_pos = {
x: attacker.node.x + x_fix,
y: attacker.node.y + y_fix
};
} else {
scene_pos = attacker.scene_pos;
}
} else if (play_type == BattleConst.Effect_Play_Type.TARGET) {
if (this.is_real_combat) {
var tag_list = attacker.attacker_info.target_list;
if (tag_list.length > 0) {
var tag_role = tag_list[0];
var erole = this.getBattleRoleByPos(tag_role.target);
if (erole) {
scene_pos = erole.scene_pos;
} else {
scene_pos = this.center_pos(attacker);
}
}
} else {
//假战斗只获取中间位置
var _pos = this.skill_act.newPos2Gird(5, false, 0, false);
scene_pos = this.skill_act.gridPosToScreenPos(_pos);
}
} else {
scene_pos = this.center_pos(attacker);
}
}
if (scene_pos) {
scene_pos.y = scene_pos.y + height;
this.skill_act.effectArea(attacker, effect_list, reverse, is_release, scene_pos, hit_callback, bid);
}
},
// 获取施法者目标对象的中心位置
center_pos: function center_pos(attacker, height_fix) {
height_fix = height_fix || 0;
var scene_pos = {
x: 0,
y: 0
};
if (this.battle_scene && attacker && attacker.attacker_info && attacker.attacker_info.target_list && attacker.attacker_info.target_list.length > 0) {
var array = attacker.attacker_info.target_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
var target = this.getBattleRoleByPos(element.target);
if (target && target.scene_pos) {
scene_pos.x = target.scene_pos.x;
scene_pos.y = target.scene_pos.y + target.model_height * height_fix * 0.01; // 这个计算位置好奇葩..竟然不是直接用偏移高度去算..
break;
}
}
}
return scene_pos;
},
// 播放攻击动作之类的
actHurt: function actHurt(attacker, is_big) {
if (attacker == null || !attacker.isValid || attacker.attacker_info == null || attacker.attacker_info.target_list == null) return;
var had_play = false;
for (var index = 0; index < attacker.attacker_info.target_list.length; index++) {
var effect_list = attacker.attacker_info.target_list[index];
var play_effect = false;
if (effect_list.hp_changed && effect_list.hp_changed < 0 && had_play == false) {
had_play = true;
play_effect = true;
}
this.playMagic2(attacker, effect_list, is_big, play_effect);
}
},
// 提前播放受击特效,回播受击动作
playMagic2: function playMagic2(attacker, effect_play, is_big, play_effect) {
if (attacker == null || !attacker.isValid || effect_play == null) return;
var target = this.real_role_list[effect_play.target];
if (target == null) return;
if (is_big == true) {
if (!target.is_big_play) {
target.is_big_play = true;
this.playHurtEffect(attacker, target);
}
} else {
if (attacker.pos != target.pos && attacker.group != target.group) {
this.skill_act.hurt(attacker, target, PlayerAction.hurt, play_effect);
}
}
},
// 攻击上层特效处理
attackPoint: function attackPoint(attacker) {
if (attacker && attacker.attack_sound != "" && attacker.is_real == true) {
nx.audio.playSFX("audios/combats/" + attacker.attack_sound);
}
if (attacker.act_effect_list == null || attacker.act_effect_list.length == 0) {
return;
}
var is_friend = attacker.is_friend;
var array = attacker.act_effect_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
var anime_res_up = element.res_up;
if (element.spec_res_up != "" && is_friend == true) {
anime_res_up = element.spec_res_up;
}
if (anime_res_up != "" || element.res_down != "") {
this.effectSpineUser(attacker, true, element.x_fix * attacker.obj_type, element.y_fix, [anime_res_up, element.res_down], attacker, element.scale * 0.001, null, element.bid);
}
}
},
/**
* 处理普通伤害
* @param {*} attacker
* @param {*} role_list
*/
hurt: function hurt(attacker, object_list) {
if (this.battle_scene == null || attacker == null || !attacker.isValid) {
return;
}
if (attacker.area_effect_list.length == 0) {
var hit_num = !attacker.in_area_effect ? attacker.hit_num : attacker.area_hit_num || 1;
var split_hurt = attacker.split_hurt || 1;
if (hit_num == 1 || split_hurt > 1) {} else {
var role_list = object_list || this.getAllBattleRoleList();
for (var key in role_list) {
var role = role_list[key];
if (role) {
role.is_hurt_play = false;
role.is_big_play = false;
}
}
}
this.batchPlayHurt(attacker);
}
},
/**
* 伤害一个人的时候
* @param {*} attacker
*/
hurtOne: function hurtOne(attacker) {
if (this.checkIsInBattle(attacker) == false) {
return;
}
var effect_play_num = attacker.attacker_info.target_list.length;
if (effect_play_num > 0) {
if (attacker.is_real) {
this.playMagic(attacker, attacker.attacker_info.target_list[0]);
} else {
this.hook_model.playMagic(attacker, attacker.attacker_info.target_list[0]);
}
}
},
// 隐藏血条
hideUI: function hideUI(attacker, delay_time) {
if (attacker) {
return this.skill_act.hideUI(attacker, delay_time);
}
},
hideTeam: function hideTeam(attacker, delay_time) {
if (attacker) {
for (var i in this.real_role_list) {
var role = this.real_role_list[i];
//除了自己和目標不隱藏
if (role.pos != attacker.pos && !role.is_die) {
//不是自己
for (var j in attacker.attacker_info.target_list) {
var tag = attacker.attacker_info.target_list[j];
if (role.pos == tag.target || role.is_not_hide) {
if (role.setVisbale) {
role.setVisbale(true);
}
break;
} else {
if (role.setVisbale) {
role.setVisbale(false);
}
}
}
}
}
}
},
// 无动作并行攻击
noActAttack: function noActAttack(attacker, delay_time, hit_fun, start_fun, next_delay_time) {
if (!this.getBattleScene()) return;
if (!attacker) return;
var start_callback = function () {
this.callfun(attacker, start_fun);
}.bind(this);
var hit_callback = function () {
this.callfun(attacker, hit_fun);
}.bind(this);
return this.skill_act.noActAttack(attacker, delay_time, hit_callback, start_callback, next_delay_time);
},
showTeam: function showTeam(attacker, delay_time) {
if (attacker) {
for (var i in this.real_role_list) {
var role = this.real_role_list[i];
if (role.pos != attacker.pos && !role.is_die) {
if (role.setVisbale) {
role.setVisbale(true);
}
}
}
}
},
// 显示血条
showUI: function showUI(attacker, delay_time) {
if (attacker) {
return this.skill_act.showUI(attacker, delay_time);
}
},
// 判断是否存在反击buff
getBuffTag: function getBuffTag(attacker) {
if (attacker == null || !attacker.isValid || attacker.buff_list == null || attacker.buff_list.length == null) {
return false;
}
var array = attacker.buff_list;
for (var index = 0; index < array.length; index++) {
var element = array[index];
var config = gskilldata('data_get_buff', element.bid); //game.configs.skill_data.data_get_buff[element.bid]
if (config && config.group == 3108) {
return true;
}
}
return false;
},
// 近战移动归位
moveBack: function moveBack(attacker, delay_time, move_time, is_back) {
if (!this.getBattleScene()) return;
if (!attacker) return;
var target_pos = attacker.scene_pos;
var skill_act = this.skill_act.move(attacker, target_pos, delay_time, move_time, is_back);
attacker.runAction(skill_act);
},
// 移动到指定区域
moveToArea: function moveToArea(attacker, config, move_time, is_back) {
if (!this.getBattleScene()) return;
if (!attacker) return;
if (!config) return;
var grid_pos_x = config.move_model_x * this.skill_act.gridSizeX();
var grid_pos_y = config.move_model_y * this.skill_act.gridSizeY();
var target_pos = {
x: SCREEN_WIDTH * 32 / 64 + grid_pos_x * attacker.obj_type,
y: SCREEN_HEIGHT * 11 / 36 + grid_pos_y
};
var skill_act = this.skill_act.move(attacker, target_pos, config.move_delay_time, move_time, is_back);
attacker.runAction(skill_act);
},
// act_args={ [[moveTo]],{ 0, 10,- 7, 0, [[run]], 0, 0, 0, 1, 1}}},
// 移动到目标处
moveTo: function moveTo(attacker, delay_time, move_time, grid_pos_x, grid_pos_y, action_name, is_jump, is_jump_delay, is_get_point, is_move, is_reverse, is_col_act, is_back) {
if (!this.getBattleScene()) return;
if (!attacker) return;
move_time = move_time || 30;
if (grid_pos_x == null) {
grid_pos_x = 0;
}
if (grid_pos_y == null) {
grid_pos_y = 0;
}
var direct = is_reverse == 1 ? -1 : 1;
var target_pos = null;
var scene_pos = attacker.scene_pos;
if (is_col_act == 1) {
var is_left = attacker.is_friend; // 是否是己方,己方就是在左边
var temp_list = null;
if (is_left) {
temp_list = [{
x: 34,
y: 17
}, {
x: 34,
y: 23
}, {
x: 34,
y: 29
}];
} else {
temp_list = [{
x: 44,
y: 17
}, {
x: 44,
y: 23
}, {
x: 44,
y: 29
}];
}
var pos = temp_list[attacker.col];
if (pos) {
var temp_pos = this.skill_act.gridPosToScreenPos(pos);
target_pos = {
x: temp_pos.x + grid_pos_x,
y: temp_pos.y + grid_pos_y
};
}
} else if (grid_pos_x > 0) {
target_pos = {
x: scene_pos.x + grid_pos_x * attacker.obj_type * direct,
y: scene_pos.y + grid_pos_y
};
} else {
if (is_reverse == 1 && attacker.target_pos_base) {
// 反转
target_pos = this.skill_act.gridPosToScreenPos({
x: attacker.target_pos_base.x + grid_pos_x * attacker.obj_type * direct,
y: attacker.target_pos_base.y + grid_pos_y * attacker.obj_type * direct
});
} else {
target_pos = this.skill_act.gridPosToScreenPos({
x: attacker.target_pos.x + grid_pos_x * attacker.obj_type * direct,
y: attacker.target_pos.y + grid_pos_y
});
}
}
if (is_get_point == null || is_get_point == 0) {
var skill_act = this.skill_act.move(attacker, target_pos, delay_time, move_time);
attacker.runAction(skill_act);
} else {
return this.skill_act.move(attacker, target_pos, delay_time, move_time, is_back);
}
},
partnerActEnd: function partnerActEnd(attacker, delay) {
var skill_act = this.skill_act.partnerActEnd(attacker, delay);
attacker.runAction(skill_act);
},
// 一些播报判断
checkIsInBattle: function checkIsInBattle(attacker) {
if (this.battle_scene == null || attacker == null || !attacker.isValid) {
return false;
}
return true;
},
// -------------------------------创景单位这一块,真是战斗单位
createRoleList: function createRoleList() {
var battle_data = this.battle_data;
var need_enter = this.needPlayEnterAction();
for (var key in battle_data.fight_object_list) {
var role_data = battle_data.fight_object_list[key];
this.createRole(role_data, need_enter, true, true);
}
},
// 创建具体单位
createRole: function createRole(role_data, enter_run, talk_back, is_real) {
if (this.battle_scene == null) return;
if (role_data == null || role_data.hp == 0) return;
var role_layer = this.battle_scene.getBattleRoleLayer();
if (role_layer == null) return;
if (this.real_role_list[role_data.pos] != null) return;
// var role = Utils.createClass("battle_role");
// role.createRole(role_layer, role_data, enter_run, talk_back, is_real);
//角色试用
var role = this.batRoleMgr.createRole(role_layer, role_data, enter_run, talk_back, is_real);
role.object_type = role_data.object_type;
this.real_role_list[role_data.pos] = role;
},
// 重置战斗单位初始化信息,比如位置层级和动作状态
resetBattleRoleBaseInfo: function resetBattleRoleBaseInfo() {
for (var key in this.real_role_list) {
var battle_role = this.real_role_list[key];
if (battle_role) {
battle_role.resetBaseInfo();
}
}
},
// 清楚掉单位
clearRealRole: function clearRealRole() {
if (this.real_role_list && Object.keys(this.real_role_list).length == 0) {
return;
}
for (var key in this.real_role_list) {
// 清楚掉定时器
gcore.Timer.del("attackerActTimeout" + key);
var battle_role = this.real_role_list[key];
if (battle_role) {
battle_role.deleteRole();
// this.real_role_list[key] = null;
delete this.real_role_list[key];
}
}
this.real_role_list = {};
},
// 当前所有单位
getAllBattleRoleList: function getAllBattleRoleList() {
return this.real_role_list;
},
// 指定单位上的对象
getBattleRoleByPos: function getBattleRoleByPos(pos) {
if (this.real_role_list[pos]) {
return this.real_role_list[pos];
}
},
// 魅魔技能黑屏,暂时也没配置了
blackScreen: function blackScreen(attacker) {},
// 只显示攻击于被攻击放,暂时都没有配置
blackScreen2: function blackScreen2(attacker) {},
roleBlackScreen: function roleBlackScreen(actor, actor_list) {
var tar_list = [];
tar_list.push(actor);
for (var i = 0; i < actor_list.length; i++) {
var v = actor_list[i];
tar_list.push(v.target);
}
if (tar_list.length == 0) return;
var obj_keys = Object.keys(this.real_role_list);
var tr_list = obj_keys.concat(tar_list).filter(function (v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v);
});
for (var a = 0; a < tr_list.length; a++) {
var tar = tr_list[a];
for (var b in this.real_role_list) {
var role = this.real_role_list[b];
if (tar == b && role.is_allow_black) {
if (role.role_black) {
role.role_black.active = true;
}
}
}
}
},
cancelRoleBlackScreen: function cancelRoleBlackScreen() {
for (var b in this.real_role_list) {
var role = this.real_role_list[b];
if (role.is_allow_black) {
if (role.role_black) {
role.role_black.active = false;
}
}
}
},
// 獲取當前出手次數
getFightActionCount: function getFightActionCount() {
return this.action_count;
},
// 黑屏------后续一律使用这个黑屏
blackScreen3: function blackScreen3(attacker, delay_time, time, alpha) {
if (time == null) {
time = 15;
}
var begin_fun = function () {
if (this.battle_scene) {
// this.roleBlackScreen(attacker.attacker_info.actor,attacker.attacker_info.target_list);
this.battle_scene.setBlack(true, alpha);
}
this.is_black = true;
}.bind(this);
var end_fun = function () {}.bind(this);
return this.skill_act.blackScreen(attacker, delay_time, time, begin_fun, end_fun);
},
// 取消黑屏
cancleBlackScreen: function cancleBlackScreen() {
this.is_black = false;
if (this.battle_scene) {
this.battle_scene.setBlack(false);
}
},
// 震屏
playShakeScreen: function playShakeScreen(shake_id) {
if (shake_id == null || shake_id == 0) return;
if (this.battle_scene) {
this.battle_scene.shakeScreen(shake_id);
}
},
// 隐身,暂时没有配置了
hide: function hide(attacker) {},
// 显示,暂时也没有配置了
show: function show(attacker) {},
// 残影,也是没有配置了
shadow: function shadow(attacker) {},
// 返回主界面控制器
getMainUICtrl: function getMainUICtrl() {
if (this.mainui_ctrl == null) {
this.mainui_ctrl = require("mainui_controller").getInstance();
}
return this.mainui_ctrl;
},
// -------------------------战斗结束
//结算界面
showWin: function showWin(data, is_replay) {
if (data.show_panel_type == null || data.combat_type == null) return;
if (data.show_panel_type == 1) {
// 显示战斗结算界面,这个时候不要立即清除掉,
if (data.combat_type == this.combat_type && this.battle_controller.getWatchReplayStatus() || is_replay == true) {}
// 这个时候都需要显示结算界面
this.setBattleTimeScale(true);
this.showWinView(data);
} else {
this.battle_controller.openFinishView(true, this.getCombatType(), data);
if (data.combat_type == this.combat_type) {
//
if (is_replay == true) {
this.clearView();
} else {
this.clearBattleScene();
// gcore.GlobalEvent.fire(EventId.EXIT_FIGHT, data.combat_type);
}
}
}
},
//游戏退出结算
showWinView: function showWinView(data) {
this.closeFormView();
if (data == null) return;
this.battle_controller.openFinishView(true, data.combat_type, data);
},
//战斗结果
result: function result(data, is_self_exit) {
this.closeFormView();
if (data == null) return;
if (this.cur_fight_type == 2 && this.combat_type == data.combat_type) {
this.clearView();
}
},
clearView: function clearView() {
this.setBattleTimeScale(true); // 还原动作速率
if (this.battle_controller.getWatchReplayStatus() == true) {
// 如果是录像状态下,退出录像
this.battle_controller.setWatchReplayStatus(false);
}
// 派发退出战斗事件,通知各个系统处理
// gcore.GlobalEvent.fire(EventId.EXIT_FIGHT, this.combat_type);
if (this.combat_type == BattleConst.Fight_Type.Darma) {
if (this.battle_controller.checkIsInDramaUIFight()) {
// 剧情副本中结束战斗,则切到假战斗
this.cleanAllBattleEffect();
this.battle_controller.send20060(BattleConst.Fight_Type.Darma);
}
} else {
if (this.battle_controller.getWatchReplayStatus() == true || this.combat_type == BattleConst.Fight_Type.PK || this.combat_type == BattleConst.Fight_Type.HeroTestWar) {
if (this.battle_controller.checkIsInDramaUIFight()) {
// 剧情副本中结束战斗,则切到假战斗
this.cleanAllBattleEffect();
this.battle_controller.send20060(BattleConst.Fight_Type.Darma);
} else {
this.clearBattleScene();
}
} else {
this.clearBattleScene();
}
}
//檢測特殊結算
this.battle_controller.checkSpecialResults();
},
// 播放资产掉落的动作
playResourceCollect: function playResourceCollect(x, y) {
gcore.GlobalEvent.fire(DramaEvent.ResourceCollect, x, y);
},
//获取group
getGroup: function getGroup() {
return this.my_group;
},
getCampIconConfigByIds: function getCampIconConfigByIds(id_list) {
if (!id_list || Utils.next(id_list) == null) return;
if (id_list.length == 1) {
var id = id_list[0];
return game.configs.combat_halo_data.data_halo_icon[id];
} else {
var min_id = Math.min(id_list[0], id_list[1]);
var max_id = Math.max(id_list[0], id_list[1]);
var id1 = min_id * 100;
var id2 = id1 + max_id;
return game.configs.combat_halo_data.data_halo_icon[id2];
}
},
getFormIdListByCamp: function getFormIdListByCamp(dic_camp) {
if (dic_camp && Utils.next(dic_camp) != null) {
var dic_form_id = [];
var configs = game.configs.combat_halo_data.data_halo;
var dic_filter = {};
for (var i in configs) {
var is_match = true;
var config = configs[i];
for (var _i2 in config.pos_info) {
var v = config.pos_info[_i2];
var camp_type = v[0];
var camp_num = v[1];
if (!dic_camp[camp_type] || dic_camp[camp_type] != camp_num) {
is_match = false;
}
}
if (is_match) {
dic_form_id[config.id] = config.id;
if (config.condition != 0) {
dic_filter[config.id] = config.condition; //過濾條件
}
}
}
//過濾
for (var id in dic_filter) {
var condition = dic_filter[id];
if (dic_form_id[condition]) {
dic_form_id[id] = null;
}
}
var form_id_list = [];
for (var _i3 in dic_form_id) {
var _id = dic_form_id[_i3];
form_id_list.push(_id);
}
form_id_list.sort(function (a, b) {
return a < b;
});
return form_id_list;
}
return [];
},
getEffectRes: function getEffectRes(effect_id) {},
// 开始准备战斗资源
preloadBattleRes: function preloadBattleRes(data, finish_cb) {
// skill_plays
// var battle_res = {};
// for (var skill_i in data.skill_plays) {
// var skill_data = data.skill_plays[skill_i]
// for (var effect_i in skill_data.effect_play) {
// var effect_data = skill_data.effect_play[effect_i];
// if (!effect_data.effect_bid)
// continue;
// var effect_config = gskilldata( 'data_get_effect', effect_data.effect_bid);
// if (!effect_config) {
// continue;
// }
// // var actor = this.real_role_list[effect_data.actor];
// var target = this.real_role_list[effect_data.target];
// // 攻击动作资源
// // if (effect_config.anime_res && actor && effect_config.anime_res != "action1") {
// // var anime_res_path = actor.getResPath(effect_config.anime_res);
// // battle_res[anime_res_path] = true;
// // // nx.info("攻击特效资源:",anime_res_path,JSON.stringify(effect_config));
// // }
// // 受击动作资源
// if (effect_config.hit_action && target) {
// if (effect_config.hit_action != "no-hurt") {
// var hit_action_path = target.getResPath(effect_config.hit_action);
// battle_res[hit_action_path] = true;
// }
// }
// // 特效资源加载
// for (var effect_d in AniRes) {
// var effct_list = nx.dt.objClone(this.getCurEffectList(effect_config[AniRes[effect_d]]));
// for (var effect_i in effct_list) {
// var effect_info = effct_list[effect_i];
// if (effect_info.res_up) {
// var action_name = PlayerAction.action;
// var res_path =PathTool.getSpinePath(effect_info.res_up,action_name,false)
// battle_res[res_path] = true;
// }
// if (effect_info.res_down) {
// var action_name = PlayerAction.action;
// var res_path =PathTool.getSpinePath(effect_info.res_down,action_name,false)
// battle_res[res_path] = true;
// }
// }
// }
// }
// }
// var total_num = 0;
// var finish_num = 0;
// for (var battle_i in battle_res) {
// total_num ++;
// }
// for (var battle_i in battle_res) {
// var skeleton_path = battle_i;// + ".atlas"
// nx.res.loadRes(skeleton_path,sp.SkeletonData,()=>{
// finish_num ++;
// if (finish_num == total_num) {
// if (finish_cb)
// finish_cb();
// }
// });
// }
// if (total_num == 0) {
// if (finish_cb)
// finish_cb();
// }
},
changeGroup: function changeGroup(group) {
//轉換組別
var group_temp = this.checkGroup(group);
if (this.battle_controller.getWatchReplayStatus() == true) {
group_temp = group;
} else if (BattleConst.isNeedChangeGroup(this.fight_type)) {
group_temp = group;
}
return group_temp;
},
//轉換組別
checkGroup: function checkGroup(group) {
var temp_group = BattleConst.BattleGroupTypeConf.TYPE_GROUP_ENEMY;
if (group == this.getGroup()) {
temp_group = BattleConst.BattleGroupTypeConf.TYPE_GROUP_ROLE;
}
return temp_group;
},
isLeft: function isLeft(group) {
//是否是左邊
return this.changeGroup(group) == BattleConst.BattleGroupTypeConf.TYPE_GROUP_ROLE;
},
// ----------------- 多戰鬥相關
// --設置是否還有未完成的戰鬥
setUnfinishedWarStatus: function setUnfinishedWarStatus(combat_type, status) {
this.unfinished_war_list = this.unfinished_war_list || {};
this.unfinished_war_list[combat_type] = status;
},
// --根據戰鬥類型判斷是否還有未完成的戰鬥
checkIsHaveUnfinishedWar: function checkIsHaveUnfinishedWar(combat_type) {
var is_have = false;
if (this.unfinished_war_list && this.unfinished_war_list[combat_type] == 1) {
is_have = true;
}
return is_have;
}
});
module.exports = BattleModel;
cc._RF.pop();