// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
// 这里是描述这个窗体的作用的
//
Create: 2019-08-09 15:58:31
// --------------------------------------------------------------------
var PathTool = require("pathtool");
var ActionController = require("action_controller")
var EliteSummonEvent = require("elitesummon_event")
var ElitesummonController = require("elitesummon_controller")
var RoleController = require("role_controller")
var BackpackController = require("backpack_controller")
var BackpackEvent = require("backpack_event")
var BackPackConst = require("backpack_const")
var SummonEvent = require("partnersummon_event");
var MainUiController = require("mainui_controller")
var PartnersummonController = require("partnersummon_controller")
var TimeTool = require("timetool")
var ElitesummonPanel = cc.Class({
extends: BasePanel,
ctor: function () {
this.prefabPath = PathTool.getPrefabPath("action", "action_time_summon_panel");
this.holiday_bid = arguments[0]
this.ctrl = ElitesummonController.getInstance()
},
// 可以初始化声明一些变量的
initConfig:function(){
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_elite_data.data_award
this.const_data = Config.recruit_holiday_elite_data.data_const
this.summon_item_bid = this.const_data["common_s"].val
this.summon_data = Config.recruit_holiday_elite_data.data_summon
this.action_config = Config.recruit_holiday_elite_data.data_action
},
// 初始化一些配置数据,可以用于声明一些变量之类的
initPanel:function(){
this.setPosition(0,-20)
let main_container = this.root_wnd.getChildByName("main_container")
this.progress_txt = main_container.getChildByName("progress_txt").getComponent(cc.Label)
let image_bg_sp = main_container.getChildByName("image_bg").getComponent(cc.Sprite)
this.progress = main_container.getChildByName("progress").getComponent(cc.ProgressBar)
this.baodi_bg = main_container.getChildByName("baodi_bg")
let str_bg = "txt_cn_elitesummon_1";
let tab_vo = ActionController.getInstance().getActionSubTabVo(this.holiday_bid)
if(tab_vo && tab_vo.aim_title != "" && tab_vo.aim_title){
str_bg = tab_vo.aim_title
}
let path = PathTool.getBigBg(str_bg,"jpg","timesummon")
this.loadRes(path,function(res){
image_bg_sp.spriteFrame = res
}.bind(this))
this.item_num_txt = main_container.getChildByName("item_num_txt").getComponent(cc.Label)
this.award_btn = main_container.getChildByName("award_btn")
this.award_btn.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("奖励预览")
main_container.getChildByName("preview_btn").active = false
this.summon_btn_1 = main_container.getChildByName("summon_btn_1")
this.summon_btn_1.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("招募1次")
this.summon_txt_1_rt = this.summon_btn_1.getChildByName("summon_txt_1").getComponent(cc.RichText)
this.summon_prop_1_nd = this.summon_btn_1.getChildByName("summon_prop")
this.summon_prop_num_lb = this.summon_prop_1_nd.getChildByName("summon_prop_num").getComponent(cc.Label)
this.summon_btn_10 = main_container.getChildByName("summon_btn_10")
this.summon_btn_10.getChildByName("label").getComponent(cc.Label).string = Utils.TI18N("招募10次")
this.summon_prop_10_nd = this.summon_btn_10.getChildByName("summon_prop");
this.summon_prop_sp = this.summon_prop_10_nd.getChildByName("summon_prop_item").getComponent(cc.Sprite)
this.summon_10_num_lb = this.summon_prop_10_nd.getChildByName("summon_prop_num").getComponent(cc.Label)
this.time_txt = main_container.getChildByName("time_txt").getComponent(cc.Label)
this.time_txt.node.setPosition(414,283)
this.time_txt.node.color = new cc.Color(255,252,187);
let line = this.time_txt.node.addComponent(cc.LabelOutline);
line.color = new cc.Color(112,18,18);
line.width = 2;
this.time_txt.lineHeight = 30;
// this.time_txt.node.active = false;
this.baodi_text_rt = this.seekChild("baodi_text",cc.RichText);
this.baodi_text_rt.node.setAnchorPoint(1,0.5)
this.baodi_text_rt.node.x = 75;
this.award_item = ItemsPool.getInstance().getItem("backpack_item")
this.award_item.setParent(main_container);
this.award_item.setPosition(60, 728)
this.award_item.initConfig(false, 0.6, false, false);
this.award_item.show();
this.award_item.addCallBack(this._onClickAwardItem.bind(this))
let item_config = Utils.getItemConfig(this.summon_item_bid)
let path1 = PathTool.getItemRes(item_config.icon)
this.loadRes(path1,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))
this.baodi_bg.getChildByName("tip").active = true;
this.btn_rule = this.baodi_bg.getChildByName("tip")
},
// 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
registerEvent:function(){
this.addGlobalEvent(EliteSummonEvent.EliteSummon_Message,function(data){
if(!data) return;
let status = this.ctrl.getModel().isHolidayHasID(data.camp_id)
if(status){
this.setData(data)
}
}.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.addGlobalEvent(SummonEvent.PartnerSummonSuccess, function() {
this.playRecruitEffect();
}.bind(this));
this.award_btn.on("click",function(){
if(this.data && this.data.camp_id){
let config = this.action_config[this.data.camp_id]
if (config){
var TimesummonController = require("timesummon_controller")
TimesummonController.getInstance().openTimeSummonAwardView(true,config.group_id, this.data,true)
}
}
},this)
this.btn_rule.on('click',function(event){
if(this.data && this.data.camp_id){
let config = this.action_config[this.data.camp_id]
if(config){
let pos = event.node.convertToWorldSpaceAR(cc.v2(0, 0))
require("tips_controller").getInstance().showCommonTips(config.desc,pos,null,null,500)
}
}
},this)
this.summon_btn_1.on('click',function(){
Utils.playButtonSound(1)
if(this.checkHeroBagIsFull(1)) return;
if(this.last_time && gcore.SmartSocket.getTime() - this.last_time < 2){
return
}
this.last_time = gcore.SmartSocket.getTime()
if(this._summon_type_1 == 3){
if(this.data && this.data.camp_id){
let group_id = this.action_config[this.data.camp_id].group_id
let config = this.summon_data[group_id]
let num = config.loss_gold_once[0][1]
let call_back = function (){
this.ctrl.send23221( 1, this._summon_type_1 )
}
let item_icon_2 = Utils.getItemConfig(config.loss_gold_once[0][0]).icon
let val_str = Utils.getItemConfig(config.gain_once[0][0]).name || ""
let val_num = config.gain_once[0][1]
let call_num = 1
this.showGoldTips(item_icon_2,num,call_num,val_num,val_str,call_back)
}
}else{
this.ctrl.send23221( 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){
if(this.data && this.data.camp_id){
let group_id = this.action_config[this.data.camp_id].group_id
let config = this.summon_data[group_id]
let num = config.loss_gold_ten[0][1]
let call_back = function (){
this.ctrl.send23221( 10, this._summon_type_10 )
}
let item_icon_2 = Utils.getItemConfig(config.loss_gold_ten[0][0]).icon
let val_str = Utils.getItemConfig(config.gain_ten[0][0]).name || ""
let val_num = config.gain_ten[0][1]
let call_num = 10
this.showGoldTips(item_icon_2,num,call_num,val_num,val_str,call_back)
}
}else{
this.ctrl.send23221( 10, this._summon_type_10 )
}
},this)
this.ctrl.send23220()
},
// 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
onShow:function(params){
},
// 面板设置不可见的回调,这里做一些不可见的屏蔽处理
onHide:function(){
},
setData(data){
this.data = data
this.updateSummonBtnStatus()
this.nextRewardLevel()
this.updateItemNum()
let str_time = cc.js.formatStr("%s-%s",TimeTool.getMD2(data.start_time),TimeTool.getMD2(data.end_time))
this.time_txt.string = str_time;
this.baodi_text_rt.string = Utils.TI18N(cc.js.formatStr(StringUtil.parseStr("