447 lines
16 KiB
JavaScript
447 lines
16 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'bba55x4625GmrPKnact56qW', 'cmp.partner.info.wnd');
|
|
// Scripts/mod/partner/cmps/cmp.partner.info.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 伙伴详情
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
var HeroController = require("hero_controller");
|
|
var HeroEvent = require("hero_event");
|
|
var RoleController = require("role_controller");
|
|
var MenuWnd = require("cmp.com.menu.wnd");
|
|
var Slider = require("cmp.slider.prog.selector");
|
|
var HeroCalculate = require("hero_calculate");
|
|
|
|
// 标签页对应关系
|
|
var TabPage = [{
|
|
tab: 0,
|
|
key: "basic"
|
|
},
|
|
// 升级
|
|
{
|
|
tab: 1,
|
|
key: "star"
|
|
},
|
|
// 升星
|
|
{
|
|
tab: 2,
|
|
key: "inset"
|
|
},
|
|
// 镶嵌
|
|
{
|
|
tab: 3,
|
|
key: "artifact"
|
|
},
|
|
// 镶嵌
|
|
{
|
|
tab: 4,
|
|
key: "skin"
|
|
} // 皮肤
|
|
];
|
|
|
|
cc.Class({
|
|
"extends": MenuWnd,
|
|
properties: {
|
|
nodSwitch: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodSkin: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
fabSkin: {
|
|
"default": null,
|
|
type: cc.Prefab
|
|
},
|
|
cmpCounter: {
|
|
"default": null,
|
|
type: Slider
|
|
}
|
|
},
|
|
// 显示
|
|
onEnable: function onEnable() {
|
|
// 视图监听
|
|
this.vbind([["ShowPartner", this.onPartnerChanged.bind(this)]]);
|
|
|
|
// 事件监听
|
|
// this.bindGEvent( HeroEvent.Hero_Data_Update, this.onUpdatePartner.bind( this ) );
|
|
this.bindGEvent(HeroEvent.Equip_Update_Event, this.onUpdateEquipments.bind(this));
|
|
this.bindGEvent(HeroEvent.Hero_Level_Up_Success_Event, this.onUpdateLevelUp.bind(this));
|
|
// this.bindGEvent( HeroEvent.Upgrade_Star_Success_Event, this.onUpdateStarUp.bind( this ) );
|
|
// this.bindGEvent( HeroEvent.Hero_Lock_Event, this.onUpdatePartner.bind( this ) );
|
|
// this.bindGEvent( HeroEvent.Hero_Get_Talent_Event, this.onUpdatePartner.bind( this ) );
|
|
},
|
|
|
|
// 隐藏
|
|
onDisable: function onDisable() {
|
|
// 视图监听解除
|
|
this.vunbind();
|
|
|
|
// 事件监听释放
|
|
this.unbindGEvents();
|
|
},
|
|
// 重载:参数打开
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
|
var _this = this;
|
|
this._super(_params);
|
|
// 无效关闭
|
|
this.partner = _params.hero_vo;
|
|
if (nx.dt.objEmpty(this.partner)) {
|
|
this.scheduleOnce(function () {
|
|
_this.close();
|
|
}, 0.05);
|
|
}
|
|
this.partnerList = _params.hero_list;
|
|
if (nx.dt.arrEmpty(this.partnerList)) {
|
|
this.partnerList = [this.partner];
|
|
}
|
|
|
|
// 游标计算
|
|
var index = 0;
|
|
for (var i = 0; i < this.partnerList.length; ++i) {
|
|
var tp = this.partnerList[i];
|
|
if (tp && tp.id == this.partner.id) {
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 刷新
|
|
this.activeShow(index);
|
|
this.nodResult = nx.gui.find(this, "panel/base/clerk");
|
|
this.initPos = this.nodResult.position;
|
|
this.initSlider();
|
|
this._super(_params);
|
|
},
|
|
initSlider: function initSlider() {
|
|
var _this2 = this;
|
|
this.max_scale = 1.5;
|
|
this.min_scale = 0.5;
|
|
this.maxLen = 101;
|
|
this.minLen = 1;
|
|
this.can = true;
|
|
// 设置滚动条
|
|
this.cmpCounter.build(1, 101, 50, function (_count) {
|
|
_this2.changeScale(_count);
|
|
});
|
|
},
|
|
// 展示下一个
|
|
activeShow: function activeShow(_index) {
|
|
if (this.curIndex == _index || _index < 0 || _index >= this.partnerList.length) {
|
|
return;
|
|
}
|
|
|
|
// 更新展示
|
|
|
|
this.partner = this.partnerList[_index];
|
|
// 空伙伴不展示
|
|
if (!this.partner || nx.dt.objEmpty(this.partner)) {
|
|
return;
|
|
}
|
|
this.curIndex = _index;
|
|
// 菜单更新
|
|
// 星级低于3级不支持升星
|
|
var canup = this.partner.star >= 4;
|
|
nx.gui.setActive(this.menu, "star", canup);
|
|
|
|
// 皮肤
|
|
var SkinPartners = game.configs.partner_skin_data.data_partner_bid_info;
|
|
var skins = SkinPartners[this.partner.bid];
|
|
nx.gui.setActive(this.menu, "skin", nx.dt.objNEmpty(skins));
|
|
// nx.gui.setActive( this.menu, "skin", false ); // 皮肤按钮 隐藏显示
|
|
// 战斗义肢
|
|
var need_star = game.configs.partner_holy_eqm_data.data_const.open_star_condition.val;
|
|
var need_level = game.configs.partner_holy_eqm_data.data_const.open_lev_condition.val;
|
|
var role = RoleController.getInstance().getRoleVo();
|
|
var need_world_level = game.configs.partner_holy_eqm_data.data_const.open_worldlev_condition.val;
|
|
var world_level = RoleController.getInstance().getModel().getWorldLev();
|
|
var canup2 = this.partner.star >= need_star && role.lev >= need_level && world_level >= need_world_level;
|
|
nx.gui.setActive(this.menu, "artifact", canup2);
|
|
if (!canup && this.curKey == "star" || !canup2 && this.curKey == "artifact") {
|
|
var cmp = this.menu.getComponent("nx.fx.togs");
|
|
if (cmp) {
|
|
cmp.togTo(0);
|
|
}
|
|
this.togMenu(this.defPage);
|
|
}
|
|
// 关注改变
|
|
nx.bridge.vset("ShowPartner", this.partner);
|
|
},
|
|
onPartnerChanged: function onPartnerChanged(_vo) {
|
|
if (_vo && this.partner && _vo.partner_id == this.partner.partner_id) {
|
|
var need_star = game.configs.partner_holy_eqm_data.data_const.open_star_condition.val;
|
|
var need_world_level = game.configs.partner_holy_eqm_data.data_const.open_worldlev_condition.val;
|
|
var need_level = game.configs.partner_holy_eqm_data.data_const.open_lev_condition.val;
|
|
var role = RoleController.getInstance().getRoleVo();
|
|
var world_level = RoleController.getInstance().getModel().getWorldLev();
|
|
var canup2 = this.partner.star >= need_star && role.lev >= need_level && world_level >= need_world_level;
|
|
nx.gui.setActive(this.menu, "artifact", canup2);
|
|
var calculate = HeroCalculate.getInstance();
|
|
var reds = calculate.checkPartnerRedPoint(this.partner, ["lev", "eqm", "star", "insert"]);
|
|
nx.mTip.openTip("partner.partner.uplevel", reds[0] || reds[1]);
|
|
nx.mTip.openTip("partner.partner.upstar", reds[2]);
|
|
nx.mTip.openTip("partner.partner.insert", reds[3]);
|
|
}
|
|
},
|
|
togMenu: function togMenu(_key) {
|
|
var _this3 = this;
|
|
this._super(_key);
|
|
this.curKey = _key;
|
|
|
|
// 标准页
|
|
if (_key != "skin") {
|
|
nx.gui.setActive(this.nodSkin, "", false);
|
|
return;
|
|
}
|
|
|
|
// 新建
|
|
if (!this.cmpSkin) {
|
|
var node = cc.instantiate(this.fabSkin);
|
|
node.parent = nx.gui.find(this.nodSkin);
|
|
this.cmpSkin = node.getComponent("cmp.partner.skin");
|
|
}
|
|
|
|
// 更新
|
|
nx.gui.setActive(this.nodSkin, "", true);
|
|
this.cmpSkin.setPartner(this.partner, function () {
|
|
// 皮肤改变手动刷新一下模型,这里不会主动改变
|
|
var base = nx.gui.getComponent(_this3, "panel/base", "cmp.partner.baseinfo");
|
|
if (base) {
|
|
base.freshSpines();
|
|
}
|
|
});
|
|
},
|
|
// 队列切换
|
|
onTouchNext: function onTouchNext(_dir) {
|
|
var index = _dir == 2 ? this.curIndex + 1 : this.curIndex - 1;
|
|
index = (index + this.partnerList.length) % this.partnerList.length;
|
|
this.activeShow(index);
|
|
},
|
|
onBackToMain: function onBackToMain() {
|
|
var HR = HeroController.getInstance();
|
|
HR.openHeroMainInfoWindow(false);
|
|
HR.openHeroBagWindow(true);
|
|
},
|
|
onTouchSingleUpStar: function onTouchSingleUpStar(_index) {
|
|
var canup = this.partner.star >= 4;
|
|
if (canup) {
|
|
this.togMenu(_index);
|
|
// this.onTogMenu( _index );
|
|
}
|
|
},
|
|
|
|
// 装备
|
|
onUpdateEquipments: function onUpdateEquipments() {
|
|
nx.audio.playSFX("audios/effects/equip");
|
|
},
|
|
// 升级
|
|
onUpdateLevelUp: function onUpdateLevelUp() {
|
|
nx.audio.playSFX("audios/effects/levelup");
|
|
},
|
|
// // 升星
|
|
onUpdateStarUp: function onUpdateStarUp() {},
|
|
onDoAnim: function onDoAnim(_nod, pos, _show) {
|
|
var tween = cc.tween(_nod).to(0.5, {
|
|
position: pos
|
|
}).call(function () {
|
|
nx.gui.setActive(_nod, "", _show);
|
|
}).start();
|
|
return tween;
|
|
},
|
|
onDoAnimf: function onDoAnimf(_nod, pos, _show) {
|
|
nx.gui.setActive(_nod, "", _show);
|
|
var tween = cc.tween(_nod).to(0.5, {
|
|
position: pos
|
|
}).start();
|
|
return tween;
|
|
},
|
|
onDoAnimation: function onDoAnimation() {
|
|
var _this4 = this;
|
|
// let nods = [];
|
|
|
|
this.onDoAnim(this.nodResult, cc.v2(this.nodResult.position.x + 172, this.nodResult.position.y), true);
|
|
var nodBase = nx.gui.find(this, "panel/smod");
|
|
this.nodBasePos = nodBase.position;
|
|
// doAni( nodBase, true );
|
|
var base = this.onDoAnim(nodBase, cc.v2(nodBase.position.x - 500, nodBase.position.y), false);
|
|
var nodPanel = nx.gui.find(this, "panel/panels");
|
|
this.nodPanel = nodPanel.position;
|
|
var panel = this.onDoAnim(nodPanel, cc.v2(nodPanel.position.x + 1000, nodPanel.position.y), false);
|
|
var menuPanel = nx.gui.find(this, "panel/menu");
|
|
this.menuPanel = menuPanel.position;
|
|
// nods.push( menuPanel );
|
|
var menu = this.onDoAnim(menuPanel, cc.v2(menuPanel.position.x - 500, menuPanel.position.y), false);
|
|
var skinPanel = nx.gui.find(this, "panel/skin");
|
|
// doAni( skinPanel, false );
|
|
this.skinPanel = skinPanel.position;
|
|
var skin = this.onDoAnim(skinPanel, cc.v2(skinPanel.position.x - 500, skinPanel.position.y), false);
|
|
var nodQa = nx.gui.find(this, "panel/base/qa");
|
|
var touch = nx.gui.find(this, "panel/base/clerk/touch");
|
|
var touchMove = this.onDoAnim(touch, cc.v2(touch.position.x, touch.position.y - 500), false);
|
|
// doAni( skinPanel, false );
|
|
this.nodQa = nodQa.position;
|
|
// let qa = this.onDoAnim( nodQa, cc.v2( nodQa.position.x , nodQa.position.y + 500 ), false );
|
|
|
|
var storyNod = nx.gui.find(this, "panel/base/infos");
|
|
// doAni( skinPanel, false );
|
|
this.storyNod = storyNod.position;
|
|
var story = this.onDoAnim(storyNod, cc.v2(storyNod.position.x, storyNod.position.y - 200), false);
|
|
var backNod = nx.gui.find(this, "panel/back");
|
|
// doAni( skinPanel, false );
|
|
var back = this.onDoAnim(backNod, cc.v2(backNod.position.x - 500, backNod.position.y), false);
|
|
var backNods = nx.gui.find(this, "panel/base/back");
|
|
// // doAni( skinPanel, false );
|
|
// let backs = this.onDoAnimf( backNods, cc.v2( backNods.position.x + 198, backNods.position.y ), true );
|
|
nx.tween.fadeIn(backNods, "", 0.3, function () {
|
|
nx.gui.getComponent(backNods, "", cc.Button).interactable = true;
|
|
});
|
|
var doNods = nx.gui.find(this, "panel/do");
|
|
// doAni( skinPanel, false );
|
|
nx.gui.setActive(doNods, "ops", true);
|
|
var doNodsMove = this.onDoAnimf(doNods, cc.v2(doNods.position.x - 398, doNods.position.y), true);
|
|
var opNod = nx.gui.find(this, "panel/base/ops");
|
|
var opNodMove = this.onDoAnim(opNod, cc.v2(opNod.position.x, opNod.position.y + 200), false);
|
|
// cc.tween().then( base ).then( panel ).then( menu ).then( skin ).then( story ).start();
|
|
nx.tween.fadeOut(this, "panel/base/switch", 0.3, function () {
|
|
nx.gui.getComponent(_this4, "panel/base/switch/left", cc.Button).interactable = false;
|
|
nx.gui.getComponent(_this4, "panel/base/switch/right", cc.Button).interactable = false;
|
|
});
|
|
var nod = nx.gui.find(this, "panel/base/skills/list");
|
|
nx.tween.fadeOut(this, "panel/base/skills", 0.3, function () {
|
|
for (var i = 0; i < nod.children.length; i++) {
|
|
var nodss = nod.children[i];
|
|
var cmp = nx.gui.getComponent(nodss, "bg", cc.Button);
|
|
if (cmp) {
|
|
cmp.interactable = false;
|
|
}
|
|
}
|
|
});
|
|
nx.tween.fadeOut(this, "panel/base/qa", 0.3);
|
|
nx.tween.fadeOut(this, "panel/coin", 0.3);
|
|
nx.tween.fadeOut(this, "panel/exp", 0.3);
|
|
this.nodResult.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
|
|
this.nodResult.on(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
|
|
},
|
|
onDoAni: function onDoAni() {
|
|
var _this5 = this;
|
|
// let nods = [];
|
|
|
|
this.onDoAnimf(this.nodResult, cc.v2(this.initPos.x, this.initPos.y), true);
|
|
this.cmpCounter.build(1, 101, 50, function (_count) {
|
|
_this5.changeScale(_count);
|
|
});
|
|
var nodBase = nx.gui.find(this, "panel/smod");
|
|
var base = this.onDoAnimf(nodBase, cc.v2(nodBase.position.x + 500, nodBase.position.y), true);
|
|
var nodPanel = nx.gui.find(this, "panel/panels");
|
|
var panel = this.onDoAnimf(nodPanel, cc.v2(nodPanel.position.x - 1000, nodPanel.position.y), true);
|
|
var menuPanel = nx.gui.find(this, "panel/menu");
|
|
// nods.push( menuPanel );
|
|
var menu = this.onDoAnimf(menuPanel, cc.v2(menuPanel.position.x + 500, menuPanel.position.y), true);
|
|
var skinPanel = nx.gui.find(this, "panel/skin");
|
|
// doAni( skinPanel, false );
|
|
var skin = this.onDoAnimf(skinPanel, cc.v2(skinPanel.position.x + 500, skinPanel.position.y), false);
|
|
var storyNod = nx.gui.find(this, "panel/base/infos");
|
|
// doAni( skinPanel, false );
|
|
var story = this.onDoAnimf(storyNod, cc.v2(storyNod.position.x, storyNod.position.y + 200), true);
|
|
var nodQa = nx.gui.find(this, "panel/base/qa");
|
|
// doAni( skinPanel, false );
|
|
var touch = nx.gui.find(this, "panel/base/clerk/touch");
|
|
var touchMove = this.onDoAnimf(touch, cc.v2(touch.position.x, touch.position.y + 500), true);
|
|
var backNod = nx.gui.find(this, "panel/back");
|
|
// doAni( skinPanel, false );
|
|
var back = this.onDoAnimf(backNod, cc.v2(backNod.position.x + 500, backNod.position.y), true);
|
|
var opNod = nx.gui.find(this, "panel/base/ops");
|
|
var opNodMove = this.onDoAnimf(opNod, cc.v2(opNod.position.x, opNod.position.y - 200), true);
|
|
var backNods = nx.gui.find(this, "panel/base/back");
|
|
// doAni( skinPanel, false );
|
|
// let backs = this.onDoAnim( backNods, cc.v2( backNods.position.x - 198, backNods.position.y ), false );
|
|
nx.tween.fadeOut(backNods, "", 0.1, function () {
|
|
nx.gui.getComponent(backNods, "", cc.Button).interactable = false;
|
|
});
|
|
var doNods = nx.gui.find(this, "panel/do");
|
|
// doAni( skinPanel, false );
|
|
var doNodsMove = this.onDoAnim(doNods, cc.v2(doNods.position.x + 398, doNods.position.y), false);
|
|
nx.tween.fadeIn(this, "panel/base/switch", 0.3, function () {
|
|
nx.gui.getComponent(_this5, "panel/base/switch/left", cc.Button).interactable = true;
|
|
nx.gui.getComponent(_this5, "panel/base/switch/right", cc.Button).interactable = true;
|
|
});
|
|
var nod = nx.gui.find(this, "panel/base/skills/list");
|
|
nx.tween.fadeIn(this, "panel/base/skills", 0.3, function () {
|
|
for (var i = 0; i < nod.children.length; i++) {
|
|
var nodss = nod.children[i];
|
|
var cmp = nx.gui.getComponent(nodss, "bg", cc.Button);
|
|
if (cmp) {
|
|
cmp.interactable = true;
|
|
}
|
|
}
|
|
});
|
|
nx.tween.fadeIn(this, "panel/base/qa", 0.3);
|
|
nx.tween.fadeIn(this, "panel/coin", 0.3);
|
|
nx.tween.fadeIn(this, "panel/exp", 0.3);
|
|
},
|
|
_onTouchMove: function _onTouchMove(touchEvent) {
|
|
// let location = touchEvent.getLocation();
|
|
// // this.nodResult.anchor =
|
|
// this.nodResult.position = this.nodResult.parent.convertToNodeSpaceAR( location ); // 确定位置
|
|
// 偏移移动
|
|
var offset = touchEvent.getDelta();
|
|
var pos = this.nodResult.position;
|
|
this.nodResult.position = cc.v2(pos.x + offset.x, pos.y + offset.y);
|
|
this.can = false;
|
|
},
|
|
_onTouchEnd: function _onTouchEnd(touchEvent) {
|
|
// 放下
|
|
this.can = true;
|
|
},
|
|
// 点击动画
|
|
onTouchSpine: function onTouchSpine() {
|
|
if (this.can) {
|
|
var cmp = nx.gui.getComponent(this.nodResult, "role", "nx.fx.spine");
|
|
if (cmp) {
|
|
// 屏蔽频繁点击打断
|
|
if (cmp.spAction != "action1") {
|
|
return;
|
|
}
|
|
|
|
// 播放 -> 常态
|
|
cmp.action("action2", false, function (_event) {
|
|
if (_event == "complete") {
|
|
cmp.action("action1", true);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
},
|
|
onTouchHide: function onTouchHide() {
|
|
var doNods = nx.gui.find(this, "panel/do/ops");
|
|
nx.gui.setActive(doNods, "", !doNods.active);
|
|
},
|
|
changeScale: function changeScale(_count) {
|
|
var scale = 0;
|
|
var dec = this.maxLen - this.minLen;
|
|
var rate = (this.max_scale - this.min_scale) / dec; // 计算比率 最大减去最小
|
|
|
|
// 计算滑动条值
|
|
var progress = _count * rate + +this.min_scale;
|
|
// 当滑动条数值为 最小时 显示的当前ui的缩放比例是0.1 (101 x 0.01)x + y = 1 (50 X 0.01)x + y = 0.5
|
|
if (progress <= this.min_scale) {
|
|
scale = this.min_scale;
|
|
} else {
|
|
if (progress >= this.max_scale) {
|
|
scale = this.max_scale;
|
|
} else {
|
|
scale = progress;
|
|
}
|
|
}
|
|
this.nodResult.scale = scale * 1;
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |