669 lines
21 KiB
TypeScript
669 lines
21 KiB
TypeScript
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
|
|
import FGUtil from "../gear_2.3.4/fgui/FGUtil";
|
|
import Bag from "../bag/Bag";
|
|
import GameModel from "../core/GameModel";
|
|
import SKDataUtil from "../gear_2.3.4/util/SKDataUtil";
|
|
import ItemUtil from "../core/ItemUtil";
|
|
import MsgAlert from "../game/msg/MsgAlert";
|
|
import { borderInfo, HeadBorderUtil } from "./HeadBorderUtil";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
var BodyEffList = [505016, 505201, 505202, 505301, 505302, 505303, 505304, 505401, 505403, 505404, 505405, 505406, 505407, 505408, 505409, 505410, 505411, 505412, 505413, 505414, 505415, 505416, 505417, 505418, 505419, 505421, 505423, 505432, 505433, 505434, 505435, 505436, 505437, 505451, 505452, 505453, 505454, 505455, 505456, 505457, 505458, 505459, 505460, 505461, 505462, 505463, 505490, 505501, 505601, 505602, 509201, 509301, 509302, 509303];
|
|
var FootEffList = [505105, 505106, 505107, 505108, 505109, 505110, 505111, 505112, 505113, 505114];
|
|
var HeadBorderList = [555101, 555102, 555103, 555104, 555105, 555106, 555107, 555108, 555109, 555110];
|
|
@ccclass
|
|
export default class Appearance extends cc.Component {
|
|
/**
|
|
* 外觀單例實例
|
|
*/
|
|
public static Instance : Appearance = null;
|
|
|
|
/**
|
|
* 外觀面板
|
|
*/
|
|
appearancePanel : fgui.GComponent = null;
|
|
|
|
haveEffList : any = [];
|
|
haveHeadList : any = [];
|
|
useBodyEffID : number = 0;
|
|
useFootEffID : number = 0;
|
|
useHeadBorderID : number = 0;
|
|
effListData : any = [];
|
|
headListData : any = [];
|
|
selecedEffId : number = -1;
|
|
selecedHeadId : number = -1;
|
|
longTouchTimes : 0;
|
|
roleNode : cc.Node = null;
|
|
prefabObject : any = {};
|
|
|
|
onLoad() {
|
|
if (Appearance.Instance === null) {
|
|
Appearance.Instance = this;
|
|
this.loadPrefab();
|
|
} else {
|
|
this.destroy();
|
|
return;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 加載預製體
|
|
*/
|
|
loadPrefab() {
|
|
// 加載所需的預製體
|
|
var prefabList = [
|
|
{ url: "Prefabs/temp/EffRole", name: "EffRole" },
|
|
]
|
|
this.prefabObject = {}
|
|
for (let item of prefabList) {
|
|
cc.loader.loadRes(item.url, cc.Prefab, (err, prefab) => {
|
|
if (err)
|
|
console.warn(err);
|
|
else {
|
|
this.prefabObject[item.name] = prefab;
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
openAppearancePanel() {
|
|
if (!SKUIUtil.isFGUIValid(this.appearancePanel)) {
|
|
this.appearancePanel = FGUtil.create("main_ui", "eff_panel");
|
|
FGUtil.root().addChild(this.appearancePanel);
|
|
this.appearancePanel.makeFullScreen();
|
|
}
|
|
|
|
this.useBodyEffID = 0;
|
|
this.useFootEffID = 0;
|
|
this.effListData = [];
|
|
this.selecedEffId = -1;
|
|
this.longTouchTimes = 0;
|
|
this.roleNode = null;
|
|
|
|
// 註冊關閉事件
|
|
var mask = FGUtil.getComponent(this.appearancePanel, "mask");
|
|
var close = FGUtil.getButton(this.appearancePanel, "alert/close");
|
|
this.pushCloseEvent(mask, this.appearancePanel, () => { this.roleNode.getComponent("EffRole").onClose(); Bag.Instance.showBagPanel() });
|
|
this.pushCloseEvent(close, this.appearancePanel, () => { this.roleNode.getComponent("EffRole").onClose(); Bag.Instance.showBagPanel() })
|
|
|
|
FGUtil.getButton(this.appearancePanel, "alert/n45").onClick(this.toHeadPage, this);
|
|
FGUtil.getButton(this.appearancePanel, "alert/n46").onClick(this.toEffPage, this);
|
|
this.toEffPage();
|
|
}
|
|
|
|
toEffPage() {
|
|
if (!SKUIUtil.isFGUIValid(this.appearancePanel)) return;
|
|
FGUtil.getControl(this.appearancePanel, "alert/page").selectedIndex = 1;
|
|
|
|
var effCom = FGUtil.getComponent(this.appearancePanel, "alert/eff_com");
|
|
// 顯示隨身特效
|
|
FGUtil.getButton(effCom, "changeBody").onClick(this.showBodyEffList, this);
|
|
// 顯示足跡特效
|
|
FGUtil.getButton(effCom, "changeFoot").onClick(this.showFootEffList, this);
|
|
// 圖鑑和已擁有切換
|
|
FGUtil.getButton(effCom, "library").onClick(this.switchLibrary, this);
|
|
// 類別切換
|
|
FGUtil.getButton(effCom, "sort_btn").onClick(this.tipNoFunc, this);
|
|
// 還原顯示
|
|
FGUtil.getButton(effCom, "reset").onClick(this.resetEff, this);
|
|
// 使用中的隨身特效
|
|
FGUtil.getComponent(effCom, "body_use").onClick(this.removeBodyEff, this);
|
|
// 使用中的足跡特效
|
|
FGUtil.getComponent(effCom, "foot_use").onClick(this.removeFootEff, this);
|
|
// 錦繡值
|
|
FGUtil.getButton(effCom, "jxz").onClick(this.tipNoFunc, this);
|
|
FGUtil.getTextField(effCom, "jxz/title").text = "錦繡值:未獲取";
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 0
|
|
// 特效列表
|
|
var effList = FGUtil.getList(effCom, "list");
|
|
effList.itemRenderer = this.initEffItem.bind(this);
|
|
effList.setVirtual();
|
|
|
|
this.showBodyEffList();
|
|
|
|
this.addUIRole();
|
|
|
|
GameModel.send("c2s_has_seffect", {
|
|
roleid: GameModel.player.roleid
|
|
})
|
|
}
|
|
|
|
toHeadPage() {
|
|
// MsgAlert.addMsg("即將開放");
|
|
if (!SKUIUtil.isFGUIValid(this.appearancePanel)) return;
|
|
FGUtil.getControl(this.appearancePanel, "alert/page").selectedIndex = 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/n44/isLibrary").selectedIndex = 0;
|
|
var effCom = FGUtil.getComponent(this.appearancePanel, "alert/n44");
|
|
|
|
FGUtil.getLoader(effCom, "head").texture = GameModel.getRoleHead(GameModel.player.resid);
|
|
|
|
// 圖鑑和已擁有切換
|
|
FGUtil.getButton(effCom, "library").onClick(this.switchLibraryHead, this);
|
|
|
|
this.changeHeadBorder();
|
|
|
|
// 頭像框列表
|
|
var effList = FGUtil.getList(effCom, "list");
|
|
effList.itemRenderer = this.initHeadItem.bind(this);
|
|
effList.setVirtual();
|
|
|
|
this.showHeadBorderList();
|
|
}
|
|
|
|
/**
|
|
* 添加人物UI
|
|
*/
|
|
addUIRole() {
|
|
var roleNode = cc.instantiate(this.prefabObject["EffRole"]);
|
|
roleNode.parent = FGUtil.getComponent(this.appearancePanel, "alert/eff_com/role").node;
|
|
roleNode.setPosition(0, 0);
|
|
roleNode.getComponent("EffRole").setInfo(GameModel.player);
|
|
this.roleNode = roleNode;
|
|
}
|
|
|
|
/**
|
|
* 刷新特效顯示
|
|
*/
|
|
refreshList() {
|
|
for (let i in this.haveEffList) {
|
|
if (this.haveEffList[i].usestate == 1) {
|
|
var itemData = ItemUtil.getItemData(this.haveEffList[i].effectid);
|
|
if (itemData.description == "足跡") {
|
|
this.useFootEffID = itemData.id;
|
|
GameModel.player.footEeffectId = itemData.id;
|
|
}
|
|
else if (itemData.description == "隨身特效") {
|
|
this.useBodyEffID = itemData.id;
|
|
GameModel.player.bodyEffectId = itemData.id;
|
|
}
|
|
else if (itemData.description == "頭像框") {
|
|
this.useHeadBorderID = itemData.id;
|
|
GameModel.player.headBorder = itemData.id;
|
|
this.refreshHeadList();
|
|
return
|
|
}
|
|
}
|
|
}
|
|
GameModel.player.changeEff();
|
|
if (!SKUIUtil.isFGUIValid(this.appearancePanel)) return;
|
|
this.changeBodyEff();
|
|
this.changeFootEff();
|
|
// FGUtil.getLoader(this.appearancePanel, "alert/eff_com/body_use/icon").url = `ui://main_ui/${this.useBodyEffID}`;
|
|
// FGUtil.getLoader(this.appearancePanel, "alert/eff_com/foot_use/icon").url = `ui://main_ui/${this.useFootEffID}`;
|
|
FGUtil.getList(this.appearancePanel, "alert/eff_com/list").refreshVirtualList();
|
|
}
|
|
|
|
/**
|
|
* 刷新頭像框顯示
|
|
*/
|
|
refreshHeadList() {
|
|
if (!SKUIUtil.isFGUIValid(this.appearancePanel)) return;
|
|
|
|
this.changeHeadBorder();
|
|
|
|
FGUtil.getList(this.appearancePanel, "alert/n44/list").refreshVirtualList();
|
|
}
|
|
|
|
/**
|
|
* 顯示隨身特效列表
|
|
*/
|
|
showBodyEffList(list : any = [], change : boolean = false) {
|
|
if (change) {
|
|
this.effListData = list;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/noEff").selectedIndex = list.length == 0 ? 1 : 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 1;
|
|
}
|
|
else {
|
|
this.effListData = BodyEffList;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/noEff").selectedIndex = 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 0;
|
|
}
|
|
FGUtil.getList(this.appearancePanel, "alert/eff_com/list").numItems = this.effListData.length;
|
|
}
|
|
|
|
/**
|
|
* 顯示足跡特效列表
|
|
*/
|
|
showFootEffList(list : any = [], change : boolean = false) {
|
|
if (change) {
|
|
this.effListData = list;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/noEff").selectedIndex = list.length == 0 ? 1 : 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 1;
|
|
}
|
|
else {
|
|
this.effListData = FootEffList;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/noEff").selectedIndex = 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 0;
|
|
}
|
|
FGUtil.getList(this.appearancePanel, "alert/eff_com/list").numItems = this.effListData.length;
|
|
}
|
|
|
|
/**
|
|
* 顯示頭像框列表
|
|
*/
|
|
showHeadBorderList(list : any = [], change : boolean = false) {
|
|
if (change) {
|
|
this.headListData = list;
|
|
FGUtil.getControl(this.appearancePanel, "alert/n44/noEff").selectedIndex = list.length == 0 ? 1 : 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 1;
|
|
}
|
|
else {
|
|
this.headListData = HeadBorderList;
|
|
FGUtil.getControl(this.appearancePanel, "alert/n44/noEff").selectedIndex = 0;
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex = 0;
|
|
}
|
|
FGUtil.getList(this.appearancePanel, "alert/n44/list").numItems = this.headListData.length;
|
|
}
|
|
|
|
/**
|
|
* 切換圖鑑和已擁有
|
|
*/
|
|
switchLibrary() {
|
|
var type = FGUtil.getControl(this.appearancePanel, "alert/eff_com/page").selectedIndex;
|
|
var libraryCtr = FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary")
|
|
var isLibrary = libraryCtr.selectedIndex;
|
|
if (type == 0) {
|
|
if (isLibrary == 1) {
|
|
this.showBodyEffList();
|
|
libraryCtr.selectedIndex = 0;
|
|
} else if (isLibrary == 0) {
|
|
this.showBodyEffList(this.checkHaveEff("隨身特效"), true);
|
|
libraryCtr.selectedIndex = 1;
|
|
}
|
|
} else if (type == 1) {
|
|
if (isLibrary == 1) {
|
|
this.showFootEffList();
|
|
libraryCtr.selectedIndex = 0;
|
|
} else if (isLibrary == 0) {
|
|
this.showFootEffList(this.checkHaveEff("足跡"), true);
|
|
libraryCtr.selectedIndex = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 切換圖鑑和已擁有
|
|
*/
|
|
switchLibraryHead() {
|
|
var libraryCtr = FGUtil.getControl(this.appearancePanel, "alert/n44/isLibrary")
|
|
var isLibrary = libraryCtr.selectedIndex;
|
|
|
|
if (isLibrary == 1) {
|
|
this.showHeadBorderList();
|
|
libraryCtr.selectedIndex = 0;
|
|
} else if (isLibrary == 0) {
|
|
this.showHeadBorderList(this.checkHaveEff("頭像框"), true);
|
|
libraryCtr.selectedIndex = 1;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 檢測包內已有特效
|
|
* @param typeStr 特效類型字符串
|
|
* @returns 擁有的特效數組
|
|
*/
|
|
checkHaveEff(typeStr : string) {
|
|
var list = [];
|
|
let itemList = this.haveEffList;
|
|
// 數據傳遞獲取
|
|
for (let i in itemList) {
|
|
let data = ItemUtil.getItemData(itemList[i].effectid);
|
|
if (!data) continue;
|
|
if (data.type == 16 && data.description == typeStr)
|
|
list.push(itemList[i].effectid)
|
|
}
|
|
// 背包內獲取
|
|
// let itemList = GameModel.player.itemList;
|
|
// for (let itemId in itemList) {
|
|
// let count = SKDataUtil.valueForKey(GameModel.player.itemList, itemId);
|
|
// let data = ItemUtil.getItemData(itemId)
|
|
// if (!data) continue;
|
|
// if (count != null && count > 0 && data.type == 16 && data.description == typeStr) {
|
|
// list.push(itemId);
|
|
// }
|
|
// }
|
|
return list;
|
|
}
|
|
checkhas(id) {
|
|
let itemList = this.haveEffList;
|
|
// 數據傳遞獲取
|
|
for (let i in itemList) {
|
|
let data = ItemUtil.getItemData(itemList[i].effectid);
|
|
if (!data) continue;
|
|
if (data.id == id)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
/**
|
|
* 提示未開放功能
|
|
*/
|
|
tipNoFunc() {
|
|
MsgAlert.addMsg("暫未開放");
|
|
}
|
|
|
|
/**
|
|
* 還原初始特效Id
|
|
*/
|
|
resetEff() {
|
|
// this.useBodyEffID = GameModel.player.bodyEffectId;
|
|
// this.useFootEffID = GameModel.player.footEeffectId;
|
|
}
|
|
|
|
/**
|
|
* 移除身體特效
|
|
*/
|
|
removeBodyEff() {
|
|
this.useBodyEffID = 0;
|
|
FGUtil.getLoader(this.appearancePanel, "alert/eff_com/body_use/icon").url = "";
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/body_use/show").selectedIndex = 0;
|
|
FGUtil.getList(this.appearancePanel, "alert/eff_com/list").refreshVirtualList();
|
|
this.roleNode.getComponent("EffRole").stopBodyEff();
|
|
}
|
|
|
|
/**
|
|
* 移除足跡特效
|
|
*/
|
|
removeFootEff() {
|
|
this.useFootEffID = 0;
|
|
FGUtil.getLoader(this.appearancePanel, "alert/eff_com/foot_use/icon").url = "";
|
|
FGUtil.getControl(this.appearancePanel, "alert/eff_com/foot_use/show").selectedIndex = 0;
|
|
FGUtil.getList(this.appearancePanel, "alert/eff_com/list").refreshVirtualList();
|
|
this.roleNode.getComponent("EffRole").stopFootEff();
|
|
}
|
|
|
|
removeHeadBorder() {
|
|
this.useHeadBorderID = 0;
|
|
|
|
var borderCom = FGUtil.getComponent(this.appearancePanel, "alert/n44/border");
|
|
var data = HeadBorderUtil.getBorderData(this.useHeadBorderID);
|
|
FGUtil.getLoader(borderCom, "border").url = `ui://main_ui/${data.border}`;
|
|
|
|
var LT = FGUtil.getComponent(borderCom, "LT")
|
|
LT.asLoader.url = ``;
|
|
|
|
var LB = FGUtil.getComponent(borderCom, "LB")
|
|
LB.asLoader.url = ``;
|
|
|
|
var RT = FGUtil.getComponent(borderCom, "RT")
|
|
RT.asLoader.url = ``;
|
|
|
|
var RB = FGUtil.getComponent(borderCom, "RB")
|
|
RB.asLoader.url = ``;
|
|
|
|
}
|
|
|
|
/**
|
|
* 初始化
|
|
*/
|
|
initEffItem(idx, obj : fairygui.GObject) {
|
|
var item = obj.asCom;
|
|
var data = ItemUtil.getItemData(this.effListData[idx]);
|
|
FGUtil.getLoader(item, "icon").url = `ui://main_ui/${data.icon}`;
|
|
FGUtil.getTextField(item, "name").text = data.name;
|
|
var type = FGUtil.getControl(this.appearancePanel, "alert/eff_com/page").selectedIndex;
|
|
var isLibrary = FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex;
|
|
if (type == 0) {
|
|
if (isLibrary == 0) {
|
|
// 圖鑑
|
|
FGUtil.getControl(item, "isShow").selectedIndex = this.useBodyEffID == data.id ? 1 : 0;
|
|
FGUtil.getControl(item, "isUse").selectedIndex = 0;
|
|
} else {
|
|
// 已擁有(穿戴)
|
|
FGUtil.getControl(item, "isUse").selectedIndex = GameModel.player.bodyEffectId == data.id ? 1 : 0;
|
|
FGUtil.getControl(item, "isShow").selectedIndex = 0;
|
|
}
|
|
} else if (type == 1) {
|
|
if (isLibrary == 0) {
|
|
FGUtil.getControl(item, "isShow").selectedIndex = this.useFootEffID == data.id ? 1 : 0;
|
|
FGUtil.getControl(item, "isUse").selectedIndex = 0;
|
|
} else {
|
|
FGUtil.getControl(item, "isUse").selectedIndex = GameModel.player.footEeffectId == data.id ? 1 : 0;
|
|
FGUtil.getControl(item, "isShow").selectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
// 檢測是否擁有該特效
|
|
if (this.checkhas(data.id)) {
|
|
FGUtil.getControl(item, "lock").selectedIndex = 0;
|
|
} else
|
|
FGUtil.getControl(item, "lock").selectedIndex = 1;
|
|
|
|
item.node["idx"] = idx;
|
|
item.onClick(this.clickEffItem, this);
|
|
}
|
|
|
|
initHeadItem(idx, obj : fairygui.GObject) {
|
|
var item = obj.asCom;
|
|
var data : borderInfo = HeadBorderUtil.getBorderData(this.headListData[idx]);
|
|
FGUtil.getLoader(item, "head").texture = GameModel.getRoleHead(GameModel.player.resid);
|
|
|
|
FGUtil.getLoader(item, "border/border").url = `ui://main_ui/${data.border}`;
|
|
|
|
var LT = FGUtil.getComponent(item, "border/LT")
|
|
LT.asLoader.url = `ui://main_ui/${data.addLT}`;
|
|
LT.x = data.LTPos.x;
|
|
LT.y = data.LTPos.y;
|
|
var LB = FGUtil.getComponent(item, "border/LB")
|
|
LB.asLoader.url = `ui://main_ui/${data.addLB}`;
|
|
LB.x = data.LBPos.x;
|
|
LB.y = data.LBPos.y;
|
|
var RT = FGUtil.getComponent(item, "border/RT")
|
|
RT.asLoader.url = `ui://main_ui/${data.addRT}`;
|
|
RT.x = data.RTPos.x;
|
|
RT.y = data.RTPos.y;
|
|
var RB = FGUtil.getComponent(item, "border/RB")
|
|
RB.asLoader.url = `ui://main_ui/${data.addRB}`;
|
|
RB.x = data.RBPos.x;
|
|
RB.y = data.RBPos.y;
|
|
|
|
FGUtil.getTextField(item, "name").text = data.name;
|
|
|
|
var isLibrary = FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex;
|
|
|
|
if (isLibrary == 0) {
|
|
// 圖鑑
|
|
FGUtil.getControl(item, "isShow").selectedIndex = this.useHeadBorderID == data.id ? 1 : 0;
|
|
FGUtil.getControl(item, "isUse").selectedIndex = 0;
|
|
} else {
|
|
// 已擁有(穿戴)
|
|
FGUtil.getControl(item, "isUse").selectedIndex = GameModel.player.headBorder == data.id ? 1 : 0;
|
|
FGUtil.getControl(item, "isShow").selectedIndex = 0;
|
|
}
|
|
|
|
|
|
// 檢測是否擁有該特效
|
|
if (this.checkhas(data.id)) {
|
|
FGUtil.getControl(item, "lock").selectedIndex = 0;
|
|
} else
|
|
FGUtil.getControl(item, "lock").selectedIndex = 1;
|
|
|
|
item.node["idx"] = idx;
|
|
item.onClick(this.clickHeadBorderItem, this);
|
|
}
|
|
|
|
/**
|
|
* 點擊特效
|
|
*/
|
|
clickEffItem(e : Event, id : number = 0) {
|
|
var idx;
|
|
if (SKDataUtil.hasProperty(e.target, "idx"))
|
|
idx = e.target["idx"];
|
|
else idx = id;
|
|
|
|
this.selecedEffId = idx;
|
|
var type = FGUtil.getControl(this.appearancePanel, "alert/eff_com/page").selectedIndex;
|
|
var isLibrary = FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex;
|
|
if (isLibrary == 0) {
|
|
if (type == 0) {
|
|
if (this.useBodyEffID == this.effListData[idx]) {
|
|
this.removeBodyEff();
|
|
return;
|
|
}
|
|
this.useBodyEffID = this.effListData[idx];
|
|
this.changeBodyEff();
|
|
} else if (type == 1) {
|
|
if (this.useFootEffID == this.effListData[idx]) {
|
|
this.removeFootEff();
|
|
return;
|
|
}
|
|
this.useFootEffID = this.effListData[idx];
|
|
this.changeFootEff();
|
|
}
|
|
} else {
|
|
if (type == 0) {
|
|
if (GameModel.player.bodyEffectId == this.effListData[idx]) {
|
|
// 移除穿戴隨身特效
|
|
GameModel.player.bodyEffectId = 0;
|
|
GameModel.send("c2s_use_seffect", {
|
|
roleid: GameModel.player.roleid,
|
|
effectid: GameModel.player.bodyEffectId,
|
|
effecttype: 1
|
|
})
|
|
|
|
this.removeBodyEff();
|
|
return;
|
|
}
|
|
GameModel.player.bodyEffectId = this.effListData[idx];
|
|
this.useBodyEffID = this.effListData[idx];
|
|
GameModel.send("c2s_use_seffect", {
|
|
roleid: GameModel.player.roleid,
|
|
effectid: GameModel.player.bodyEffectId,
|
|
effecttype: 1
|
|
})
|
|
this.changeBodyEff();
|
|
} else if (type == 1) {
|
|
if (GameModel.player.footEeffectId == this.effListData[idx]) {
|
|
// 移除足跡特效
|
|
GameModel.player.footEeffectId = 0;
|
|
GameModel.send("c2s_use_seffect", {
|
|
roleid: GameModel.player.roleid,
|
|
effectid: GameModel.player.footEeffectId,
|
|
effecttype: 2
|
|
})
|
|
this.removeFootEff();
|
|
return;
|
|
}
|
|
GameModel.player.footEeffectId = this.effListData[idx];
|
|
this.useFootEffID = this.effListData[idx];
|
|
GameModel.send("c2s_use_seffect", {
|
|
roleid: GameModel.player.roleid,
|
|
effectid: GameModel.player.footEeffectId,
|
|
effecttype: 2
|
|
})
|
|
this.changeFootEff();
|
|
}
|
|
}
|
|
|
|
FGUtil.getList(this.appearancePanel, "alert/eff_com/list").refreshVirtualList();
|
|
|
|
}
|
|
|
|
clickHeadBorderItem(e : Event, id : number = 0) {
|
|
var idx;
|
|
if (SKDataUtil.hasProperty(e.target, "idx"))
|
|
idx = e.target["idx"];
|
|
else idx = id;
|
|
|
|
this.selecedHeadId = idx;
|
|
|
|
var isLibrary = FGUtil.getControl(this.appearancePanel, "alert/eff_com/isLibrary").selectedIndex;
|
|
|
|
if (isLibrary == 0) {
|
|
if (this.useHeadBorderID == this.headListData[idx]) {
|
|
this.removeHeadBorder();
|
|
FGUtil.getList(this.appearancePanel, "alert/n44/list").refreshVirtualList();
|
|
return;
|
|
}
|
|
this.useHeadBorderID = this.headListData[idx];
|
|
this.changeHeadBorder();
|
|
} else {
|
|
if (GameModel.player.useHeadBorderID == this.headListData[idx]) {
|
|
// 移除頭像框
|
|
GameModel.player.headBorder = 0;
|
|
GameModel.send("c2s_use_seffect", {
|
|
roleid: GameModel.player.roleid,
|
|
effectid: GameModel.player.headBorder,
|
|
effecttype: 3
|
|
})
|
|
this.removeHeadBorder();
|
|
FGUtil.getList(this.appearancePanel, "alert/n44/list").refreshVirtualList();
|
|
this.changeUIHeadBorder(GameModel.player.headBorder)
|
|
return;
|
|
}
|
|
GameModel.player.headBorder = this.headListData[idx];
|
|
this.useHeadBorderID = this.headListData[idx];
|
|
GameModel.send("c2s_use_seffect", {
|
|
roleid: GameModel.player.roleid,
|
|
effectid: GameModel.player.headBorder,
|
|
effecttype: 3
|
|
})
|
|
this.changeHeadBorder();
|
|
this.changeUIHeadBorder(GameModel.player.headBorder)
|
|
}
|
|
FGUtil.getList(this.appearancePanel, "alert/n44/list").refreshVirtualList();
|
|
}
|
|
|
|
changeBodyEff() {
|
|
// FGUtil.getControl(this.appearancePanel, "alert/eff_com/body_use/show").selectedIndex = 1;
|
|
FGUtil.getLoader(this.appearancePanel, "alert/eff_com/body_use/icon").url = `ui://main_ui/${this.useBodyEffID}`;
|
|
|
|
this.roleNode.getComponent("EffRole").changeBodyEff(this.useBodyEffID);
|
|
}
|
|
|
|
changeFootEff() {
|
|
// FGUtil.getControl(this.appearancePanel, "alert/eff_com/foot_use/show").selectedIndex = 1;
|
|
FGUtil.getLoader(this.appearancePanel, "alert/eff_com/foot_use/icon").url = `ui://main_ui/${this.useFootEffID}`;
|
|
|
|
this.roleNode.getComponent("EffRole").changeFootEff(this.useFootEffID);
|
|
}
|
|
|
|
changeHeadBorder() {
|
|
var borderCom = FGUtil.getComponent(this.appearancePanel, "alert/n44/border");
|
|
var data = HeadBorderUtil.getBorderData(this.useHeadBorderID);
|
|
FGUtil.getLoader(borderCom, "border").url = `ui://main_ui/${data.border}`;
|
|
|
|
var LT = FGUtil.getComponent(borderCom, "LT")
|
|
LT.asLoader.url = `ui://main_ui/${data.addLT}`;
|
|
LT.x = data.LTPos.x;
|
|
LT.y = data.LTPos.y;
|
|
var LB = FGUtil.getComponent(borderCom, "LB")
|
|
LB.asLoader.url = `ui://main_ui/${data.addLB}`;
|
|
LB.x = data.LBPos.x;
|
|
LB.y = data.LBPos.y;
|
|
var RT = FGUtil.getComponent(borderCom, "RT")
|
|
RT.asLoader.url = `ui://main_ui/${data.addRT}`;
|
|
RT.x = data.RTPos.x;
|
|
RT.y = data.RTPos.y;
|
|
var RB = FGUtil.getComponent(borderCom, "RB")
|
|
RB.asLoader.url = `ui://main_ui/${data.addRB}`;
|
|
RB.x = data.RBPos.x;
|
|
RB.y = data.RBPos.y;
|
|
}
|
|
|
|
changeUIHeadBorder(id) {
|
|
// 更改自己主ui頭像框
|
|
let mainUI = GameModel.player.getMainUILogic();
|
|
mainUI.changeHeadBorder(id);
|
|
|
|
if (GameModel.player.teamid > 0) {
|
|
GameModel.send("c2s_team_info", {
|
|
nRoleID: GameModel.player.roleid
|
|
})
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 添加關閉事件
|
|
*/
|
|
pushCloseEvent(item : fairygui.GComponent, target : fairygui.GComponent, call : Function = null) {
|
|
item.clearClick();
|
|
item.onClick(() => {
|
|
call && call()
|
|
FGUtil.dispose(target);
|
|
target = null;
|
|
}, this)
|
|
}
|
|
} |