Files
fc/dev/project/library/imports/bd/bd0da8a3-41ce-4e06-954f-4f8d463ef1de.js
2026-05-24 10:21:26 +08:00

312 lines
11 KiB
JavaScript

"use strict";
cc._RF.push(module, 'bd0daijQc5OBpVPT41GPvHe', 'act.newherosum.wnd');
// Scripts/mod/acts/newherosum/act.newherosum.wnd.js
"use strict";
var BasePage = require("act.page.base");
var NXSpine = require("nx.fx.spine");
var BCController = require("backpack_controller");
var FID = require("bridge.function.ids");
var TipsController = require("tips_controller");
cc.Class({
"extends": BasePage,
properties: {
nodRole: {
"default": null,
type: NXSpine,
displayName: "顯示的夥伴節點"
},
nodMiniRole: {
"default": null,
type: NXSpine,
displayName: "小顯示的夥伴節點"
},
nodTimesInfo: {
"default": null,
type: cc.Node,
displayName: "結束時間"
},
nodOp: {
"default": null,
type: cc.Node,
displayName: "操作節點"
},
nodInfo: {
"default": null,
type: cc.Node,
displayName: "夥伴信息節點"
},
nodMat: {
"default": null,
type: cc.Node,
displayName: "材料显示"
},
nodRank: {
"default": null,
type: cc.Node,
displayName: "排行显示"
},
nodLog: {
"default": null,
type: cc.Node,
displayName: "日志"
}
},
build: function build(_data) {
var _this = this;
this._super(_data);
// console.log( "當前的相關數據顯示" + JSON.stringify( _data ) );
// 获取指定主题信息
if (!this.mod) {
return;
}
this.unscheduleAllCallbacks();
this.totaldiamond = gdata(this.data.config, "data_const").diamond_times.val;
var mats = this.mod.getNewHeroMat();
for (var m = 0; m < this.nodMat.children.length; m++) {
var mat = mats[m];
var nod = this.nodMat.children[m];
var cmp = nx.gui.getComponent(nod, "", "bridge.binder.item.icon.count");
if (cmp) {
cmp.setID(mat);
}
}
nx.gui.setString(this.nodTimesInfo, "date/txt", nx.bridge.time.toNeedTime(this.data.end_time));
// 取相關的配置
var showinfo = this.mod.getNewHeroCfg();
this.showinfo = showinfo;
if (nx.dt.objNEmpty(showinfo)) {
var roleInfo = game.configs.partner_data.data_partner_base[showinfo.bid];
this.roleInfo = roleInfo;
var skills = gdata("partner_data", "data_partner_star", roleInfo.bid + "_" + roleInfo.init_star).skills;
var path = "resDB/models/" + roleInfo.draw_res + "/show";
var spath = "resDB/models/" + roleInfo.draw_res + "/" + roleInfo.draw_res;
this.nodRole.load(path, function (_e) {
if (!_e) {
_this.nodRole.action(showinfo.action, true);
} else {
_this.nodRole.stop();
}
});
this.nodMiniRole.load(spath, function (_e) {
if (!_e) {
_this.nodMiniRole.action("stand2", true);
} else {
_this.nodMiniRole.stop();
}
});
nx.gui.setString(this.nodInfo, "base/name", roleInfo.name);
nx.gui.setSpriteFrame(this.nodInfo, "base/camp", cc.path.join("coms/images/camps" + roleInfo.camp_type));
nx.gui.setSpriteFrame(this.nodInfo, "stars", cc.path.join("coms/images", "star" + roleInfo.init_star));
nx.gui.setSpriteFrame(this.nodInfo, "qa", cc.path.join("coms/images", "mk_partner_qa" + roleInfo.quality));
var ccskills = nx.dt.objClone(skills);
var delskill = ccskills.shift();
var skillsnod = nx.gui.find(this.nodInfo, "skills");
nx.gui.gocChildren(skillsnod, "", ccskills.length);
this.scheduleOnce(function () {
var skillsnods = nx.gui.find(_this.nodInfo, "skills").children;
for (var i = 0; i < skillsnods.length; i++) {
var skill = ccskills[i];
var skillnod = skillsnods[i];
var _cmp = nx.gui.getComponent(skillnod, "", "cmp.skill.base");
if (_cmp) {
_cmp.setData(skill[1]);
}
}
}, 0.1);
}
this.mod.vbind(this, [["newheroSummonInfo", this.freshInfo.bind(this)], ["newheroSummonLog", this.freshLog.bind(this)]]);
// 12秒調用相關請求接口
this.schedule(function () {
_this.mod.reqSummonLog();
}, 12, cc.macro.REPEAT_FOREVER);
this.mod.reqSummonLog();
},
onEnable: function onEnable() {
// this.unscheduleAllCallbacks();
this.mod.reqBaseInfo();
},
// 销毁
onDestroy: function onDestroy() {
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
this._super();
},
/***
* [11:22:57:463][recv] <<<[23270]:{
* "camp_id":51174,
* "free_time":0,
* "gold_time":20,
* "times":0,
* "start_time":1717603200,
* "end_time":1718812559,
* "item_id":1006,
* "item_num":0,"must_count":110,"lucky_bid":20514,"my_idx":0,"name":"明月之極速","my_val1":0,"rank_list":[]}
*/
freshInfo: function freshInfo(_data) {
if (!_data) {
return;
}
this.herodatacfg = gdata(this.data.config, "data_const");
this.summoninfo = _data;
var gold_times = _data.gold_time;
var must_time = _data.must_count;
nx.gui.setString(this.nodTimesInfo, "times/must/times", must_time);
nx.gui.setString(this.nodTimesInfo, "times/diamond/times", gold_times + "/" + this.totaldiamond);
nx.gui.setString(this.nodTimesInfo, "times/diamond/desc", this.herodatacfg.diamond_times.desc);
nx.gui.setString(this.nodTimesInfo, "times/must/desc", nx.text.format("ActNewHeroMustTip", this.roleInfo.name));
this.freshOp();
var ranks = _data.rank_list;
/***
* <<[23270]:{"camp_id":51174,
* "free_time":1717689600,"gold_time":7,
* "times":14,"start_time":1717603200,
* "end_time":1718812559,"item_id":1006,
* "item_num":0,"must_count":96,"lucky_bid":20514,
* "my_idx":1,"name":"愛你半夏","my_val1":14,
* "rank_list":[{"name":"愛你半夏","val1":14,"idx":1},{"name":"琉璃冷漠","val1":1,"idx":2}]}
*/
nx.gui.gocChildren(this.nodRank, "list/view/content", _data.rank_list.length);
var chd = nx.gui.find(this.nodRank, "list/view/content").children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
var info = ranks[i];
if (info) {
nx.gui.setString(nod, "name", info.name);
nx.gui.setString(nod, "times", info.val1);
nx.gui.setActive(nod, "rank/" + ("rank" + info.idx), true);
}
}
nx.gui.setString(this.nodRank, "me/name", _data.name);
nx.gui.setString(this.nodRank, "me/rank/rank4/txt", _data.my_idx);
nx.gui.setActive(this.nodRank, _data.my_idx <= 3 ? "me/rank/" + ("rank" + _data.my_idx) : "me/rank/rank4", true);
nx.gui.setString(this.nodRank, "me/name", _data.name);
nx.gui.setString(this.nodRank, "me/times", _data.my_val1);
},
freshOp: function freshOp() {
nx.gui.setString(this.nodOp, "once/free/time", this.summoninfo.free_time == 0 ? nx.text.getKey("Free") : nx.text.format("FreeCD", nx.bridge.time.toNeedTime(this.summoninfo.free_time)));
// nx.gui.setActive( this.nodOp, "once/free", this.summoninfo.free_time != 0 );
nx.gui.setActive(this.nodOp, "once/tip", this.summoninfo.free_time == 0);
var mat = this.showinfo.loss_item_once[0][0];
var BC = BCController.getInstance().getModel();
var have = BC.getItemNumByBid(mat);
var matfirst = [];
var matten = [];
var self = this;
var dealShow = function dealShow() {
if (have == 0) {
matfirst = self.showinfo.loss_gold_once[0];
matten = self.showinfo.loss_gold_ten[0];
} else if (have >= self.showinfo.loss_item_ten[0][1]) {
matfirst = self.showinfo.loss_item_once[0];
matten = self.showinfo.loss_item_ten[0];
} else if (have >= self.showinfo.loss_item_once[0][1] && have < self.showinfo.loss_item_ten[0][1]) {
matfirst = self.showinfo.loss_item_once[0];
matten = self.showinfo.loss_gold_ten[0];
}
};
if (this.summoninfo.gold_time != 0) {
if (this.summoninfo.gold_time >= 10) {
/**
* 沒有材料,顯示鑽石
* 材料不小於十次時 顯示的都是材料
* 材料不多於十次消耗 一次抽顯示的材料 十次抽顯示的鑽石
* */
dealShow();
} else {
matfirst = this.showinfo.loss_gold_once[0];
matten = this.showinfo.loss_gold_ten[0];
}
} else {
dealShow();
}
// ActNewHeroSum
nx.gui.setString(this.nodOp, "once/btn/list/num", matfirst[1]);
nx.bridge.setIconS(this.nodOp, "once/btn/list/icon", matfirst[0]);
nx.gui.setString(this.nodOp, "once/btn/txt", nx.text.format("ActNewHeroSum", this.showinfo.loss_item_once[0][1]));
nx.gui.find(this.nodOp, "once/btn").times = this.showinfo.loss_item_once[0][1];
nx.gui.find(this.nodOp, "once/btn").itemm = matfirst;
nx.gui.find(this.nodOp, "ten/btn").times = this.showinfo.loss_item_ten[0][1];
nx.gui.setString(this.nodOp, "ten/btn/list/num", matten[1]);
nx.gui.find(this.nodOp, "ten/btn").itemm = matten;
nx.bridge.setIconS(this.nodOp, "ten/btn/list/icon", matten[0]);
nx.gui.setString(this.nodOp, "ten/btn/txt", nx.text.format("ActNewHeroSum", this.showinfo.loss_item_ten[0][1]));
},
// 傳入 次數 類型 --1 免費 --3 鑽石 --4 道具
onTouchSum: function onTouchSum(_nod) {
var type = 0;
if (_nod.times == this.showinfo.loss_item_once[0][1]) {
if (this.summoninfo.free_time == 0) {
type = 1;
} else {
if (_nod.itemm[0] == this.showinfo.loss_item_once[0][0]) {
type = 4;
} else {
type = 3;
}
}
} else {
if (_nod.itemm[0] == this.showinfo.loss_item_ten[0][0]) {
type = 4;
} else {
type = 3;
}
}
var mat = _nod.itemm[0];
var num = _nod.itemm[1];
var BC = BCController.getInstance().getModel();
var have = BC.getItemNumByBid(mat);
if (this.summoninfo.gold_time - _nod.times < 0 && type == 3) {
nx.tbox("ActNewHeroDiaTimeNoEnough");
return;
}
if (have < num) {
nx.tbox("SummonItemNotEnough");
return;
}
this.mod.reqSummon(_nod.times, type);
},
freshLog: function freshLog(_log) {
if (!_log) {
return;
}
// if( _log )
var log = _log.logs;
nx.gui.gocChildren(this.nodLog, "", log.length);
var chd = this.nodLog.children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
var logss = log[i];
nx.gui.setString(nod, "", logss.msg);
}
},
onTouchExchange: function onTouchExchange() {
nx.bridge.jumper.jump2ActPage(this.showinfo.exchange);
},
onTouchGift: function onTouchGift() {
nx.bridge.jumper.jump2ActPage(this.showinfo.jump);
},
onTouchRank: function onTouchRank() {
nx.bridge.createPanel("WndRankInfo", {
type: 66,
camp_id: this.data.camp_id
});
},
onTouchRate: function onTouchRate() {
var txt = this.mod.getNewHeroRate();
TipsController.getInstance().showTextPanel("PrayRate", txt);
},
onTouchHelp: function onTouchHelp() {
var explain = this.mod.getNewHeroHelp();
TipsController.getInstance().showTextPanel(explain.name, explain.desc);
}
});
cc._RF.pop();