"use strict";
|
cc._RF.push(module, '9c0138j0WVGHa8i965vYoCW', 'action_time_summon_panel');
|
// Scripts/mod/timesummon/view/action_time_summon_panel.js
|
|
"use strict";
|
|
// --------------------------------------------------------------------
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
// @description:
|
// 这里是描述这个窗体的作用的
|
// <br/>Create: 2019-07-08 21:18:12
|
// --------------------------------------------------------------------
|
var PathTool = require("pathtool");
|
|
var TimesummonEvent = require("timesummon_event");
|
|
var TimesummonController = require("timesummon_controller");
|
|
var BackpackController = require("backpack_controller");
|
|
var TimeTool = require("timetool");
|
|
var BackPackConst = require("backpack_const");
|
|
var HeroController = require("hero_controller");
|
|
var RoleController = require("role_controller");
|
|
var SummonEvent = require("partnersummon_event");
|
|
var PartnersummonController = require("partnersummon_controller");
|
|
var MainUiController = require("mainui_controller");
|
|
var BackpackEvent = require("backpack_event");
|
|
var ActionConst = require("action_const");
|
|
var ActionTimeSummonPanel = cc.Class({
|
"extends": BasePanel,
|
ctor: function ctor() {
|
this.prefabPath = PathTool.getPrefabPath("action", "action_time_summon_panel");
|
var item_bid_cfg = Config.recruit_holiday_data.data_const["common_s"];
|
this.ctrl = TimesummonController.getInstance();
|
|
if (item_bid_cfg) {
|
this.summon_item_bid = item_bid_cfg.val; // 召唤道具bid
|
}
|
},
|
// 可以初始化声明一些变量的
|
initConfig: function initConfig() {
|
this._summon_type_1 = 1; // 单抽的抽取类型(1免费 3钻石 4道具)
|
|
this._summon_type_10 = 3; // 十连抽抽取类型(3钻石 4道具)
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
this.arard_data = Config.recruit_holiday_data.data_award;
|
},
|
// 初始化一些配置数据,可以用于声明一些变量之类的
|
initPanel: function initPanel() {
|
var x = this.getPositionX();
|
this.setPosition(x, -20);
|
var self = this;
|
var main_container = this.root_wnd.getChildByName("main_container");
|
self.image_bg_sp = main_container.getChildByName("image_bg").getComponent(cc.Sprite);
|
self.progress_txt = main_container.getChildByName("progress_txt").getComponent(cc.Label);
|
self.item_num_txt = main_container.getChildByName("item_num_txt").getComponent(cc.Label);
|
self.progress = main_container.getChildByName("progress").getComponent(cc.ProgressBar);
|
self.baodi_bg = main_container.getChildByName("baodi_bg");
|
self.award_btn = main_container.getChildByName("award_btn");
|
self.award_btn.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("奖励预览");
|
self.preview_btn = main_container.getChildByName("preview_btn");
|
self.preview_btn.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("战斗预览");
|
self.summon_btn_1 = main_container.getChildByName("summon_btn_1");
|
self.summon_btn_1.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("招募1次");
|
self.summon_txt_1_rt = self.summon_btn_1.getChildByName("summon_txt_1").getComponent(cc.RichText);
|
self.summon_prop_1_nd = self.summon_btn_1.getChildByName("summon_prop");
|
self.summon_prop_num_lb = self.summon_prop_1_nd.getChildByName("summon_prop_num").getComponent(cc.Label);
|
var item_config = Utils.getItemConfig(self.summon_item_bid);
|
var path = PathTool.getItemRes(item_config.icon);
|
this.loadRes(path, function (res) {
|
this.summon_prop_1_nd.getChildByName("summon_prop_item").getComponent(cc.Sprite).spriteFrame = res;
|
main_container.getChildByName("item_icon").getComponent(cc.Sprite).spriteFrame = res;
|
}.bind(this));
|
self.summon_btn_10 = main_container.getChildByName("summon_btn_10");
|
self.summon_btn_10.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("招募10次");
|
self.summon_prop_10_nd = self.summon_btn_10.getChildByName("summon_prop");
|
self.summon_prop_sp = self.summon_prop_10_nd.getChildByName("summon_prop_item").getComponent(cc.Sprite);
|
self.summon_10_num_lb = self.summon_prop_10_nd.getChildByName("summon_prop_num").getComponent(cc.Label);
|
self.time_txt = main_container.getChildByName("time_txt").getComponent(cc.Label);
|
this.baodi_text_rt = this.seekChild("baodi_text", cc.RichText);
|
self.award_item = ItemsPool.getInstance().getItem("backpack_item");
|
self.award_item.setParent(main_container);
|
self.award_item.setPosition(60, 728);
|
self.award_item.initConfig(false, 0.6, false, false);
|
self.award_item.show();
|
self.award_item.addCallBack(this._onClickAwardItem.bind(this));
|
},
|
// 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
|
registerEvent: function registerEvent() {
|
this.addGlobalEvent(TimesummonEvent.Update_Summon_Data_Event, function (data) {
|
this.setData(data);
|
}, this); // 召唤成功
|
|
this.addGlobalEvent(SummonEvent.PartnerSummonSuccess, function () {
|
this.playRecruitEffect();
|
}.bind(this)); // --物品道具增加
|
|
this.addGlobalEvent(BackpackEvent.ADD_GOODS, function (bag_code, data_list) {
|
this.updateItemNum(bag_code, data_list);
|
}.bind(this)); //物品道具删除
|
|
this.addGlobalEvent(BackpackEvent.DELETE_GOODS, function (bag_code, data_list) {
|
this.updateItemNum(bag_code, data_list);
|
}.bind(this)); //物品道具改变
|
|
this.addGlobalEvent(BackpackEvent.MODIFY_GOODS_NUM, function (bag_code, data_list) {
|
this.updateItemNum(bag_code, data_list);
|
}.bind(this));
|
this.preview_btn.on('click', function () {
|
this.ctrl.send23219(ActionConst.ActionRankCommonType.time_summon);
|
}, this);
|
this.summon_btn_1.on('click', function () {
|
Utils.playButtonSound(1);
|
if (this.checkHeroBagIsFull(1)) return;
|
cc.log(this.last_time, gcore.SmartSocket.getTime());
|
|
if (this.last_time && gcore.SmartSocket.getTime() - this.last_time < 2) {
|
return;
|
}
|
|
this.last_time = gcore.SmartSocket.getTime();
|
|
if (this._summon_type_1 == 3 && this.config) {
|
var num = this.config.loss_gold_once[0][1];
|
|
var call_back = function call_back() {
|
this.ctrl.requestTimeSummon(1, this._summon_type_1);
|
};
|
|
var item_icon_2 = Utils.getItemConfig(this.config.loss_gold_once[0][0]).icon;
|
var val_str = Utils.getItemConfig(this.config.gain_once[0][0]).name || "";
|
var val_num = this.config.gain_once[0][1];
|
var call_num = 1;
|
this.showGoldTips(item_icon_2, num, call_num, val_num, val_str, call_back);
|
} else {
|
this.ctrl.requestTimeSummon(1, this._summon_type_1);
|
}
|
}, this);
|
this.summon_btn_10.on("click", function () {
|
Utils.playButtonSound(1);
|
if (this.checkHeroBagIsFull(10)) return;
|
|
if (this.last_time && Math.abs(gcore.SmartSocket.getTime() - this.last_time) < 0.5) {
|
return;
|
}
|
|
this.last_time = gcore.SmartSocket.getTime();
|
|
if (this._summon_type_10 == 3 && this.config) {
|
var num = this.config.loss_gold_ten[0][1];
|
|
var call_back = function call_back() {
|
this.ctrl.requestTimeSummon(10, this._summon_type_10);
|
};
|
|
var item_icon_2 = Utils.getItemConfig(this.config.loss_gold_ten[0][0]).icon;
|
var val_str = Utils.getItemConfig(this.config.gain_ten[0][0]).name || "";
|
var val_num = this.config.gain_ten[0][1];
|
var call_num = 10;
|
this.showGoldTips(item_icon_2, num, call_num, val_num, val_str, call_back);
|
} else {
|
this.ctrl.requestTimeSummon(10, this._summon_type_10);
|
}
|
}, this);
|
this.award_btn.on("click", function () {
|
this.ctrl.openTimeSummonAwardView(true, this.config.group_id, this.data);
|
}, this);
|
},
|
_onClickAwardItem: function _onClickAwardItem() {
|
if (this.data) {
|
if (this.is_can_award) {
|
this.ctrl.requestSummonGetAward();
|
} else {
|
this.ctrl.openTimeSummonProgressView(true, this.data.times, this.data.camp_id);
|
}
|
}
|
},
|
checkHeroBagIsFull: function checkHeroBagIsFull(times) {
|
// 判断英雄背包空间
|
var HeroController = require("hero_controller");
|
|
var hero_model = HeroController.getInstance().getModel();
|
var hero_bag_info = hero_model.getHeroMaxCount();
|
var limit_num = hero_bag_info.max_count - hero_bag_info.have_coutn;
|
|
if (times > limit_num) {
|
var str = Utils.TI18N("英雄列表已满,可通过提升贵族等级或购买增加英雄携带数量,是否前往购买?");
|
|
var CommonAlert = require("commonalert");
|
|
CommonAlert.show(str, Utils.TI18N("确定"), function () {
|
var MainuiConst = require("mainui_const");
|
|
var ActionController = require("action_controller");
|
|
MainUiController.getInstance().changeMainUIStatus(MainuiConst.btn_index.partner);
|
ActionController.getInstance().openActionMainPanel(false);
|
}, Utils.TI18N("取消"), function () {});
|
return true;
|
}
|
|
return false;
|
},
|
// 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
|
onShow: function onShow(params) {
|
this.ctrl.requestTimeSummonData();
|
},
|
setVisibleStatus: function setVisibleStatus(status) {
|
if (this.root_wnd && status) {
|
this.ctrl.requestTimeSummonData();
|
}
|
|
status = status || false;
|
this.setVisible(status);
|
},
|
setData: function setData(data) {
|
if (!data) return;
|
this.data = data;
|
var action_cfg = Config.recruit_holiday_data.data_action[this.data.camp_id];
|
|
if (action_cfg && action_cfg.group_id) {
|
this.config = Config.recruit_holiday_data.data_summon[action_cfg.group_id];
|
} // this._can_get_award = false;
|
// this._award_is_over = false;
|
// this._cur_award_data = {};
|
// let award_config = Config.recruit_holiday_data.data_award[this.data.camp_id];
|
// if(award_config){
|
// let temp_data = [] //-- 次数达到要求的阶段数据
|
// for(let k in award_config){
|
// let v = award_config[k]
|
// if(v.times && v.times <= this.data.times){
|
// temp_data.push(v)
|
// }
|
// }
|
// this.data.reward_list = this.data.reward_list || []
|
// if(temp_data.length > this.data.reward_list.length){ // 有可领取的奖励
|
// this._can_get_award = true
|
// for(let i=0;i< temp_data.length;++i){
|
// this._cur_award_data = temp_data[temp_data.length-1] // 取最靠后的阶段展示
|
// }
|
// }else if(Utils.next(temp_data) == null){
|
// this._cur_award_data = award_config[1]
|
// }else{
|
// let last_data = temp_data[temp_data.length-1]
|
// let id = last_data.id + 1
|
// if(award_config[id]){
|
// this._cur_award_data = award_config[id]
|
// }else{
|
// this._award_is_over = true
|
// this._cur_award_data = award_config[last_data.id]
|
// }
|
// }
|
|
|
this.time_txt.string = TimeTool.getMD2(this.data.start_time) + "~" + TimeTool.getMD2(this.data.end_time);
|
this.nextRewardLevel();
|
this.updateImageBg();
|
this.updateSummonBtnStatus(); // this.updateProgress()
|
|
this.updateItemNum();
|
this.updateBaodiCount(); // }
|
},
|
nextRewardLevel: function nextRewardLevel() {
|
var count = this.nextCount(this.data.times);
|
|
if (this.arard_data[this.data.camp_id] && this.arard_data[this.data.camp_id][count]) {
|
var data = this.arard_data[this.data.camp_id];
|
var _award_is_over = false;
|
|
if (this.award_item) {
|
var bid = data[count].reward[0][0];
|
var num = data[count].reward[0][1];
|
this.award_item.setData({
|
bid: bid,
|
num: num
|
});
|
var obj = this.getBaoDIStatus();
|
this.is_can_award = obj.status;
|
var can_id = obj.id;
|
|
if (this.is_can_award == true) {
|
if (can_id) {
|
var _bid = data[can_id].reward[0][0];
|
var _num = data[can_id].reward[0][1];
|
this.award_item.setData({
|
bid: _bid,
|
num: _num
|
});
|
}
|
|
this.award_item.showItemEffect(true, 263, PlayerAction.action_1, true, 1.1);
|
} else {
|
this.award_item.showItemEffect(false);
|
} // --全部领取完毕的时候
|
|
|
if (this.is_can_award == false && this.data.times >= data[Utils.getArrLen(data)].times) {
|
// setChildUnEnabled(true, this.award_item)
|
this.award_item.setReceivedIcon(true);
|
_award_is_over = true;
|
}
|
}
|
|
var num_times = data[count].times;
|
var label = "";
|
|
if (_award_is_over) {
|
label = Utils.TI18N("招募次数 ") + this.data.times + "/" + num_times;
|
} else {
|
label = Utils.TI18N("下一阶段 ") + this.data.times + "/" + num_times;
|
}
|
|
this.progress_txt.string = label;
|
var cur_num = 0;
|
var totle_num = num_times;
|
|
if (count == 1) {
|
cur_num = this.data.times;
|
} else {
|
cur_num = this.data.times - data[count - 1].times;
|
totle_num = num_times - data[count - 1].times;
|
}
|
|
var percent = cur_num / totle_num;
|
|
if (this.data.times >= data[Utils.getArrLen(data)].times) {
|
percent = 1;
|
}
|
|
this.progress.progress = percent;
|
}
|
},
|
nextCount: function nextCount(cur_num) {
|
var count = 1;
|
var data = this.arard_data[this.data.camp_id];
|
|
if (this.arard_data && data) {
|
var len = Utils.getArrLen(data);
|
|
if (cur_num >= data[len].times) {
|
return data[len].id;
|
}
|
|
for (var i in data) {
|
var m = i + 1;
|
|
if (m >= len) {
|
m = len;
|
}
|
|
if (data[i].times > cur_num && cur_num <= data[m].times) {
|
count = data[i].id;
|
break;
|
}
|
}
|
}
|
|
return count;
|
},
|
// --领取保底状态
|
getBaoDIStatus: function getBaoDIStatus() {
|
var status = false;
|
var id = null;
|
|
if (this.data) {
|
if (this.arard_data[this.data.camp_id]) {
|
for (var i in this.arard_data[this.data.camp_id]) {
|
var v = this.arard_data[this.data.camp_id][i];
|
var cur_status = false;
|
var cur_id = null;
|
|
if (this.data.times >= v.times) {
|
cur_status = true;
|
cur_id = v.id;
|
}
|
|
var true_status = true;
|
|
if (cur_status == true) {
|
for (var j = 0; j < this.data.reward_list.length; ++j) {
|
var k = this.data.reward_list[j];
|
|
if (k.id == cur_id) {
|
true_status = false;
|
break;
|
}
|
}
|
}
|
|
if (cur_id && true_status == true) {
|
status = true;
|
id = cur_id;
|
}
|
}
|
}
|
}
|
|
return {
|
status: status,
|
id: id
|
};
|
},
|
updateImageBg: function updateImageBg() {
|
if (this.config && this.config.res_id && (!this.cur_res_id || this.cur_res_id != this.config.res_id)) {
|
var path = PathTool.getBigBg("timesummon/txt_cn_timesummon_bigbg_" + this.config.res_id, "jpg");
|
this.loadRes(path, function (res) {
|
this.image_bg_sp.spriteFrame = res;
|
}.bind(this));
|
this.cur_res_id = this.config.res_id;
|
}
|
},
|
updateSummonBtnStatus: function updateSummonBtnStatus() {
|
if (this.data && this.config && this.summon_item_bid) {
|
var summon_have_num = BackpackController.getInstance().getModel().getItemNumByBid(this.summon_item_bid); // -- 单抽
|
|
var cur_time = gcore.SmartSocket.getTime();
|
|
if (this.data.free_time == 0 && this.data.free_time <= cur_time) {
|
var txt_str_1 = Utils.TI18N(StringUtil.parseStr("<div fontcolor=#ffffff>免费召唤</div>").string);
|
this._summon_type_1 = 1;
|
this.openSummonFreeTimer(false);
|
this.summon_txt_1_rt.node.active = true; //免费 或者 倒计时
|
|
this.summon_prop_1_nd.active = false; //道具
|
|
this.summon_txt_1_rt.string = txt_str_1;
|
} else if (summon_have_num >= 1) {
|
this._summon_type_1 = 4;
|
this.openSummonFreeTimer(false);
|
this.summon_txt_1_rt.node.active = false; //免费 或者 倒计时
|
|
this.summon_prop_1_nd.active = true; //道具
|
|
this.summon_prop_num_lb.string = summon_have_num;
|
} else if (this.data.free_time) {
|
this.left_time = this.data.free_time - cur_time;
|
this.summon_txt_1_rt.node.active = true; //免费 或者 倒计时
|
|
this.summon_prop_1_nd.active = false; //道具
|
|
this._summon_type_1 = 3;
|
this.openSummonFreeTimer(true);
|
} // -- 十连抽
|
|
|
if (summon_have_num >= 10) {
|
var item_config = Utils.getItemConfig(this.summon_item_bid);
|
|
if (item_config) {
|
var path = PathTool.getItemRes(item_config.icon);
|
this.summon_10_num_lb.string = summon_have_num;
|
this.summon_prop_sp.node.scale = 0.4;
|
this.loadRes(path, function (res) {
|
this.summon_prop_sp.spriteFrame = res;
|
}.bind(this));
|
}
|
|
this._summon_type_10 = 4;
|
} else {
|
var bid = this.config.loss_gold_ten[0][0];
|
var num = this.config.loss_gold_ten[0][1];
|
|
var _path = PathTool.getItemRes(bid);
|
|
this.summon_prop_sp.node.scale = 0.3;
|
this.loadRes(_path, function (res) {
|
this.summon_prop_sp.spriteFrame = res;
|
}.bind(this));
|
this.summon_10_num_lb.string = num;
|
this._summon_type_10 = 3;
|
}
|
}
|
},
|
openSummonFreeTimer: function openSummonFreeTimer(status) {
|
if (status) {
|
if (this.left_time > 0 && this.summon_txt_1_rt) {
|
if (!this.summon_timer) {
|
this.setTimeFormatString();
|
this.summon_timer = gcore.Timer.set(function () {
|
this.setTimeFormatString();
|
}.bind(this), 1000, -1);
|
}
|
} else {
|
if (this.summon_timer) {
|
gcore.Timer.del(this.summon_timer);
|
this.summon_timer = null;
|
}
|
}
|
} else {
|
if (this.summon_timer != null) {
|
gcore.Timer.del(this.summon_timer);
|
this.summon_timer = null;
|
}
|
}
|
},
|
setTimeFormatString: function setTimeFormatString() {
|
if (this.data && this.data.free_time - gcore.SmartSocket.getTime() > 0) {
|
this.left_time = this.data.free_time - gcore.SmartSocket.getTime();
|
this.summon_txt_1_rt.string = cc.js.formatStr(Utils.TI18N(StringUtil.parseStr("<div fontcolor=#35ff14>%s</div><div fontcolor=#ffffff>后免费</div>").string), TimeTool.getTimeFormat(this.left_time));
|
this._summon_type_1 = 3;
|
} else {
|
this.summon_txt_1_rt.string = Utils.TI18N(StringUtil.parseStr("<div fontcolor=#ffffff>免费召唤</div>").string);
|
this._summon_type_1 = 1;
|
|
if (this.summon_timer) {
|
gcore.Timer.del(this.summon_timer);
|
this.summon_timer = null;
|
}
|
}
|
},
|
// -- 刷新进度条显示
|
updateProgress: function updateProgress() {
|
if (this.data && this._cur_award_data && Utils.next(this._cur_award_data) != null) {
|
var reward = this._cur_award_data.reward[0];
|
var bid = reward[0];
|
var num = reward[1];
|
this.award_item.setData({
|
bid: bid,
|
num: num
|
});
|
var percent = this.data.times / this._cur_award_data.times;
|
this.progress.progress = percent;
|
|
if (this._award_is_over) {
|
this.progress_txt.string = Utils.TI18N("招募次数 ") + this.data.times + "/" + this._cur_award_data.times;
|
this.award_item.setReceivedIcon(true);
|
} else {
|
this.progress_txt.string = Utils.TI18N("下一阶段 ") + this.data.times + "/" + this._cur_award_data.times;
|
this.award_item.setReceivedIcon(false);
|
} // -- 有奖励可领时显示特效
|
|
|
if (this._can_get_award == true) {
|
this.award_item.showItemEffect(true, 263, PlayerAction.action_1, true, 1.1);
|
} else {
|
this.award_item.showItemEffect(false);
|
}
|
}
|
},
|
updateItemNum: function updateItemNum(bag_code, data_list) {
|
if (this.summon_item_bid) {
|
if (bag_code && data_list) {
|
if (bag_code == BackPackConst.Bag_Code.BACKPACK) {
|
for (var i in data_list) {
|
var v = data_list[i];
|
|
if (v && v.base_id && this.summon_item_bid == v.base_id) {
|
var summon_have_num = BackpackController.getInstance().getModel().getItemNumByBid(this.summon_item_bid);
|
this.item_num_txt.string = summon_have_num;
|
this.updateSummonBtnStatus();
|
break;
|
}
|
}
|
}
|
} else {
|
var _summon_have_num = BackpackController.getInstance().getModel().getItemNumByBid(this.summon_item_bid);
|
|
this.item_num_txt.string = _summon_have_num;
|
}
|
}
|
},
|
// -- 刷新保底次数显示
|
updateBaodiCount: function updateBaodiCount() {
|
if (!this.baodi_bg || !this.data) return;
|
|
if (!this.data.item_id || this.data.item_id == 0) {
|
this.baodi_bg.active = false;
|
return;
|
}
|
|
this.baodi_bg.active = true;
|
|
if (!this.baodi_item) {
|
this.baodi_item = ItemsPool.getInstance().getItem("backpack_item");
|
this.baodi_item.setParent(this.baodi_bg);
|
this.baodi_item.initConfig(false, 0.35, false, true);
|
this.baodi_item.setPosition(-118, 0);
|
this.baodi_item.show();
|
}
|
|
if (!this.cur_show_bid || this.cur_show_bid != this.data.item_id) {
|
this.baodi_item.setData({
|
bid: this.data.item_id,
|
num: this.data.item_num
|
});
|
this.cur_show_bid = this.data.item_id;
|
}
|
|
var count = this.data.must_count || 0;
|
this.baodi_text_rt.string = Utils.TI18N(cc.js.formatStr(StringUtil.parseStr("<div fontcolor=#ffffff outline=2,#000000>剩余</div><div fontcolor=#5fde46 outline=2,#000000>%d</div><div fontcolor=#ffffff outline=2,#000000>次招募内必出</div>").string, count));
|
},
|
showGoldTips: function showGoldTips(good_res_path, need_num, call_num, val_num, val_str, call_back) {
|
//图标 买几次 购买经验 回调函数
|
if (this.alert) {
|
this.alert.close();
|
this.alert = null;
|
}
|
|
var hvae_num = this.role_vo.gold;
|
var buy_ori = cc.js.formatStr(StringUtil.parseStr(Lang.DIAMOND_CONSUME).string, good_res_path, need_num, hvae_num);
|
var get_ori = cc.js.formatStr(StringUtil.parseStr(Lang.BUY_DES).string, val_num, val_str, call_num);
|
var des_str = buy_ori + get_ori;
|
var frame_arrays = [];
|
var good_path = PathTool.getIconPath("item", "3");
|
frame_arrays.push(good_path);
|
|
var CommonAlert = require("commonalert");
|
|
this.alert = CommonAlert.show(des_str, "确定", call_back.bind(this), "取消", null, null, null, {
|
resArr: frame_arrays,
|
maxWidth: 450,
|
align: cc.macro.TextAlignment.LEFT
|
});
|
},
|
playRecruitEffect: function playRecruitEffect() {
|
if (this.summonBg == null) {
|
this.summonBg = new cc.Node().addComponent(cc.Sprite);
|
ViewManager.getInstance().addToSceneNode(this.summonBg.node, SCENE_TAG.dialogue);
|
this.summonBg.node.scale = FIT_SCALE;
|
this.summonBg.node.setPosition(0, 0);
|
var resources_id = "timesummon_bg";
|
|
if (this.config && this.config.res_id) {
|
resources_id = "timesummon_bg_" + this.config.res_id;
|
}
|
|
var path = PathTool.getBigBg("timesummon/" + resources_id, "jpg");
|
this.loadRes(path, function (res) {
|
this.summonBg.spriteFrame = res;
|
this.summonBg.node.setContentSize(cc.size(720, 1280));
|
}.bind(this));
|
this.summonBg.node.on("touchend", function () {
|
this.summonBg.node.active = !this.summonBg.node.active;
|
|
if (this.floor_effect) {
|
this.floor_effect.paused = true;
|
}
|
|
if (this.book_effect) {
|
this.book_effect.paused = true;
|
}
|
|
if (this.light_effect) {
|
this.light_effect.paused = true;
|
}
|
|
this.animaComplete();
|
}, this);
|
} else {
|
this.summonBg.node.active = !this.summonBg.node.active;
|
}
|
|
var data = PartnersummonController.getInstance().getModel().getRecruitData();
|
var rewards = this.ctrl.getModel().getEffectAction(data.rewards);
|
this.floor_action = rewards[0];
|
this.light_action = rewards[1];
|
var config_data = Config.recruit_holiday_data.data_summon;
|
var config = config_data[data.group_id];
|
var action_name = "action";
|
|
if (config) {
|
action_name = config.action_name;
|
} // 播放音效
|
|
|
var music_name = "recruit_" + action_name;
|
Utils.playEffectSound(AUDIO_TYPE.Recruit, music_name);
|
this.handleFloorEffect();
|
this.handleLightEffect();
|
this.handleBookEffect();
|
MainUiController.getInstance().setMainUIBottomStatus(false);
|
MainUiController.getInstance().setMainUITopStatus(false);
|
},
|
handleFloorEffect: function handleFloorEffect() {
|
var action = this.floor_action || PlayerAction.action_1;
|
|
if (this.summonBg && this.floor_effect == null) {
|
this.floor_effect = new cc.Node().addComponent(sp.Skeleton);
|
this.summonBg.node.addChild(this.floor_effect.node);
|
this.floor_effect.node.setPosition(0, -270);
|
var effect_res = PathTool.getEffectRes("671");
|
var effect_path = PathTool.getSpinePath(effect_res, "action");
|
this.loadRes(effect_path, function (recruit_sk) {
|
this.floor_effect.skeletonData = recruit_sk;
|
this.floor_effect.setAnimation(0, action);
|
}.bind(this));
|
} else if (this.floor_effect) {
|
this.floor_effect.setToSetupPose();
|
this.floor_effect.paused = false;
|
this.floor_effect.setAnimation(0, action);
|
}
|
},
|
handleLightEffect: function handleLightEffect() {
|
var action = this.light_action || PlayerAction.action_1;
|
|
if (this.summonBg && this.light_effect == null) {
|
this.light_effect = new cc.Node().addComponent(sp.Skeleton);
|
this.summonBg.node.addChild(this.light_effect.node);
|
this.light_effect.node.setPosition(0, -240);
|
var effect_res = PathTool.getEffectRes("670");
|
var effect_path = PathTool.getSpinePath(effect_res, "action");
|
this.light_effect.setCompleteListener(this.animaComplete.bind(this));
|
this.loadRes(effect_path, function (recruit_sk) {
|
this.light_effect.skeletonData = recruit_sk;
|
this.light_effect.setAnimation(0, action);
|
}.bind(this));
|
} else if (this.light_effect) {
|
this.light_effect.setToSetupPose();
|
this.light_effect.paused = false;
|
this.light_effect.setAnimation(0, action);
|
}
|
},
|
handleBookEffect: function handleBookEffect() {
|
if (this.summonBg && this.book_effect == null) {
|
this.book_effect = new cc.Node().addComponent(sp.Skeleton);
|
this.summonBg.node.addChild(this.book_effect.node);
|
this.book_effect.node.setPosition(0, -240);
|
var effect_res = PathTool.getEffectRes("672");
|
var effect_path = PathTool.getSpinePath(effect_res, "action");
|
this.loadRes(effect_path, function (recruit_sk) {
|
this.book_effect.skeletonData = recruit_sk;
|
this.book_effect.setAnimation(0, PlayerAction.action);
|
}.bind(this));
|
} else if (this.book_effect) {
|
this.book_effect.setToSetupPose();
|
this.book_effect.paused = false;
|
this.book_effect.setAnimation(0, PlayerAction.action);
|
}
|
},
|
animaComplete: function animaComplete() {
|
cc.log("animaComplete");
|
this.summonBg.node.active = false;
|
MainUiController.getInstance().setMainUIBottomStatus(true);
|
MainUiController.getInstance().setMainUITopStatus(true);
|
|
var PartnersummonController = require("partnersummon_controller");
|
|
PartnersummonController.getInstance().openSummonGainWindow(true);
|
},
|
// 面板设置不可见的回调,这里做一些不可见的屏蔽处理
|
onHide: function onHide() {},
|
// 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
|
onDelete: function onDelete() {
|
if (this.summon_timer) {
|
gcore.Timer.del(this.summon_timer);
|
this.summon_timer = null;
|
}
|
|
if (this.award_item) {
|
this.award_item.deleteMe();
|
this.award_item = null;
|
}
|
|
if (this.summonBg) {
|
this.summonBg.node.destroy();
|
this.summonBg = null;
|
}
|
}
|
});
|
|
cc._RF.pop();
|