// --------------------------------------------------------------------
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
// @description:
|
// 这里是描述这个窗体的作用的
|
// <br/>Create: 2019-01-16 11:47:41
|
// --------------------------------------------------------------------
|
var PathTool = require("pathtool");
|
var GuideEvent = require("guide_event");
|
var PartnersummonConst = require("partnersummon_const");
|
|
var PartnersummonShowWindow = cc.Class({
|
extends: BaseView,
|
|
properties: {
|
skelton_data: null,
|
conmmon_sp: null,
|
},
|
|
ctor: function () {
|
this.prefabPath = PathTool.getPrefabPath("partnersummon", "partnersummon_show_window");
|
this.viewTag = SCENE_TAG.dialogue; // 该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
|
this.win_type = WinType.Full; // 是否是全屏窗体 WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
|
|
this.ctrl = arguments[0];
|
this.model = this.ctrl.getModel();
|
this.show_bids = arguments[1];
|
this.finish_cb = arguments[2];
|
this.bg_type = arguments[3];
|
},
|
|
// 初始化一些配置数据,可以用于声明一些变量之类的
|
initConfig:function(){
|
this.partnersummon_config = Config.recruit_data.data_partnersummon_data;
|
},
|
|
// 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
|
openCallBack:function(){
|
|
},
|
|
// 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
|
registerEvent:function(){
|
|
},
|
|
// 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
|
openRootWnd:function(params){
|
this.initWidget();
|
this.initBgInfo();
|
this.showRecruit();
|
},
|
|
// 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
|
closeCallBack:function(){
|
gcore.GlobalEvent.fire(GuideEvent.CloseTaskEffect);
|
var PartnersummonController = require("partnersummon_controller");
|
PartnersummonController.getInstance().openSummonGainShowWindow(false)
|
},
|
|
initBgInfo: function() {
|
this.recruit_data = this.model.getRecruitData();
|
|
// 背景
|
if( this.recruit_data){
|
var summon_cfg_item = this.partnersummon_config[this.recruit_data.group_id];
|
}
|
var resources_id = "partnersummon_call_bg_100";
|
if(this.bg_type != null && this.bg_type == 2){
|
resources_id = "partnersummon_call_bg_200";
|
}
|
if (summon_cfg_item)
|
resources_id = summon_cfg_item.call_bg;
|
var bg_path = PathTool.getUIIconPath("bigbg/partnersummon", resources_id);
|
this.loadRes(bg_path, function(bigbg_sf) {
|
this.summon_bg_sp.spriteFrame = bigbg_sf;
|
}.bind(this));
|
|
// 背景动画
|
// var bg_effect_id = "140"
|
// if (summon_cfg_item)
|
// bg_effect_id = summon_cfg_item.call_bg_action;
|
// var effect_res = PathTool.getEffectRes(bg_effect_id);
|
// var effect_path = PathTool.getSpinePath(effect_res, "action");
|
// this.loadRes(effect_path, function(bg_sd) {
|
// this.bg_effect_sk.skeletonData = bg_sd;
|
// this.bg_effect_sk.setAnimation(0, "action", true);
|
// }.bind(this));
|
},
|
|
initWidget: function() {
|
this.summon_bg_sp = this.seekChild("summon_bg", cc.Sprite);
|
this.bg_effect_sk = this.seekChild("bg_effect", sp.Skeleton);
|
this.herocard_info_nd = this.seekChild("herocard_info");
|
|
this.partnersummon_bg = this.seekChild("partnersummon_bg");
|
this.summon_bg_nd = this.seekChild("summon_bg");
|
this.summon_bg_nd.scale = this.summon_bg_nd.scale * FIT_SCALE
|
this.partnersummon_bg.scale = FIT_SCALE;
|
|
this.share_conten_nd = this.seekChild("share_conten");
|
this.show_conten_nd = this.seekChild("show_conten");
|
|
this.skill_item_nd = this.seekChild("skill_item"); // 可复制的技能item
|
this.star_item_nd = this.seekChild("star_item"); // 可复制的星星
|
|
this.herocard_sp = this.seekChild("herocard", cc.Sprite);
|
this.stars_conten_nd = this.seekChild("stars_conten");
|
this.hero_type_sp = this.seekChild("hero_type", cc.Sprite);
|
this.hero_name_lb = this.seekChild("hero_name", cc.Label);
|
this.hero_slogn_lb = this.seekChild("hero_slogn", cc.Label);
|
this.camp_type_sp = this.seekChild("camp_type", cc.Sprite);
|
|
// 展示相关
|
this.share_btn_nd = this.seekChild("share_btn");
|
|
this.partnersummon_tag_bg_nd = this.seekChild("partnersummon_tag_bg")
|
|
this.again_one_txt_nd = this.seekChild("again_one_txt");
|
this.again_ten_txt_nd = this.seekChild("again_ten_txt");
|
this.confirm_btn_nd = this.seekChild("confirm_btn");
|
if(PLATFORM_TYPR == "QQ_SDK"){
|
this.share_btn_nd.active = true;//临时屏蔽
|
}else{
|
this.share_btn_nd.active = false;//临时屏蔽
|
this.confirm_btn_nd.x = 360;
|
}
|
this.skills_content_nd = this.seekChild("skills_content");
|
this.reward_nd = this.seekChild("reward");
|
this.reward_nd.active = false;//临时屏蔽
|
this.get_des_nd = this.seekChild("get_des");
|
this.gongxi_img_nd = this.seekChild("gongxi_img");
|
|
// 分享相关
|
this.return_btn_nd = this.seekChild("return_btn");
|
this.weixin_btn_nd = this.seekChild("weixin_btn");
|
this.friend_btn_nd = this.seekChild("friend_btn");
|
|
this.card_skeleton = this.seekChild("card_skelton", sp.Skeleton);
|
this.card_skeleton.setCompleteListener(this.animaComplete.bind(this));
|
|
this.get_anima_sp = this.seekChild("get_anima", sp.Skeleton);
|
|
this.share_btn_nd.on(cc.Node.EventType.TOUCH_END, this.didClickShareBtn, this);
|
this.confirm_btn_nd.on(cc.Node.EventType.TOUCH_END, this.didClickConfimBtn, this);
|
this.return_btn_nd.on(cc.Node.EventType.TOUCH_END, this.didClickReturnBtn, this)
|
},
|
|
updateWidget: function(bid_info) {
|
if (!this.par_base_config || !this.par_star_config || !bid_info) return;
|
if(bid_info.show_type && bid_info.show_type == PartnersummonConst.Gain_Show_Type.Skin_show){
|
let skin_config = Config.partner_skin_data.data_skin_info[bid_info.skin_id];
|
if(skin_config){
|
this.hero_name_lb.string = skin_config.skin_name;
|
this.hero_slogn_lb.string = cc.js.formatStr(Utils.TI18N("%s·皮肤"), this.par_base_config.name);
|
this.stars_conten_nd.active = false;
|
this.partnersummon_tag_bg_nd.active = false;
|
return
|
}
|
}
|
|
var camp_path = PathTool.getHeroCampRes(this.par_base_config.camp_type)
|
// var common_res_path = PathTool.getUIIconPath("partnersummon", camp_path);
|
// this.loadRes(common_res_path, function(sf_obj){
|
// this.camp_type_sp.spriteFrame = sf_obj;
|
// }.bind(this))
|
|
this.loadRes(PathTool.getUIIconPath("common", camp_path), function(sf_obj){
|
this.camp_type_sp.spriteFrame = sf_obj;
|
}.bind(this))
|
|
var common_res_path_2 = PathTool.getUIIconPath("partnersummon", "partnersummon_type_" + this.par_base_config.type);
|
this.loadRes(common_res_path_2, function(sf_obj){
|
this.hero_type_sp.spriteFrame = sf_obj;
|
}.bind(this))
|
|
if (this.par_base_config.voice) {
|
Utils.playEffectSound(AUDIO_TYPE.DUBBING, this.par_base_config.voice);
|
}
|
|
// 星星
|
this.stars_conten_nd.removeAllChildren();
|
for (var i = 0; i < bid_info.init_star; i++) {
|
var star_nd = cc.instantiate(this.star_item_nd);
|
this.stars_conten_nd.addChild(star_nd);
|
}
|
|
this.hero_name_lb.string = this.par_base_config.name;
|
this.hero_slogn_lb.string = this.par_base_config.hero_pos;
|
|
// 技能
|
// var SkillItem = require("skill_item");
|
// this.skill_item = new SkillItem();
|
// this.skill_item.setPosition(cc.v2(60, 90));
|
// this.skill_item.setLeveStatus(false);
|
// this.skill_item.setShowTips(true);
|
// this.skill_item.setParent(this.container);
|
|
this.skills_content_nd.removeAllChildren();
|
var skill_list = this.par_star_config.skills;
|
for (var skill_i = 0; skill_i < skill_list.length; skill_i++) {
|
var skill_info = skill_list[skill_i];
|
if (skill_info[0] != 1) {
|
// var skill_config = gdata("skill_data", "data_get_skill", skill_info[1]);
|
// var icon_path = PathTool.getIconPath("skillicon", skill_config.icon);
|
var skill_nd = cc.instantiate(this.skill_item_nd);
|
skill_nd.y = 0;
|
var skill_con = skill_nd.getChildByName("skill_con");
|
// this.loadRes(icon_path, function(skill_item, sf_obj){
|
// if (skill_item && sf_obj) {
|
// var skill_item_sp = skill_item.getComponent(cc.Sprite);
|
// skill_item_sp.spriteFrame = sf_obj;
|
// }
|
// }.bind(this, skill_item));
|
this.skills_content_nd.addChild(skill_nd);
|
|
var SkillItem = require("skill_item");
|
var skill_item = new SkillItem();
|
skill_item.setLeveStatus(false);
|
skill_item.setShowTips(true);
|
skill_item.setParent(skill_con);
|
skill_item.setData(skill_info[1]);
|
skill_item.showBG(false);
|
}
|
}
|
},
|
|
showRecruit: function() {
|
if (this.show_bids.length > 0) {
|
|
// 重置显示
|
this.show_conten_nd.active = false;
|
this.herocard_info_nd.active = false;
|
|
var bid_info = this.show_bids.shift();
|
this.par_base_config = Config.partner_data.data_partner_base[bid_info.partner_bid];
|
this.par_star_config = gdata("partner_data", "data_partner_star", bid_info.partner_bid.toString() + "_" + bid_info.init_star.toString());
|
// if (!this.conmmon_sp) {
|
// var common_atlas_path = PathTool.getResFrame("partnersummon", "partnersummon");
|
// this.loadRes(common_atlas_path, function(bid_info, atlas_obj) {
|
// this.conmmon_sp = atlas_obj;
|
// this.updateWidget(bid_info);
|
// }.bind(this, bid_info));
|
// } else {
|
this.updateWidget(bid_info);
|
// }
|
|
// 卡牌资源
|
var card_path = null;
|
if(bid_info.show_type && bid_info.show_type == PartnersummonConst.Gain_Show_Type.Skin_show){
|
let skin_config = Config.partner_skin_data.data_skin_info[bid_info.skin_id];
|
card_path = PathTool.getBigBg("partnercard_" + skin_config.head_card_id, "png", "partnercard");
|
}else{
|
card_path = PathTool.getBigBg("partnercard_" + bid_info.partner_bid, "png", "partnercard");
|
}
|
this.loadRes(card_path, function(sf_bof) {
|
this.herocard_sp.spriteFrame = sf_bof;
|
}.bind(this))
|
|
// 卡牌动画
|
var action_name = "action1"
|
if (this.card_skeleton) {
|
this.is_playing = true
|
if (this.card_skeleton.skeletonData) {
|
this.card_skeleton.setAnimation(0, "action1");
|
} else {
|
var sketon_path = PathTool.getSpinePath("E51007", "action");
|
this.loadRes(sketon_path, function(skeleton_data) {
|
this.card_skeleton.skeletonData = skeleton_data;
|
this.card_skeleton.setAnimation(0, "action1");
|
}.bind(this));
|
}
|
}
|
|
// 获得动作
|
this.get_des_nd.scale = 1.5;
|
if (!this.get_action) {
|
var delay_act = cc.delayTime(0.1);
|
var scale_act = cc.scaleTo(0.1, 1);
|
var call_act = cc.callFunc(function() {
|
// 获得动画
|
if (this.get_anima_sp) {
|
if (this.get_anima_sp.skeletonData) {
|
this.get_anima_sp.setAnimation(0, "action");
|
} else {
|
var sketon_path = PathTool.getSpinePath("E50093", "action");
|
this.loadRes(sketon_path, function(skeleton_data){
|
this.get_anima_sp.skeletonData = skeleton_data;
|
this.get_anima_sp.setAnimation(0, "action");
|
}.bind(this));
|
}
|
}
|
}.bind(this));
|
this.get_action = cc.sequence(call_act, delay_act, scale_act);
|
}
|
this.get_des_nd.runAction(this.get_action);
|
}
|
},
|
|
didClickShareBtn: function(event) {
|
Utils.playButtonSound(1)
|
if(PLATFORM_TYPR == "QQ_SDK"){
|
SDK.canvasToTempFilePath();
|
}
|
|
// this.share_conten_nd.active = true;
|
},
|
|
didClickConfimBtn: function(event) {
|
Utils.playButtonSound(1)
|
if (this.show_bids.length > 0) {
|
this.showRecruit();
|
} else {
|
if (this.finish_cb) this.finish_cb();
|
var PartnersummonController = require("partnersummon_controller");
|
PartnersummonController.getInstance().openSummonGainShowWindow(false);
|
}
|
if(window.TASK_TIPS)
|
gcore.GlobalEvent.fire(GuideEvent.TaskNextStep,"confirm_btn");//任务引导用到
|
},
|
|
didClickReturnBtn: function() {
|
Utils.playButtonSound(1)
|
this.show_conten_nd.active = true;
|
this.show_conten_nd.active = true;
|
this.share_conten_nd.active = false;
|
},
|
|
animaComplete: function(trackEntry, loopCount) {
|
if(this.is_playing == false)return;
|
var animationName = trackEntry.animation ? trackEntry.animation.name : "";
|
if (animationName == "action1" || animationName == "action2") {
|
this.card_skeleton.setAnimation(0, "action3", true);
|
this.show_conten_nd.active = true;
|
this.herocard_info_nd.active = true;
|
}
|
this.is_playing = false;
|
this.shakeScreen(this.root_wnd)
|
},
|
shakeScreen(root_wnd){
|
let node = root_wnd;
|
if(node.action){
|
this.is_shake = false;
|
node.stopAllActions();
|
node.action = null;
|
}
|
this.camera_shake_pos = root_wnd.getPosition();
|
this.is_shake = true;
|
let returnPos = function(){
|
this.is_shake = false;
|
node.setPosition(this.camera_shake_pos);
|
}.bind(this)
|
let order = [1, 4, 7, 8, 9, 6, 3, 2]
|
let str = 15 //--振幅,单位像素
|
let damp = 3 //--振动减衰, 单位像素
|
let step = 0.015 //--振动间隔,单位秒
|
let shakeXTime = 0.25 //--横向加倍
|
let shakeYTime = 0.25 //--纵向加倍
|
let shakeTime = 1 //--振动次数
|
let xy_list = [ [-0.7, 0.7 ], [ 0, 1 ], [ 0.7, 0.7 ], [-1, 0 ], [ 0, 0 ], [ 1, 0 ], [-0.7, -0.7 ], [ 0, -1 ], [ 0.7, -0.7 ] ];
|
let setRandomPos = function (index){
|
let pos_x, pos_y;
|
pos_x = str * shakeYTime * xy_list[order[index] - 1][0];
|
pos_y = -str * shakeXTime * xy_list[order[index] - 1][1];
|
let pos = cc.v2(this.camera_shake_pos.x + pos_x, this.camera_shake_pos.y + pos_y);
|
node.setPosition(pos);
|
}.bind(this)
|
let base_call = cc.delayTime(0);
|
for(let j=0;j<shakeTime;++j){
|
for(let i=0;i<order.length;++i){
|
let delay = cc.delayTime(step);
|
base_call = cc.sequence(base_call,cc.callFunc(function(){
|
setRandomPos(i);
|
}.bind(this)),delay)
|
}
|
str = str - damp;
|
}
|
base_call = cc.sequence(base_call, cc.callFunc(returnPos));
|
node.action = base_call;
|
node.runAction(base_call);
|
},
|
|
})
|