496 lines
15 KiB
JavaScript
496 lines
15 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '6a9864pbzdCAZYwsDhB2QBN', 'cmp.planesafk.wnd');
|
|
// Scripts/mod/pve/planesafk/cmp/cmp.planesafk.wnd.js
|
|
|
|
"use strict";
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var PlanesafkController = require("planesafk_controller");
|
|
var PlanesafkEvent = require("planesafk_event");
|
|
var TipsController = require("tips_controller");
|
|
var MallController = require("mall_controller");
|
|
var MallConst = require("mall_const");
|
|
var NXSpine = require("nx.fx.spine");
|
|
var PlaneRole = require("cmp.planesafk.role");
|
|
var RoleController = require("role_controller");
|
|
var _require = require("define"),
|
|
PlayerAction = _require.PlayerAction;
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
map: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
list: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
fabLine: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
fabMap: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
//当前层数
|
|
floor_txt: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
//剩余时间
|
|
time_val: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
//難度等級
|
|
diff_txt: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
ico_list: {
|
|
"default": [],
|
|
type: [cc.Node]
|
|
},
|
|
reward_list: {
|
|
"default": [],
|
|
type: [cc.RichText]
|
|
},
|
|
cmpRole: {
|
|
"default": null,
|
|
type: PlaneRole
|
|
},
|
|
scroll: {
|
|
"default": null,
|
|
type: cc.ScrollView
|
|
},
|
|
boxNd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
holeNd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
endNd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// LIFE-CYCLE CALLBACKS:
|
|
onLoad: function onLoad() {
|
|
var _this = this;
|
|
this.ctrl = PlanesafkController.getInstance();
|
|
this.model = this.ctrl.getModel();
|
|
this.pushPath = [];
|
|
this.up_item_list = [];
|
|
//最大层数
|
|
this.max_floor = 3;
|
|
var diff_config = gdata("planes_data", "data_const", "planes_difficult_limit_lev");
|
|
if (diff_config) {
|
|
this.difficult_limit_lev = diff_config.val || 30;
|
|
}
|
|
var diff_power = gdata("planes_data", "data_const", "planes_difficult_max_power");
|
|
if (diff_power) {
|
|
this.planes_difficult_max_power = diff_power.val || 300000;
|
|
}
|
|
this.is_init_over = false;
|
|
|
|
// 冒险角色
|
|
var role = RoleController.getInstance().getRoleVo();
|
|
var cfgs = game.configs.looks_data.data_data[role.look_id];
|
|
this.cmpRole.setModel(cfgs ? cfgs.model : "", this.roleMoveEvent.bind(this));
|
|
this.scroll.node.on("scrolling", this.roleMapMove.bind(this));
|
|
|
|
//基础信息
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Main_Base_Info_Event, this.baseInfoData.bind(this));
|
|
//地图信息
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Main_Map_Info_Event, this.initMapData.bind(this));
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Update_Map_Info_Event, this.initMapData.bind(this));
|
|
//buff进背包
|
|
this.bindGEvent(PlanesafkEvent.Chose_Buff_Event, this.showBuffItemMoveAni.bind(this));
|
|
//领取宝箱状态
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Pass_Reward_Info_Event, this.passRewardInfo.bind(this));
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Last_Reward_Info_Event, this.lastRewardInfo.bind(this));
|
|
//下一章地图
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Next_Map_Info_Event, function () {
|
|
_this.scroll.scrollTo(0);
|
|
_this.ctrl.sender28603();
|
|
});
|
|
//本月以获取
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Update_Get_Reward_Event, this.updateRewardInfo.bind(this));
|
|
//创建角色
|
|
this.bindGEvent(PlanesafkEvent.Planesafk_Create_Role_Event, this.showRoleInfo.bind(this));
|
|
},
|
|
roleMapMove: function roleMapMove() {
|
|
this.map.x = this.scroll.content.x;
|
|
},
|
|
roleMoveEvent: function roleMoveEvent(_key) {
|
|
if (_key == "end") {
|
|
//检测是否要触发事件
|
|
var cur_pos = this.model.getRolePos();
|
|
var len = this.list.children.length;
|
|
var per = cur_pos[0] / len;
|
|
this.scroll.scrollTo(per);
|
|
this.map.x = this.scroll.content.x;
|
|
} else if (_key == "start") {//有可能要重置状态
|
|
} else if (_key == "move") {//移动中的事件
|
|
}
|
|
},
|
|
updateRewardInfo: function updateRewardInfo(data) {
|
|
if (!data) return;
|
|
var self = this;
|
|
this.up_item_list = data.item_list;
|
|
// if (data.item_list) {
|
|
// var item_list = [];
|
|
// for (var i in data.item_list) {
|
|
// var v = data.item_list[i];
|
|
// item_list.push(v);
|
|
// }
|
|
|
|
// item_list.sort((a,b)=>{
|
|
// return b.base_id - a.base_id;
|
|
// });
|
|
// for (var i in item_list) {
|
|
// var v = item_list[i]
|
|
// var item_config = gitemdata(v.base_id);
|
|
// if (item_config && this.reward_list[i]) {
|
|
// let mst = self.reward_list[i];
|
|
// let str = cc.js.formatStr(":%s",Utils.getMoneyString(v.num))
|
|
// mst.string = str;
|
|
// let res = PathTool.querySmallIconPath(item_config.id);
|
|
// nx.gui.setSpriteFrame(this.ico_list[i],"",res);
|
|
// }
|
|
// }
|
|
// }
|
|
},
|
|
lastRewardInfo: function lastRewardInfo(data) {
|
|
if (this.map_data) {
|
|
this.map_data.is_can_reward = data.is_can_reward;
|
|
this.map_data.is_reward = data.is_reward;
|
|
this.updateBoxInfo();
|
|
}
|
|
},
|
|
passRewardInfo: function passRewardInfo() {
|
|
if (this.map_data) {
|
|
this.map_data.is_reward = 1;
|
|
this.updateBoxInfo();
|
|
}
|
|
},
|
|
showBuffItemMoveAni: function showBuffItemMoveAni(buff_id, world_pos) {},
|
|
baseInfoData: function baseInfoData(data) {
|
|
//人物和 时间
|
|
if (!data) return;
|
|
this.base_data = data;
|
|
this.setData();
|
|
},
|
|
initMapData: function initMapData(data) {
|
|
var _this2 = this;
|
|
if (!data) return;
|
|
//層級
|
|
if (data.floor) {
|
|
nx.gui.setString(this.floor_txt, "", "0" + data.floor);
|
|
}
|
|
|
|
//難易度
|
|
if (data.difficulty) {
|
|
nx.gui.setString(this.diff_txt, "", data.difficulty == 1 ? nx.text.getKey("lab_guildwar_defend_look_item_tip3") : nx.text.getKey("lab_guildwar_defend_look_item_tip5"));
|
|
}
|
|
if (data.tile_list) {
|
|
if (data.is_reward != null && data.is_can_reward != null) {
|
|
this.map_data = data;
|
|
if (this.map_data.is_reward == 0) {
|
|
this.holeNd.active = false;
|
|
} else {
|
|
this.holeNd.active = true;
|
|
}
|
|
if (this.map_data.is_can_reward != 1) {
|
|
this.boxNd.active = true;
|
|
} else {
|
|
this.boxNd.active = false;
|
|
}
|
|
}
|
|
var map_list = [];
|
|
if (!this.is_init_over) {
|
|
var len = data.tile_list.length;
|
|
var pop = data.tile_list[len - 1];
|
|
var bottom = data.tile_list[0];
|
|
var max_line = Math.max(pop.line, bottom.line);
|
|
for (var i = max_line; i >= 1; i--) {
|
|
this.createLineList(i);
|
|
}
|
|
map_list = this.formSortList(data.tile_list);
|
|
for (var _i in map_list) {
|
|
var tile_cfg = map_list[_i];
|
|
this.createMapItem(tile_cfg, _i);
|
|
}
|
|
this.is_init_over = true;
|
|
} else {
|
|
map_list = this.formSortList(data.tile_list);
|
|
for (var _i2 in map_list) {
|
|
var _tile_cfg = map_list[_i2];
|
|
var par = null;
|
|
for (var _i3 in this.list.children) {
|
|
var line = this.list.children[_i3];
|
|
if (Number(line.name) == _tile_cfg.line) {
|
|
par = line;
|
|
}
|
|
}
|
|
if (par) {
|
|
for (var j in par.children) {
|
|
var map = par.children[j];
|
|
var cmp = nx.gui.getComponent(map, "", "cmp.planesafk.item.map");
|
|
if (cmp.data && cmp.data.index == _tile_cfg.index) {
|
|
cmp.setData(_tile_cfg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.updateRoleInfo();
|
|
this.scheduleOnce(function () {
|
|
_this2.updateBoxInfo();
|
|
}, 0.5);
|
|
},
|
|
formSortList: function formSortList(tile_list) {
|
|
if (!tile_list || tile_list.length == 0) return [];
|
|
var len = tile_list.length;
|
|
var pop = tile_list[len - 1];
|
|
var bottom = tile_list[0];
|
|
var max_line = Math.max(pop.line, bottom.line);
|
|
var map_list = [];
|
|
for (var i = max_line; i >= 1; i--) {
|
|
var maps = [];
|
|
for (var l in tile_list) {
|
|
if (tile_list[l].line == i) {
|
|
maps.push(tile_list[l]);
|
|
}
|
|
}
|
|
maps.sort(function (a, b) {
|
|
return b.index - a.index;
|
|
});
|
|
map_list = map_list.concat(maps);
|
|
}
|
|
return map_list;
|
|
},
|
|
createLineList: function createLineList(index) {
|
|
var line = cc.instantiate(this.fabLine);
|
|
line.parent = this.list;
|
|
line.name = String(index);
|
|
line.y = 0;
|
|
line.x = 0;
|
|
line.active = true;
|
|
},
|
|
createMapItem: function createMapItem(cfg, index) {
|
|
var par = null;
|
|
for (var i in this.list.children) {
|
|
var line = this.list.children[i];
|
|
if (Number(line.name) == cfg.line) {
|
|
par = line;
|
|
}
|
|
}
|
|
if (par) {
|
|
var map = cc.instantiate(this.fabMap);
|
|
map.parent = par;
|
|
map.x = 0;
|
|
map.y = 0;
|
|
map.name = String(cfg.line - 1);
|
|
map.active = true;
|
|
map.zIndex = index;
|
|
var cmp = nx.gui.getComponent(map, "", "cmp.planesafk.item.map");
|
|
if (cmp) {
|
|
cmp.setData(cfg);
|
|
}
|
|
}
|
|
},
|
|
//直接更换冒险形象
|
|
// 显示角色信息角色
|
|
showRoleInfo: function showRoleInfo(line, index) {
|
|
//先保存位置
|
|
this.pushPath.push([line, index]);
|
|
},
|
|
updateRoleInfo: function updateRoleInfo() {
|
|
var _, _2, _3, _pos_group;
|
|
//常规定点位置无效,使用line,index当坐标
|
|
var line_box = {
|
|
w: 300,
|
|
h: 624
|
|
};
|
|
var line_padx = 80;
|
|
//line上的item从上到下排列,从0向上下延伸
|
|
//分为2,4 1,3,5两种模式
|
|
var par = this.list.children;
|
|
var line_group = {};
|
|
for (var i in par) {
|
|
line_group[par[i].name] = par[i].children.length;
|
|
}
|
|
var pos_group = (_pos_group = {}, _pos_group[1] = (_ = {}, _[3] = 0, _), _pos_group[2] = (_2 = {}, _2[2] = -84, _2[4] = 84, _2), _pos_group[3] = (_3 = {}, _3[1] = -168, _3[3] = 0, _3[5] = 168, _3), _pos_group);
|
|
this.pathSort(this.pushPath);
|
|
var pts = [];
|
|
var start_pos = null;
|
|
for (var _i4 = 0; _i4 < this.pushPath.length; _i4++) {
|
|
var mpos = this.pushPath[_i4];
|
|
if (line_group[mpos[0]]) {
|
|
var poses = pos_group[line_group[mpos[0]]];
|
|
var role_y = poses[mpos[1]] + 50;
|
|
var role_x = mpos[0] * line_box.w - (mpos[0] - 1) * line_padx - 150;
|
|
var real_pos = new cc.v2(role_x, role_y);
|
|
if (_i4 == 0) {
|
|
start_pos = real_pos;
|
|
}
|
|
pts.push(real_pos);
|
|
}
|
|
}
|
|
if (start_pos != null) {
|
|
this.cmpRole.node.position = start_pos;
|
|
this.cmpRole.pushPaths(pts);
|
|
this.pushPath = [];
|
|
} else {
|
|
this.roleMapMove();
|
|
}
|
|
},
|
|
pathSort: function pathSort(arr) {
|
|
arr.sort(function (a, b) {
|
|
if (a[0] != b[0]) {
|
|
return a[0] - b[0];
|
|
}
|
|
});
|
|
},
|
|
setData: function setData() {
|
|
var time = this.base_data.update_time - client.socket.getTime();
|
|
//处理时间
|
|
nx.gui.setCdTxt(this.time_val, "", time);
|
|
},
|
|
getBoxStatus: function getBoxStatus() {
|
|
if (!this.map_data) return;
|
|
//显示宝箱状态 1 表示 未激活 2 表示可领取 3 表示已领取 0 表示不显示并且要显示门
|
|
var is_show_box_staus = 0;
|
|
if (this.map_data.is_can_reward == 1) {
|
|
if (this.map_data.is_reward == 1) {
|
|
//已领取
|
|
if (this.max_floor > this.map_data.floor) {
|
|
// 不是最后一层 要显示门
|
|
is_show_box_staus = 0;
|
|
} else {
|
|
is_show_box_staus = 3;
|
|
}
|
|
} else {
|
|
//可领取
|
|
is_show_box_staus = 2;
|
|
}
|
|
} else {
|
|
//未激活
|
|
is_show_box_staus = 1;
|
|
}
|
|
return is_show_box_staus;
|
|
},
|
|
//更新宝箱逻辑
|
|
updateBoxInfo: function updateBoxInfo() {
|
|
var self = this;
|
|
var is_show_box_staus = this.getBoxStatus();
|
|
this.is_show_box_staus = is_show_box_staus;
|
|
if (is_show_box_staus == 0) {
|
|
this.boxNd.active = false;
|
|
this.holeNd.active = true;
|
|
} else if (is_show_box_staus == 3) {
|
|
this.boxNd.active = false;
|
|
this.holeNd.active = false;
|
|
this.endNd.active = true;
|
|
} else {
|
|
this.boxNd.active = true;
|
|
this.holeNd.active = false;
|
|
// this.spBox.stop();
|
|
if (is_show_box_staus == 3) {
|
|
this.onClickHardBtn();
|
|
}
|
|
// let res_path = PathTool.getSpinePath( "E27703", "action", false );
|
|
// self.spBox.load( res_path, ( _e ) => {
|
|
// if( !_e ) {
|
|
// if (is_show_box_staus == 1) {
|
|
// //未激活
|
|
// self.spBox.action( "action", true );
|
|
// }
|
|
// else if ( is_show_box_staus == 2) {
|
|
// //可领取
|
|
// self.spBox.action( "action1", true );
|
|
// }
|
|
// else if ( is_show_box_staus == 3) {
|
|
// //已领取
|
|
// self.spBox.action( "baoji", true );
|
|
// this.onClickHardBtn();
|
|
// }
|
|
// } else {
|
|
// self.spBox.stop();
|
|
// }
|
|
// } );
|
|
}
|
|
|
|
//判断弹窗逻辑
|
|
if (this.is_reward != null && this.is_reward != this.map_data.is_reward && is_show_box_staus == 3) {
|
|
this.model.setIsShowSearchFinish(true);
|
|
}
|
|
this.is_reward = this.map_data.is_reward;
|
|
},
|
|
start: function start() {},
|
|
onOpenConfigs: function onOpenConfigs(param) {
|
|
this.ctrl.sender28602(); // 基本信息
|
|
this.ctrl.sender28603(); //地图信息
|
|
this.ctrl.sender28625();
|
|
},
|
|
onPreClosed: function onPreClosed() {
|
|
nx.bridge.NodeChidrenDestroy(this.list);
|
|
},
|
|
// 打开振魂结晶
|
|
onClickBagBtn: function onClickBagBtn() {
|
|
this.ctrl.openPlanesafkItemUsePanel(true);
|
|
},
|
|
// 打开英雄列表
|
|
onClickHeroBtn: function onClickHeroBtn() {
|
|
this.ctrl.openPlanesafkHeroListPanel(true);
|
|
},
|
|
// 打开buff列表
|
|
onClickBuffBtn: function onClickBuffBtn() {
|
|
this.ctrl.openPlanesafkBuffListPanel(true);
|
|
},
|
|
// 打开商店
|
|
onClickShopBtn: function onClickShopBtn() {
|
|
MallController.getInstance().openMallPanel(true, [MallConst.MallType.ScoreShop, MallConst.MallType.FriendShop]);
|
|
},
|
|
//点击难度
|
|
onClickHardBtn: function onClickHardBtn(index) {
|
|
if (!this.map_data) {
|
|
return;
|
|
}
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
|
if (this.map_data.floor && this.map_data.floor > 1 && role_vo && role_vo.power >= this.planes_difficult_max_power && role_vo.lev >= this.difficult_limit_lev) {
|
|
this.ctrl.sender28604(this.map_data.floor + 1, 2);
|
|
} else {
|
|
this.ctrl.sender28604(this.map_data.floor + 1, 1);
|
|
}
|
|
},
|
|
//点击了宝箱
|
|
onClickBoxBtn: function onClickBoxBtn() {
|
|
if (!this.map_data) {
|
|
return;
|
|
}
|
|
if (this.map_data.is_can_reward == 1) {
|
|
this.ctrl.sender28605(this.map_data.floor);
|
|
}
|
|
},
|
|
onOpenTip: function onOpenTip() {
|
|
var TC = TipsController.getInstance();
|
|
if (TC) {
|
|
var config = gdata("planes_data", "data_const", "planes_rule");
|
|
TC.showTextPanel(null, config.desc);
|
|
}
|
|
},
|
|
onClickShowGet: function onClickShowGet() {
|
|
nx.bridge.createPanel("WndPlanesafkGet", {
|
|
item_list: this.up_item_list
|
|
});
|
|
} // update (dt) {},
|
|
});
|
|
|
|
cc._RF.pop(); |