215 lines
6.6 KiB
JavaScript
215 lines
6.6 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '3de79Cc+5xH5ZTVq0sSxLLs', 'cmp.act.planeact');
|
|
// Scripts/mod/acts/planeact/cmp/cmp.act.planeact.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 活动 中心城保卫战
|
|
*
|
|
******************************************************************/
|
|
|
|
var BasePage = require("act.page.base");
|
|
var NxSpine = require("nx.fx.spine");
|
|
var TipsController = require("tips_controller");
|
|
cc.Class({
|
|
"extends": BasePage,
|
|
properties: {
|
|
nodContent: {
|
|
type: cc.Node,
|
|
"default": null
|
|
},
|
|
spRole: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
nodEndTime: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodScore: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodCloseIco: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 初始化
|
|
build: function build(_data) {
|
|
var _this = this;
|
|
this.spRole.load("resDB/models/H30115/show", function (_e) {
|
|
if (!_e) {
|
|
_this.spRole.action("drama1", true);
|
|
} else {
|
|
_this.spRole.stop();
|
|
}
|
|
});
|
|
this._super(_data);
|
|
this.rfgs = gdata(this.data.config, "data_get_info3");
|
|
var len = Object.keys(this.rfgs).length;
|
|
nx.gui.gocChildren(this.nodContent, "", len);
|
|
// 无效
|
|
if (!this.mod) {
|
|
return;
|
|
}
|
|
nx.gui.setActive(this.nodCloseIco, "", false);
|
|
// 活动监听
|
|
this.mod.vbind(this, [["planeact", this.freshInfo.bind(this)], ["activepoints", this.freshActivePoints.bind(this)]]);
|
|
},
|
|
onEnable: function onEnable() {
|
|
// 请求信息
|
|
this.mod.reqPlaneActData();
|
|
this.mod.reqGetActivePoints();
|
|
},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 活动监听解除
|
|
if (this.mod) {
|
|
this.mod.vunbind(this);
|
|
}
|
|
this._super();
|
|
},
|
|
freshInfo: function freshInfo(_data) {
|
|
var _this2 = this;
|
|
if (!_data || nx.dt.objEmpty(_data)) {
|
|
return;
|
|
}
|
|
/****
|
|
* "aim_args":[
|
|
* {"aim_args_key":4,"aim_args_val":56,"aim_args_str":""},
|
|
* {"aim_args_key":5,"aim_args_val":0,"aim_args_str":""}
|
|
* ]
|
|
*/
|
|
var aim_list = _data.aim_list;
|
|
aim_list.sort(function (a, b) {
|
|
return a.sortid - b.sortid;
|
|
});
|
|
this.planeInfo = _data;
|
|
this.aims = aim_list;
|
|
var chd = this.nodContent.children;
|
|
var _loop = function _loop() {
|
|
var nod = chd[i];
|
|
var sinfo = aim_list[i];
|
|
var info = _this2.rfgs[sinfo.aim];
|
|
nx.gui.setString(nod, "descs/desc/title", info.desc);
|
|
var cmp = nx.gui.getComponent(nod, "lst", "cmp.common.itemlayout");
|
|
if (cmp) {
|
|
cmp.rebuild(info.reward);
|
|
}
|
|
var target = 0;
|
|
var value = 0;
|
|
nx.gui.find(nod, "go").zIndex = info.source_id;
|
|
nx.gui.find(nod, "get").aim = sinfo.aim;
|
|
sinfo.aim_args.forEach(function (_aim) {
|
|
if (_aim && _aim.aim_args_key == 4) {
|
|
target = _aim.aim_args_val;
|
|
}
|
|
if (_aim && _aim.aim_args_key == 5) {
|
|
value = _aim.aim_args_val;
|
|
}
|
|
});
|
|
nx.gui.setActive(nod, "go", sinfo.status == 0);
|
|
nx.gui.setActive(nod, "get", sinfo.status == 1);
|
|
nx.gui.setActive(nod, "finish", sinfo.status == 2);
|
|
nx.gui.setString(nod, "descs/leftdesc/prog", value + "/" + target);
|
|
nx.gui.setActive(nod, "descs/leftdesc", sinfo.status != 2);
|
|
};
|
|
for (var i = 0; i < chd.length; i++) {
|
|
_loop();
|
|
}
|
|
var left = _data.remain_sec > 0 ? _data.remain_sec : 0.1;
|
|
nx.gui.setCdTxt(this.nodEndTime, "txt", left, function () {
|
|
nx.gui.setString(_this2.nodEndTime, "txt", nx.text.getKey("lab_planesafk_main_have_over"));
|
|
});
|
|
},
|
|
freshActivePoints: function freshActivePoints(_actinfo) {
|
|
var _this3 = this;
|
|
var point = _actinfo.point;
|
|
nx.gui.setString(this.nodScore, "title/points/point", point);
|
|
this.rfg = gdata(this.data.config, "data_get_reward");
|
|
var len = gdata(this.data.config, "data_get_reward_length");
|
|
var prog = nx.gui.getComponent(this.nodScore, "prog", cc.ProgressBar);
|
|
var total = this.rfg[len].need_point;
|
|
var percent = parseFloat(point / total);
|
|
if (prog) {
|
|
prog.progress = percent;
|
|
}
|
|
var rewards = _actinfo.reward_list;
|
|
var chd = nx.gui.find(this.nodScore, "rewards").children;
|
|
var _loop2 = function _loop2(i) {
|
|
var nod = chd[i];
|
|
var item = _this3.rfg[i + 1];
|
|
var showcmp = nx.gui.getComponent(nod, "show", "cmp.common.itemlayout");
|
|
if (showcmp) {
|
|
showcmp.rebuild(item.reward);
|
|
}
|
|
nx.gui.setString(nod, "point", nx.text.format("ActPoint", item.need_point));
|
|
nx.gui.find(nod, "touch").zIndex = i + 1;
|
|
nx.gui.find(nod, "get").zIndex = i + 1;
|
|
nx.gui.setActive(nod, "ico_close", true);
|
|
nx.gui.setActive(nod, "ico_open", false);
|
|
nx.gui.setActive(nod, "get", point >= item.need_point);
|
|
rewards.forEach(function (_get) {
|
|
if (_get && _get.id == i + 1) {
|
|
nx.gui.setActive(nod, "ico_open", true);
|
|
nx.gui.setActive(nod, "get", false);
|
|
}
|
|
});
|
|
nx.gui.setActive(nod, "show", false);
|
|
};
|
|
for (var i = 0; i < chd.length; i++) {
|
|
_loop2(i);
|
|
}
|
|
},
|
|
onTouchHideAllDesc: function onTouchHideAllDesc() {
|
|
var chd = nx.gui.find(this.nodScore, "rewards").children;
|
|
for (var i = 0; i < chd.length; i++) {
|
|
var nod = chd[i];
|
|
nx.gui.setActive(nod, "show", false);
|
|
}
|
|
nx.gui.setActive(this.nodCloseIco, "", false);
|
|
},
|
|
onTouchGetActiveReward: function onTouchGetActiveReward(_btn) {
|
|
var id = this.rfg[_btn.zIndex].id;
|
|
this.mod.reqGetActiveReward(id);
|
|
},
|
|
onTouchGet: function onTouchGet(_btn) {
|
|
if (this.planeInfo.remain_sec == 0) {
|
|
nx.tbox("lab_recruit_hero_window_tip_6");
|
|
return;
|
|
}
|
|
var id = _btn.aim;
|
|
this.mod.reqGetPlaneActGift(id);
|
|
},
|
|
onTouchGoto: function onTouchGoto(_btn) {
|
|
if (this.planeInfo.remain_sec == 0) {
|
|
nx.tbox("lab_recruit_hero_window_tip_6");
|
|
return;
|
|
}
|
|
var source = _btn.zIndex;
|
|
nx.bridge.jumper.jump2Window(source);
|
|
},
|
|
onTouchShow: function onTouchShow(_btn) {
|
|
var index = parseInt(_btn.zIndex - 1);
|
|
var chd = nx.gui.find(this.nodScore, "rewards").children;
|
|
for (var i = 0; i < chd.length; i++) {
|
|
var nod = chd[i];
|
|
if (i != index) {
|
|
nx.gui.setActive(nod, "show", false);
|
|
}
|
|
}
|
|
var nodShow = nx.gui.find(chd[index], "show");
|
|
nx.gui.setActive(nodShow, "", !nodShow.active);
|
|
nx.gui.setActive(this.nodCloseIco, "", nodShow.active == true);
|
|
},
|
|
onTouchHelp: function onTouchHelp() {
|
|
var TC = TipsController.getInstance();
|
|
var explain = gdata(this.data.config, "data_explain");
|
|
TC.showDetailPanel(explain);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |