695 lines
23 KiB
JavaScript
695 lines
23 KiB
JavaScript
import GameModel from "../ts/core/GameModel";
|
|
import GameUtil from "../ts/core/GameUtil";
|
|
import ItemUtil from "../ts/core/ItemUtil";
|
|
import MsgAlert from "../ts/game/msg/MsgAlert";
|
|
import EquipUtil from "../ts/game/equip/EquipUtil";
|
|
import EquipRefine from "../ts/EquipRefine"
|
|
import { EAttrTypeL1 } from "../ts/core/EEnum";
|
|
import SKDataUtil from "../ts/gear_2.3.4/util/SKDataUtil";
|
|
import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil";
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
titleNodes: [cc.Node],
|
|
listContent: cc.Node,
|
|
|
|
upgradeNode: cc.Node,
|
|
refineNode: cc.Node,
|
|
inlayNode: cc.Node,
|
|
recastNode: cc.Node,
|
|
tipsNode: cc.Node,
|
|
|
|
refinePreNode: cc.Node,
|
|
recastPreNode: cc.Node,
|
|
|
|
equipListItem: cc.Prefab,
|
|
shenbingUpPre: cc.Prefab,
|
|
xianqiUpPre: cc.Prefab,
|
|
|
|
oldScore: 0,
|
|
newScore: 0,
|
|
pbNode: cc.Node,
|
|
},
|
|
|
|
onLoad() {
|
|
this.name = 'WorkShopPanel';
|
|
this.listItems = [];
|
|
this.curSelected = null;
|
|
this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegan.bind(this));
|
|
this.nextEquipInfo = null;
|
|
this.refineData = null;
|
|
this.recastData = null;
|
|
this.refineItemId = 0;
|
|
this.refinePreNode.active = false
|
|
this.loadEquipList();
|
|
},
|
|
|
|
start() {
|
|
},
|
|
|
|
reloadListData(info) {
|
|
for (let index = 0; index < this.listItems.length; index++) {
|
|
if (this.listItems[index].getComponent('EquipListItem').iteminfo.EquipID == info.EquipID) {
|
|
this.listItems[index].getComponent('EquipListItem').loadInfo(info);
|
|
if (this.listItems[index] == this.curSelected) {
|
|
this.showInfo();
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
loadEquipList() {
|
|
this.upgradeNode.active = false;
|
|
this.refineNode.active = false;
|
|
this.inlayNode.active = false;
|
|
this.recastNode.active = false;
|
|
this.tipsNode.active = false;
|
|
|
|
let curListY = 0;
|
|
this.listContent.destroyAllChildren();
|
|
this.listItems = [];
|
|
if (!GameModel.equipData || !GameModel.equipData.info) {
|
|
return;
|
|
}
|
|
let list = GameModel.equipData.info;
|
|
for (let key in list) {
|
|
let itemInfo = list[key];
|
|
// 翅膀不加入顯示列表
|
|
if (itemInfo.EIndex == 6) {
|
|
continue;
|
|
}
|
|
if (ItemUtil.isBaldric(itemInfo.EIndex)) {
|
|
continue;
|
|
}
|
|
let item = cc.instantiate(this.equipListItem);
|
|
item.x = 0;
|
|
item.y = curListY;
|
|
curListY -= 90;
|
|
item.parent = this.listContent;
|
|
item.getComponent('EquipListItem').loadInfo(itemInfo);
|
|
if (GameModel.equipData.use[itemInfo.EIndex] == itemInfo.EquipID) {
|
|
cc.find('tips', item).active = true;
|
|
}
|
|
let btn = item.getComponent(cc.Button);
|
|
var clickEventHandler = new cc.Component.EventHandler();
|
|
clickEventHandler.target = this.node;
|
|
clickEventHandler.component = "WorkShopPanel";
|
|
clickEventHandler.handler = "equipItemClicked";
|
|
btn.clickEvents.push(clickEventHandler);
|
|
this.listItems.push(item);
|
|
}
|
|
this.listContent.height = -curListY;
|
|
if (this.listContent.height < this.listContent.parent.height) {
|
|
this.listContent.height = this.listContent.parent.height;
|
|
}
|
|
if (this.listItems.length == 0) {
|
|
return;
|
|
}
|
|
this.curSelected = this.listItems[0];
|
|
this.curSelected.getComponent('EquipListItem').selected();
|
|
this.curInfo = this.curSelected.getComponent('EquipListItem').iteminfo;
|
|
this.upgradeNode.active = true;
|
|
this.showInfo();
|
|
},
|
|
|
|
getNextEquipInfo() {
|
|
let resid = 0;
|
|
let type = 0;
|
|
let grade = 0;
|
|
if (this.curInfo.EquipType == 0) {
|
|
type = 1;
|
|
grade = 2;
|
|
} else if (this.curInfo.EquipType == 1 && this.curInfo.Grade < 5) {
|
|
type = 1;
|
|
grade = this.curInfo.Grade + 1;
|
|
} else if ((this.curInfo.EquipType == 2 || this.curInfo.EquipType == 3) && this.curInfo.NextType > 0) {
|
|
resid = this.curInfo.NextType;
|
|
type = this.curInfo.EquipType;
|
|
grade = this.curInfo.Grade + 1;
|
|
} else {
|
|
return;
|
|
}
|
|
GameModel.send('c2s_next_equip', {
|
|
resid: resid,
|
|
type: type,
|
|
index: this.curInfo.EIndex,
|
|
grade: grade,
|
|
roleid: GameModel.player.roleid
|
|
});
|
|
},
|
|
|
|
getRecastInfo() {
|
|
let resid = 0;
|
|
let type = 0;
|
|
let grade = 0;
|
|
if (this.curInfo.EquipType == 0 || this.curInfo.EquipType == 2) {
|
|
return;
|
|
}
|
|
else if (this.curInfo.EquipType == 1) {
|
|
type = 1;
|
|
grade = this.curInfo.Grade;
|
|
} else if (this.curInfo.EquipType == 3) {
|
|
resid = 0;
|
|
type = this.curInfo.EquipType;
|
|
grade = this.curInfo.Grade;
|
|
} else {
|
|
return;
|
|
}
|
|
GameModel.send('c2s_next_equip', {
|
|
resid: resid,
|
|
type: type,
|
|
index: this.curInfo.EIndex,
|
|
grade: grade,
|
|
roleid: GameModel.player.roleid
|
|
});
|
|
},
|
|
|
|
setCurItem(equipid) {
|
|
for (let item of this.listItems) {
|
|
let itemInfo = item.getComponent('EquipListItem').iteminfo;
|
|
if (itemInfo.EquipID == equipid) {
|
|
if (this.curSelected != null) {
|
|
this.curSelected.getComponent('EquipListItem').unSelected();
|
|
}
|
|
this.refineItemId = 0;
|
|
this.curSelected = item;
|
|
this.curSelected.getComponent('EquipListItem').selected();
|
|
this.curInfo = itemInfo;
|
|
this.nextEquipInfo = null;
|
|
this.showInfo();
|
|
if (this.listContent.y + this.listContent.parent.height < -(item.y - 90)) {
|
|
this.listContent.y = -this.listContent.parent.height - (item.y - 90);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
|
|
setCurPanel(pos) {
|
|
for (let index = 1; index <= 4; index++) {
|
|
if (pos == index) {
|
|
cc.find(`ToggleGroup/toggle${index}`, this.node).getComponent(cc.Toggle).isChecked = true;
|
|
this.panelToggleClicked(null, pos);
|
|
} else {
|
|
cc.find(`ToggleGroup/toggle${index}`, this.node).getComponent(cc.Toggle).isChecked = false;
|
|
}
|
|
}
|
|
},
|
|
|
|
showInfo() {
|
|
this.curInfo = this.curSelected.getComponent('EquipListItem').iteminfo;
|
|
if (!this.curInfo.BaseAttr) {
|
|
return;
|
|
}
|
|
for (let index = 0; index < 4; index++) {
|
|
if (cc.find(`ToggleGroup/toggle${index + 1}`, this.node).getComponent(cc.Toggle).isChecked) {
|
|
this.panelToggleClicked(null, index + 1);
|
|
}
|
|
}
|
|
this.showPreProperty();
|
|
},
|
|
|
|
showUpgradeInfo() {
|
|
this.upgradeNode.getChildByName('EquipItem1').getComponent('EquipItem').loadInfo(this.curInfo);
|
|
if (this.nextEquipInfo != null) {
|
|
this.upgradeNode.getChildByName('EquipItem2').getComponent('EquipItem').loadInfo(this.nextEquipInfo);
|
|
} else {
|
|
this.getNextEquipInfo();
|
|
}
|
|
this.upgradeNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: 10405, count: 1 });
|
|
this.upgradeNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[10405] == null ? 0 : GameModel.player.itemList[10405]}/1`;
|
|
},
|
|
|
|
// 顯示材料選擇面板
|
|
showRefineInfo() {
|
|
this.refineNode.getChildByName('EquipItem').getComponent('EquipItem').loadInfo(this.curInfo);
|
|
this.refineNode.getChildByName('tips').getComponent(cc.Label).string = "請先選擇煉化材料";
|
|
},
|
|
|
|
showInlayInfo() {
|
|
this.inlayNode.getChildByName('EquipItem').getComponent('EquipItem').loadInfo(this.curInfo);
|
|
let gemLevel = Math.floor(this.curInfo.GemCnt / 3) + 1;
|
|
let level_lb = this.inlayNode.getChildByName('BagItem').getChildByName('levellab').getComponent(cc.Label);
|
|
level_lb.string = `Lv.${gemLevel}`;
|
|
let curitemid = EquipUtil.getInlayGemId(this.curInfo.EIndex, this.curInfo.GemCnt);
|
|
let curitemcnt = 0;
|
|
if (GameModel.player.itemList[curitemid]) {
|
|
curitemcnt = GameModel.player.itemList[curitemid];
|
|
}
|
|
this.inlayNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: curitemid, count: curitemcnt });
|
|
// if (curitemcnt <= 0) {
|
|
// this.inlayNode.getChildByName('BagItem').color = cc.Color.GRAY;
|
|
// }
|
|
this.inlayNode.getChildByName('gemlist').destroyAllChildren();
|
|
let gemX = -(this.curInfo.MaxEmbedGemCnt - 1) * 10;
|
|
for (let index = 0; index < this.curInfo.MaxEmbedGemCnt; index++) {
|
|
let gem = cc.instantiate(this.inlayNode.getChildByName('gem'));
|
|
gem.active = true;
|
|
gem.x = gemX + index * 20;
|
|
gem.y = 0;
|
|
gem.parent = this.inlayNode.getChildByName('gemlist');
|
|
if (index < this.curInfo.GemCnt) {
|
|
gem.getChildByName(`gem${this.curInfo.EIndex}`).active = true;
|
|
}
|
|
}
|
|
},
|
|
|
|
showRecastInfo() {
|
|
this.recastNode.getChildByName('EquipItem1').getComponent('EquipItem').loadInfo(this.curInfo);
|
|
if (this.nextEquipInfo != null) {
|
|
this.nextEquipInfo.BaseAttr = {};
|
|
this.recastNode.getChildByName('EquipItem2').getComponent('EquipItem').loadInfo(this.nextEquipInfo);
|
|
} else {
|
|
this.getRecastInfo();
|
|
}
|
|
// this.recastNode.getChildByName('EquipItem2').getComponent('EquipItem').loadInfo(this.curInfo);
|
|
if (this.curInfo.EquipType == 3) {
|
|
this.recastNode.getChildByName('itemname').getComponent(cc.Label).string = '悔夢石';
|
|
this.recastNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: 10401, count: 1 });
|
|
this.recastNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[10401] == null ? 0 : GameModel.player.itemList[10401]}/1`;
|
|
}
|
|
else {
|
|
this.recastNode.getChildByName('itemname').getComponent(cc.Label).string = '盤古精鐵';
|
|
this.recastNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: 10405, count: 1 });
|
|
this.recastNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[10405] == null ? 0 : GameModel.player.itemList[10405]}/1`;
|
|
}
|
|
},
|
|
|
|
showNewProperty(info) {
|
|
if (this.refinePreNode.active) {
|
|
this.showPropertyInfo(info, this.refinePreNode.getChildByName('new'));
|
|
this.refreshNewScore();
|
|
}
|
|
else if (this.recastPreNode.active) {
|
|
this.showPropertyInfo(info, this.recastPreNode.getChildByName('new'));
|
|
}
|
|
},
|
|
refreshNewScore() {
|
|
if (this.newScore > 0) {
|
|
this.refinePreNode.getChildByName('newScore').getComponent(cc.Label).string = this.newScore
|
|
this.refinePreNode.getChildByName('scoreIcon1').active = true
|
|
} else {
|
|
this.refinePreNode.getChildByName('newScore').getComponent(cc.Label).string = ""
|
|
this.refinePreNode.getChildByName('scoreIcon1').active = false
|
|
}
|
|
},
|
|
refreshOldScore() {
|
|
if (this.oldScore > 0) {
|
|
this.refinePreNode.getChildByName('oldScore').getComponent(cc.Label).string = this.oldScore
|
|
this.refinePreNode.getChildByName('scoreIcon').active = true
|
|
} else {
|
|
this.refinePreNode.getChildByName('oldScore').getComponent(cc.Label).string = ""
|
|
this.refinePreNode.getChildByName('scoreIcon').active = false
|
|
}
|
|
},
|
|
showPreProperty() {
|
|
if (this.refinePreNode.active) {
|
|
this.showPropertyInfo(this.curInfo.LianhuaAttr, this.refinePreNode.getChildByName('pre'));
|
|
this.refreshOldScore()
|
|
}
|
|
else if (this.recastPreNode.active) {
|
|
this.showPropertyInfo(this.curInfo.BaseAttr, this.recastPreNode.getChildByName('pre'));
|
|
}
|
|
},
|
|
|
|
showPropertyInfo(info, node) {
|
|
if (!info || info.length == 0) {
|
|
info = '{}';
|
|
}
|
|
node.destroyAllChildren();
|
|
this.infoPos = cc.v2(0, 120);
|
|
let propertyInfo = JSON.parse(info);
|
|
if (Array.isArray(propertyInfo)) {
|
|
for (const info of propertyInfo) {
|
|
this.addPropertyInfo(info, node);
|
|
}
|
|
} else {
|
|
this.addPropertyInfo(propertyInfo, node);
|
|
}
|
|
},
|
|
|
|
addPropertyInfo(propertyInfo, node) {
|
|
for (const key in propertyInfo) {
|
|
let valuestr = propertyInfo[key];
|
|
let valNum = propertyInfo[key];
|
|
if (GameUtil.equipTypeNumerical.indexOf(Number(key)) == -1) {
|
|
valuestr = (valuestr > 0 ? '+' : '') + (valuestr / 10).toFixed(1) + '%';
|
|
}
|
|
else {
|
|
valuestr = (valuestr > 0 ? '+' : '') + valuestr;
|
|
}
|
|
if (GameUtil.equipTypeNumerical.indexOf(Number(key)) == -1)
|
|
valNum = valNum / 10;
|
|
|
|
let maxNum = 0;
|
|
if (node.x > 0)
|
|
maxNum = this.getMaxValue(key, this.curInfo.Grade, 0)
|
|
else
|
|
maxNum = this.getMaxValue(key, this.curInfo.Grade, this.curInfo.GemCnt)
|
|
|
|
// this.addPb(this.infoPos, valNum, maxNum, node)
|
|
this.addPb(SKUIUtil.add(this.infoPos, cc.v2(20, 20)), valNum, maxNum, node)
|
|
this.addInfoLab(GameUtil.getAttrTypeL1Name(key), valuestr, node);
|
|
}
|
|
},
|
|
|
|
addInfoLab(name, value, node) {
|
|
let detail = cc.instantiate(this.node.getChildByName('item'));
|
|
detail.active = true;
|
|
detail.parent = node;
|
|
detail.setPosition(this.infoPos);
|
|
detail.getChildByName('name').getComponent(cc.Label).string = name;
|
|
detail.getChildByName('value').getComponent(cc.Label).string = value;
|
|
this.infoPos.y -= 60;
|
|
},
|
|
|
|
addPb(pos, value, max, node) {
|
|
if (!pos && pos == null) {
|
|
pos = this.infoPos;
|
|
}
|
|
let detail = cc.instantiate(this.pbNode);
|
|
detail.active = true;
|
|
detail.parent = node;
|
|
detail.setPosition(pos);
|
|
var pro = value / max;
|
|
pro = pro > 1 ? 1 : pro
|
|
if (pro >= 0.85) {
|
|
var icon = cc.find("icon", detail)
|
|
if (icon) icon.active = true
|
|
}
|
|
detail.getComponent(cc.ProgressBar).progress = pro
|
|
},
|
|
getMaxValue(key, grade, GemCnt) {
|
|
// 一階屬性上限
|
|
let score = 15;
|
|
// 如果是抗性
|
|
if (key < 12)
|
|
score = 30;
|
|
|
|
// 品階加成
|
|
if (grade > 1)
|
|
if (key < 12) score = 30 + (grade - 1) * 5;
|
|
else score = 15 + (grade - 1) * 3;
|
|
|
|
// 特殊值屬性
|
|
if (key == EAttrTypeL1.ATK) {
|
|
score = 3000;
|
|
if (grade > 1)
|
|
score = 3000 + (grade - 1) * 1000;
|
|
}
|
|
if (key == EAttrTypeL1.MP_MAX || key == EAttrTypeL1.HP_MAX) {
|
|
score = 5040;
|
|
if (grade > 1)
|
|
score = 5040 + (grade - 1) * 1050;
|
|
}
|
|
if (key == EAttrTypeL1.SPD) {
|
|
score = 87;
|
|
if (grade > 1)
|
|
score = 87 + (grade - 1) * 40;
|
|
}
|
|
|
|
score = Math.floor(SKDataUtil.toDecimal2(score * (1 + 0.03 * GemCnt)));
|
|
return score;
|
|
},
|
|
|
|
equipItemClicked(e, d) {
|
|
if (this.curSelected == e.target || !e.target.getComponent('EquipListItem').iteminfo.EName) {
|
|
return;
|
|
}
|
|
this.refineItemId = 0;
|
|
if (this.curSelected != null) {
|
|
this.curSelected.getComponent('EquipListItem').unSelected();
|
|
}
|
|
this.curSelected = e.target;
|
|
this.curSelected.getComponent('EquipListItem').selected();
|
|
this.curInfo = this.curSelected.getComponent('EquipListItem').iteminfo;
|
|
this.nextEquipInfo = null;
|
|
this.showInfo();
|
|
},
|
|
|
|
chooseItemClicked(e, d) {
|
|
this.refineNode.getChildByName('itemlist').active = true;
|
|
// 只讓玩家選擇高級和超級的,忽略低級和中級
|
|
// cc.find('itemlist/item1/BagItem', this.refineNode).getComponent('BagItem').loadInfo({ itemid: 10402, count: 0 });
|
|
// cc.find('itemlist/item1/countlab', this.refineNode).getComponent(cc.Label).string = `擁有${GameModel.player.itemList[10402] == null ? 0 : GameModel.player.itemList[10402]}個`;
|
|
// cc.find('itemlist/item2/BagItem', this.refineNode).getComponent('BagItem').loadInfo({ itemid: 10403, count: 0 });
|
|
// cc.find('itemlist/item2/countlab', this.refineNode).getComponent(cc.Label).string = `擁有${GameModel.player.itemList[10403] == null ? 0 : GameModel.player.itemList[10403]}個`;
|
|
cc.find('itemlist/item1/BagItem', this.refineNode).getComponent('BagItem').loadInfo({ itemid: 10404, count: 0 });
|
|
cc.find('itemlist/item1/countlab', this.refineNode).getComponent(cc.Label).string = `擁有${GameModel.player.itemList[10404] == null ? 0 : GameModel.player.itemList[10404]}個`;
|
|
cc.find('itemlist/item2/BagItem', this.refineNode).getComponent('BagItem').loadInfo({ itemid: 10410, count: 0 });
|
|
cc.find('itemlist/item2/countlab', this.refineNode).getComponent(cc.Label).string = `擁有${GameModel.player.itemList[10410] == null ? 0 : GameModel.player.itemList[10410]}个`;
|
|
},
|
|
// 材料選擇點擊
|
|
refineItemClicked(event, data) {
|
|
let count = GameModel.player.itemList[data];
|
|
if (count > 0) {
|
|
this.refineItemId = data;
|
|
let useItem = this.refineNode.getChildByName('BagItem');
|
|
useItem.active = true;
|
|
let bagItem = useItem.getComponent("BagItem");
|
|
bagItem.loadInfo({ itemid: data, count: 0 });
|
|
this.refineNode.getChildByName('BagBtn').active = false;
|
|
this.refineNode.getChildByName('tips').getComponent(cc.Label).string = ItemUtil.getItemName(this.refineItemId);
|
|
}
|
|
this.refineNode.getChildByName('itemlist').active = false;
|
|
},
|
|
// 點擊選項卡
|
|
panelToggleClicked(event, data) {
|
|
let type = parseInt(data);
|
|
if (!this.curInfo) {
|
|
return;
|
|
}
|
|
// 檢查材料是否還有足夠的數量
|
|
if (this.refineItemId != 0) {
|
|
let count = GameModel.player.itemList[this.refineItemId];
|
|
if (count < 1) {
|
|
this.refineItemId = 0;
|
|
}
|
|
}
|
|
for (const lab of this.titleNodes) {
|
|
lab.active = false;
|
|
}
|
|
this.titleNodes[type - 1].active = true;
|
|
this.upgradeNode.active = false;
|
|
this.refineNode.active = false;
|
|
this.inlayNode.active = false;
|
|
this.recastNode.active = false;
|
|
this.tipsNode.active = false;
|
|
if (type == 1) {
|
|
if (this.curInfo.EquipType == 1 && this.curInfo.Grade == 120) {
|
|
this.tipsNode.active = true;
|
|
this.tipsNode.getChildByName('tips').active = true;
|
|
this.tipsNode.getChildByName('shenbing').active = false;
|
|
this.tipsNode.getChildByName('xianqi').active = false;
|
|
this.tipsNode.getChildByName('tips').getComponent(cc.Label).string = '該裝備不能升級哦';
|
|
}
|
|
else if (this.curInfo.EquipType == 2) {
|
|
this.tipsNode.active = true;
|
|
this.tipsNode.getChildByName('tips').active = false;
|
|
this.tipsNode.getChildByName('shenbing').active = true;
|
|
this.tipsNode.getChildByName('xianqi').active = false;
|
|
}
|
|
else if (this.curInfo.EquipType == 3) {
|
|
this.tipsNode.active = true;
|
|
this.tipsNode.getChildByName('tips').active = false;
|
|
this.tipsNode.getChildByName('shenbing').active = false;
|
|
this.tipsNode.getChildByName('xianqi').active = true;
|
|
}
|
|
else {
|
|
this.upgradeNode.active = true;
|
|
this.showUpgradeInfo();
|
|
}
|
|
}
|
|
else if (type == 2) {
|
|
if (this.curInfo.EquipType == 0) {
|
|
this.tipsNode.active = true;
|
|
this.tipsNode.getChildByName('tips').active = true;
|
|
this.tipsNode.getChildByName('shenbing').active = false;
|
|
this.tipsNode.getChildByName('xianqi').active = false;
|
|
this.tipsNode.getChildByName('tips').getComponent(cc.Label).string = '該裝備不能煉化哦';
|
|
}
|
|
else {
|
|
this.refineNode.active = true;
|
|
this.showRefineInfo();
|
|
this.refineNode.getChildByName('BagItem').active = false;
|
|
this.refineNode.getChildByName('BagBtn').active = true;
|
|
this.refineNode.getChildByName('tips').getComponent(cc.Label).string = "請先選擇煉化材料";
|
|
}
|
|
}
|
|
else if (type == 3) {
|
|
this.inlayNode.active = true;
|
|
this.showInlayInfo();
|
|
}
|
|
else if (type == 4) {
|
|
if (this.curInfo.EquipType == 0 || this.curInfo.EquipType == 2) {
|
|
this.tipsNode.active = true;
|
|
this.tipsNode.getChildByName('tips').active = true;
|
|
this.tipsNode.getChildByName('shenbing').active = false;
|
|
this.tipsNode.getChildByName('xianqi').active = false;
|
|
this.tipsNode.getChildByName('tips').getComponent(cc.Label).string = '該裝備不能重鑄哦';
|
|
}
|
|
else {
|
|
this.recastNode.active = true;
|
|
this.showRecastInfo();
|
|
}
|
|
}
|
|
},
|
|
|
|
inlayBtnClicked(e, d) {
|
|
if (d == 1 && this.GemCnt >= this.MaxEmbedGemCnt) {
|
|
return;
|
|
}
|
|
GameModel.send('c2s_equip_inlay', {
|
|
operation: d,
|
|
roleid: GameModel.player.roleid,
|
|
equipid: this.curInfo.EquipID
|
|
});
|
|
},
|
|
|
|
upgradeBtnClicked(e, d) {
|
|
GameModel.send('c2s_equip_upgrade', {
|
|
roleid: GameModel.player.roleid,
|
|
equipid: this.curInfo.EquipID
|
|
});
|
|
this.nextEquipInfo = null;
|
|
},
|
|
|
|
refinePreBtnClicked(e, d) {
|
|
if (this.refineItemId == 0) {
|
|
MsgAlert.addMsg("請先選擇煉化材料");
|
|
return;
|
|
}
|
|
|
|
GameModel.send("c2s_attribute_score", {
|
|
roleId: GameModel.player.roleid,
|
|
type: 0,
|
|
equipId: this.curInfo.EquipID
|
|
})
|
|
this.refinePreNode.active = true;
|
|
this.showPropertyInfo(this.curInfo.LianhuaAttr, this.refinePreNode.getChildByName('pre'));
|
|
// this.showNewProperty('');
|
|
this.refinePreNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: this.refineItemId, count: 0 });
|
|
this.refinePreNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[this.refineItemId] == null ? 0 : GameModel.player.itemList[this.refineItemId]}/30`;
|
|
},
|
|
refreshNeedLabel() {
|
|
this.refinePreNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[this.refineItemId] == null ? 0 : GameModel.player.itemList[this.refineItemId]}/30`;
|
|
},
|
|
recastPreBtnClicked(e, d) {
|
|
this.recastPreNode.active = true;
|
|
this.showPropertyInfo(this.curInfo.BaseAttr, this.recastPreNode.getChildByName('pre'));
|
|
// this.showNewProperty('');
|
|
if (this.curInfo.EquipType == 3) {
|
|
this.recastPreNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: 10401, count: 1 });
|
|
this.recastPreNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[10401] == null ? 0 : GameModel.player.itemList[10401]}/1`;
|
|
}
|
|
else {
|
|
this.recastPreNode.getChildByName('BagItem').getComponent('BagItem').loadInfo({ itemid: 10405, count: 1 });
|
|
this.recastPreNode.getChildByName('needlab').getComponent(cc.Label).string = `${GameModel.player.itemList[10405] == null ? 0 : GameModel.player.itemList[10405]}/1`;
|
|
}
|
|
},
|
|
|
|
refineBtnClicked(e, d) {
|
|
this.refineData = null;
|
|
let level = 0;
|
|
if (this.refineItemId == 10403) level = 1;
|
|
if (this.refineItemId == 10404) level = 2;
|
|
if (this.refineItemId == 10410) level = 3;
|
|
if (GameModel.player.itemList[this.refineItemId])
|
|
GameModel.player.itemList[this.refineItemId]--;
|
|
else {
|
|
MsgAlert.addMsg("煉化材料不足")
|
|
return;
|
|
}
|
|
// this.refinePreBtnClicked();
|
|
|
|
GameModel.send('c2s_equip_refine', {
|
|
operation: 0,
|
|
roleid: GameModel.player.roleid,
|
|
level: level,
|
|
equipid: this.curInfo.EquipID,
|
|
});
|
|
if (level == 2)
|
|
EquipRefine.Instance.eqId = this.curInfo.EquipID
|
|
},
|
|
|
|
recastBtnClicked(e, d) {
|
|
let itemid = 10401;
|
|
if (this.curInfo.EquipType == 3) {
|
|
itemid = 10401;
|
|
} else {
|
|
itemid = 10405;
|
|
}
|
|
let itemnum = GameModel.player.itemList[itemid];
|
|
if (itemnum == null || itemnum <= 0) {
|
|
MsgAlert.addMsg('材料不足');
|
|
return;
|
|
}
|
|
this.recastData = null;
|
|
GameModel.send('c2s_equip_recast', {
|
|
operation: 0,
|
|
roleid: GameModel.player.roleid,
|
|
equipid: this.curInfo.EquipID
|
|
});
|
|
GameModel.player.itemList[itemid]--;
|
|
this.recastPreBtnClicked();
|
|
},
|
|
refineChangeBtnClicked(e, d) {
|
|
this.refineData = null;
|
|
GameModel.send('c2s_equip_refine', {
|
|
operation: 1,
|
|
roleid: GameModel.player.roleid,
|
|
level: 0,
|
|
equipid: this.curInfo.EquipID
|
|
});
|
|
this.oldScore = this.newScore
|
|
this.newScore = 0
|
|
this.refinePreNode.getChildByName('oldScore').getComponent(cc.Label).string = this.oldScore
|
|
this.refinePreNode.getChildByName('scoreIcon').active = true
|
|
this.refinePreNode.getChildByName('newScore').getComponent(cc.Label).string = ""
|
|
this.refinePreNode.getChildByName('scoreIcon1').active = false
|
|
},
|
|
|
|
recastChangeBtnClicked(e, d) {
|
|
this.recastData = null;
|
|
GameModel.send('c2s_equip_recast', {
|
|
operation: 1,
|
|
roleid: GameModel.player.roleid,
|
|
equipid: this.curInfo.EquipID
|
|
});
|
|
GameModel.send('c2s_equip_update', {
|
|
operation: 2,
|
|
roleid: GameModel.player.roleid,
|
|
equipid: this.curInfo.EquipID
|
|
});
|
|
},
|
|
|
|
closeRefine() {
|
|
this.refinePreNode.active = false;
|
|
},
|
|
|
|
closeRecast() {
|
|
this.recastPreNode.active = false;
|
|
},
|
|
|
|
touchBegan(event) {
|
|
this.refineNode.getChildByName('itemlist').active = false;
|
|
},
|
|
|
|
onCloseBtnClicked(e, d) {
|
|
this.node.destroy();
|
|
},
|
|
|
|
onShenBingUpClicked(e, d) {
|
|
let shenbingup = cc.instantiate(this.shenbingUpPre);
|
|
shenbingup.parent = cc.find('Canvas');
|
|
this.node.destroy();
|
|
},
|
|
|
|
onXianQiUpClicked(e, d) {
|
|
let xianqiup = cc.instantiate(this.xianqiUpPre);
|
|
xianqiup.parent = cc.find('Canvas');
|
|
this.node.destroy();
|
|
},
|
|
});
|