1457 lines
51 KiB
TypeScript
1457 lines
51 KiB
TypeScript
|
/**
|
|||
|
* 道具工具類
|
|||
|
*/
|
|||
|
|
|||
|
import Lottery from "../bag/Lottery";
|
|||
|
import RecastPanel from "../game/baldric/RecastPanel";
|
|||
|
import MsgAlert from "../game/msg/MsgAlert";
|
|||
|
import SkillBase, { ESkillQuality, ESkillType } from "../game/skill/core/SkillBase";
|
|||
|
import SkillUtil from "../game/skill/core/SkillUtil";
|
|||
|
import FGAlert from "../gear_2.3.4/fgui/FGAlert";
|
|||
|
import FGUtil, { TipAlign } from "../gear_2.3.4/fgui/FGUtil";
|
|||
|
import Report from "../gear_2.3.4/net/Report";
|
|||
|
import SKDataUtil from "../gear_2.3.4/util/SKDataUtil";
|
|||
|
import SKLogger from "../gear_2.3.4/util/SKLogger";
|
|||
|
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
|
|||
|
import { EEquipIndex, EItemMenu } from "./EEnum";
|
|||
|
import GameModel from "./GameModel";
|
|||
|
import GameUtil from "./GameUtil";
|
|||
|
import SafeCheckAlert from "./SafeCheckAlert";
|
|||
|
import PopupManager from "../gear_2.3.4/manager/PopupManager";
|
|||
|
import Transformation from "../transformation/Transformation";
|
|||
|
import HorsePanel from "../horse/HorsePanel";
|
|||
|
import PubFunction = require('../../game/PubFunction');
|
|||
|
import Bag from "../bag/Bag";
|
|||
|
|
|||
|
export default class ItemUtil {
|
|||
|
// 圖標圖集
|
|||
|
static itemAtlas0: cc.SpriteAtlas;
|
|||
|
static itemAtlas1: cc.SpriteAtlas;
|
|||
|
// 預製體
|
|||
|
static workShopPrefab: cc.Prefab;
|
|||
|
// 使用道具
|
|||
|
static useItemsAlert: fgui.GComponent;
|
|||
|
static mask: fgui.GObject;
|
|||
|
static clickUseItemBlock: (data: any) => void;
|
|||
|
// 道具詳情
|
|||
|
static itemDetailAlert: fgui.GComponent;
|
|||
|
static showMenu: boolean = true;
|
|||
|
static itemData: any;
|
|||
|
// 套裝技能
|
|||
|
static suitDetailAlert: fgui.GComponent;
|
|||
|
static suitId: number = 0;
|
|||
|
static suitSkillId: ESkillType = ESkillType.NONE;
|
|||
|
|
|||
|
static menu = [
|
|||
|
EItemMenu.EQUIP, EItemMenu.RECAST, EItemMenu.RESOLVE
|
|||
|
];
|
|||
|
static sexName = ["男", "女"];
|
|||
|
static raceName = ['人', '仙', '魔', '鬼', '龍'];
|
|||
|
|
|||
|
static launch() {
|
|||
|
let url = `Prefabs/WorkShopPanel`;
|
|||
|
cc.loader.loadRes(url, cc.Prefab, (error, prefab) => {
|
|||
|
if (error) {
|
|||
|
SKLogger.warn(`$警告:加載資源${url}錯誤!`);
|
|||
|
return;
|
|||
|
}
|
|||
|
ItemUtil.workShopPrefab = prefab;
|
|||
|
});
|
|||
|
let url2 = `Prefabs/WorkShopPanel`;
|
|||
|
cc.loader.loadRes(url2, cc.Prefab, (error, prefab) => {
|
|||
|
if (error) {
|
|||
|
SKLogger.warn(`$警告:加載資源${url}錯誤!`);
|
|||
|
return;
|
|||
|
}
|
|||
|
ItemUtil.workShopPrefab = prefab;
|
|||
|
});
|
|||
|
let url3 = `Prefabs/WorkShopPanel`;
|
|||
|
cc.loader.loadRes(url3, cc.Prefab, (error, prefab) => {
|
|||
|
if (error) {
|
|||
|
SKLogger.warn(`$警告:加載資源${url}錯誤!`);
|
|||
|
return;
|
|||
|
}
|
|||
|
ItemUtil.workShopPrefab = prefab;
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
// 獲得道具圖標
|
|||
|
static getItemIconBy(value: any): cc.SpriteFrame {
|
|||
|
let result: cc.SpriteFrame = null;
|
|||
|
// 是否有json配置
|
|||
|
if (value.json && value.json.length > 0) {
|
|||
|
try {
|
|||
|
let json = JSON.parse(value.json);
|
|||
|
// 是否為寶寶
|
|||
|
if (json.petid) {
|
|||
|
let item = GameModel.conf_pet[json.petid];
|
|||
|
if (item) {
|
|||
|
result = ItemUtil.getItemIcon(item.resid);
|
|||
|
if (result) {
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
} catch (error) {
|
|||
|
}
|
|||
|
}
|
|||
|
if (value.icon) {
|
|||
|
result = this.getItemIcon(value.icon);
|
|||
|
} else if (value.Shape) {
|
|||
|
let data = this.getItemData(value.Shape);
|
|||
|
if (data == null) {
|
|||
|
result = this.getItemIcon(value.Shape);
|
|||
|
} else {
|
|||
|
result = this.getItemIcon(data.icon);
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得道具定義
|
|||
|
static getItemName(itemId: any): string {
|
|||
|
let result = this.getItemData(itemId);
|
|||
|
if (result) {
|
|||
|
return result.name;
|
|||
|
}
|
|||
|
SKLogger.warn(`$警告:找不到道具名稱定義:${itemId}`);
|
|||
|
return "";
|
|||
|
}
|
|||
|
|
|||
|
// 獲得道具定義
|
|||
|
static getItemData(itemId: any): any {
|
|||
|
let conf = GameModel.game_conf;
|
|||
|
if (!conf) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
let items = conf.item;
|
|||
|
if (!items) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
let result = items[itemId];
|
|||
|
if (!result) {
|
|||
|
return null;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得背包道具數量
|
|||
|
static getBagItemCount(itemId: number): number {
|
|||
|
let bagList: any = GameModel.player.itemList;
|
|||
|
if (!bagList) {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
let result = bagList[itemId];
|
|||
|
if (!result) {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得使用道具顏色,不足時為紅色否則為白色
|
|||
|
static getUseItemColor(count: number): cc.Color {
|
|||
|
let result = SKUIUtil.colorOfString(count < 1 ? "#F90201" : "#FFFFFF");
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得FGUI圖標定義
|
|||
|
static getFGuiIcon(value: any): string {
|
|||
|
let result: string = "";
|
|||
|
// 是否有json配置
|
|||
|
if (value.json && value.json.length > 0) {
|
|||
|
try {
|
|||
|
let json = JSON.parse(value.json);
|
|||
|
// 是否為寶寶
|
|||
|
if (json.petid) {
|
|||
|
let item = GameModel.conf_pet[json.petid];
|
|||
|
if (item) {
|
|||
|
result = item.resid;
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
} catch (error) {
|
|||
|
}
|
|||
|
}
|
|||
|
if (value.icon) {
|
|||
|
result = value.icon;
|
|||
|
} else if (value.Shape) {
|
|||
|
result = value.Shape;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得道具圖標
|
|||
|
static getItemIcon(iconId: string): cc.SpriteFrame {
|
|||
|
let item = fgui.UIPackage.getItemByURL(`ui://main_ui/${iconId}`);
|
|||
|
if (item == null) {
|
|||
|
SKLogger.warn(`找不到圖標項目:${iconId}`);
|
|||
|
return null;
|
|||
|
}
|
|||
|
item.load();
|
|||
|
let asset: cc.SpriteFrame = <cc.SpriteFrame>item.asset;
|
|||
|
if (asset == null) {
|
|||
|
SKLogger.warn(`找不到圖標資源:${iconId}`);
|
|||
|
}
|
|||
|
return asset;
|
|||
|
}
|
|||
|
|
|||
|
// 能否合成
|
|||
|
static canSynthesis(itemId: number): Boolean {
|
|||
|
// 如果配置不存在則返回不能合成
|
|||
|
if (!GameModel.game_conf) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
let list = GameModel.game_conf.synthesis;
|
|||
|
for (let key in list) {
|
|||
|
let item = list[key];
|
|||
|
// 如果是合成物品則能合成
|
|||
|
if (itemId == item.id) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
// 如果在合成列表中能合成
|
|||
|
if (item.list.indexOf(itemId) != -1) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
// 能否分解
|
|||
|
static canResolve(data: any): number {
|
|||
|
if (SKDataUtil.atRange(data.id, [20011, 20012, 20013, 20014, 20015])) {
|
|||
|
return 5;
|
|||
|
}
|
|||
|
if (SKDataUtil.atRange(data.id, [21011, 21012, 21013, 21014, 21015])) {
|
|||
|
return 10;
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得合成表
|
|||
|
static synthesisMap(): any {
|
|||
|
let result: any = GameModel.game_conf;
|
|||
|
if (result == null) {
|
|||
|
return {};
|
|||
|
}
|
|||
|
result = result.synthesis;
|
|||
|
if (result == null) {
|
|||
|
return {};
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得合成表
|
|||
|
static getSynthesisItem(index: number): string {
|
|||
|
let result: any = GameModel.game_conf;
|
|||
|
if (result == null) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
result = result.synthesis;
|
|||
|
if (result == null) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
result = result[index];
|
|||
|
if (result == null) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
result = result.map;
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 是否為召喚獸使用
|
|||
|
static isPetUse(value: number): boolean {
|
|||
|
if (value >= 10110 && value <= 10114) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
if (value >= 10116 && value <= 10118) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
if (value >= 10501 && value <= 10589) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
if (value >= 20001 && value <= 20005) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
if (value >= 20006 && value <= 21015) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
static useItem(itemId: number, count: number = 1, operateid: number = 0) {
|
|||
|
let itemData = this.getItemData(itemId);
|
|||
|
if (itemData.id >= 30001 && itemData.id <= 30030) {
|
|||
|
let workshop = cc.instantiate(this.workShopPrefab);
|
|||
|
workshop.parent = cc.find('Canvas');
|
|||
|
workshop.getComponent('WorkShopPanel').setCurPanel(3);
|
|||
|
let bagLayer = cc.find('Canvas/MainUI/BagPanel');
|
|||
|
if (bagLayer != null) {
|
|||
|
bagLayer.destroy();
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
if (itemData == null || (itemData.count <= 0 && itemData.effect == 1)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
if (itemId == 50023) {
|
|||
|
Lottery.shared.show(itemId);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (itemId == 50004) {
|
|||
|
Lottery.shared.loadNewTreasure()
|
|||
|
}
|
|||
|
if (SKDataUtil.atRange(itemId, [50001, 50002, 50003])) //藏寶圖類型
|
|||
|
{
|
|||
|
let json = SKDataUtil.jsonBy(itemData.json);
|
|||
|
GameUtil.myPlayerToDo(json.map, json.x, json.y, () => {
|
|||
|
GameUtil.createWaitTip('挖寶', 1, () => {
|
|||
|
GameModel.send('c2s_use_bagitem', {
|
|||
|
roleid: Report.roleId,
|
|||
|
itemid: itemId,
|
|||
|
count: count,
|
|||
|
operateid: operateid
|
|||
|
});
|
|||
|
});
|
|||
|
});
|
|||
|
return;
|
|||
|
}
|
|||
|
let params = {
|
|||
|
roleid: Report.roleId,
|
|||
|
itemid: itemId,
|
|||
|
count: count,
|
|||
|
operateid: operateid
|
|||
|
};
|
|||
|
GameModel.send('c2s_use_bagitem', params);
|
|||
|
}
|
|||
|
|
|||
|
static useItems(target: fgui.GObject, itemList: number[], clickBlock: (data: any) => void) {
|
|||
|
if (this.useItemsAlert != null) {
|
|||
|
if (SKUIUtil.isValid(this.useItemsAlert.node)) {
|
|||
|
this.clickMask(null);
|
|||
|
} else {
|
|||
|
this.useItemsAlert = null;
|
|||
|
}
|
|||
|
}
|
|||
|
if (this.useItemsAlert == null) {
|
|||
|
this.useItemsAlert = fgui.UIPackage.createObject("main_ui", "use_items").asCom;
|
|||
|
let list = FGUtil.getList(this.useItemsAlert, "list");
|
|||
|
list.removeChildrenToPool();
|
|||
|
for (let itemId of itemList) {
|
|||
|
let item = ItemUtil.getItemData(itemId);
|
|||
|
let cell = list.addItemFromPool().asCom;
|
|||
|
cell.getChild("title").asTextField.text = item.name;
|
|||
|
cell.getChild("desc").asTextField.text = item.typedetail;
|
|||
|
let count = ItemUtil.getBagItemCount(itemId);
|
|||
|
item.count = count;
|
|||
|
let count_tf = cell.getChild("count").asTextField;
|
|||
|
count_tf.text = `${count}`;
|
|||
|
let color = ItemUtil.getUseItemColor(count);
|
|||
|
count_tf.color = color;
|
|||
|
cell.icon = `ui://main_ui/${item.icon}`;
|
|||
|
cell.data = item;
|
|||
|
}
|
|||
|
list.resizeToFit();
|
|||
|
this.useItemsAlert.height = list.height;
|
|||
|
FGUtil.align(target, this.useItemsAlert, TipAlign.TOP_RIGHT);
|
|||
|
this.mask = fgui.UIPackage.createObject("main_ui", "alpha_mask").asCom;
|
|||
|
this.mask.onClick(this.clickMask, this);
|
|||
|
this.clickUseItemBlock = clickBlock;
|
|||
|
list.on(fgui.Event.CLICK_ITEM, this.clickUseItem, this);
|
|||
|
FGUtil.root().addChild(this.mask);
|
|||
|
this.mask.makeFullScreen();
|
|||
|
FGUtil.root().addChild(this.useItemsAlert);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static clickUseItem(item: fgui.GObject, clickBlock: (data: any) => void) {
|
|||
|
let data = item.data;
|
|||
|
if (this.clickUseItemBlock) {
|
|||
|
this.clickUseItemBlock(data);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static clickMask(even: fgui.Event) {
|
|||
|
if (this.useItemsAlert) {
|
|||
|
this.mask.dispose();
|
|||
|
this.useItemsAlert.dispose();
|
|||
|
this.mask = null;
|
|||
|
this.useItemsAlert = null;
|
|||
|
this.clickUseItemBlock = null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static resetUseItemsCount() {
|
|||
|
if (this.useItemsAlert) {
|
|||
|
let list = FGUtil.getList(this.useItemsAlert, "list");
|
|||
|
for (let i = 0; i < list.numItems; i++) {
|
|||
|
let cell: fgui.GComponent = <fgui.GComponent>list.getChildAt(i);
|
|||
|
let data = cell.data;
|
|||
|
let count = ItemUtil.getBagItemCount(data.id);
|
|||
|
let count_tf = cell.getChild("count").asTextField;
|
|||
|
count_tf.text = `${count}`;
|
|||
|
let color = ItemUtil.getUseItemColor(count);
|
|||
|
count_tf.color = color;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 是否為佩飾
|
|||
|
static isBaldric(index: number): boolean {
|
|||
|
if (SKDataUtil.atRange(index, [EEquipIndex.CAPE, EEquipIndex.PENDANT, EEquipIndex.BELT, EEquipIndex.RING_LEFT, EEquipIndex.RING_RIGHT])) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
static isShowDetail(): boolean {
|
|||
|
if (this.itemData == null) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
// 顯示物品詳情
|
|||
|
static showItemDetail(itemId: any, count: number = 0) {
|
|||
|
let itemData = ItemUtil.getItemData(itemId);
|
|||
|
if (itemData == null) {
|
|||
|
SKLogger.warn(`找不到道具定義`);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (this.itemDetailAlert) {
|
|||
|
FGUtil.dispose(this.itemDetailAlert);
|
|||
|
}
|
|||
|
this.itemDetailAlert = fgui.UIPackage.createObject("main_ui", "item_detail_panel").asCom;
|
|||
|
FGUtil.root().addChild(this.itemDetailAlert);
|
|||
|
let mask = FGUtil.getComponent(this.itemDetailAlert, "mask");
|
|||
|
mask.onClick(this.closeItemDetail, this);
|
|||
|
var typearr = ['物品', '五行天書', '材料', '藥品', '經驗', '銀兩', '仙玉', '神兵', '仙器', '召喚獸', '技能書', '綁定仙玉', '元氣丹', '寶箱', `鑰匙`, `變身卡`];
|
|||
|
FGUtil.getTextField(this.itemDetailAlert, "group/alert/type").text = typearr[itemData.type];
|
|||
|
// 圖示
|
|||
|
let iconLoader = FGUtil.getLoader(this.itemDetailAlert, "group/alert/item/icon");
|
|||
|
iconLoader.url = `ui://main_ui/${itemData.icon}`;
|
|||
|
// 名稱
|
|||
|
let itemName = FGUtil.getTextField(this.itemDetailAlert, "group/alert/name_tf");
|
|||
|
itemName.text = itemData.name;
|
|||
|
// 描述
|
|||
|
let desc = FGUtil.getRichTextField(this.itemDetailAlert, "group/alert/desc_group/desc");
|
|||
|
let info = itemData.description;
|
|||
|
desc.text = `${itemData.description}\n【用途】${info.usedetail}`;
|
|||
|
// 刪除按鈕
|
|||
|
let remove_btn = FGUtil.getButton(this.itemDetailAlert, "group/alert/remove_btn");
|
|||
|
remove_btn.node["itemId"] = itemData.id;
|
|||
|
remove_btn.node["itemCount"] = count;
|
|||
|
remove_btn.node["itemName"] = itemData.name;
|
|||
|
remove_btn.onClick(this.removeItem, this);
|
|||
|
|
|||
|
// 操作按鈕部分
|
|||
|
let menuList = FGUtil.getList(this.itemDetailAlert, "group/menu/list");
|
|||
|
menuList.removeChildrenToPool();
|
|||
|
|
|||
|
let index = 0;
|
|||
|
this.menu = [];
|
|||
|
|
|||
|
// 使用
|
|||
|
this.menu.push(EItemMenu.USE);
|
|||
|
// 能否合成
|
|||
|
if (ItemUtil.canSynthesis(itemData.id))
|
|||
|
this.menu.push(EItemMenu.COMPOSE);
|
|||
|
// 能否分解
|
|||
|
if (ItemUtil.canResolve(itemData) > 0)
|
|||
|
this.menu.push(EItemMenu.RESOLVE);
|
|||
|
|
|||
|
|
|||
|
for (let type of this.menu) {
|
|||
|
let title = this.getMenu(type);
|
|||
|
if (SKDataUtil.isEmptyString(title)) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
let cell = menuList.addItemFromPool().asButton;
|
|||
|
cell.title = this.getMenu(type);
|
|||
|
var data = {
|
|||
|
type: type,
|
|||
|
itemId: itemData.id,
|
|||
|
count: count
|
|||
|
}
|
|||
|
cell.data = data;
|
|||
|
index++;
|
|||
|
}
|
|||
|
menuList.height = 50 * index + 10;
|
|||
|
menuList.on(fgui.Event.CLICK_ITEM, this.onClickItemMenu, this);
|
|||
|
}
|
|||
|
|
|||
|
// 顯示配飾詳情
|
|||
|
static showAccessDetail(data: any, isUse: boolean = false, isOpe: boolean = true) {
|
|||
|
let itemData = ItemUtil.getItemData(data.Type);
|
|||
|
if (itemData == null) {
|
|||
|
SKLogger.warn(`找不到道具定義`);
|
|||
|
return;
|
|||
|
}
|
|||
|
this.itemData = data;
|
|||
|
if (this.itemData.BaseAttr == null) {
|
|||
|
let params = {
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: data.EquipID
|
|||
|
}
|
|||
|
GameModel.send('c2s_equip_info', params);
|
|||
|
return;
|
|||
|
}
|
|||
|
var needAppraisal = data.BaseAttr == "[]";
|
|||
|
if (this.itemDetailAlert) {
|
|||
|
FGUtil.dispose(this.itemDetailAlert);
|
|||
|
}
|
|||
|
this.itemDetailAlert = fgui.UIPackage.createObject("main_ui", "access_detail_panel").asCom;
|
|||
|
FGUtil.root().addChild(this.itemDetailAlert);
|
|||
|
let mask = FGUtil.getComponent(this.itemDetailAlert, "mask");
|
|||
|
mask.onClick(this.closeItemDetail, this);
|
|||
|
let iconLoader = FGUtil.getLoader(this.itemDetailAlert, "group/alert/item/icon");
|
|||
|
iconLoader.url = `ui://main_ui/${itemData.icon}`;
|
|||
|
let itemName = FGUtil.getTextField(this.itemDetailAlert, "group/alert/name_tf");
|
|||
|
itemName.text = (needAppraisal ? "待鑑定的" : "") + itemData.name;
|
|||
|
let titleBar = FGUtil.getControl(this.itemDetailAlert, "group/alert/title_bar");
|
|||
|
if (titleBar) {
|
|||
|
titleBar.selectedIndex = needAppraisal ? 3 : data.Grade - 1;
|
|||
|
}
|
|||
|
if (!needAppraisal) {
|
|||
|
FGUtil.getControl(this.itemDetailAlert, "group/alert/grade4").selectedIndex = data.Grade >= 3 ? 1 : 0;
|
|||
|
}
|
|||
|
let desc = FGUtil.getRichTextField(this.itemDetailAlert, "group/alert/desc_group/desc");
|
|||
|
let info = needAppraisal ? "???" : itemData.description;
|
|||
|
info = this.addLine(info, needAppraisal ? '【配飾品階】? ? ? ' : `【配飾品階】${ItemUtil.getGrade(data.Grade)}`);
|
|||
|
info = this.addLine(info, ItemUtil.getIndex(data.EIndex));
|
|||
|
if (!needAppraisal) {
|
|||
|
info = this.addLine(info, ItemUtil.getUse(data));
|
|||
|
info = this.addLine(info, ItemUtil.getLevel(data));
|
|||
|
info = this.addLine(info, ItemUtil.getBase(data));
|
|||
|
info = this.addLine(info, ItemUtil.getEndure(data));
|
|||
|
info = this.addLine(info, ItemUtil.getCan(data));
|
|||
|
} else {
|
|||
|
info = this.addLine(info, "[color=#CFCE8A]待鑑定 ???[/color]");
|
|||
|
info = this.addLine(info, "[color=#CFCE8A]待鑑定 ???[/color]");
|
|||
|
info = this.addLine(info, "[color=#CFCE8A]待鑑定 ???[/color]");
|
|||
|
info = this.addLine(info, "[color=#CFCE8A]待鑑定 ???[/color]");
|
|||
|
info = this.addLine(info, "[color=#FF0000]該物品無法裝備,請先鑑定[/color]\n");
|
|||
|
}
|
|||
|
desc.text = info;
|
|||
|
let list = FGUtil.getList(this.itemDetailAlert, "group/alert/desc_group/attr");
|
|||
|
list.removeChildrenToPool();
|
|||
|
|
|||
|
let baseAttr = SKDataUtil.jsonBy(data.BaseAttr);
|
|||
|
if (baseAttr) {
|
|||
|
if (SKDataUtil.isArray(baseAttr)) {
|
|||
|
for (let item of baseAttr) {
|
|||
|
for (let key in item) {
|
|||
|
let value = SKDataUtil.toNumber(item[key]);
|
|||
|
let type = SKDataUtil.toNumber(key);
|
|||
|
let cell = list.addItemFromPool().asCom;
|
|||
|
FGUtil.getTextField(cell, "title").text = GameUtil.getAttrTypeL1Name(type);
|
|||
|
let text = ``;
|
|||
|
if (GameUtil.equipTypeNumerical.indexOf(type) == -1) {
|
|||
|
text = `${value > 0 ? "+" : ""}${SKDataUtil.toDecimal1(value / 10)}%`;
|
|||
|
} else {
|
|||
|
text = `${value > 0 ? "+" : ""}${SKDataUtil.toDecimal1(value)}`;
|
|||
|
}
|
|||
|
FGUtil.getTextField(cell, "value").text = text;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
} else {
|
|||
|
for (let key in baseAttr) {
|
|||
|
let type = SKDataUtil.toNumber(key);
|
|||
|
let cell = list.addItemFromPool().asCom;
|
|||
|
FGUtil.getTextField(cell, "title").text = GameUtil.getAttrTypeL1Name(type);
|
|||
|
let value = SKDataUtil.toNumber(baseAttr[key]);
|
|||
|
let text = ``;
|
|||
|
if (GameUtil.equipTypeNumerical.indexOf(type) == -1) {
|
|||
|
text = `${value > 0 ? "+" : ""}${SKDataUtil.toDecimal1(value / 10)}%`;
|
|||
|
} else {
|
|||
|
text = `${value > 0 ? "+" : ""}${SKDataUtil.toDecimal1(value)}`;
|
|||
|
}
|
|||
|
FGUtil.getTextField(cell, "value").text = text;
|
|||
|
}
|
|||
|
}
|
|||
|
list.resizeToFit();
|
|||
|
list.visible = true;
|
|||
|
} else {
|
|||
|
list.visible = false;
|
|||
|
}
|
|||
|
|
|||
|
this.itemDetailAlert.makeFullScreen();
|
|||
|
// 套裝技能
|
|||
|
let desc_tail = FGUtil.getRichTextField(this.itemDetailAlert, "group/alert/desc_group/desc_tail");
|
|||
|
desc_tail.text = ItemUtil.getSuitSkill(data);
|
|||
|
desc_tail.onClick(this.clickSuitSkill, this);
|
|||
|
desc_tail.visible = !needAppraisal;
|
|||
|
|
|||
|
let flag = FGUtil.getImage(this.itemDetailAlert, "group/alert/equip_flag");
|
|||
|
let remove_btn = FGUtil.getButton(this.itemDetailAlert, "group/alert/remove_btn")
|
|||
|
|
|||
|
// 是否已裝備
|
|||
|
if (this.isEquip(data)) {
|
|||
|
flag.visible = true;
|
|||
|
remove_btn.visible = false;
|
|||
|
} else {
|
|||
|
flag.visible = false;
|
|||
|
remove_btn.visible = true;
|
|||
|
}
|
|||
|
if (!isOpe) {
|
|||
|
remove_btn.visible = false;
|
|||
|
}
|
|||
|
|
|||
|
// 裝備分數
|
|||
|
FGUtil.getTextField(this.itemDetailAlert, "group/alert/score").text = needAppraisal ? "???" : data.BaseScore;
|
|||
|
remove_btn.onClick(this.removeAccess, this);
|
|||
|
FGUtil.getComponent(this.itemDetailAlert, "group/menu").visible = this.showMenu;
|
|||
|
// if (!this.showMenu) {
|
|||
|
// console.log(FGUtil.getObject(this.itemDetailAlert, "group").x)
|
|||
|
// FGUtil.getObject(this.itemDetailAlert, "group").x=75;
|
|||
|
// }
|
|||
|
let desc_belong = FGUtil.getRichTextField(this.itemDetailAlert, "group/alert/desc_group/desc_belong");
|
|||
|
if (data.name) {
|
|||
|
desc_belong.text = `擁有者:${data.name}(${data.roleid})`;
|
|||
|
desc_belong.visible = true;
|
|||
|
} else {
|
|||
|
desc_belong.visible = true;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
// 操作按鈕部分
|
|||
|
let menuList = FGUtil.getList(this.itemDetailAlert, "group/menu/list");
|
|||
|
menuList.removeChildrenToPool();
|
|||
|
|
|||
|
let index = 0;
|
|||
|
|
|||
|
if (needAppraisal) {
|
|||
|
this.menu = [
|
|||
|
// EItemMenu.APPRAISAL, EItemMenu.RESOLVE, EItemMenu.RESOLVEAll
|
|||
|
EItemMenu.APPRAISAL, EItemMenu.RESOLVE
|
|||
|
];
|
|||
|
} else {
|
|||
|
this.menu = [
|
|||
|
EItemMenu.EQUIP, EItemMenu.RECAST, EItemMenu.RESOLVE
|
|||
|
];
|
|||
|
}
|
|||
|
for (let type of this.menu) {
|
|||
|
let title = this.getMenu(type);
|
|||
|
if (SKDataUtil.isEmptyString(title)) {
|
|||
|
continue;
|
|||
|
}
|
|||
|
let cell = menuList.addItemFromPool().asButton;
|
|||
|
cell.title = this.getMenu(type);
|
|||
|
cell.data = type;
|
|||
|
index++;
|
|||
|
}
|
|||
|
menuList.height = 50 * index + 10;
|
|||
|
menuList.on(fgui.Event.CLICK_ITEM, this.onClickMenu, this);
|
|||
|
}
|
|||
|
|
|||
|
static clickSuitSkill() {
|
|||
|
let itemData: any = ItemUtil.getItemData(this.itemData.Type);
|
|||
|
if (itemData == null) {
|
|||
|
return;
|
|||
|
}
|
|||
|
let suitId = itemData.level;
|
|||
|
this.showSuitSkill(suitId);
|
|||
|
}
|
|||
|
|
|||
|
static showSuitSkill(suitId: number) {
|
|||
|
FGUtil.dispose(this.suitDetailAlert);
|
|||
|
this.suitDetailAlert = fgui.UIPackage.createObject("main_ui", "suit_skill_main").asCom;
|
|||
|
FGUtil.root().addChild(this.suitDetailAlert);
|
|||
|
let mask = FGUtil.getComponent(this.suitDetailAlert, "mask");
|
|||
|
mask.onClick(this.closeSuitDetail, this);
|
|||
|
let suitData = ItemUtil.getSuitData(suitId);
|
|||
|
FGUtil.getTextField(this.suitDetailAlert, "alert/group/name_tf").text = suitData.name;
|
|||
|
let index = 1;
|
|||
|
for (let itemId of suitData.list) {
|
|||
|
let key = `alert/group/equip_group/item_${index}`;
|
|||
|
let item = FGUtil.getButton(this.suitDetailAlert, key);
|
|||
|
let itemData = ItemUtil.getItemData(itemId);
|
|||
|
if (itemData != null) {
|
|||
|
item.icon = `ui://main_ui/${itemData.icon}`;
|
|||
|
} else {
|
|||
|
item.icon = `ui://main_ui/1000`;
|
|||
|
}
|
|||
|
item.getController("suit_grade").selectedIndex = suitData.grade;
|
|||
|
index++;
|
|||
|
}
|
|||
|
let skills = this.getSuitSkillGroup(suitData.group);
|
|||
|
let info = ``;
|
|||
|
index = 0;
|
|||
|
for (let skill of skills) {
|
|||
|
info += `${index > 0 ? `\n` : ``}[img]ui://main_ui/${skill.icon}[/img]`;
|
|||
|
info += ` [color=${this.getSuitSkillColor(skill)}]${skill.name}`;
|
|||
|
info += `${this.suitSkillId == skill.id ? `[color=#ffff00] 已激活[/color][/color]` : ` (需全套${this.getSkillGrade(skill)}以上激活)[/color]`}`;
|
|||
|
info += `\n${skill.getSuitDesc()}`;
|
|||
|
index++;
|
|||
|
}
|
|||
|
FGUtil.getRichTextField(this.suitDetailAlert, "alert/group/desc").text = info;
|
|||
|
this.suitDetailAlert.makeFullScreen();
|
|||
|
}
|
|||
|
|
|||
|
static getSkillGrade(skill: SkillBase): string {
|
|||
|
if (skill.quality == ESkillQuality.HIGH) {
|
|||
|
return "珍藏";
|
|||
|
} else if (skill.quality == ESkillQuality.FINAL) {
|
|||
|
return "無價"
|
|||
|
}
|
|||
|
return "把玩";
|
|||
|
}
|
|||
|
|
|||
|
// 獲得佩飾顏色
|
|||
|
static getBaldricColor(item: any): string {
|
|||
|
if (item.BaseAttr != "[]") {
|
|||
|
if (item.Grade == 1) {
|
|||
|
return "#60d566";
|
|||
|
} else if (item.Grade == 2) {
|
|||
|
return "#5fd5d6";
|
|||
|
} else if (item.Grade == 3) {
|
|||
|
return "#b94bd1";
|
|||
|
}
|
|||
|
}
|
|||
|
return "#ff0000";
|
|||
|
}
|
|||
|
|
|||
|
// 獲得佩飾顏色
|
|||
|
static getBaldricScore(item: any): number {
|
|||
|
if (item.BaseAttr != "[]") {
|
|||
|
if (item.Grade == 1) {
|
|||
|
return 1;
|
|||
|
} else if (item.Grade == 2) {
|
|||
|
return 2;
|
|||
|
} else if (item.Grade == 3) {
|
|||
|
return 5;
|
|||
|
}
|
|||
|
}
|
|||
|
return 1;
|
|||
|
}
|
|||
|
|
|||
|
static getSuitSkillColor(skill: SkillBase): string {
|
|||
|
if (skill.quality == ESkillQuality.LOW) {
|
|||
|
return "#60d566";
|
|||
|
} else if (skill.quality == ESkillQuality.HIGH) {
|
|||
|
return "#5fd5d6";
|
|||
|
} else if (skill.quality == ESkillQuality.FINAL) {
|
|||
|
return "#b94bd1";
|
|||
|
}
|
|||
|
return "#ff0000";
|
|||
|
}
|
|||
|
static getSuitSkillUnActiveColor(skill: SkillBase): string {
|
|||
|
if (skill.quality == ESkillQuality.LOW) {
|
|||
|
return "#39803d";
|
|||
|
} else if (skill.quality == ESkillQuality.HIGH) {
|
|||
|
return "#388080";
|
|||
|
} else if (skill.quality == ESkillQuality.FINAL) {
|
|||
|
return "#712e80";
|
|||
|
}
|
|||
|
return "#ff0000";
|
|||
|
}
|
|||
|
static getSuitData(suitId: number): any {
|
|||
|
let conf = GameModel.game_conf.baldric_suit;
|
|||
|
let data = conf[suitId];
|
|||
|
return data;
|
|||
|
}
|
|||
|
|
|||
|
static getSuitSkillGroup(group: number): SkillBase[] {
|
|||
|
let result = [];
|
|||
|
let conf = GameModel.game_conf.baldric_suit;
|
|||
|
for (let key in conf) {
|
|||
|
let data = conf[key];
|
|||
|
if (data.group == group) {
|
|||
|
let skill = SkillUtil.getSkill(data.skill);
|
|||
|
if (skill) {
|
|||
|
result.push(skill);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
// 道具分解
|
|||
|
static itemResolve(data: any) {
|
|||
|
let count = this.canResolve(data);
|
|||
|
// FGAlert.show(`確定將道具[color=#b94bd1][${data.name}][/color]分解為${count}點功績?`, () => {
|
|||
|
// FGAlert.hide();
|
|||
|
// }, () => {
|
|||
|
// FGAlert.hide();
|
|||
|
let params = {
|
|||
|
roleId: GameModel.player.roleid,
|
|||
|
itemId: data.id,
|
|||
|
count: ItemUtil.getBagItemCount(data.id)
|
|||
|
}
|
|||
|
GameModel.send("c2s_item_resolve", params);
|
|||
|
// });
|
|||
|
}
|
|||
|
|
|||
|
// 裝備分解
|
|||
|
static equipResolve(data: any) {
|
|||
|
if (data.EIndex == 6) {
|
|||
|
|
|||
|
FGAlert.show(`確定將翅膀[color=${this.getEquipColor(data)}][${data.EDesc}・${data.EName}][/color]分解為10個[img]ui://main_ui/10411[/img]翅膀精華?`, () => {
|
|||
|
FGAlert.hide();
|
|||
|
}, () => {
|
|||
|
FGAlert.hide();
|
|||
|
let params = {
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: data.EquipID,
|
|||
|
}
|
|||
|
GameModel.send("c2s_equip_resolve", params);
|
|||
|
});
|
|||
|
|
|||
|
} else {
|
|||
|
|
|||
|
|
|||
|
FGAlert.show(`確定將仙器[color=${this.getEquipColor(data)}][${data.EDesc}・${data.EName}][/color]分解為${this.getEquipResolve(data.Grade)}個[img]ui://main_ui/10406[/img]八荒遺風?`, () => {
|
|||
|
FGAlert.hide();
|
|||
|
}, () => {
|
|||
|
FGAlert.hide();
|
|||
|
let params = {
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: data.EquipID,
|
|||
|
}
|
|||
|
GameModel.send("c2s_equip_resolve", params);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static getEquipColor(data: any): string {
|
|||
|
if (data.Grade == 1) {
|
|||
|
return "#60d566";
|
|||
|
} else if (data.Grade == 2) {
|
|||
|
return "#5fd5d6";
|
|||
|
} else if (data.Grade == 3) {
|
|||
|
return "#b94bd1";
|
|||
|
}
|
|||
|
return "#ff0000";
|
|||
|
}
|
|||
|
|
|||
|
// 二階仙器分解為50個八荒,三階分解為80,四階160,五階320
|
|||
|
private static getEquipResolve(grade: number): number {
|
|||
|
if (grade == 2) {
|
|||
|
return 50;
|
|||
|
}
|
|||
|
if (grade == 3) {
|
|||
|
return 80;
|
|||
|
}
|
|||
|
if (grade == 4) {
|
|||
|
return 160;
|
|||
|
}
|
|||
|
if (grade == 5) {
|
|||
|
return 320;
|
|||
|
}
|
|||
|
return 50;
|
|||
|
}
|
|||
|
static removeItem() {
|
|||
|
let logic = GameModel.player.getMainUILogic();
|
|||
|
if (logic && logic.isBattle) {
|
|||
|
MsgAlert.addMsg('戰鬥中無法丟棄裝備');
|
|||
|
return;
|
|||
|
}
|
|||
|
if (this.itemData == null) {
|
|||
|
SKLogger.warn(`$警告:刪除裝備無效`);
|
|||
|
return;
|
|||
|
}
|
|||
|
let self = this;
|
|||
|
FGAlert.show(`是否刪除裝備?`, () => {
|
|||
|
FGAlert.hide();
|
|||
|
}, () => {
|
|||
|
let safeLock = (GameModel.player.safe_lock == 1);
|
|||
|
if (safeLock) {
|
|||
|
SafeCheckAlert.show(() => {
|
|||
|
SafeCheckAlert.hide();
|
|||
|
}, () => {
|
|||
|
if (self.itemData) {
|
|||
|
GameModel.send('c2s_equip_update', {
|
|||
|
operation: 0,
|
|||
|
roleid: Report.roleId,
|
|||
|
equipid: self.itemData.EquipID
|
|||
|
});
|
|||
|
SafeCheckAlert.hide();
|
|||
|
FGAlert.hide();
|
|||
|
self.closeItemDetail();
|
|||
|
}
|
|||
|
})
|
|||
|
return;
|
|||
|
}
|
|||
|
GameModel.send('c2s_equip_update', {
|
|||
|
operation: 0,
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: self.itemData.EquipID
|
|||
|
});
|
|||
|
FGAlert.hide();
|
|||
|
self.closeItemDetail();
|
|||
|
});
|
|||
|
}
|
|||
|
static removeAccess() {
|
|||
|
let logic = GameModel.player.getMainUILogic();
|
|||
|
if (logic && logic.isBattle) {
|
|||
|
MsgAlert.addMsg('戰鬥中無法丟棄裝備');
|
|||
|
return;
|
|||
|
}
|
|||
|
if (this.itemData == null) {
|
|||
|
SKLogger.warn(`$警告:刪除裝備無效`);
|
|||
|
return;
|
|||
|
}
|
|||
|
let self = this;
|
|||
|
FGAlert.show(`是否刪除裝備?`, () => {
|
|||
|
FGAlert.hide();
|
|||
|
}, () => {
|
|||
|
let safeLock = (GameModel.player.safe_lock == 1);
|
|||
|
if (safeLock) {
|
|||
|
SafeCheckAlert.show(() => {
|
|||
|
SafeCheckAlert.hide();
|
|||
|
}, () => {
|
|||
|
if (self.itemData) {
|
|||
|
GameModel.send('c2s_equip_update', {
|
|||
|
operation: 0,
|
|||
|
roleid: Report.roleId,
|
|||
|
equipid: self.itemData.EquipID
|
|||
|
});
|
|||
|
SafeCheckAlert.hide();
|
|||
|
FGAlert.hide();
|
|||
|
self.closeItemDetail();
|
|||
|
}
|
|||
|
})
|
|||
|
return;
|
|||
|
}
|
|||
|
GameModel.send('c2s_equip_update', {
|
|||
|
operation: 0,
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: self.itemData.EquipID
|
|||
|
});
|
|||
|
FGAlert.hide();
|
|||
|
self.closeItemDetail();
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
static getMenu(type: EItemMenu): string {
|
|||
|
if (type == EItemMenu.EQUIP) {
|
|||
|
if (this.isEquip(this.itemData)) {
|
|||
|
return "卸下";
|
|||
|
} else {
|
|||
|
return "裝備";
|
|||
|
}
|
|||
|
} else if (type == EItemMenu.RECAST) {
|
|||
|
return "重鑄"
|
|||
|
} else if (type == EItemMenu.RESOLVE) {
|
|||
|
if (this.isEquip(this.itemData)) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
return "分解"
|
|||
|
} else if (type == EItemMenu.RESOLVEAll) {
|
|||
|
if (this.isEquip(this.itemData)) {
|
|||
|
return "";
|
|||
|
}
|
|||
|
return "一鍵分解"
|
|||
|
} else if (type == EItemMenu.APPRAISAL) {
|
|||
|
return "鑑定";
|
|||
|
} else if (type == EItemMenu.COMPOSE) {
|
|||
|
return "合成";
|
|||
|
}
|
|||
|
return "使用";
|
|||
|
}
|
|||
|
|
|||
|
static onClickItemMenu(item: fgui.GObject) {
|
|||
|
/*
|
|||
|
let type: EItemMenu = item.data.type;
|
|||
|
var itemId = item.data.itemId
|
|||
|
if (type == EItemMenu.USE) {
|
|||
|
let canuse = true;
|
|||
|
if (ItemUtil.isPetUse(itemId)) { // 親密丹,靈獸丹,聖獸丹,神獸丹,凝魂丹,龍之骨,金柳露
|
|||
|
let petpanel = cc.instantiate(this.PetsPanel);
|
|||
|
petpanel.name = 'PetPanel';
|
|||
|
petpanel.parent = cc.find('Canvas/MainUI');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId == 10401) {//悔夢石
|
|||
|
let workshop = cc.instantiate(this.WorkShopPanel);
|
|||
|
workshop.parent = cc.find('Canvas');
|
|||
|
workshop.getComponent('WorkShopPanel').setCurPanel(4);
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
|
|||
|
else if (itemId == 10201) {//回夢丹
|
|||
|
PubFunction.CreateSubNode(cc.find('Canvas/MainUI'), { nX: 0, nY: 0 }, this.RestoryUI, 'RestoryUI');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId >= 10402 && itemId <= 10404) {
|
|||
|
let workshop = cc.instantiate(this.WorkShopPanel);
|
|||
|
workshop.parent = cc.find('Canvas');
|
|||
|
workshop.getComponent('WorkShopPanel').setCurPanel(2);
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId == 10405) {//盤古精鐵
|
|||
|
let workshop = cc.instantiate(this.WorkShopPanel);
|
|||
|
workshop.parent = cc.find('Canvas');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId == 10406) {//八荒遺風
|
|||
|
let xianqi = cc.instantiate(this.XianQiUpPanel);
|
|||
|
xianqi.parent = cc.find('Canvas');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId == 10408) {//神兵碎片
|
|||
|
let shenbing = cc.instantiate(this.ShenBingCombinePanel);
|
|||
|
shenbing.parent = cc.find('Canvas');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId >= 20001 && itemId <= 20015) {//五行材料,合成召喚獸
|
|||
|
let hecheng = cc.instantiate(this.PetHeChengPanel);
|
|||
|
hecheng.parent = cc.find('Canvas');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId == 10202 || itemId == 10204) {//夥伴修煉冊
|
|||
|
PubFunction.CreateSubNode(cc.find('Canvas/MainUI'), { nX: 0, nY: 0 }, this.PartnerUI, 'PartnerUI');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId == 10205) { // 世界鈴鐺廣播
|
|||
|
let myLevel = GameModel.player.level;
|
|||
|
let itemLevel = this.iteminfo.level;
|
|||
|
if (myLevel < itemLevel) {
|
|||
|
MsgAlert.addMsg(`${this.iteminfo.name}需要${this.iteminfo.level}級才能使用`);
|
|||
|
return;
|
|||
|
}
|
|||
|
let notice_edit_node = cc.instantiate(this.NoticeEditUI);
|
|||
|
notice_edit_node.parent = cc.find('Canvas');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
else if (itemId >= 10501 && itemId <= 10583) { //元氣丹
|
|||
|
let petpanel = cc.instantiate(this.PetsPanel);
|
|||
|
petpanel.name = 'PetPanel';
|
|||
|
petpanel.parent = cc.find('Canvas/MainUI');
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
// 使用坐骑修炼丹,则打开坐骑面板,关闭背包
|
|||
|
else if (SKDataUtil.atRange(itemId, [10605, 10606, 10607, 10608])) {
|
|||
|
HorsePanel.shared.show();
|
|||
|
canuse = false;
|
|||
|
}
|
|||
|
// 使用变身卡
|
|||
|
else if (ItemUtil.isComposeTransformation(itemId)) {
|
|||
|
Transformation.Instance.openComposePanel(ItemUtil.getBagItemCount(itemId), itemId)
|
|||
|
return;
|
|||
|
}
|
|||
|
if (!canuse) {
|
|||
|
let bagLayer = cc.find('Canvas/MainUI/BagPanel');
|
|||
|
if (bagLayer != null) {
|
|||
|
bagLayer.destroy();
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
ItemUtil.useItem(itemId);
|
|||
|
}
|
|||
|
*/
|
|||
|
}
|
|||
|
static isComposeTransformation(id) {
|
|||
|
if (SKDataUtil.atRange(id, [100311, 100313, 100315, 100317])) {
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
static onClickMenu(item: fgui.GObject) {
|
|||
|
let type: EItemMenu = item.data;
|
|||
|
if (type == EItemMenu.EQUIP) {
|
|||
|
if (this.isEquip(this.itemData)) {
|
|||
|
this.unload();
|
|||
|
} else {
|
|||
|
this.equip();
|
|||
|
}
|
|||
|
} else if (type == EItemMenu.RECAST) {
|
|||
|
let itemData = ItemUtil.itemData;
|
|||
|
this.closeItemDetail();
|
|||
|
RecastPanel.shared.show(itemData);
|
|||
|
} else if (type == EItemMenu.RESOLVE) {
|
|||
|
let itemData = ItemUtil.itemData;
|
|||
|
this.closeItemDetail();
|
|||
|
let characters = "待鑑定的";
|
|||
|
if (itemData.BaseAttr != "[]") {
|
|||
|
characters = "";
|
|||
|
}
|
|||
|
// FGAlert.show(`確定將${characters}佩飾[color=${this.getBaldricColor(itemData)}][${itemData.EName}][/color]分解為${this.getBaldricScore(itemData)}點功績?`, () => {
|
|||
|
// FGAlert.hide();
|
|||
|
// }, () => {
|
|||
|
// FGAlert.hide();
|
|||
|
let params = {
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: itemData.EquipID,
|
|||
|
}
|
|||
|
GameModel.send("c2s_baldric_resolve", params);
|
|||
|
// });
|
|||
|
} else if (type == EItemMenu.RESOLVEAll) {
|
|||
|
// this.closeItemDetail();
|
|||
|
// FGAlert.show(`確定將背包內所有佩飾分解為功績?`, () => {
|
|||
|
// FGAlert.hide();
|
|||
|
// }, () => {
|
|||
|
// FGAlert.hide();
|
|||
|
let params = {
|
|||
|
roleid: GameModel.player.roleid
|
|||
|
}
|
|||
|
GameModel.send("c2s_batch_resolve", params);
|
|||
|
// });
|
|||
|
} else if (type == EItemMenu.APPRAISAL) {
|
|||
|
this.onAppraisalClick()
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 鑑定
|
|||
|
static onAppraisalClick() {
|
|||
|
Bag.Instance.closeBagPanel();
|
|||
|
let url = `Prefabs/Accessory/accessory_main_third`;
|
|||
|
cc.loader.loadRes(url, cc.Prefab, (error, prefab) => {
|
|||
|
if (error) {
|
|||
|
SKLogger.warn(`$警告:加載資源${url}錯誤!`);
|
|||
|
return;
|
|||
|
}
|
|||
|
PopupManager.showView(prefab, 0, (node) => {
|
|||
|
var jsScript = node.getComponent("Appraisal");
|
|||
|
jsScript && jsScript.initPanel(this.itemData)
|
|||
|
this.closeItemDetail();
|
|||
|
});
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
// 裝備
|
|||
|
static equip() {
|
|||
|
GameModel.send('c2s_equip_update', {
|
|||
|
operation: 1,
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: this.itemData.EquipID
|
|||
|
});
|
|||
|
this.closeItemDetail();
|
|||
|
}
|
|||
|
|
|||
|
// 卸下
|
|||
|
static unload() {
|
|||
|
GameModel.send('c2s_equip_update', {
|
|||
|
operation: 2,
|
|||
|
roleid: GameModel.player.roleid,
|
|||
|
equipid: this.itemData.EquipID
|
|||
|
});
|
|||
|
this.closeItemDetail();
|
|||
|
}
|
|||
|
|
|||
|
// 是否裝備
|
|||
|
static isEquip(data: any): boolean {
|
|||
|
if (data.EquipID == null) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
let equipId = GameModel.equipData.use[data.EIndex];
|
|||
|
if (equipId == null) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (equipId != data.EquipID) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
static getSuitSkill(data: any): string {
|
|||
|
// if (data.LianhuaAttr) {
|
|||
|
// let lianhuaInfo = SKDataUtil.jsonBy(info.LianhuaAttr);
|
|||
|
// if (Array.isArray(lianhuaInfo)) {
|
|||
|
// for (const info of lianhuaInfo) {
|
|||
|
// for (const key in info) {
|
|||
|
// this.addInfoLab(GameUtil.getAttrTypeL1Name(key), this.infoPos, false, new cc.color(46, 143, 9));
|
|||
|
// let valuestr = info[key];
|
|||
|
// if (GameUtil.equipTypeNumerical.indexOf(Number(key)) == -1) {
|
|||
|
// valuestr = (valuestr > 0 ? '+' : '') + (valuestr / 10).toFixed(1) + '%';
|
|||
|
// }
|
|||
|
// else {
|
|||
|
// valuestr = (valuestr > 0 ? '+' : '') + valuestr;
|
|||
|
// }
|
|||
|
// this.addInfoLab(valuestr, SKUIUtil.add(this.infoPos, cc.v2(120, 0)), true, new cc.color(46, 143, 9));
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
let itemData = ItemUtil.getItemData(data.Type);
|
|||
|
if (itemData) {
|
|||
|
let suitData = ItemUtil.getBaldricSuit(itemData.level);
|
|||
|
let suitSkill = ItemUtil.getBaldricSuitSkill();
|
|||
|
// if (!suitSkill)
|
|||
|
// suitSkill = { id: -1 };
|
|||
|
let suitSkillId = suitSkill ? suitSkill.id : -1;
|
|||
|
let skills = this.getSuitSkillGroup(suitData.group);
|
|||
|
let suitInfo = `【套裝技能】`;
|
|||
|
let index = 0;
|
|||
|
for (let skill of skills) {
|
|||
|
if (index >= data.Grade) break;
|
|||
|
if (suitSkillId == skill.id) { //啟用設定
|
|||
|
suitInfo += `\n[img]ui://main_ui/${skill.icon}[/img] `;
|
|||
|
suitInfo += `[color=${this.getSuitSkillColor(skill)}]${skill.name}[/color]`;
|
|||
|
} else { //未激活
|
|||
|
suitInfo += `\n[img]ui://main_ui/${skill.icon}[/img] `;
|
|||
|
suitInfo += `[color=${this.getSuitSkillUnActiveColor(skill)}]${skill.name}(未激活)[/color]`;
|
|||
|
}
|
|||
|
index++;
|
|||
|
}
|
|||
|
return suitInfo;
|
|||
|
}
|
|||
|
return ``;
|
|||
|
}
|
|||
|
|
|||
|
// 獲得佩飾套裝技能
|
|||
|
static getBaldricSuitSkill(): SkillBase {
|
|||
|
let suitId: number = -1;
|
|||
|
let suitShot: string = "";
|
|||
|
let suitCount: number = 0;
|
|||
|
let equipData: any = GameModel.equipData;
|
|||
|
for (let key in equipData.use) {
|
|||
|
let equipId = equipData.use[key];
|
|||
|
let equip = equipData.info[equipId];
|
|||
|
if (ItemUtil.isBaldric(equip.EIndex)) {
|
|||
|
let itemData = ItemUtil.getItemData(equip.Type);
|
|||
|
if (itemData) {
|
|||
|
if (suitShot == "") {
|
|||
|
suitShot = itemData.detailshot;
|
|||
|
suitId = itemData.level;
|
|||
|
suitCount++;
|
|||
|
} else if (suitShot == itemData.detailshot) {
|
|||
|
suitId = Math.min(suitId, itemData.level);
|
|||
|
suitCount++;
|
|||
|
} else {
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (suitCount >= 5) {
|
|||
|
let suitData = ItemUtil.getBaldricSuit(suitId);
|
|||
|
if (suitData) {
|
|||
|
let skill = SkillUtil.getSkill(suitData.skill);
|
|||
|
this.suitId = suitId;
|
|||
|
this.suitSkillId = skill.id;
|
|||
|
return skill;
|
|||
|
}
|
|||
|
}
|
|||
|
this.suitId = 0;
|
|||
|
this.suitSkillId = ESkillType.NONE;
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
static addLine(value: string, line: string): string {
|
|||
|
if (line.length > 0) {
|
|||
|
value += `\n${line}`;
|
|||
|
}
|
|||
|
return value;
|
|||
|
}
|
|||
|
|
|||
|
static getGrade(grade: number): string {
|
|||
|
let result = ``;
|
|||
|
if (grade == 2) {
|
|||
|
result += "珍藏";
|
|||
|
} else if (grade == 3) {
|
|||
|
result += "無價";
|
|||
|
} else {
|
|||
|
result += "把玩";
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
static getIndex(index: number): string {
|
|||
|
if (index == EEquipIndex.CAPE) {
|
|||
|
return "【配飾部位】披風";
|
|||
|
}
|
|||
|
if (index == EEquipIndex.PENDANT) {
|
|||
|
return "【配飾部位】挂件";
|
|||
|
}
|
|||
|
if (index == EEquipIndex.BELT) {
|
|||
|
return "【配飾部位】腰帶";
|
|||
|
}
|
|||
|
if (index == EEquipIndex.RING_LEFT) {
|
|||
|
return "【配飾部位】戒指・左";
|
|||
|
}
|
|||
|
if (index == EEquipIndex.RING_RIGHT) {
|
|||
|
return "【配飾部位】戒指・右";
|
|||
|
}
|
|||
|
return "【配飾部位】未知";
|
|||
|
}
|
|||
|
|
|||
|
// 適用
|
|||
|
static getUse(data: any): string {
|
|||
|
let result = `【配飾適用】`;
|
|||
|
if (data.Sex == 9 && data.Race == 9) {
|
|||
|
return `${result}通用`;
|
|||
|
}
|
|||
|
if (data.OwnerRoleId && data.OwnerRoleId > 0) {
|
|||
|
if (data.OwnerRoleId != GameModel.player.resid) {
|
|||
|
result += `[color=#FF0000]${GameUtil.roleName[data.OwnerRoleId]}[/color]`;
|
|||
|
return result;
|
|||
|
} else {
|
|||
|
result += `${GameUtil.roleName[data.OwnerRoleId]}`;
|
|||
|
return result;
|
|||
|
}
|
|||
|
} else {
|
|||
|
// 非種族數組
|
|||
|
if (!Array.isArray(data.Race)) {
|
|||
|
if (data.Race != GameModel.player.race) {
|
|||
|
if (data.Sex == 9) {
|
|||
|
result += `[color=#FF0000]${this.raceName[data.Race - 1]}[/color]`;
|
|||
|
} else {
|
|||
|
result += `[color=#FF0000]${this.sexName[data.Sex - 1]}${this.raceName[data.Race - 1]}[/color]`;
|
|||
|
}
|
|||
|
return result;
|
|||
|
} else {
|
|||
|
if (data.Sex == 9) {
|
|||
|
result += `${this.raceName[data.Race - 1]}`;
|
|||
|
} else {
|
|||
|
result += `${this.sexName[data.Sex - 1]}${this.raceName[data.Race - 1]}`;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
} else {
|
|||
|
var str = "";
|
|||
|
var canUse = false;
|
|||
|
for (let i = 0; i < data.Race.length; i++) {
|
|||
|
str += this.getUseRace(data.Race[i], data.Sex);
|
|||
|
if (data.Race[i] == GameModel.player.race)
|
|||
|
canUse = true
|
|||
|
if (i + 1 != data.Race.length)
|
|||
|
str += "、"
|
|||
|
}
|
|||
|
if (!canUse)
|
|||
|
str = `[color=#FF0000]${str}[/color]`
|
|||
|
return result + str;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
static getUseRace(race, sex) {
|
|||
|
if (sex == 9) {
|
|||
|
return this.raceName[race - 1]
|
|||
|
} else {
|
|||
|
return this.sexName[sex - 1] + this.raceName[race - 1]
|
|||
|
}
|
|||
|
}
|
|||
|
static getLevel(data: any): string {
|
|||
|
let result = `【等級需求】`;
|
|||
|
if (data.NeedGrade) {
|
|||
|
if (data.NeedRei) {
|
|||
|
if (data.NeedRei < 4) {
|
|||
|
result += `${data.NeedRei}轉`;
|
|||
|
} else {
|
|||
|
result += `飛升`;
|
|||
|
}
|
|||
|
}
|
|||
|
result += `${data.NeedGrade}級`;
|
|||
|
if (data.NeedGrade > GameModel.player.level || data.NeedRei > GameModel.player.relive) {
|
|||
|
return `[color=#FF0000]${result}[/color]`;
|
|||
|
} else {
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static getBase(data: any): string {
|
|||
|
let attr1 = GameModel.player.gameData.attr1;
|
|||
|
let result = ``;
|
|||
|
if (data.Shuxingxuqiu && data.Shuxingxuqiu.length > 0) {
|
|||
|
let xuqiuInfo = SKDataUtil.jsonBy(data.Shuxingxuqiu);
|
|||
|
for (let key in xuqiuInfo) {
|
|||
|
let type = SKDataUtil.toNumber(key);
|
|||
|
let item = `【${GameUtil.getAttrTypeL2Name(type)}要求】${xuqiuInfo[type]}\n`;
|
|||
|
if (attr1[key] < xuqiuInfo[key]) {
|
|||
|
result += `[color=#FF0000]${item}[/color]`;
|
|||
|
} else {
|
|||
|
result += `${item}`;
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
static getEndure(data: any): string {
|
|||
|
let result = `【配飾耐久】${data.MaxEndure}/${data.MaxEndure}`;
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
static getCan(data: any): string {
|
|||
|
if (data.EIndex == 7) {
|
|||
|
return `[color=#73f875]可重鑄[/color]`
|
|||
|
}
|
|||
|
return ``;
|
|||
|
}
|
|||
|
|
|||
|
static closeItemDetail() {
|
|||
|
if (this.itemDetailAlert == null) {
|
|||
|
return;
|
|||
|
}
|
|||
|
this.itemDetailAlert.dispose();
|
|||
|
this.itemDetailAlert = null;
|
|||
|
this.itemData = null;
|
|||
|
}
|
|||
|
|
|||
|
static closeSuitDetail() {
|
|||
|
if (this.suitDetailAlert == null) {
|
|||
|
return;
|
|||
|
}
|
|||
|
this.suitDetailAlert.dispose();
|
|||
|
this.suitDetailAlert = null;
|
|||
|
}
|
|||
|
|
|||
|
static getBaldricSuit(suitId: number): any {
|
|||
|
let conf = GameModel.game_conf.baldric_suit;
|
|||
|
let data = SKDataUtil.valueForKey(conf, suitId);
|
|||
|
return data;
|
|||
|
}
|
|||
|
|
|||
|
// 顯示道具數據
|
|||
|
static showItem(itemBtn: fgui.GButton, itemData: any, hasEffect: boolean = false) {
|
|||
|
if (itemBtn == null || itemData == null) {
|
|||
|
return;
|
|||
|
}
|
|||
|
;
|
|||
|
itemBtn.data = itemData;
|
|||
|
itemBtn.icon = `ui://main_ui/${itemData.icon}`;
|
|||
|
let tip = FGUtil.getTextField(itemBtn, "tip");
|
|||
|
tip.text = `${SKDataUtil.transform(itemData.count)}`;
|
|||
|
tip.visible = true;
|
|||
|
let dugBG = FGUtil.getImage(itemBtn, "dug_bg");
|
|||
|
dugBG.visible = false;
|
|||
|
let effect = FGUtil.getAnim(itemBtn, "effect");
|
|||
|
effect.visible = hasEffect;
|
|||
|
effect.playing = hasEffect;
|
|||
|
}
|
|||
|
|
|||
|
// 清除道具顯示
|
|||
|
static clearItemBtn(itemBtn: fgui.GButton) {
|
|||
|
if (itemBtn == null) {
|
|||
|
return;
|
|||
|
}
|
|||
|
itemBtn.data = null;
|
|||
|
itemBtn.icon = "";
|
|||
|
let tip = FGUtil.getTextField(itemBtn, "tip");
|
|||
|
tip.text = "";
|
|||
|
tip.visible = false;
|
|||
|
let dugBG = FGUtil.getImage(itemBtn, "dug_bg");
|
|||
|
dugBG.visible = false;
|
|||
|
let effect = FGUtil.getAnim(itemBtn, "effect");
|
|||
|
effect.visible = false;
|
|||
|
effect.playing = false;
|
|||
|
}
|
|||
|
|
|||
|
static getItemCountByType(type) {
|
|||
|
var conf = GameModel.game_conf.item
|
|||
|
var count = 0
|
|||
|
for (let itemId in conf) {
|
|||
|
var item = this.getItemData(itemId)
|
|||
|
if (!!item && type == item.type) {
|
|||
|
count = count + 1
|
|||
|
}
|
|||
|
}
|
|||
|
return count
|
|||
|
}
|
|||
|
|
|||
|
static getItemsByType(type) {
|
|||
|
var conf = GameModel.game_conf.item
|
|||
|
var list = []
|
|||
|
for (let itemId in conf) {
|
|||
|
var item = this.getItemData(itemId)
|
|||
|
if (!!item && type == item.type) {
|
|||
|
list.push(item)
|
|||
|
}
|
|||
|
}
|
|||
|
return list
|
|||
|
}
|
|||
|
}
|