"use strict";
|
cc._RF.push(module, 'cb705YL5LFHF6D9qaJoi8H3', 'activity_item_panel');
|
// Scripts/mod/activity/view/activity_item_panel.js
|
|
"use strict";
|
|
// --------------------------------------------------------------------
|
// @author: xxx@syg.com(必填, 创建模块的人员)
|
// @description:
|
// 活动 Item 项
|
// <br/>Create: 2019-05-06 14:34:33
|
// --------------------------------------------------------------------
|
var PathTool = require("pathtool");
|
|
var ActivityConst = require("activity_const");
|
|
var GuildBossController = require("guildboss_controller");
|
|
var ActivityController = require("activity_controller");
|
|
var MainuiController = require("mainui_controller");
|
|
var Activity_itemPanel = cc.Class({
|
"extends": BasePanel,
|
ctor: function ctor() {
|
this.prefabPath = PathTool.getPrefabPath("activity", "activity_item");
|
this.ctrl = ActivityController.getInstance();
|
},
|
// 可以初始化声明一些变量的
|
initConfig: function initConfig() {
|
this.is_double = false;
|
this.list_item = [];
|
},
|
// 初始化一些配置数据,可以用于声明一些变量之类的
|
initPanel: function initPanel() {
|
this.mainContainer = this.root_wnd.getChildByName("main_container");
|
this.itemMask = this.mainContainer.getChildByName("itemMask");
|
this.textLimit = this.itemMask.getChildByName("textLimit").getComponent(cc.Label);
|
this.textLimit.string = Utils.TI18N("敬请期待");
|
this.itemMask.zIndex = 11;
|
this.btnRule = this.mainContainer.getChildByName("btnRule");
|
this.btnRule.active = false;
|
this.textTimeStart = this.mainContainer.getChildByName("textTimeStart").getComponent(cc.Label);
|
this.textTimeStart.string = "";
|
this.textTimeStart.node.active = false;
|
this.itemBG = this.mainContainer.getChildByName("itemBG");
|
this.redPoint = this.mainContainer.getChildByName("redPoint");
|
this.redPoint.active = false;
|
},
|
changeEscortCount: function changeEscortCount() {
|
if (this.activityData.id == ActivityConst.limit_index.escort) {
|
// var totle = EscortController.getInstance().getModel().getMyMaxCount(EscortConst.times_type.escort);
|
// var current = EscortController.getInstance().getModel().getMyCount(EscortConst.times_type.escort);
|
var num = totle - current;
|
|
if (num < 0) {
|
num = 0;
|
}
|
|
var str = cc.js.formatStr(Utils.TI18N("护送次数:%d/%d"), num, totle);
|
|
if (!this.count) {
|
this.count = Utils.createLabel(20, new cc.Color(0xff, 0xff, 0xff, 0xff), new cc.Color(0x74, 0x35, 0x0b, 0xff), 582, 65, str, this.mainContainer, 2, cc.v2(1, 0.5));
|
} else {
|
this.count.string = str;
|
}
|
}
|
},
|
setData: function setData(data) {
|
this.activityData = data; // 只对萌受夺宝列表做判断
|
|
if (this.activityData.id == ActivityConst.limit_index.escort) {
|
// this.is_double = EscortController.getInstance().getModel().isDoubleTimes();
|
this.changeEscortCount();
|
}
|
|
this.changeItemData(data); // 引导使用,不要删
|
// if(data && data.id){
|
// this.setName("guide_activity_item_"+data.id)
|
// }
|
},
|
getData: function getData() {
|
return this.activityData;
|
},
|
addCallBack: function addCallBack(value) {
|
this.callback = value;
|
},
|
// 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
|
registerEvent: function registerEvent() {
|
Utils.onTouchEnd(this.btnRule, function () {
|
if (this.activityData.id == ActivityConst.limit_index.escort) {
|
MainuiController.getInstance().openCommonExplainView(true, Config.EscortData.data_explain);
|
} else if (this.activityData.id == ActivityConst.limit_index.union) {
|
MainuiController.getInstance().openCommonExplainView(true, Config.GuildDunData.data_explain);
|
} else if (this.activityData.id == ActivityConst.limit_index.fightFirst) {} else if (this.activityData.id == ActivityConst.limit_index.allGod) {
|
MainuiController.getInstance().openCommonExplainView(true, Config.ZsWarData.data_explain);
|
} else if (this.activityData.id == ActivityConst.limit_index.guildwar) {
|
MainuiController.getInstance().openCommonExplainView(true, Config.GuildWarData.data_explain);
|
} else if (this.activityData.id == ActivityConst.limit_index.champion) {
|
MainuiController.getInstance().openCommonExplainView(true, Config.ArenaChampionData.data_explain);
|
} else if (this.activityData.id == ActivityConst.limit_index.ladder) {
|
MainuiController.getInstance().openCommonExplainView(true, Config.SkyLadderData.data_explain);
|
}
|
}.bind(this), 1); //当用户点击的时候记录鼠标点击状态
|
|
this.root_wnd.on(cc.Node.EventType.TOUCH_START, function (event) {
|
var touches = event.getTouches();
|
this.touch_began = touches[0].getDelta();
|
}, this); //当鼠标抬起的时候恢复状态
|
|
this.root_wnd.on(cc.Node.EventType.TOUCH_END, function (event) {
|
var touches = event.getTouches();
|
this.touch_end = touches[0].getDelta();
|
var is_click = true;
|
|
if (this.touch_began != null) {
|
is_click = Math.abs(this.touch_end.x - this.touch_began.x) <= 20 && Math.abs(this.touch_end.y - this.touch_began.y) <= 20;
|
}
|
|
if (is_click == true) {
|
Utils.playButtonSound(ButtonSound.Normal);
|
|
if (this.callback) {
|
this.callback();
|
}
|
}
|
}, this);
|
},
|
updateRedStatus: function updateRedStatus() {
|
if (this.activityData) {
|
var red_status = false;
|
|
if (this.activityData.id == ActivityConst.limit_index.escort) {// red_status = EscortController:getInstance():getModel():checkRedStatus()
|
} else if (this.activityData.id == ActivityConst.limit_index.union) {
|
if (GuildBossController.getInstance().getModel().getChangeCount() == true && this.ctrl.getBossActivityDoubleTime() == true && this.ctrl.getFirstComeGuild() == true) {
|
red_status = true;
|
}
|
} else if (this.activityData.id == ActivityConst.limit_index.guildwar) {// red_status = GuildwarController.getInstance().getModel().checkGuildGuildWarRedStatus();
|
} else if (this.activityData.id == ActivityConst.limit_index.ladder) {// red_status = LadderController.getInstance().getModel().checkLadderRedStatus();
|
}
|
|
this.redPoint.active = red_status;
|
}
|
},
|
changeItemData: function changeItemData(data) {
|
if (data.val[0]) {
|
for (var i in data.val[0]) {
|
if (!this.list_item[i]) {
|
var item = ItemsPool.getInstance().getItem("backpack_item");
|
|
if (this.mainContainer) {
|
item.setParent(this.mainContainer);
|
}
|
|
this.list_item[i] = item;
|
}
|
|
if (this.list_item[i]) {
|
this.list_item[i].initConfig(false, 0.5, false, true);
|
this.list_item[i].show();
|
this.list_item[i].setPosition(40 * i + (24 * i - 1), 67);
|
this.list_item[i].setData(data.val[0][i]); // this.list_item[i].setDoubleIcon(this.is_double);
|
}
|
}
|
}
|
|
this.limitItemData(data);
|
|
if (data.desc) {
|
if (this.textTimeStart) {
|
this.textTimeStart.string = data.desc;
|
this.textTimeStart.node.active = true;
|
}
|
}
|
},
|
// 限时活动子项
|
limitItemData: function limitItemData(data) {
|
var RoleController = require("role_controller");
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
var res = PathTool.getIconPath("activity/activity_big", "txt_cn_activity_item_" + data.id, false, false);
|
this.loadRes(res, function (resObject) {
|
this.itemBG.getComponent(cc.Sprite).spriteFrame = resObject;
|
}.bind(this));
|
|
if (data.is_open == 1) {
|
var _bool = MainuiController.getInstance().checkIsOpenByActivate(data.activate);
|
|
if (_bool == true) {
|
this.handleEffect(true);
|
this.itemMask.active = false;
|
|
if (this.btnRule) {
|
this.btnRule.active = true;
|
}
|
|
if (data.id == ActivityConst.limit_index.union) {
|
if (role_vo.gname == "") {
|
this.textLimit.string = Utils.TI18N("当前未加入公会");
|
this.handleEffect(false);
|
}
|
}
|
} else {
|
this.handleEffect(false);
|
|
if (this.btnRule) {
|
this.btnRule.active = false;
|
}
|
|
this.textLimit.string = data.lock_desc;
|
}
|
} else {
|
if (data.id == ActivityConst.limit_index.union) {
|
if (role_vo.gname != "") {
|
this.textLimit.string = Utils.TI18N("公会副本玩法暂未开启");
|
}
|
}
|
}
|
},
|
handleEffect: function handleEffect(status) {
|
if (status == false) {
|
if (this.play_effect) {
|
this.play_effect.setToSetupPose();
|
this.play_effect.clearTracks();
|
this.play_effect = null;
|
}
|
} else {
|
if (this.mainContainer && this.play_effect == null) {
|
var node = new cc.Node();
|
node.setAnchorPoint(1, 0);
|
node.setPosition(this.itemBG.getContentSize().width - 106, 28);
|
this.mainContainer.addChild(node, 1);
|
this.play_effect = node.addComponent(sp.Skeleton);
|
var anima_path = PathTool.getSpinePath(PathTool.getEffectRes(505), "action");
|
LoaderManager.getInstance().loadRes(anima_path, function (ske_data) {
|
if (this.play_effect) {
|
this.play_effect.skeletonData = ske_data;
|
this.play_effect.setAnimation(0, PlayerAction.action, true);
|
}
|
}.bind(this));
|
}
|
}
|
},
|
// 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
|
onShow: function onShow(params) {},
|
// 面板设置不可见的回调,这里做一些不可见的屏蔽处理
|
onHide: function onHide() {},
|
// 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
|
onDelete: function onDelete() {
|
if (this.list_item && Utils.next(this.list_item) != null) {
|
for (var i in this.list_item) {
|
if (this.list_item[i].deleteMe) {
|
this.list_item[i].deleteMe();
|
}
|
}
|
}
|
|
this.list_item = [];
|
this.handleEffect(false);
|
this.count = null;
|
}
|
});
|
|
cc._RF.pop();
|