1644 lines
64 KiB
JavaScript
1644 lines
64 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '02f16IcbypK9beOp9b1Xx4L', 'battle_role');
|
|
// Scripts/mod/battle/act/battle_role.js
|
|
|
|
// // --------------------------------------------------------------------
|
|
// // @author: shiraho@syg.com(必填, 创建模块的人员)
|
|
// // @description:
|
|
// // 战斗单位实例对象
|
|
// // <br/>Create: new Date().toISOString()
|
|
// // --------------------------------------------------------------------
|
|
|
|
// const BridgeClass = require( "bridge.class" );
|
|
// const { PlayerAction,SCREEN_WIDTH,SCREEN_HEIGHT } = require( "define" );
|
|
// const BattleEvent = require("battle_event");
|
|
// var BattleRolePool = require("battle_role_pool");
|
|
// var PathTool = require("pathtool")
|
|
// var BattleConst = require("battle_const");
|
|
// var BattleEffect = require("battle_effect");
|
|
// var BattleLoop = require("battle_loop")
|
|
|
|
// var BattleRole = cc.Class({
|
|
// extends: cc.Component,
|
|
|
|
// properties: {
|
|
// // skelon_cache: {
|
|
// // default: {}
|
|
// // }
|
|
// },
|
|
|
|
// ctor:function(){
|
|
// // 假战斗才需要,当前这一排是否有其他单位,确定初始位置
|
|
// if (arguments && arguments.length > 0){
|
|
// this.is_next_offset = arguments[0];
|
|
// }else{
|
|
// this.is_next_offset = false;
|
|
// }
|
|
// this.initConfig();
|
|
// },
|
|
|
|
// initConfig:function(){
|
|
// this.role = null;
|
|
// this.parent = null;
|
|
// this.prefabPath = PathTool.getPrefabPath("battle", "battle_real_role");
|
|
// this.role_data = null;
|
|
|
|
// this.top_off_y = 10; // 血条向上的偏移量
|
|
|
|
// this.is_real = false; // 是否是真战斗单位
|
|
// this.play_enter = false; // 是否需要播放进场动画
|
|
// this.talk_back = false; // 是否需要通知播放完成
|
|
|
|
// this.grid_pos = null; // 格子坐标,
|
|
// this.scene_pos = null; // 场景坐标
|
|
// this.is_friend = false; // 是否是友方
|
|
// this.obj_type = 0; // 是己方还是敌方
|
|
// // this.skeletonData_list = {} // 动作列表
|
|
// this.model_height = 120; // 模型的高度
|
|
// this.model_width = 60; // 模型的宽度,暂时先这样,后面加接口计算
|
|
|
|
// this.pos = 0; // 当前站位
|
|
// this.group = 0; // 当前分组
|
|
|
|
// this.spine_name = ""; // 单位资源名字 ,H10000这种
|
|
// this.spine_name_1 = ""; // 单位资源名字 ,H10000这种
|
|
// this.base_spine_name = ""; // 单位初始资源模型,防止变身后无法转换回来
|
|
// this.play_action_name = ""; // 当前动作名字,
|
|
// this.is_aid = false;
|
|
|
|
// //变身参数
|
|
// this.change_spine_res = ""
|
|
// this.change_spine_action = ""
|
|
// this.is_change_status = false
|
|
// this.buff_spine = null;
|
|
|
|
// this.is_round = false; // 当前技能播报是否播放完成
|
|
// this.effect_list = {}; // 挂在身上的特效列表
|
|
|
|
// this.hp_show_status = true; // 是否显示或者隐藏血条
|
|
|
|
// this.is_die = false; // 该单位是否是死亡 == role_data.hp == 0
|
|
// this.role_cur_zorder = 0; // 当前单位深度值
|
|
|
|
// this.in_hurt_act = false; // 是否在播放受击效果中
|
|
// this.need_play_die = false; // 需要播放死亡动作
|
|
// this.is_use_skill = false; // 是否使用皮肤
|
|
// this.fashion_id = 0; // 皮肤映射id
|
|
|
|
// var BattleController = require("battle_controller");
|
|
// this.model = BattleController.getInstance().getModel();
|
|
// this.hook_model = BattleController.getInstance().getHookModel();
|
|
// this.skill_act = require("skill_act");
|
|
|
|
// this.wait_action_name = null;
|
|
// this.wait_res_name = null;
|
|
// this.wait_is_loop = null;
|
|
|
|
// this.tips_list = {}; // 当前飘字记录
|
|
// this.buff_list = {}; // 当前buff列表信息,以唯一id作为key
|
|
// this.buff_list_data = {}; // 当前buff信息,以buff_config.icon作为key
|
|
// this.buff_list_item = {}; // 当前buff的实例化显示对象,以buff_config.icon作为key
|
|
|
|
// this.action_call_list = {}; // 制动动作回调
|
|
|
|
// this.wait_add_effect_list = {}; // 待添加特效
|
|
|
|
// this.dmg_index = 0; // 当前伤害数字的个数
|
|
|
|
// this.elfin_list = []
|
|
// },
|
|
|
|
// /**
|
|
// * 创建战斗单位
|
|
// * @param {*} parent 所在父节点
|
|
// * @param {*} battle_role_data 对象基础数据,BattleRoleData
|
|
// * @param {*} play_enter 是否需要播放进场动画
|
|
// * @param {*} talk_back 是否需要通知进场完成
|
|
// * @param {*} is_real 是否是真实战斗
|
|
// * @param {*} finish_cb 创建完成之后的回调
|
|
// */
|
|
// createRole:function(parent, battle_role_data, play_enter, talk_back, is_real, finish_cb){
|
|
// this.parent = parent;
|
|
// this.role_data = battle_role_data;
|
|
// this.play_enter = false;
|
|
// this.finish_cb = finish_cb;
|
|
// if (!is_real)
|
|
// this.play_enter = false;
|
|
|
|
// this.talk_back = talk_back || false;
|
|
// this.is_real = is_real || false;
|
|
// this.pos = battle_role_data.pos;
|
|
// this.group = battle_role_data.group;
|
|
// this.sprites = battle_role_data.sprites || []
|
|
// this.skills = battle_role_data.skills || []
|
|
// this.is_camera = false;//每次战斗每回合敌我双方只有一个加镜头特效
|
|
// this.is_not_hide = false;
|
|
|
|
// nx.res.loadPrefab( this.prefabPath, ( _err, _fab ) => {
|
|
// // 载入错误
|
|
// if( _err ) {
|
|
// nx.error( "$UI:载入失败!", nx.fmtError( _err ) );
|
|
// nx.dt.fnInvoke( _cb, false, nx.fmtError( _err ) );
|
|
// return;
|
|
// }
|
|
|
|
// // 实例化
|
|
// let role = cc.instantiate( _fab );
|
|
// this.createRootWnd(role);
|
|
// // nx.timers.newTimer( "role"+String(this.pos), 0.1, 1, () => {
|
|
// // this.createRootWnd(role);
|
|
// // nx.timers.delTimer( "role"+String(this.pos) );
|
|
// // } );
|
|
// // 预制常驻
|
|
// nx.assets.pushResident( this.prefabPath, _fab );
|
|
|
|
// } );
|
|
// },
|
|
// // 初始化状态
|
|
// resetInitStatus: function () {
|
|
// if (this.skeleton) {
|
|
// this.skeleton.setToSetupPose();
|
|
// this.skeleton.clearTracks();
|
|
// }
|
|
// },
|
|
|
|
// //繼續使用假戰鬥單位
|
|
// createUnrealRole:function(parent, battle_role_data, play_enter, talk_back, is_real, finish_cb){
|
|
// this.parent = parent;
|
|
// this.role_data = battle_role_data;
|
|
// this.play_enter = false;
|
|
// this.finish_cb = finish_cb;
|
|
// if (!is_real)
|
|
// this.play_enter = false;
|
|
|
|
// this.talk_back = talk_back || false;
|
|
// this.is_real = is_real || false;
|
|
// this.pos = battle_role_data.pos;
|
|
// this.group = battle_role_data.group;
|
|
// this.sprites = battle_role_data.sprites || []
|
|
// this.skills = battle_role_data.skills || []
|
|
|
|
// this.is_die = false;
|
|
|
|
// if (this.role_data.group == BattleConst.Group_Type.Enemgy){
|
|
// this.playUnrealEnterAction();
|
|
// }
|
|
// // 看看有没有待添加的特效
|
|
// // this.checkEffectNeedAdd();
|
|
// },
|
|
|
|
// // 初始化创建对象
|
|
// createRootWnd: function (role) {
|
|
// let valid = this.parent && this.parent.isValid && role && role.isValid ? true : false;
|
|
// if(!valid)return;
|
|
// if(this.role)return;
|
|
// this.role = role;
|
|
// if (this.parent) {
|
|
// this.parent.addChild(this.role);
|
|
// }
|
|
// this.role_node = this.role.getChildByName("role_node"); // 模型节点
|
|
// // this.role_black = this.role_node.getChildByName("black");
|
|
// this.role_died_sp = this.role_node.getChildByName("died").getComponent(sp.Skeleton);
|
|
// this.role_died_sp.node.active = false;
|
|
// this.container = this.role_node.getChildByName("container"); // spine节点
|
|
// this.role_effect = this.role_node.getChildByName("effect");
|
|
// this.top_container = this.role_node.getChildByName("top_container"); // 血条部分
|
|
// this.shadow = this.role_node.getChildByName("shadow"); // 脚底阴影
|
|
// this.boss_bar = this.role_node.getChildByName("boss").getComponent(cc.ProgressBar);
|
|
|
|
// this.progress = this.top_container.getChildByName("hp").getComponent(cc.ProgressBar);
|
|
// this.red = this.top_container.getChildByName("hp").getChildByName("red");
|
|
// this.once = this.top_container.getChildByName("hp").getChildByName("once");
|
|
// this.level = this.top_container.getChildByName("level").getComponent(cc.Label);
|
|
// this.camp = this.top_container.getChildByName("camp").getComponent(cc.Sprite);
|
|
// this.buff_container = this.top_container.getChildByName("buff_container"); // buff的主节点
|
|
|
|
// this.hallow_node = this.role.getChildByName("hallow_node"); // 神器节点
|
|
// // this.round_progress = this.hallow_node.getChildByName("progress").getComponent(cc.ProgressBar); // 回合进度条
|
|
// this.spine_renderer = this.role.getChildByName("spine_renderer"); // 精灵技能
|
|
// this.spine_renderer.active = false;
|
|
|
|
// // 神器和模型区分
|
|
// if (this.role_data.object_type == BattleConst.Unit_Type.Hallows){
|
|
// this.spine = this.hallow_node.getChildByName("spine");
|
|
// this.skeleton = this.spine.getComponent(sp.Skeleton);
|
|
// this.role_node.active = false;
|
|
// this.hallow_node.active = true;
|
|
// this.spine_renderer.active = false;
|
|
// this.spine.scale = 0.8
|
|
// }else if (this.role_data.object_type == BattleConst.Unit_Type.Elfin){
|
|
// this.spine = this.hallow_node.getChildByName("spine");
|
|
// this.skeleton = this.spine.getComponent(sp.Skeleton);
|
|
// this.role_node.active = false;
|
|
// this.hallow_node.active = false;
|
|
// // 初始化精灵节点
|
|
// this.initSpineRenderer();
|
|
// }else{
|
|
// this.is_allow_black = true;//只有角色允许黑屏处理
|
|
// this.spine_renderer.active = false;
|
|
// this.spine = this.container.getChildByName("spine");
|
|
// this.spine.active = false;
|
|
// this.skeleton = this.spine.getComponent(sp.Skeleton);
|
|
// this.skeleton.clearTracks();
|
|
|
|
// this.effect = this.container.getChildByName("effect"); // 10星光环特效
|
|
|
|
// this.hallow_node.active = false;
|
|
// this.role_node.active = true;
|
|
// // this.setActive(true);
|
|
// // 真实战斗才需要显示这些东西
|
|
// if (this.is_real) {
|
|
// this.level.string = "Lv." + this.role_data.lev;
|
|
// } else {
|
|
// this.role.active = false;
|
|
// this.updateBossHp();
|
|
// }
|
|
// }
|
|
// this.spine_zorder = this.spine.zIndex;
|
|
|
|
// // 设置当前的模型速率
|
|
// if (this.skeleton_time_scale){
|
|
// this.skeleton.timeScale = this.skeleton_time_scale;
|
|
// this.setEffectScale(this.skeleton_time_scale);
|
|
// this.skeleton_time_scale = null;
|
|
// }else{
|
|
// var timeScale = this.model.getTimeScale();
|
|
// this.skeleton.timeScale = timeScale;
|
|
// this.setEffectScale(timeScale);
|
|
// }
|
|
|
|
// // 监听事件
|
|
// this.registerEvent();
|
|
// // 初始化
|
|
// this.resetInitStatus();
|
|
// // 设置当前位置
|
|
// this.setGridPos();
|
|
// if(this.role_data.object_type == BattleConst.Unit_Type.Hallows){
|
|
// // 更新神器
|
|
// gcore.GlobalEvent.fire(BattleEvent.BATTLE_FORM_VIEW_HALLOW,true,this,this.is_friend,this.role_data.hallows_val, this.role_data.hallows_max);
|
|
// // this.setHallowsRound(this.role_data.hallows_val, this.role_data.hallows_max);
|
|
// }
|
|
// // 实例化模型
|
|
// this.instantModelRole();
|
|
// // 设置气血
|
|
// this.setHP(0);
|
|
// // 看看有没有待添加的特效
|
|
// // this.checkEffectNeedAdd();
|
|
// },
|
|
|
|
// // 设置10星特效的播放速率
|
|
// setEffectScale:function(time_scale){
|
|
// if (this.effect_skeleton){
|
|
// // this.effect_skeleton.timeScale = time_scale;
|
|
// }
|
|
// },
|
|
|
|
// registerEvent:function(){
|
|
// this.skeleton.setCompleteListener((function (trackEntry, loopCount) {
|
|
// var animationName = trackEntry.animation ? trackEntry.animation.name : "";
|
|
// if( this.action_call_list ){
|
|
// var action_object = this.action_call_list[animationName];
|
|
// if (action_object && action_object.over){
|
|
// action_object.over(animationName);
|
|
// this.action_call_list[animationName] = null;
|
|
// }
|
|
// }
|
|
|
|
// }).bind(this))
|
|
|
|
// this.skeleton.setEventListener((function (trackEntry, event) {
|
|
// var animationName = trackEntry.animation ? trackEntry.animation.name : "";
|
|
// if( this.action_call_list ){
|
|
// var action_object = this.action_call_list[animationName];
|
|
// if (action_object && action_object.event){
|
|
// action_object.event(event.data.name);
|
|
// }
|
|
// }
|
|
// }).bind(this))
|
|
// },
|
|
|
|
// // 设置角色格子位置,这个是要确定站位是在左边还是在右边
|
|
// setGridPos:function(){
|
|
// var is_friend = false;
|
|
// if (this.role_data == null){ return; }
|
|
// if (this.role == null){ return; }
|
|
// // 站位要区分真假战斗
|
|
// if (this.is_real == true){
|
|
// is_friend = this.model.isFriend(this.role_data.group);
|
|
// }else{
|
|
// is_friend = (this.role_data.group == 1);
|
|
// }
|
|
// if(is_friend){
|
|
// this.obj_type = BattleConst.Battle_Type_Conf.TYPE_ROLE
|
|
// }else{
|
|
// this.obj_type = BattleConst.Battle_Type_Conf.TYPE_ENEMY
|
|
// }
|
|
// this.is_friend = is_friend;
|
|
|
|
// // 非己方的需要反转处理
|
|
// if (this.role_data.object_type == BattleConst.Unit_Type.Hallows){
|
|
// if (this.is_friend == false){
|
|
// // rnx.gui.setActive(this.hallow_node,"2",true);
|
|
// // this.round_pogress = this.hallow_node.getChildByName("2").getComponent(cc.ProgressBar); // 回合进度条
|
|
// // this.role.scaleX = -1;
|
|
// }else{
|
|
// // nx.gui.setActive(this.hallow_node,"1",true);
|
|
// // this.round_progress = this.hallow_node.getChildByName("1").getComponent(cc.ProgressBar); // 回合进度条
|
|
// // this.role.scaleX = 1;
|
|
// }
|
|
// }else
|
|
// {
|
|
// if (this.is_friend == false){
|
|
// this.spine.scaleX = -1;
|
|
// this.spine_renderer.x = 0
|
|
// }else{
|
|
// this.spine.scaleX = 1;
|
|
// this.spine_renderer.x = 25
|
|
// }
|
|
// }
|
|
// // 获取当前格子站位
|
|
// this.grid_pos = this.skill_act.newPos2Gird(this.role_data.pos, is_friend, this.role_data.group, this.is_real);
|
|
// this.scene_pos = this.skill_act.gridPosToScreenPos(this.grid_pos);
|
|
// this.role.setPosition(this.scene_pos);
|
|
// this.resetZOrder();
|
|
// },
|
|
|
|
// // 设置坐标
|
|
// setScenePos:function(pos){
|
|
// this.role.setPosition(pos);
|
|
// },
|
|
|
|
// // 是否需要反转劫色,因为可能存在背刺技能
|
|
// reverse:function(rev){
|
|
// rev = rev || -1;
|
|
// if (this.rev_value == rev) return;
|
|
// this.rev_value = rev;
|
|
|
|
// if (this.spine){
|
|
// this.spine.scaleX = rev;
|
|
// }
|
|
// if (this.role_data.object_type == BattleConst.Unit_Type.Hallows){
|
|
// if (this.spine){
|
|
// this.spine.scaleX = rev*0.8;
|
|
// }
|
|
// }else
|
|
// {
|
|
// if (this.spine){
|
|
// this.spine.scaleX = rev;
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 实例化角色模型数据
|
|
// instantModelRole: function () {
|
|
// if (this.role_data == null){ return; }
|
|
// // 去配置表数据
|
|
// var camp_type = 0; // 当前阵营
|
|
// var spine_name = "";
|
|
// var encircle_effect = ""; // 10星英雄特效
|
|
// var fashion = 0; // 时装数据
|
|
// if (this.role_data.object_type == BattleConst.Unit_Type.Hero){
|
|
// var key = Utils.getNorKey(this.role_data.object_bid, this.role_data.star);
|
|
// var config_data = gdata("partner_data", "data_partner_star", key);
|
|
// if (config_data){
|
|
// spine_name = config_data.res_id;
|
|
// encircle_effect = config_data.fight_effect;
|
|
// }
|
|
// var base_config = game.configs.partner_data.data_partner_base[this.role_data.object_bid];
|
|
// if(base_config){
|
|
// camp_type = base_config.camp_type;
|
|
// }
|
|
// }else if(this.role_data.object_type == BattleConst.Unit_Type.Hallows){
|
|
// var config_data = game.configs.hallows_data.data_base[this.role_data.object_bid]
|
|
// if (config_data){
|
|
// spine_name = config_data.c_res_id;
|
|
// }
|
|
// }
|
|
// else if(this.role_data.object_type == BattleConst.Unit_Type.Elfin){
|
|
// spine_name = "H70000"
|
|
// }else{
|
|
// var config_data = Utils.getUnitConfig(this.role_data.object_bid);
|
|
// if(config_data){
|
|
// spine_name = config_data.body_id;
|
|
// camp_type = config_data.camp_type;
|
|
// encircle_effect = config_data.fight_effect;
|
|
// }
|
|
// }
|
|
// // 真是战斗就从服务端那边去,否则从battleloop2里面去数值
|
|
// if(this.is_real == true){
|
|
// this.role_node.setAnchorPoint(0.5,0.5);
|
|
// fashion = this.getBattleRoleExtendData(5); // 时装数据
|
|
// }else{
|
|
// if(!this.is_friend){//挂机boss需要重设锚点
|
|
// this.role_node.setAnchorPoint(0.7,0.5);
|
|
// }else{
|
|
// this.role_node.setAnchorPoint(0.5,0.5);
|
|
// }
|
|
// fashion = this.role_data.fashion;
|
|
// }
|
|
// this.role_data.face_id = this.role_data.object_bid;
|
|
// if(fashion != 0){
|
|
// let skin_config = game.configs.partner_skin_data.data_skin_info[fashion];
|
|
// if(skin_config){
|
|
// spine_name = skin_config.res_id;
|
|
// this.role_data.face_id = skin_config.head_id;
|
|
// if(skin_config.fight_effect != "" && encircle_effect != ""){
|
|
// encircle_effect = skin_config.fight_effect;
|
|
// }
|
|
// }
|
|
// this.is_use_skill = true;
|
|
// this.fashion_id = fashion;
|
|
// }
|
|
// if (spine_name == ""){return;}
|
|
// this.spine_name = spine_name;
|
|
// this.base_spine_name = spine_name;
|
|
|
|
// // 设置阵营
|
|
// if (this.is_real && this.role_data.object_type != BattleConst.Unit_Type.Hallows){
|
|
// this.setCampIcon(camp_type);
|
|
// }
|
|
|
|
// // 设置10星光环特效
|
|
// // if (encircle_effect != ""){
|
|
// // this.createEncircleEffect(encircle_effect);
|
|
// // }
|
|
|
|
// // 设置模型的高度
|
|
// var config_model = game.configs.skill_data.data_get_model_data[spine_name];
|
|
// if (config_model){
|
|
// this.model_height = config_model.model_height ; // 模型的高度再上浮20个像素
|
|
// }
|
|
// this.top_container.y = this.model_height + this.top_off_y;
|
|
// //是否需要播放进场动作
|
|
// if (this.play_enter) {
|
|
// this.showEnterAction();
|
|
// } else {
|
|
// if (this.is_real){
|
|
// this.doRunToStand(function() {
|
|
// if(!this.role)return;
|
|
// this.role.active = true;
|
|
// this.setActive(true);
|
|
// }.bind(this));
|
|
// // this.doStand(function() {
|
|
// // if(!this.role)return;
|
|
// // this.role.active = true;
|
|
// // this.setActive(true);
|
|
// // }.bind(this));
|
|
// }else{
|
|
// this.doStand(function() {
|
|
// if(!this.role)return;
|
|
// if (!this.is_real) {
|
|
// this.role.active = true;
|
|
// if (this.finish_cb)
|
|
// this.finish_cb();
|
|
// }
|
|
// this.setActive(true);
|
|
// if (this.role_data.group == BattleConst.Group_Type.Enemgy){
|
|
// this.playUnrealEnterAction();
|
|
// }
|
|
// }.bind(this));
|
|
// // this.doRun(function() {
|
|
// // if (!this.is_real) {
|
|
// // this.role.active = true;
|
|
// // if (this.finish_cb)
|
|
// // this.finish_cb();
|
|
// // }
|
|
// // this.setActive(true);
|
|
// // if (this.role_data.group == BattleConst.Group_Type.Enemgy){
|
|
// // this.playUnrealEnterAction();
|
|
// // }
|
|
// // }.bind(this))
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 获取指定类型的额外数据
|
|
// getBattleRoleExtendData:function(key){
|
|
// if (this.role_data == null) return 0;
|
|
// for (let index = 0; index < this.role_data.extra_data.length; index++) {
|
|
// const element = this.role_data.extra_data[index];
|
|
// if (element.extra_key == key){
|
|
// return element.extra_value;
|
|
// }
|
|
// }
|
|
// return 0;
|
|
// },
|
|
|
|
// // 设置神器回合进度条
|
|
// setHallowsRound:function(val, max){
|
|
// // if(this.role_data == null || this.role_data.object_type != BattleConst.Unit_Type.Hallows) return;
|
|
// // if(val == 0 || val == null){
|
|
// // this.round_progress.progress = 0;
|
|
// // }else{
|
|
// // if (max == 0 || max == null){
|
|
// // max = 3;
|
|
// // }
|
|
// // var per = Math.min(1, Math.max(val / max))
|
|
// // this.round_progress.progress = per;
|
|
// // }
|
|
// },
|
|
|
|
// // 是否需要播放进场动作
|
|
// showEnterAction:function(){
|
|
// if(this.role_data && this.role_data.object_type == BattleConst.Unit_Type.Hallows||this.role_data.object_type == BattleConst.Unit_Type.Elfin){ // 神器不需要走任何处理
|
|
// this.doStand();
|
|
// return;
|
|
// }
|
|
|
|
// var time = 0.5;
|
|
// var start_x = this.scene_pos.x
|
|
// var offset_x = SCREEN_WIDTH * 0.25
|
|
// var move_by = null
|
|
// if (this.is_friend == true){
|
|
// start_x = start_x - offset_x
|
|
// move_by = cc.moveTo(time, this.scene_pos.x, this.scene_pos.y)
|
|
// } else {
|
|
// start_x = start_x + offset_x
|
|
// move_by = cc.moveTo(time, this.scene_pos.x, this.scene_pos.y)
|
|
// }
|
|
|
|
// this.doRun();
|
|
// this.role.x = start_x;
|
|
// this.role.runAction(cc.sequence(move_by, cc.callFunc(function () {
|
|
// this.doStand();
|
|
// }.bind(this))))
|
|
// },
|
|
|
|
// // 设置阵营
|
|
// setCampIcon:function(camp_type){
|
|
// let cfg = game.configs.combat_halo_data.data_halo_icon[camp_type];
|
|
// if(!cfg)return;
|
|
// var camp_icon = cc.js.formatStr("prefab/battle/ui/camps%s",cfg.id);
|
|
// nx.gui.setSpriteFrame(this.camp,"",camp_icon);
|
|
// },
|
|
|
|
// // 假战斗地方的进场效果
|
|
// playUnrealEnterAction:function(){
|
|
// if (this.role == null) return;
|
|
// this.clearNextActTimer();
|
|
// this.clearNextCallTimer();
|
|
|
|
// var skill_plays_data = BattleLoop.play(this.pos);
|
|
// if (skill_plays_data) {
|
|
// // cc.log("开始准备假战斗");
|
|
// var skill_plays_list = this.hook_model.getSkillPlayData(skill_plays_data.actor);
|
|
// if (skill_plays_list == null || skill_plays_list.length == 0) {
|
|
// this.hook_model.handleSkillPlayData(skill_plays_data, function(start_cb) {
|
|
// // cc.log("开始进行假战斗0");
|
|
// var wait_time = 2500 - this.hook_model.getFinalMoveTime();
|
|
// if (!this.next_ack_mon_timer) {
|
|
// this.next_ack_mon_timer = gcore.Timer.set(function () {
|
|
// // cc.log("准备攻击1");
|
|
// if (start_cb)
|
|
// start_cb();
|
|
// }.bind(this), wait_time, 1)
|
|
// }
|
|
// }.bind(this));
|
|
// }
|
|
// this.hook_model.updateActorPlaysList(skill_plays_data);
|
|
// }
|
|
// },
|
|
|
|
// // 清楚下一个攻击的定时器
|
|
// clearNextActTimer:function(){
|
|
// if (this.next_ack_mon_timer){
|
|
// gcore.Timer.del(this.next_ack_mon_timer);
|
|
// this.next_ack_mon_timer = null;
|
|
// }
|
|
// },
|
|
|
|
// // 清除下一波怪物刷新定时器
|
|
// clearNextCallTimer:function(){
|
|
// if (this.next_call_mon_timer) {
|
|
// gcore.Timer.del(this.next_call_mon_timer);
|
|
// this.next_call_mon_timer = null;
|
|
// }
|
|
// },
|
|
|
|
// doRun:function(cb){
|
|
// this.playActionOnce(PlayerAction.run, this.spine_name, null, null, cb)
|
|
// },
|
|
|
|
// doStand:function(finish_cb){
|
|
// this.playActionOnce(PlayerAction.battle_stand, this.spine_name, null, null, finish_cb);
|
|
// if (this.pos < 40 && this.talk_back ){
|
|
// this.talk_back = false;
|
|
// this.model.addReadySum();
|
|
// }
|
|
// },
|
|
|
|
// doRunToStand(finish_cb){
|
|
// if(!this.role)return;
|
|
// if(this.role_data && this.role_data.object_type == BattleConst.Unit_Type.Hallows||this.role_data.object_type == BattleConst.Unit_Type.Elfin){ // 神器不需要走任何处理
|
|
// this.doStand(finish_cb);
|
|
// return;
|
|
// }
|
|
|
|
// var time = 0.2;
|
|
// var start_x = this.scene_pos.x;
|
|
// var offset_x = SCREEN_WIDTH * 0.5;
|
|
// var move_by = null;
|
|
// if (this.is_friend == true){
|
|
// start_x = start_x - offset_x
|
|
// move_by = cc.moveTo(time, this.scene_pos.x, this.scene_pos.y)
|
|
// } else {
|
|
// start_x = start_x + offset_x
|
|
// move_by = cc.moveTo(time, this.scene_pos.x, this.scene_pos.y)
|
|
// }
|
|
|
|
// this.role.x = start_x;
|
|
// this.doRun(()=>{
|
|
// if(!this.role)return;
|
|
// this.role.runAction(cc.sequence(move_by, cc.delayTime(0.1), cc.callFunc(function () {
|
|
// this.role.position = this.scene_pos;
|
|
// this.playActionOnce(PlayerAction.battle_stand, this.spine_name, null, null, finish_cb);
|
|
// if (this.pos < 40 && this.talk_back ){
|
|
// this.talk_back = false;
|
|
// this.model.addReadySum();
|
|
// }
|
|
// }.bind(this))))
|
|
// });
|
|
// },
|
|
|
|
// // 设置动作伴随事件和动作结束事件回调
|
|
// setAnimationActionFunc:function(event_func, over_func, action_name){
|
|
// if (action_name == null) return;
|
|
// if(this.action_call_list[action_name] == null){
|
|
// this.action_call_list[action_name] = {over:null, event:null};
|
|
// }
|
|
// this.action_call_list[action_name].over = over_func;
|
|
// this.action_call_list[action_name].event = event_func;
|
|
// },
|
|
|
|
// isCHeckDel30075(key){
|
|
// let is_del = false;
|
|
// if(key == "H30075_jineng21" || key == "H30075_jineng22"||key == "H30075_jineng23"
|
|
// || key == "H30075_jineng24" || key == "H30075_jineng25"){
|
|
// is_del = true;
|
|
// }
|
|
// return is_del;
|
|
// },
|
|
|
|
// /**
|
|
// * 切换动作,由于处于待机的时候,可能马上切换到其他动作,所以这里要看看要不要处理成待机播放完成之后
|
|
// * @param {*} action_name 目标动作名字
|
|
// * @param {*} res_name 目标资源名字
|
|
// */
|
|
// playActionOnce:function(action_name, res_name2, is_loop, force, load_fini){
|
|
// if(!this.role)return;
|
|
// let res_name = res_name2 ;
|
|
// if( res_name2!= "" && res_name2!= null){
|
|
// this.spine_name = res_name2;
|
|
// }
|
|
// let self = this;
|
|
// //|| "H99999";
|
|
|
|
// if(is_loop == null){
|
|
// is_loop = true
|
|
// }
|
|
|
|
// if(!this.skeleton){
|
|
// return false;
|
|
// }
|
|
|
|
// // this.skeleton.skeletonData = null;
|
|
// var skeleton_path = PathTool.getSpinePath(self.spine_name, self.spine_name,false);
|
|
// if( this.play_action_res == skeleton_path ) {
|
|
// // nx.res.loadRes(skeleton_path,sp.SkeletonData,(_e,res)=>{
|
|
// // if(res && self.spine && self.skeleton){
|
|
// // this.skeleton.skeletonData = res;
|
|
// // self.skeleton.setToSetupPose();
|
|
// self.play_action_name = action_name;
|
|
// self.skeleton.setAnimation(0, action_name, is_loop);
|
|
// self.spine.active = true;
|
|
// self.skeleton.node.opacity = 255;
|
|
// // }
|
|
// // });
|
|
// }
|
|
// else {
|
|
// nx.res.loadRes(skeleton_path,sp.SkeletonData,(_e,_p)=>{
|
|
// if( _e ) {
|
|
// nx.dt.fnInvoke( load_fini, _e );
|
|
// return;
|
|
// }
|
|
// // 资源绑定
|
|
// // nx.assets.cacheAsset( _p, skeleton_path );
|
|
// if(self.spine && self.skeleton){
|
|
// self.skeleton.skeletonData = _p;
|
|
// // self.skeleton.setToSetupPose();
|
|
// self.skeleton.setAnimation(0, action_name, is_loop);
|
|
|
|
// self.spine.active = true;
|
|
// self.skeleton.node.opacity = 255;
|
|
// }
|
|
// self.play_action_name = action_name;
|
|
|
|
// // nx.assets.uncacheAsset( self.spSkeleton );
|
|
// self.spSkeleton = _p;
|
|
// self.play_action_res = skeleton_path;
|
|
|
|
// nx.dt.fnInvoke( load_fini );
|
|
// });
|
|
// }
|
|
// },
|
|
|
|
// // 重设基础数据,包含切换到战力动作等
|
|
// resetBaseInfo:function(){
|
|
// if(!this.role)return;
|
|
// this.playActionOnce(PlayerAction.battle_stand,this.spine_name);
|
|
// if(this.scene_pos){
|
|
// this.role.setPosition(this.scene_pos);
|
|
// }
|
|
// this.resetZOrder();
|
|
// this.reverse(this.obj_type);
|
|
// },
|
|
|
|
// // 设置深度值
|
|
// resetZOrder: function () {
|
|
// if (this.role_data == null) { return; }
|
|
// if (this.role == null) { return; }
|
|
// if (this.role_base_zorder){
|
|
// if(this.role_cur_zorder != this.role_base_zorder){
|
|
// this.role_cur_zorder = this.role_base_zorder;
|
|
// this.role.zIndex = this.role_base_zorder;
|
|
// }
|
|
// return;
|
|
// }
|
|
|
|
// var zorder = 0
|
|
// var group = this.role_data.group - 1;
|
|
// var pos = this.role_data.pos - 1;
|
|
// if (this.role_data.group == BattleConst.Group_Type.Enemgy){
|
|
// zorder = BattleConst.BattleRoleZorder[group][pos-BattleConst.GIRD_POS_OFFSET];
|
|
// }else{
|
|
// zorder = BattleConst.BattleRoleZorder[group][pos]
|
|
// }
|
|
// this.role_base_zorder = zorder;
|
|
// this.role_cur_zorder = zorder;
|
|
// this.role.zIndex = zorder;
|
|
// },
|
|
|
|
// // 设置深度
|
|
// setLocalZOrder:function(zIndex){
|
|
// if(this.role_cur_zorder == zIndex){ return; }
|
|
// this.role_cur_zorder = zIndex;
|
|
// if(this.role){
|
|
// this.role.zIndex = zIndex;
|
|
// }
|
|
// },
|
|
|
|
// // 当前深度值
|
|
// getLocalZOrder:function(){
|
|
// return this.role_cur_zorder || 0;
|
|
// },
|
|
|
|
// // 战斗动作播报
|
|
// runAction:function(action){
|
|
// if(this.role){
|
|
// // this.role.stopAllActions();
|
|
// if (action) {
|
|
|
|
// this.role.runAction(action);
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 添加一个战斗特效,可能是buff, index:0 为上层特效 1:为下层特效
|
|
// addBattleEfffect:function(fix, fiy, effect_id, action_name, index, obj_type,tag_pos){
|
|
// if(!this.role)return;
|
|
// // 这个确定是否要反转特效
|
|
// if (obj_type == null){
|
|
// obj_type = this.obj_type;
|
|
// }
|
|
// if(this.effect_list[effect_id] == null){
|
|
// this.effect_list[effect_id] = {}
|
|
// }
|
|
// if (this.effect_list[effect_id][action_name] == null){
|
|
// this.effect_list[effect_id][action_name] = {num:1, object:null}
|
|
// }
|
|
// var effect_object = this.effect_list[effect_id][action_name];
|
|
// if (effect_object.object == null){
|
|
// effect_object.object = this.model.getEftMgr().createRoleEft(this.pos+effect_id+action_name,this.role_effect, cc.v2(fix, fiy), obj_type, effect_id);
|
|
// // effect_object.object = new BattleEffect();
|
|
// // effect_object.object.createEffect(this.role_effect, cc.v2(fix, fiy), obj_type, effect_id);
|
|
// }else{
|
|
// //临时
|
|
// effect_object.object = this.model.getEftMgr().findRoleEft(this.pos+effect_id+action_name);
|
|
// //临时
|
|
|
|
// effect_object.num += 1;
|
|
// if(effect_object.num > 0){
|
|
// effect_object.object.setActiveEffect(true);
|
|
// }
|
|
// }
|
|
// // 设置特效的深度值
|
|
// var zorder = this.spine_zorder + 1;
|
|
// if (index == 1){
|
|
// zorder = this.spine_zorder - 1;
|
|
// }
|
|
// effect_object.object.setLocalZOrder(zorder);
|
|
// return effect_object;
|
|
// },
|
|
|
|
// // 监测是否有待添加特效
|
|
// checkEffectNeedAdd:function(){
|
|
// // for(var effect_id in this.wait_add_effect_list){
|
|
// // for (var action_name in this.wait_add_effect_list[effect_id]){
|
|
// // var object = this.wait_add_effect_list[effect_id][action_name];
|
|
// // if (object && object.effect_id){
|
|
// // this.addBattleEfffect(object.fix, object.fiy, object.effect_id, object.action_name, object.index);
|
|
// // }
|
|
// // }
|
|
// // }
|
|
// // this.wait_add_effect_list = {};
|
|
// },
|
|
|
|
// // 移除一个特效,并不是强制移除,只是把计数器-1,如果计数器为0,才是彻底移除
|
|
// delBattleEffect:function(effect_id, action_name, tag_pos){
|
|
// if (this.wait_add_effect_list[effect_id]){
|
|
// if (this.wait_add_effect_list[effect_id][action_name] != null) {
|
|
// this.wait_add_effect_list[effect_id][action_name] = null;
|
|
// }
|
|
// }
|
|
|
|
// if(this.effect_list[effect_id] == null){
|
|
// return;
|
|
// }
|
|
// var effect_object = this.effect_list[effect_id][action_name];
|
|
// if(effect_object == null){
|
|
// return;
|
|
// }
|
|
|
|
// effect_object.num -= 1;
|
|
// if (effect_object.num <= 0) {
|
|
// // this.model.getEftMgr().delRoleEft(effect_id+action_name);
|
|
// // this.effect_list[effect_id][action_name].object = null;
|
|
// effect_object.object.setActiveEffect(false)
|
|
// }
|
|
// },
|
|
|
|
// // 显示或者隐藏掉血条
|
|
// showHpRoot:function(status){
|
|
// if(!this.role)return;
|
|
// if (this.is_real == false ) return; // 假战斗不需要管这个
|
|
// if(this.hp_show_status == status){ return; }
|
|
// this.hp_show_status = status;
|
|
// if(this.top_container){
|
|
// this.red.active = false;
|
|
// this.top_container.active = status
|
|
// }
|
|
// },
|
|
|
|
// /**
|
|
// * 血量变化的值
|
|
// * @param {*} dmg 正数是治疗,负数是扣血
|
|
// * @param {*} is_die 是否死亡
|
|
// * @param {*} without 是否提出掉非死亡状态
|
|
// * @param {*} is_must_die 如果为0,就标识可以移除了.否则就算死了也不移除.因为可能在连击中
|
|
// */
|
|
// updateHP:function(dmg, is_die, without, is_must_die){
|
|
// if(!this.role)return;
|
|
// if(this.role_data == null) { return; }
|
|
// if(this.top_container == null) { return; }
|
|
// if(this.role_data && this.role_data.object_type == BattleConst.Unit_Type.Hallows) return;
|
|
|
|
// this.setHP(dmg);
|
|
// if (without == null){
|
|
// without = false
|
|
// }
|
|
// if (is_die == 1 && is_must_die == 0){
|
|
// if (this.is_die == false){
|
|
// if(this.is_real){
|
|
// this.died()
|
|
// }else{
|
|
// this.unrealDied();
|
|
// }
|
|
// // this.died()
|
|
// }
|
|
// }else{
|
|
// if(this.is_die == true && without == false){
|
|
// this.relive()
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 处理角色复活
|
|
// relive: function () {
|
|
// if (this.is_die == false) { return };
|
|
// this.is_die = false;
|
|
// this.showHpRoot(true);
|
|
// this.setActive(true)
|
|
// this.resetBaseInfo();
|
|
// var cur_hp = this.role_data.hp;
|
|
// var per = Math.min(1, Math.max(cur_hp / this.role_data.hp_max))
|
|
// this.progress.progress = per;
|
|
// },
|
|
|
|
// // 立刻移除对象
|
|
// doDied:function(){
|
|
// if(this.is_die == true) {
|
|
// return;
|
|
// }
|
|
// this.is_die = true;
|
|
// this.showHpRoot(false);
|
|
// this.setActive(false)
|
|
// this.clearAllEffect();
|
|
// },
|
|
|
|
// //處理假戰鬥角色死亡
|
|
// unrealDied: function(){
|
|
// this.need_play_die = false;
|
|
// if(this.role == null) {
|
|
// return;
|
|
// }
|
|
// if(this.is_die == true) {
|
|
// return;
|
|
// }
|
|
|
|
// this.is_die = true;
|
|
// this.assetJumpTo();
|
|
// if (this.next_call_mon_timer == null){
|
|
// this.next_call_mon_timer = gcore.Timer.set(function(){
|
|
// this.hook_model.playEnd(this.pos);
|
|
// this.hook_model.updateNextRoundData();
|
|
// }.bind(this), 300, 1)
|
|
// }
|
|
|
|
// this.updateBossHp();
|
|
// },
|
|
|
|
// updateBossHp(){
|
|
// if(!this.role)return;
|
|
// let drama_ctrl = require("battle_drama_controller");
|
|
// let hookTime = drama_ctrl.getInstance().getModel().getHookAccumulateInfo().hook_time || 0;
|
|
// let totalTime = game.configs.dungeon_data.data_drama_const.profit_time_max.val;
|
|
// let role_ctrl = require("role_controller").getInstance();
|
|
// let afkTime = 1;
|
|
// if(role_ctrl.getRoleVo().vip_lev > 0){
|
|
// afkTime = game.configs.vip_data.data_get_vip_info[role_ctrl.getRoleVo().vip_lev].val[2][1];
|
|
// }
|
|
// let vipTime = afkTime * 3600;
|
|
// let progress = (totalTime + vipTime - hookTime) / (totalTime + vipTime);
|
|
// this.boss_bar.progress = progress;
|
|
// },
|
|
|
|
// // 处理角色死亡
|
|
// died: function () {
|
|
// if(this.in_hurt_act == true){
|
|
// this.need_play_die = true;
|
|
// return;
|
|
// }
|
|
// if(this.role == null) {
|
|
// return;
|
|
// }
|
|
// if(this.is_die == true) {
|
|
// return;
|
|
// }
|
|
|
|
// this.showHpRoot(false);
|
|
// this.role_died_sp.node.active = true;
|
|
// this.role_died_sp.setToSetupPose();
|
|
// this.role_died_sp.clearTracks();
|
|
|
|
// let die_func = (delay)=>{
|
|
// this.is_die = true;
|
|
// var callFunc_1 = cc.callFunc((function(){
|
|
// this.role_died_sp.node.active = false;
|
|
// this.is_act_die = true;
|
|
// this.setActive(false);
|
|
// }).bind(this))
|
|
// var act = cc.sequence(cc.delayTime(delay),callFunc_1);
|
|
|
|
// this.runAction(act);
|
|
// // 清除所有的特效
|
|
// this.clearAllEffect(false);
|
|
// // 回收掉所有buff图标
|
|
// // this.removeBuffItemRes();
|
|
// this.removeBuffList();
|
|
// }
|
|
|
|
// this.model.getDiedEffectObj((res)=>{
|
|
// if(res && this.role_died_sp){
|
|
// this.role_died_sp.skeletonData = res;
|
|
// this.role_died_sp.setAnimation(0,"action",false);
|
|
// die_func(0.2);
|
|
// }else{
|
|
// die_func(0.2);
|
|
// }
|
|
// });
|
|
// },
|
|
|
|
// // 设置是否激活
|
|
// setActive:function(status){
|
|
// if(this.is_real){
|
|
// if(status){
|
|
// this.active_timer = setTimeout(()=>{
|
|
// if(!this.role)return;
|
|
// if(!this.is_real){
|
|
// this.top_container.active = false;
|
|
// if(!this.is_friend){
|
|
// this.boss_bar.node.active = true;
|
|
// }
|
|
// }
|
|
|
|
// this.role.opacity = status?255:0;
|
|
// this.skeleton.markForRender(status);
|
|
// this.shadow.active = status;
|
|
// // if (this.effect){
|
|
// // this.effect.active = status;
|
|
// // }
|
|
// },400);
|
|
// }else{
|
|
// if(!this.role)return;
|
|
// if(!this.is_real){
|
|
// this.top_container.active = false;
|
|
// if(!this.is_friend){
|
|
// this.boss_bar.node.active = true;
|
|
// }
|
|
// }
|
|
|
|
// this.role.opacity = status?255:0;
|
|
// this.skeleton.markForRender(status);
|
|
// this.shadow.active = status;
|
|
// // if (this.effect){
|
|
// // this.effect.active = status;
|
|
// // }
|
|
// }
|
|
// }else{
|
|
// if(!this.role)return;
|
|
// if(!this.is_real){
|
|
// this.top_container.active = false;
|
|
// if(!this.is_friend){
|
|
// this.boss_bar.node.active = true;
|
|
// }
|
|
// }
|
|
|
|
// this.role.opacity = status?255:0;
|
|
// this.skeleton.markForRender(status);
|
|
// this.shadow.active = status;
|
|
// // if (this.effect){
|
|
// // this.effect.active = status;
|
|
// // }
|
|
// }
|
|
// },
|
|
|
|
// // 受击动作播放完成之后的处理
|
|
// checkIsDied:function(){
|
|
// if (this.need_play_die == true){
|
|
// this.need_play_die = false;
|
|
// this.died();
|
|
// }else{
|
|
// this.doStand()
|
|
// }
|
|
// },
|
|
|
|
// // 设置气血
|
|
// setHP:function(dmg){
|
|
// if(!this.role)return;
|
|
// if(this.role_data == null) { return; }
|
|
// var cur_hp = 0;
|
|
// if(dmg <= 0){ // 伤害
|
|
// cur_hp = Math.max(0, dmg + this.role_data.hp);
|
|
// }else{ // 恢复
|
|
// cur_hp = Math.min(this.role_data.hp_max, dmg + this.role_data.hp)
|
|
// }
|
|
// this.role_data.hp = cur_hp;
|
|
// var per = Math.min(1, Math.max(cur_hp / this.role_data.hp_max))
|
|
// this.progress.progress = per;
|
|
// nx.gui.setActive(this.once,"",per == 1);
|
|
// if(per <= 0.3){
|
|
// this.red.active = true;
|
|
// this.red.width = this.progress.totalLength * per;
|
|
// }else{
|
|
// this.red.active = false;
|
|
// }
|
|
// },
|
|
|
|
// // 下一波怪如果是己方需要清掉所有的buff之类的
|
|
// updataNextBattleRole:function(data){
|
|
// if(!this.role)return;
|
|
// if (this.role_data){
|
|
// if(this.role_data.updateData){
|
|
// this.role_data.updateData(data);
|
|
// }
|
|
// this.clearAllEffect(false);
|
|
// this.removeBuffList();
|
|
// if(this.role_data.hp <= 0){
|
|
// this.died();
|
|
// }else{
|
|
// var per = Math.min(1, Math.max(this.role_data.hp / this.role_data.hp_max))
|
|
// this.progress.progress = per;
|
|
// this.red.width = this.progress.totalLength * per;
|
|
// if(per <= 0.3){
|
|
// if(per != 0){
|
|
// this.red.active = true;
|
|
// this.progress.barSprite.node.active = false;
|
|
// }
|
|
// }else{
|
|
// this.red.active = false;
|
|
// this.progress.barSprite.node.active = true;
|
|
// }
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 变身操作
|
|
// // --- BattleRole:changeSpine 變出處理,後續會用到
|
|
// // -- @param bool 是否變身
|
|
// // -- @param spine 變身資源
|
|
// // -- @param anima_name 變身動作資源
|
|
// changeSpine:function(bool, spine2, anima_name2){
|
|
// let self = this;
|
|
|
|
// // 如果是在播放動作過程中,切換模型這個時候不處理
|
|
// if (bool && this.in_animation == true) {
|
|
// self.change_spine_res = spine2
|
|
// self.change_spine_action = anima_name2
|
|
// return
|
|
// }
|
|
|
|
// let spine = spine2 || self.base_spine_name;
|
|
// if (bool) {
|
|
// self.is_change_status = true
|
|
// self.buff_spine = spine2
|
|
// }else{
|
|
// self.is_change_status = false
|
|
// self.buff_spine = null;
|
|
// spine = self.base_spine_name;
|
|
// self.change_spine_res = self.base_spine_name;
|
|
// }
|
|
|
|
// this.spine_name = spine;
|
|
// let anima_name = anima_name2 || PlayerAction.battle_stand
|
|
// this.playActionOnce(anima_name, this.spine_name, null, null, null)
|
|
// },
|
|
|
|
// // 動作播放完成之後,嘗試切換模型
|
|
// reTryChangeSpine(){
|
|
// let self = this;
|
|
// if (self.change_spine_res && self.change_spine_action ){
|
|
// self.changeSpine(true, self.change_spine_res, self.change_spine_action)
|
|
// if(!self.is_change_status){
|
|
// self.change_spine_action = null
|
|
// self.change_spine_res = null
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 通知播放假战斗资源掉落
|
|
// assetJumpTo:function(){
|
|
// var node_root_pos = this.role.convertToWorldSpaceAR(cc.v2(0, 0)); // 转到世界坐标
|
|
// this.model.playResourceCollect(node_root_pos.x+ this.model_width*2, node_root_pos.y + this.model_height * 0.5); //
|
|
// },
|
|
|
|
// setVisbale(status){
|
|
// if(!this.role)return;
|
|
// if(status){
|
|
// this.role.setPosition(this.scene_pos);
|
|
// }else{
|
|
// this.role.x = this.is_friend?-2000:3000;
|
|
// }
|
|
// },
|
|
|
|
// // 隐身
|
|
// setOpacity:function(status, value){
|
|
// if(!this.role)return;
|
|
// if(status){
|
|
// this.role.opacity = value;
|
|
// }else{
|
|
// this.role.opacity = 0;
|
|
// }
|
|
// },
|
|
|
|
// // 更新buff,包含更新buff列表
|
|
// updateBuffList:function(buff, buff_cfg){
|
|
// if(buff == null || buff_cfg == null){
|
|
// return;
|
|
// }
|
|
// this.buff_list[buff.id] = null;
|
|
// this.buff_list[buff.id] = {buff:buff, config:buff_cfg, res_id: buff_cfg.icon};
|
|
|
|
// var temp_group_list = {};
|
|
// var res_id = buff_cfg.icon;
|
|
// if(res_id != 0){
|
|
// var buff_data = this.buff_list_data[res_id];
|
|
// if (buff_data == null){
|
|
// buff_data = {res_id: res_id, num: 0, list: []};
|
|
// this.buff_list_data[res_id] = buff_data;
|
|
// }
|
|
|
|
// if (buff_data.num == 0 || (buff_cfg.join_type && buff_cfg.join_type != 3)) {
|
|
// buff_data.num += 1;
|
|
// if (buff_cfg.group) {
|
|
// temp_group_list[buff_cfg.group] = true;
|
|
// }
|
|
// } else if (buff_cfg.join_type && buff_cfg.join_type == 3 && buff_cfg.group && !temp_group_list[buff_cfg.group]) {
|
|
// temp_group_list[buff_cfg.group] = true;
|
|
// buff_data.num += 1;
|
|
// }
|
|
// buff_data.list.push(buff.id);
|
|
|
|
// var temp_ary = []
|
|
// for(var key in this.buff_list_data){
|
|
// var data = this.buff_list_data[key];
|
|
// if(data){
|
|
// temp_ary.push(data);
|
|
// }
|
|
// }
|
|
// if (temp_ary.length > 0){
|
|
// temp_ary.sort(Utils.tableLowerSorter(["res_id"]));
|
|
// // if(this.is_friend){
|
|
// // this.model.handleSelfFriendBuff(this.role_data.object_bid,temp_ary);
|
|
// // }
|
|
|
|
// for (let index = 0; index < temp_ary.length; index++) {
|
|
// var data = temp_ary[index];
|
|
// var buff_object = this.buff_list_item[data.res_id];
|
|
// if (buff_object == null){
|
|
// buff_object = this.createBuffItem();
|
|
// this.buff_list_item[data.res_id] = buff_object;
|
|
// }
|
|
// buff_object.label.string = data.num;
|
|
// nx.bridge.setIcon(buff_object.icon.node,"",data.res_id);
|
|
// buff_object.node.active = true;
|
|
// }
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 移除buff没如果没有传参数,就是移除全部
|
|
// removeBuffList:function(buff_id){
|
|
// if(buff_id == null){
|
|
// this.buff_list = {};
|
|
// this.buff_list_data = {};
|
|
// this.buff_list_item = {};
|
|
// if(this.buff_container && this.buff_container.removeAllChildren){
|
|
// this.buff_container.removeAllChildren();
|
|
// }
|
|
// }else{
|
|
// var data = this.buff_list[buff_id]; // {buff:buff, config:buff_data, res_id: buff_data.icon};
|
|
// if(data){
|
|
// var buff_object = this.buff_list_item[data.res_id];
|
|
// if (buff_object){
|
|
// var buff_data = this.buff_list_data[data.res_id]; // 取出具体数字
|
|
// if (buff_data){
|
|
// buff_data.num -= 1;
|
|
// // 将该buff从列表中删除
|
|
// for (let index = 0; index < buff_data.list.length; index++) {
|
|
// const element = buff_data.list[index];
|
|
// if (element == buff_id){
|
|
// buff_data.list.splice(index, 1);
|
|
// break;
|
|
// }
|
|
// }
|
|
// // 当前没有可用于显示的buff了,把buff节点丢到对象池里面去
|
|
// if (buff_data.num <= 0){
|
|
// this.buff_list_item[data.res_id] = null;
|
|
// this.buff_list_data[data.res_id] = null;
|
|
// delete this.buff_list_item[data.res_id];
|
|
// delete this.buff_list_data[data.res_id];
|
|
// buff_object.node.removeFromParent();
|
|
// }else{
|
|
// buff_object.label.string = buff_data.num;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// this.buff_list[buff_id] = null;
|
|
// }
|
|
// },
|
|
|
|
// // 回收buff图标的时候,优先清理掉缓存的纹理信息
|
|
// removeBuffItemRes:function(){
|
|
|
|
// },
|
|
|
|
// // 创建buff,手动创建,但是对象池获取,包含 node, label, path icon
|
|
// createBuffItem:function(){
|
|
// var buff_object = {node:null, label:null, icon:null, path:""};
|
|
// var node = null;
|
|
// var label = null;
|
|
// var icon = null;
|
|
|
|
// node = new cc.Node();
|
|
// node.setAnchorPoint(0, 0.5);
|
|
// node.width = 22;
|
|
// node.height = 22;
|
|
|
|
// var icon_node = new cc.Node();
|
|
// icon_node.setAnchorPoint(0, 0.5);
|
|
// icon_node.name = "icon_sprite";
|
|
// node.addChild(icon_node);
|
|
// icon = icon_node.addComponent(cc.Sprite);
|
|
|
|
// var font_node = new cc.Node();
|
|
// font_node.color = new cc.Color(cc.Color.WHITE);
|
|
// font_node.setAnchorPoint(1, 0.5);
|
|
// font_node.x = 20;
|
|
// font_node.y = -3;
|
|
// font_node.name = "font_label";
|
|
// node.addChild(font_node);
|
|
// label = font_node.addComponent(cc.Label);
|
|
// label.lineHeight = 14;
|
|
// label.fontSize = 14;
|
|
// label.horizontalAlign = cc.macro.TextAlignment.RIGHT;
|
|
// var outline_label = font_node.addComponent(cc.LabelOutline);
|
|
// outline_label.color = new cc.Color(cc.Color.BLACK);
|
|
|
|
// buff_object.node = node;
|
|
|
|
// this.buff_container.addChild(node);
|
|
// buff_object.label = label;
|
|
// buff_object.icon = icon;
|
|
// return buff_object;
|
|
// },
|
|
|
|
// // 重新设置buff的位置
|
|
// resetBuffPostion:function(){
|
|
|
|
// },
|
|
|
|
// // 判断是否拥有当前id的buff
|
|
// hadBuff:function(buff_id){
|
|
// return (this.buff_list && this.buff_list[buff_id] != null)
|
|
// },
|
|
|
|
// getRoleData:function(){
|
|
// return this.role_data;
|
|
// },
|
|
|
|
// addTips:function(bid){
|
|
// if(this && this.tips_list){
|
|
// this.tips_list[bid] = true;
|
|
// }
|
|
// },
|
|
|
|
// removeTips:function(bid){
|
|
// if(this && this.tips_list){
|
|
// this.tips_list[bid] = false;
|
|
// }
|
|
// },
|
|
|
|
// // 设置当前模型和绑在模型上面的特效播放速率
|
|
// setTimeScale:function(speed){
|
|
// if(!this.role)return;
|
|
// if (this.skeleton == null || this.skeleton.skeletonData == null){
|
|
// this.skeleton_time_scale = speed;
|
|
// }else{
|
|
// if (this.skeleton_timeScale == speed) return;
|
|
// this.skeleton_timeScale = speed
|
|
// this.skeleton.timeScale = speed;
|
|
// //// this.setEffectScale(speed);
|
|
// // 设置特效
|
|
// for (var effect_id in this.effect_list) {
|
|
// var effect_object = this.effect_list[effect_id]
|
|
// for (var action_name in effect_object) {
|
|
// var effect = effect_object[action_name]
|
|
// if (effect && effect.object) {
|
|
// effect.object.setTimeScale(speed);
|
|
// }
|
|
// // if(effect){
|
|
// // let eft = this.model.getEftMgr().findRoleEft(effect_id+action_name);
|
|
// // eft.setTimeScale(speed);
|
|
// // }
|
|
// }
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// // 清空所有特效
|
|
// clearAllEffect:function(is_force){
|
|
// for (var effect_id in this.effect_list) {
|
|
// var effect_object = this.effect_list[effect_id]
|
|
// for (var action_name in effect_object) {
|
|
// var effect = effect_object[action_name]
|
|
// if (effect && effect.object) {//
|
|
// //临时 effect.object.deleEffect();
|
|
// this.model.getEftMgr().delRoleEft(this.pos+effect_id+action_name);
|
|
// this.effect_list[effect_id][action_name] = null;
|
|
// }
|
|
// }
|
|
// }
|
|
// if (is_force) {
|
|
// this.effect_list = null;
|
|
// this.wait_add_effect_list = null;
|
|
// }else{
|
|
// this.effect_list = {};
|
|
// this.wait_add_effect_list = {};
|
|
// }
|
|
// },
|
|
|
|
// /**
|
|
// * 从场景中移除这个单位,回收掉所有的创建节点和预制,并且删除掉所有的资源纹理信息
|
|
// */
|
|
// deleteRole: function () {
|
|
// if(this.role){
|
|
// this.role.stopAllActions();
|
|
// }
|
|
// this.clearAllEffect(true);
|
|
// this.clearNextActTimer();
|
|
// this.clearNextCallTimer();
|
|
// // this.removeBuffItemRes(); // 优先清掉buff缓存的纹理信息
|
|
|
|
// if(this.camp){
|
|
// this.camp.spriteFrame = null; // 先释放掉节点对象资源引用对象
|
|
// }
|
|
// this.action_call_list = {};
|
|
// this.tips_list = {};
|
|
|
|
// // 资源释放
|
|
// // if( this.spSkeleton ) {
|
|
// // nx.assets.uncacheAsset( this.spSkeleton );
|
|
// // this.spSkeleton = null;
|
|
// // }
|
|
// this.spine = null;
|
|
// this.skeleton = null;
|
|
// this.role_node = null;
|
|
// this.role_died_sp = null;
|
|
// this.container = null; // spine节点
|
|
// this.role_effect = null;
|
|
// this.top_container = null // 血条部分
|
|
// this.shadow = null // 脚底阴影
|
|
// this.boss_bar = null;
|
|
|
|
// this.progress = null;
|
|
// this.red = null;
|
|
// this.once = null;
|
|
// this.level = null;
|
|
// this.camp = null;
|
|
// this.hallow_node = null;
|
|
// this.spine_renderer = null;
|
|
// if(this.active_timer){
|
|
// clearTimeout(this.active_timer);
|
|
// this.active_timer = 0;
|
|
// }
|
|
|
|
// // 移除掉所有的buff节点
|
|
// this.removeBuffList();
|
|
// this.buff_container = null;
|
|
|
|
// // this.role.destroy();
|
|
// // this.role = null;
|
|
// this.node = this.role;
|
|
// this.destroy();
|
|
// this.role.destroy();
|
|
// // console.log("del1====>",this.role);
|
|
// // console.log("del2====>",this);
|
|
// },
|
|
|
|
// getResPath: function(action_name) {
|
|
// let spine_name = this.spine_name;
|
|
// if(this.spine_name == ""){
|
|
// var key = Utils.getNorKey(this.role_data.object_bid, this.role_data.star);
|
|
// var config_data = gdata("partner_data", "data_partner_star", key);
|
|
// spine_name = config_data.res_id;
|
|
// }
|
|
// return PathTool.getSpinePath(spine_name,spine_name,false);
|
|
// },
|
|
|
|
// initSpineRenderer: function () {
|
|
// if(!this.role)return;
|
|
// let path = "prefab/battle/elfin_real_role";
|
|
// nx.res.loadPrefab( path, ( _err, _fab ) => {
|
|
// // 载入错误
|
|
// if( _err ) {
|
|
// this.is_err_elfin = true;
|
|
// return;
|
|
// }
|
|
// this.is_err_elfin = false;
|
|
// // 预制常驻
|
|
// nx.assets.pushResident( path, _fab );
|
|
|
|
// // 实例化
|
|
// let elfin = cc.instantiate( _fab );
|
|
// if(this.spine_renderer){
|
|
// this.spine_renderer.addChild(elfin);
|
|
|
|
// let container = nx.gui.find(this.spine_renderer,"elfin_real_role/skills");
|
|
// this.elfin_list = []
|
|
// for (let i = 0; i < 4; i++) {
|
|
// let elfin_panel = {};
|
|
// let itemNode = container.children[i];
|
|
// elfin_panel.icon = itemNode.getChildByName("skill"); //技能图标
|
|
// elfin_panel.icon.active = false;
|
|
// elfin_panel.mask = itemNode.getChildByName("mask"); //技能图标
|
|
// elfin_panel.mask.active = false;
|
|
// elfin_panel.cd_lab = elfin_panel.mask.getChildByName("cd_lab").getComponent(cc.Label); //技能CD
|
|
// this.elfin_list.push(elfin_panel);
|
|
// }
|
|
|
|
// this.showElfinSkillIcon(this.sprites, this.skills)
|
|
// }
|
|
// } );
|
|
// },
|
|
|
|
// showElfinSkillIcon: function (data, skills) {
|
|
// if(!this.role)return;
|
|
// if (!this.elfin_list) { return }
|
|
// this.all_elfin_data = data || []
|
|
// if (Utils.next(this.all_elfin_data) != null) {
|
|
// let bool = false;
|
|
// for (let i = 0; i < 4; i++) {
|
|
// let elfin_object = this.elfin_list[i]
|
|
// let elfin_data = this.getElfinDataByPos(i + 1)
|
|
// if (elfin_data) {
|
|
// let item_bid = elfin_data.item_bid || 0
|
|
// if (item_bid == 0) { // 解鎖了,但是未佈置精靈
|
|
// elfin_object.icon.active = (false)
|
|
// elfin_object.mask.active = (false)
|
|
// elfin_object.cd_lab.node.active = (false)
|
|
// } else {
|
|
// bool = true
|
|
// let elfin_cfg = game.configs.sprite_data.data_elfin_data[item_bid]
|
|
// if (elfin_cfg && elfin_cfg[1]) {
|
|
// let skill_cfg = gskilldata("data_get_skill", [elfin_cfg[1]]);
|
|
// if (skill_cfg) {
|
|
// elfin_object.skill_bid = elfin_cfg[1] // 記錄一下技能bid,用於更新技能cd時間
|
|
// }
|
|
// }
|
|
|
|
// elfin_object.icon.active = true
|
|
// elfin_object.mask.active = false
|
|
// elfin_object.cd_lab.node.active = true
|
|
// elfin_object.cd_lab.string = ""
|
|
// }
|
|
// } else { // 未解鎖
|
|
// elfin_object.icon.active = (false)
|
|
// elfin_object.mask.active = false
|
|
// elfin_object.cd_lab.node.active = false
|
|
// }
|
|
// }
|
|
|
|
// if (skills) {
|
|
// this.updateElfinSkillState(skills)
|
|
// }
|
|
|
|
// this.spine_renderer.active = bool;
|
|
// } else { // 全都未解鎖
|
|
// this.spine_renderer.active = false
|
|
// }
|
|
// },
|
|
|
|
// addSpriteRole(sp_skill_bid,is_left){
|
|
// if(!this.role)return;
|
|
// let cmp = nx.gui.getComponent(this.spine_renderer,"elfin_real_role","battle_elfin");
|
|
// if(cmp){
|
|
// cmp.setRoleSp(sp_skill_bid);
|
|
// cmp.setNameString(this.skill_data.name || "");
|
|
// }
|
|
// },
|
|
|
|
// spriteAction(){
|
|
// if(!this.role)return;
|
|
// let spCmp = nx.gui.getComponent(this.spine_renderer,"elfin_real_role/mask/ef","nx.fx.spine");
|
|
// if(spCmp){
|
|
// spCmp.node.active = true;
|
|
// spCmp.action("action", false, ( _key, _name ) => {
|
|
// if( _key == "complete" ){
|
|
// spCmp.node.active = false;
|
|
// return;
|
|
// }
|
|
// } );
|
|
// }
|
|
// },
|
|
|
|
// // 更新精靈技能CD時間
|
|
// updateElfinSkillState (data) {
|
|
// if (!this.elfin_list) { return }
|
|
// data = data || {}
|
|
// for (const _ in data) {
|
|
// const v = data[_];
|
|
// let skill_bid = v.skill_bid
|
|
// let end_round = v.end_round
|
|
// for (const k in this.elfin_list) {
|
|
// const elfin_object = this.elfin_list[k];
|
|
// if (elfin_object.skill_bid == skill_bid) {
|
|
// let cur_round = this.model.getFightActionCount()
|
|
// let cd_round = end_round - cur_round
|
|
// if (cd_round <= 0) { // 無CD時間,當前回合播放
|
|
// elfin_object.mask.active = false
|
|
// } else {
|
|
// elfin_object.cd_lab.string = cd_round
|
|
// elfin_object.mask.active = true
|
|
// }
|
|
// break
|
|
// }
|
|
// }
|
|
// }
|
|
// },
|
|
|
|
// //根據位置獲取精靈數據
|
|
// getElfinDataByPos (pos) {
|
|
// if (!this.all_elfin_data) return
|
|
// for (const k in this.all_elfin_data) {
|
|
// const v = this.all_elfin_data[k];
|
|
// if (v.pos == pos)
|
|
// return v
|
|
// }
|
|
// },
|
|
|
|
// });
|
|
"use strict";
|
|
|
|
cc._RF.pop(); |