142 lines
3.8 KiB
JavaScript
142 lines
3.8 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'cf78cLk7yVGP72kBbc1VqH8', 'cmp.campfight.battle');
|
||
|
|
// Scripts/mod/pvp/campfight/cmp/cmp.campfight.battle.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var CampfightConst = require("campfight.const");
|
||
|
|
var CampfightMod = require("campfight.mod");
|
||
|
|
var BridgeCmp = require("bridge.component");
|
||
|
|
var NxTogs = require("nx.fx.togs");
|
||
|
|
var ItemLay = require("cmp.common.itemlayout");
|
||
|
|
var ReportCmp = require("cmp.campfight.report");
|
||
|
|
var HeroConst = require("hero_const");
|
||
|
|
var HeroController = require("hero_controller");
|
||
|
|
var PartnerConst = require("partner_const");
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeCmp,
|
||
|
|
properties: {
|
||
|
|
groupTog: {
|
||
|
|
"default": null,
|
||
|
|
type: NxTogs
|
||
|
|
},
|
||
|
|
seats: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
fabSeat: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Prefab
|
||
|
|
},
|
||
|
|
// seatList:{
|
||
|
|
// default:null,
|
||
|
|
// type:ItemLay
|
||
|
|
// },
|
||
|
|
reportView: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
ReportCmp: {
|
||
|
|
"default": null,
|
||
|
|
type: ReportCmp
|
||
|
|
},
|
||
|
|
emptyTip: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
onLoad: function onLoad() {
|
||
|
|
this._super();
|
||
|
|
this.mod = CampfightMod.getInstance();
|
||
|
|
this.seatsCamps = {};
|
||
|
|
this.groupTog.posTog = this.onTogMenu.bind(this);
|
||
|
|
this.bindGEvent(CampfightConst.EVT_CAMP_BATUI, this.freshSeats.bind(this));
|
||
|
|
this.bindGEvent(CampfightConst.EVT_CAMP_UPSEAT, this.ChangeGroup.bind(this));
|
||
|
|
},
|
||
|
|
onTogMenu: function onTogMenu(_index) {
|
||
|
|
var _this = this;
|
||
|
|
this.mod.reqBatGroup(_index + 1, function (_data) {
|
||
|
|
if (_data) {
|
||
|
|
_this.mod.setReqGroup(_index + 1);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
this.ReportCmp.setCurGroup(_index + 1);
|
||
|
|
},
|
||
|
|
freshSeats: function freshSeats(data) {
|
||
|
|
if (nx.dt.objEmpty(data)) return;
|
||
|
|
this.emptyTip.active = false;
|
||
|
|
if (nx.dt.arrEmpty(data.role_list)) {
|
||
|
|
this.emptyTip.active = true;
|
||
|
|
}
|
||
|
|
data.role_list.sort(Utils.tableLowerSorter(["rank"]));
|
||
|
|
// this.seatList.rebuild(data.role_list);
|
||
|
|
//刷新座位
|
||
|
|
for (var d = 0; d < 8; d++) {
|
||
|
|
var mdata = data.role_list[d];
|
||
|
|
var nd = nx.gui.find(this.seats, String(d));
|
||
|
|
if (mdata) {
|
||
|
|
var cmp = this.seatsCamps[mdata.rank];
|
||
|
|
if (cmp) {
|
||
|
|
cmp.setData(mdata);
|
||
|
|
} else {
|
||
|
|
if (nd) {
|
||
|
|
var fab = cc.instantiate(this.fabSeat);
|
||
|
|
fab.parent = nd;
|
||
|
|
var newcmp = nx.gui.getComponent(fab, "", "cmp.campfight.battle.item");
|
||
|
|
if (newcmp) {
|
||
|
|
newcmp.setData(mdata);
|
||
|
|
this.seatsCamps[mdata.rank] = newcmp;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
this.seatsCamps[d + 1] = null;
|
||
|
|
if (nd) {
|
||
|
|
nx.bridge.NodeChidrenDestroy(nd);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
ChangeGroup: function ChangeGroup(group) {
|
||
|
|
var _this2 = this;
|
||
|
|
if (group == 0) {
|
||
|
|
this.groupTog.togTo(0, true);
|
||
|
|
this.mod.reqBatGroup(1, function (_data) {
|
||
|
|
if (_data) {
|
||
|
|
_this2.mod.setReqGroup(1);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
this.groupTog.togTo(group - 1);
|
||
|
|
this.mod.reqBatGroup(group, function (_data) {
|
||
|
|
if (_data) {
|
||
|
|
_this2.mod.setReqGroup(group);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onEnable: function onEnable() {
|
||
|
|
this.mod.reqSelfGroup(); //再次請求分組
|
||
|
|
},
|
||
|
|
onDisable: function onDisable() {
|
||
|
|
// this.seatList.rebuild([]);
|
||
|
|
this.seatsCamps = null;
|
||
|
|
// 监听事件释放
|
||
|
|
this.unbindGEvents();
|
||
|
|
},
|
||
|
|
//商店
|
||
|
|
onClickShop: function onClickShop() {},
|
||
|
|
//戰報
|
||
|
|
onClickReport: function onClickReport() {
|
||
|
|
this.reportView.active = true;
|
||
|
|
},
|
||
|
|
onSetDefendForm: function onSetDefendForm() {
|
||
|
|
HeroController.getInstance().openFormGoFightPanel(true, PartnerConst.Fun_Form.YearDefend, {
|
||
|
|
period: this.mod.getCurPeriod(),
|
||
|
|
need_hide_top: true
|
||
|
|
}, HeroConst.FormShowType.eFormSave);
|
||
|
|
} // update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|