149 lines
5.0 KiB
TypeScript
149 lines
5.0 KiB
TypeScript
|
import SKUIUtil from "./gear_2.3.4/util/SKUIUtil";
|
|||
|
import FGUtil from "./gear_2.3.4/fgui/FGUtil";
|
|||
|
import GameUtil from "./core/GameUtil";
|
|||
|
import SKDataUtil from "./gear_2.3.4/util/SKDataUtil";
|
|||
|
import GameModel from "./core/GameModel";
|
|||
|
import MsgAlert from "./game/msg/MsgAlert";
|
|||
|
import FGAlert from "./gear_2.3.4/fgui/FGAlert";
|
|||
|
const { ccclass, property } = cc._decorator;
|
|||
|
export default class EquipRefine extends cc.Component {
|
|||
|
|
|||
|
/**
|
|||
|
* 單例實例
|
|||
|
*/
|
|||
|
public static Instance: EquipRefine = null;
|
|||
|
|
|||
|
/**
|
|||
|
* 主面板
|
|||
|
*/
|
|||
|
refinePanel: fgui.GComponent = null;
|
|||
|
refineList: any = [];
|
|||
|
eqId: string = "";
|
|||
|
selectId: number = 0;
|
|||
|
tipWarn: boolean = false;
|
|||
|
tipNum: number = 0;
|
|||
|
inCD: boolean = false
|
|||
|
onLoad() {
|
|||
|
if (EquipRefine.Instance === null) {
|
|||
|
EquipRefine.Instance = this;
|
|||
|
} else {
|
|||
|
this.destroy();
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
openEquipRefinePanel(listData: any) {
|
|||
|
this.tipWarn = false
|
|||
|
if (!SKUIUtil.isFGUIValid(this.refinePanel)) {
|
|||
|
this.refinePanel = FGUtil.create("main_ui", "priview_more_panel");
|
|||
|
FGUtil.root().addChild(this.refinePanel);
|
|||
|
this.refinePanel.makeFullScreen();
|
|||
|
}
|
|||
|
this.refineList = listData;
|
|||
|
FGUtil.getButton(this.refinePanel, "alert/back").onClick(this.backClick, this);
|
|||
|
FGUtil.getButton(this.refinePanel, "alert/coast").onClick(this.changeRefine, this);
|
|||
|
FGUtil.getButton(this.refinePanel, "alert/change").onClick(this.changeProp, this);
|
|||
|
|
|||
|
var hasNum = GameModel.player.itemList[10404] == null ? 0 : GameModel.player.itemList[10404]
|
|||
|
|
|||
|
FGUtil.getRichTextField(this.refinePanel, "alert/num").text = `[color=#${hasNum > 29 ? "00A03C" : "FB8C84"}]${hasNum}[/color]/30`
|
|||
|
|
|||
|
for (let i = 0; i < 6; i++) {
|
|||
|
var item = FGUtil.getComponent(this.refinePanel, `alert/n${i}`);
|
|||
|
var list = FGUtil.getList(item, "list");
|
|||
|
var info = listData[i];
|
|||
|
FGUtil.getTextField(item, "score").text = info.score;
|
|||
|
list.removeChildren();
|
|||
|
var chongfu = {}
|
|||
|
for (let m in info.property) {
|
|||
|
var attr = list.addItem().asCom;
|
|||
|
var prop = info.property[m]
|
|||
|
|
|||
|
for (var key in prop) {
|
|||
|
if (!chongfu[key]) {
|
|||
|
chongfu[key] = 1
|
|||
|
} else
|
|||
|
chongfu[key]++
|
|||
|
let valuestr = prop[key];
|
|||
|
if (GameUtil.equipTypeNumerical.indexOf(Number(key)) == -1) {
|
|||
|
valuestr = (valuestr > 0 ? '+' : '') + (valuestr / 10).toFixed(1) + '%';
|
|||
|
}
|
|||
|
else {
|
|||
|
valuestr = (valuestr > 0 ? '+' : '') + valuestr;
|
|||
|
}
|
|||
|
// @ts-ignore
|
|||
|
FGUtil.getTextField(attr, "title").text = GameUtil.getAttrTypeL1Name(key);
|
|||
|
FGUtil.getTextField(attr, "value").text = valuestr;
|
|||
|
}
|
|||
|
}
|
|||
|
for (var keyC in chongfu) {
|
|||
|
if (chongfu[keyC] >= 3) {
|
|||
|
this.tipWarn = true;
|
|||
|
this.tipNum = i + 1
|
|||
|
}
|
|||
|
}
|
|||
|
item.node["idx"] = i
|
|||
|
item.onClick(this.ClickRefineItem, this)
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
backClick() {
|
|||
|
FGUtil.dispose(this.refinePanel);
|
|||
|
this.refinePanel = null;
|
|||
|
}
|
|||
|
|
|||
|
ClickRefineItem(e: Event) {
|
|||
|
var id = 0;
|
|||
|
if (e && e.target && SKDataUtil.hasProperty(e.target, "idx"))
|
|||
|
id = e.target["idx"];
|
|||
|
if (id == this.selectId) return;
|
|||
|
FGUtil.getControl(this.refinePanel, `alert/n${this.selectId}/selected`).selectedIndex = 0
|
|||
|
FGUtil.getControl(this.refinePanel, `alert/n${id}/selected`).selectedIndex = 1
|
|||
|
this.selectId = id
|
|||
|
}
|
|||
|
|
|||
|
changeProp() {
|
|||
|
GameModel.send("c2s_equip_refine", {
|
|||
|
operation: 1, // 0獲取,1確認
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
level: 2, // 0使用低九彩雲龍珠,1中級,2高級
|
|||
|
equipid: this.eqId,
|
|||
|
refine: JSON.stringify(this.refineList[this.selectId].property)
|
|||
|
})
|
|||
|
this.backClick()
|
|||
|
}
|
|||
|
changeRefine() {
|
|||
|
if (this.inCD) {
|
|||
|
MsgAlert.addMsg("您點擊太快啦")
|
|||
|
return;
|
|||
|
}
|
|||
|
this.inCD = true
|
|||
|
this.scheduleOnce(() => {
|
|||
|
this.inCD = false
|
|||
|
}, 0.8)
|
|||
|
if (this.tipWarn) {
|
|||
|
FGAlert.show(`預覽${this.tipNum}中有存在三條相同屬性,確定要重新煉化麼?`, () => {
|
|||
|
FGAlert.hide()
|
|||
|
}, () => {
|
|||
|
FGAlert.hide()
|
|||
|
this.tipWarn = false
|
|||
|
this.changeRefine()
|
|||
|
})
|
|||
|
return
|
|||
|
}
|
|||
|
this.tipWarn = false
|
|||
|
if (GameModel.player.itemList[10404])
|
|||
|
GameModel.player.itemList[10404]--;
|
|||
|
else {
|
|||
|
MsgAlert.addMsg("煉化材料不足")
|
|||
|
return;
|
|||
|
}
|
|||
|
GameModel.send('c2s_equip_refine', {
|
|||
|
operation: 0,
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
level: 2,
|
|||
|
equipid: this.eqId,
|
|||
|
});
|
|||
|
|
|||
|
}
|
|||
|
}
|