2025-04-24 17:03:28 +08:00

1380 lines
46 KiB
TypeScript

import { EAttrTypeL1, LongPressSpeedAttr } from "../core/EEnum";
import GameModel from "../core/GameModel";
import GameUtil from "../core/GameUtil";
import ItemUtil from "../core/ItemUtil";
import MsgAlert from "../game/msg/MsgAlert";
import FGAlert from "../gear_2.3.4/fgui/FGAlert";
import FGUtil from "../gear_2.3.4/fgui/FGUtil";
import SKDataUtil from "../gear_2.3.4/util/SKDataUtil";
import SKUIUtil from "../gear_2.3.4/util/SKUIUtil";
import PracticeMgr = require("../../game/RolePracticeMgr");
import FactionTalent from "../FactionTalent";
const { ccclass, property } = cc._decorator;
export default class Gang extends cc.Component {
/**
* 幫派單例實例
*/
public static Instance : Gang = null;
/**
* 幫派面板
*/
gangPanel : fgui.GComponent = null;
/**
* 幫派數據
*/
gangInfoData : any = null;
/**
* 幫派信息界面
*/
gangInfoView : fgui.GComponent = null;
/**
* 幫派人員數據
*/
gangRoleListData : any = [];
isMaster : boolean = false
/**
* 選擇的幫派人員下標
*/
selectRoleIdx : number = -1;
/**
* 幫派內政界面
*/
gangManageView : fgui.GComponent = null;
/**
* 入幫申請數據
*/
requireListData : any = [];
/**
* 幫派列表面板
*/
gangListPanel : fgui.GComponent = null;
/**
* 幫派列表數據
*/
gangListData : any = [];
/**
* 選擇的幫派項目下標
*/
selectListIdx : number = -1;
searching : boolean = false
/**
* 人物修煉面板
*/
practicePanel : fgui.GComponent = null;
practiceData : any = {};
/**
* 人物修煉提升等級面板
*/
practiceUpGradePanel : fgui.GComponent = null;
/**
* 創建幫派面板
*/
creatGangPanel : fgui.GComponent = null;
/**
* 發布通知面板
*/
noticePanel : fgui.GComponent = null;
/**
* 職位
*/
job : number = 7;
/**
* 需要加载的预制体
*/
prefabObject : any = {};
onLoad() {
if (Gang.Instance === null) {
Gang.Instance = this;
this.loadPrefab();
} else {
this.destroy();
return;
}
}
/**
* 加載預製體
*/
loadPrefab() {
// 加載所需的預製體
var prefabList = [
{ url: "Prefabs/UIRole", name: "UIRole" },
]
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;
}
})
}
}
/**
* 打開幫派列表面板
*/
openGangListPanel(hasGang : boolean = false) {
if (!SKUIUtil.isFGUIValid(this.gangListPanel)) {
this.gangListPanel = FGUtil.create("main_ui", "gang_list_panel");
FGUtil.root().addChild(this.gangListPanel);
this.gangListPanel.makeFullScreen();
}
var mask = FGUtil.getComponent(this.gangListPanel, "mask");
var close = FGUtil.getButton(this.gangListPanel, "alert/closeBtn");
this.pushCloseEvent(mask, this.gangListPanel, () => { this.gangListData = null; this.selectListIdx = -1 });
this.pushCloseEvent(close, this.gangListPanel, () => { this.gangListData = null; this.selectListIdx = -1 });
//初始化按鈕
var joinBtn = FGUtil.getButton(this.gangListPanel, "alert/join_gang");
var onKeyJoinBtn = FGUtil.getButton(this.gangListPanel, "alert/onekeyapply");
var createBtn = FGUtil.getButton(this.gangListPanel, "alert/creat");
var searchBtn = FGUtil.getButton(this.gangListPanel, "alert/search");
var clearBtn = FGUtil.getButton(this.gangListPanel, "alert/clear");
var backBtn = FGUtil.getComponent(this.gangListPanel, "alert/back");
joinBtn.onClick(this.joinGang, this);
onKeyJoinBtn.onClick(this.onKeyJoin, this);
createBtn.onClick(this.openCreateGangPanel, this);
searchBtn.onClick(this.searchGang, this);
clearBtn.onClick(this.clearSearch, this);
backBtn.onClick(this.backSearch, this);
if (!hasGang) {
//滑動頁面按鈕組件
var infoPageBtn = FGUtil.getComponent(this.gangListPanel, "alert/swtich_info/n1");
infoPageBtn.onClick(this.changeInfoPage, this);
var pageCom = FGUtil.getComponent(this.gangListPanel, "alert/gang_info");
pageCom.on(fgui.Event.SCROLL, this.onScroll, this)
pageCom.on(fgui.Event.SCROLL_END, this.onScrollEnd, this)
} else {
FGUtil.getControl(this.gangListPanel, "alert/hasGangId").selectedIndex = 1;
}
var list = FGUtil.getList(this.gangListPanel, "alert/bang_list");
// 設置初始化方法
list.itemRenderer = this.initGangListItem.bind(this);
// 虛擬列表
list.setVirtual();
GameModel.send("c2s_getbanglist", {
roleid: GameModel.player.roleid
})
}
/**
* 幫派列表初始化方法
*/
initGangListItem(idx, obj : fairygui.GObject) {
var item = obj.asCom;
FGUtil.getTextField(item, "n1").text = (idx + 1).toString();
FGUtil.getTextField(item, "n2").text = this.gangListData[idx].name;
FGUtil.getTextField(item, "n3").text = "1";
FGUtil.getTextField(item, "n4").text = this.gangListData[idx].rolenum.toString();
FGUtil.getTextField(item, "n5").text = "0";
FGUtil.getTextField(item, "n6").text = this.gangListData[idx].mastername;
FGUtil.getControl(item, "bg").selectedIndex = idx % 2 == 1 ? 0 : 1;
FGUtil.getControl(item, "selected").selectedIndex = this.selectListIdx == idx ? 1 : 0;
item.node["idx"] = idx;
item.onClick(this.selectedGangItem, this);
}
/**
* 選擇幫派列表子項目
*/
selectedGangItem(e : Event, id : number = 0) {
if (!SKUIUtil.isFGUIValid(this.gangListPanel)) return;
var idx;
if (e.target && SKDataUtil.hasProperty(e.target, "idx"))
idx = e.target["idx"];
else
idx = id;
this.selectListIdx = idx;
var hasGang = FGUtil.getControl(this.gangListPanel, "alert/hasGangId").selectedIndex;
var aim = FGUtil.getRichTextField(this.gangListPanel, `alert${hasGang == 0 ? '/gang_info' : ''}/zongzhi/info/info`);
var battleInfo = FGUtil.getRichTextField(this.gangListPanel, `alert${hasGang == 0 ? '/gang_info' : ''}/zhanbao/info/info`);
aim.text = this.gangListData[idx].aim == "" ? "無" : this.gangListData[idx].aim;
battleInfo.text = "無";
var list = FGUtil.getList(this.gangListPanel, "alert/bang_list");
list.refreshVirtualList();
}
/**
* 刷新幫派列表
*/
refreshGangListPanel(data : any = []) {
this.gangListData = data;
if (!SKUIUtil.isFGUIValid(this.gangListPanel)) return;
if (data.length == 0) {
var noGang;
noGang = FGUtil.getComponent(this.gangListPanel, "alert/noGang");
if (!noGang)
noGang = FGUtil.create("main_ui", "no_tip");
noGang.name = "noGang";
FGUtil.getComponent(this.gangListPanel, "alert").addChild(noGang);
if (this.searching) {
noGang.setPosition(145, 73);
FGUtil.getControl(noGang, "type").selectedIndex = 0;
this.searching = false;
} else {
noGang.setPosition(200, 115);
FGUtil.getControl(this.gangListPanel, "alert/no_gang").selectedIndex = 1;
FGUtil.getControl(noGang, "type").selectedIndex = 1;
}
FGUtil.getButton(noGang, "n5").onClick(this.openCreateGangPanel, this);
}
var list = FGUtil.getList(this.gangListPanel, "alert/bang_list");
list.numItems = data.length;
}
/**
* 打開創建幫派面板
*/
openCreateGangPanel() {
if (!SKUIUtil.isFGUIValid(this.creatGangPanel)) {
this.creatGangPanel = FGUtil.create("main_ui", "gang_create_panel");
FGUtil.root().addChild(this.creatGangPanel);
this.creatGangPanel.makeFullScreen();
}
var mask = FGUtil.getComponent(this.creatGangPanel, "mask");
var close = FGUtil.getButton(this.creatGangPanel, "alert/close");
this.pushCloseEvent(mask, this.creatGangPanel);
this.pushCloseEvent(close, this.creatGangPanel);
var autoBtn = FGUtil.getButton(this.creatGangPanel, "alert/auto");
autoBtn.onClick(this.switchAutoBtn, this);
var createBtn = FGUtil.getButton(this.creatGangPanel, "alert/do");
createBtn.onClick(this.createGang, this);
autoBtn.visible = false
FGUtil.getObject(this.creatGangPanel, "alert/n38").visible = false
}
/**
* 自動招募切換
*/
switchAutoBtn() {
if (!SKUIUtil.isFGUIValid(this.creatGangPanel)) {
console.warn("未找到面板");
return;
}
var type = FGUtil.getControl(this.creatGangPanel, "alert/auto/selected").selectedIndex
FGUtil.getControl(this.creatGangPanel, "alert/auto/selected").selectedIndex = type == 0 ? 1 : 0;
}
/**
* 創建幫派
*/
createGang() {
if (!SKUIUtil.isFGUIValid(this.creatGangPanel)) {
console.warn("未找到面板");
return;
}
var name = FGUtil.getTextInput(this.creatGangPanel, "alert/name");
var zongzhi = FGUtil.getTextInput(this.creatGangPanel, "alert/zongzhi");
if (name.text == '') {
MsgAlert.addMsg(`請輸入幫會名稱!`);
return;
}
if (GameModel.player.level < 50) {
MsgAlert.addMsg(`創建幫派需要50級!`);
return;
}
GameModel.send('c2s_createbang', {
name: name.text,
aim: zongzhi.text,
masterid: GameModel.player.roleid,
mastername: GameModel.player.name
});
FGUtil.dispose(this.creatGangPanel);
this.creatGangPanel = null;
FGUtil.dispose(this.gangListPanel);
this.gangListPanel = null;
this.gangListData = null;
this.openGangPanel();
}
/**
* 加入幫派
*/
joinGang() {
if (this.selectListIdx < 0 || this.selectListIdx > this.gangListData.length - 1) {
MsgAlert.addMsg("請先選擇幫派");
return;
}
var gangId = this.gangListData[this.selectListIdx].bangid;
GameModel.send("c2s_requestbang", {
roleid: GameModel.player.roleid,
bangid: gangId
})
}
/**
* 一鍵加入幫派
*/
onKeyJoin() {
MsgAlert.addMsg("暫時無法一鍵申請");
return;
}
/**
* 搜索幫派
*/
searchGang() {
if (!SKUIUtil.isFGUIValid(this.gangListPanel)) {
console.warn("未找到面板");
return;
}
var edit = FGUtil.getTextInput(this.gangListPanel, "alert/search_bang_edit");
if (edit.text == "") {
MsgAlert.addMsg("請輸入幫派名稱");
return;
}
this.searching = true;
FGUtil.getComponent(this.gangListPanel, "alert/back").visible = true;
GameModel.send('c2s_searchbang', {
roleid: GameModel.player.roleid,
data: edit.text
});
}
/**
* 返回搜索結果
*/
backSearch() {
if (!SKUIUtil.isFGUIValid(this.gangListPanel)) return;
var noGang = FGUtil.getComponent(this.gangListPanel, "alert/noGang");
if (noGang)
FGUtil.dispose(noGang);
FGUtil.getComponent(this.gangListPanel, "alert/back").visible = false;
this.selectListIdx = -1;
GameModel.send("c2s_getbanglist", {
roleid: GameModel.player.roleid
})
}
/**
* 清空搜索內容
*/
clearSearch() {
if (!SKUIUtil.isFGUIValid(this.gangListPanel)) {
console.warn("未找到面板");
return;
}
var edit = FGUtil.getTextInput(this.gangListPanel, "alert/search_bang_edit");
edit.text = "";
}
/**
* 切換信息頁面和滑動監聽
*/
changeInfoPage(e : Event = null, page : number = -1) {
if (SKUIUtil.isFGUIValid(this.gangInfoView)) {
var type = FGUtil.getControl(this.gangInfoView, "swtich_info/type").selectedIndex;
if (page == -1)
page = type == 0 ? 1 : 0;
FGUtil.getControl(this.gangInfoView, "swtich_info/type").selectedIndex = page;
var pageCom = FGUtil.getComponent(this.gangInfoView, "aim_notice");
var scroll = pageCom.scrollPane;
scroll.setCurrentPageX(page);
return;
} else
if (SKUIUtil.isFGUIValid(this.gangListPanel)) {
var type = FGUtil.getControl(this.gangListPanel, "alert/swtich_info/type").selectedIndex;
if (page == -1)
page = type == 0 ? 1 : 0;
FGUtil.getControl(this.gangListPanel, "alert/swtich_info/type").selectedIndex = page;
var pageCom = FGUtil.getComponent(this.gangListPanel, "alert/gang_info");
var scroll = pageCom.scrollPane;
scroll.setCurrentPageX(page);
return;
}
}
onScroll() {
if (SKUIUtil.isFGUIValid(this.gangInfoView)) {
var pageCom = FGUtil.getComponent(this.gangInfoView, "aim_notice");
var scroll = pageCom.scrollPane;
FGUtil.getControl(this.gangInfoView, "swtich_info/type").selectedIndex = scroll.currentPageX;
return;
} else
if (SKUIUtil.isFGUIValid(this.gangListPanel)) {
var pageCom = FGUtil.getComponent(this.gangListPanel, "alert/gang_info");
var scroll = pageCom.scrollPane;
FGUtil.getControl(this.gangListPanel, "alert/swtich_info/type").selectedIndex = scroll.currentPageX;
return;
}
}
onScrollEnd() {
if (SKUIUtil.isFGUIValid(this.gangInfoView)) {
var pageCom = FGUtil.getComponent(this.gangInfoView, "aim_notice");
var scroll = pageCom.scrollPane;
this.changeInfoPage(null, scroll.currentPageX)
return;
} else
if (SKUIUtil.isFGUIValid(this.gangListPanel)) {
var pageCom = FGUtil.getComponent(this.gangListPanel, "alert/gang_info");
var scroll = pageCom.scrollPane;
this.changeInfoPage(null, scroll.currentPageX)
return;
}
}
/**
* 打開幫派面板
*/
openGangPanel() {
if (!SKUIUtil.isFGUIValid(this.gangPanel)) {
this.gangPanel = FGUtil.create("main_ui", "gang_panel");
FGUtil.root().addChild(this.gangPanel);
this.gangPanel.makeFullScreen();
}
var mask = FGUtil.getComponent(this.gangPanel, "mask");
var close = FGUtil.getButton(this.gangPanel, "alert/closeBtn");
this.pushCloseEvent(mask, this.gangPanel, () => { this.closeAllView() });
this.pushCloseEvent(close, this.gangPanel, () => { this.closeAllView() });
var infoBtn = FGUtil.getButton(this.gangPanel, "alert/gang_btn");
infoBtn.onClick(this.openGangInfoView, this);
var interiorBtn = FGUtil.getButton(this.gangPanel, "alert/interior_btn");
interiorBtn.onClick(this.openGangManageView, this);
FGUtil.getButton(this.gangPanel, "alert/build_btn").onClick(this.tipno, this)
FGUtil.getButton(this.gangPanel, "alert/report_btn").onClick(this.tipno, this)
this.openGangInfoView();
}
tipno() {
MsgAlert.addMsg("暫未開放232323")
FGUtil.getControl(this.gangPanel, "alert/build_btn/button").selectedIndex = 0
FGUtil.getControl(this.gangPanel, "alert/report_btn/button").selectedIndex = 0
}
/**
* 打開幫派信息界面
*/
openGangInfoView() {
if (!SKUIUtil.isFGUIValid(this.gangPanel)) return;
if (!SKUIUtil.isFGUIValid(this.gangInfoView)) {
this.gangInfoView = FGUtil.create("main_ui", "gang_info_alert");
this.gangInfoView.setPosition(20, 20);
FGUtil.getComponent(this.gangPanel, "alert/info").addChild(this.gangInfoView);
var backGangBtn = FGUtil.getButton(this.gangInfoView, "back");
backGangBtn.onClick(this.backGang, this);
var practiceBtn = FGUtil.getButton(this.gangInfoView, "practice");
practiceBtn.onClick(this.openPracticePanel, this);
var tianyanBtn = FGUtil.getButton(this.gangInfoView, "tianyan");
tianyanBtn.onClick(this.tianYanFunc, this);
var gangListBtn = FGUtil.getButton(this.gangInfoView, "gangList");
gangListBtn.onClick(this.showGangList, this);
var list = FGUtil.getList(this.gangInfoView, "n10");
// 設置初始化方法
list.itemRenderer = this.initGangRoleItem.bind(this);
// 虛擬列表
list.setVirtual();
var jobMask = FGUtil.getComponent(this.gangInfoView, "takeOfficeMask");
jobMask.onClick(this.offtakeOffice, this);
// 任命職位按鈕
var fbzBtn = FGUtil.getButton(this.gangInfoView, "takeOffice/fbz");
fbzBtn.node["job"] = 2;
fbzBtn.onClick(this.bangPost, this);
var zhfBtn = FGUtil.getButton(this.gangInfoView, "takeOffice/zhf");
zhfBtn.node["job"] = 3;
zhfBtn.onClick(this.bangPost, this);
var yhfBtn = FGUtil.getButton(this.gangInfoView, "takeOffice/yhf");
yhfBtn.node["job"] = 4;
yhfBtn.onClick(this.bangPost, this);
var zlBtn = FGUtil.getButton(this.gangInfoView, "takeOffice/zl");
zlBtn.node["job"] = 5;
zlBtn.onClick(this.bangPost, this);
var tzBtn = FGUtil.getButton(this.gangInfoView, "takeOffice/tz");
tzBtn.node["job"] = 6;
tzBtn.onClick(this.bangPost, this);
var bzBtn = FGUtil.getButton(this.gangInfoView, "takeOffice/bz");
bzBtn.node["job"] = 7;
bzBtn.onClick(this.bangPost, this);
var infoPageBtn = FGUtil.getComponent(this.gangInfoView, "swtich_info/n1");
infoPageBtn.onClick(this.changeInfoPage, this);
var pageCom = FGUtil.getComponent(this.gangInfoView, "aim_notice");
pageCom.on(fgui.Event.SCROLL, this.onScroll, this);
pageCom.on(fgui.Event.SCROLL_END, this.onScrollEnd, this);
FGUtil.getButton(this.gangInfoView, "aim_notice/n1").onClick(() => {
this.openNoticePanel(1);
})
FGUtil.getButton(this.gangInfoView, "aim_notice/n2").onClick(() => {
this.openNoticePanel(2);
})
}
GameModel.send('c2s_getbanginfo', {
roleid: GameModel.player.roleid,
bangid: GameModel.player.bangid
});
}
/**
* 幫派列表初始化方法
*/
initGangRoleItem(idx, obj : fairygui.GObject) {
var item = obj.asCom;
var info = this.gangRoleListData[idx];
var postArr = ["幫主", "副幫主", "左護法", "右護法", "長老", "堂主", "幫眾"]
FGUtil.getTextField(item, "n9").text = info.name;
FGUtil.getTextField(item, "n10").text = GameUtil.getReliveRichText(info.relive, info.level);
FGUtil.getTextField(item, "n11").text = this.getRaceSex(info.race, info.sex);
FGUtil.getTextField(item, "n12").text = postArr[info.bangpost ? info.bangpost - 1 : 6];
FGUtil.getTextField(item, "n13").text = `${info.online == 1 ? '在線' : '離線'}`;
FGUtil.getControl(item, "bg").selectedIndex = idx % 2 == 1 ? 0 : 1;
FGUtil.getControl(item, "selected").selectedIndex = this.selectRoleIdx == idx ? 1 : 0;
item.node["idx"] = idx;
item.onClick(this.selectedRoleItem, this);
}
selectedRoleItem(e : Event, id : number = 0) {
if (!SKUIUtil.isFGUIValid(this.gangInfoView)) return;
var idx;
if (e.target && SKDataUtil.hasProperty(e.target, "idx"))
idx = e.target["idx"];
else
idx = id;
this.selectRoleIdx = idx;
var list = FGUtil.getList(this.gangInfoView, "n10");
list.refreshVirtualList();
this.showRoleInfo(this.gangRoleListData[idx]);
}
showRoleInfo(info : any = null) {
if (info == null) return;
if (!SKUIUtil.isFGUIValid(this.gangInfoView)) return;
// 幫主自己不顯示任命和開除按鈕
if (this.isMaster) {
if (info.roleid == this.gangInfoData.info.masterid)
FGUtil.getControl(this.gangInfoView, "master").selectedIndex = 0;
else
FGUtil.getControl(this.gangInfoView, "master").selectedIndex = 1;
}
var menuListName = [
"任 命",
"開 除",
"聊 天",
"組 隊",
"添加好友",
]
var menuList = FGUtil.getList(this.gangInfoView, "menulist");
menuList.removeChildren();
for (let i in menuListName) {
var word = menuListName[i];
if (!this.isMaster && word == "任 命")
continue;
if (!this.isMaster && word == "開 除")
continue;
if (info.roleid == GameModel.player.roleid)
continue;
var item = menuList.addItem().asCom;
FGUtil.getTextField(item, "title").text = word;
FGUtil.getTextField(item, "title").color = new cc.Color(125, 0, 0);
item.node["wordType"] = word;
item.node["info"] = info;
item.onClick(this.clickRoleMenuList, this)
}
FGUtil.getControl(this.gangInfoView, "showRole").selectedIndex = 1;
FGUtil.getTextField(this.gangInfoView, "roleName").text = info.name;
this.addUIRole(info);
}
clickRoleMenuList(e : Event) {
if (!SKDataUtil.hasProperty(e.target, "wordType")) return;
if (!SKDataUtil.hasProperty(e.target, "info")) return;
var word = e.target["wordType"]
var info = e.target["info"]
if (word == "任 命") {
this.takeOffice()
}
else if (word == "開 除") {
this.expelMember();
}
else if (word == "聊 天") {
MsgAlert.addMsg("暫不支持臨時聊天")
}
else if (word == "組 隊") {
if (!GameModel.player.isleader) {
MsgAlert.addMsg("你還不是隊長")
return
}
GameModel.send('c2s_team_invite', {
toroleid: info.roleid,
});
}
else if (word == "添加好友") {
GameModel.send('c2s_add_friend', {
roleid: info.roleid
});
}
}
/**
* 添加人物UI
*/
addUIRole(info : any = null) {
if (!SKUIUtil.isFGUIValid(this.gangInfoView) || this.prefabObject["UIRole"] == null) return;
var pNode = FGUtil.getComponent(this.gangInfoView, "roleNode").node;
var role = cc.find("UIRole", pNode);
if (!role) {
var roleNode = cc.instantiate(this.prefabObject["UIRole"]);
roleNode.parent = pNode;
roleNode.name = "UIRole"
roleNode.setPosition(0, 20);
roleNode.getComponent("UIRole").setInfo(info)
roleNode.getComponent("UIRole").offTouchRole();
} else {
role.getComponent("UIRole").setInfo(info)
}
}
takeOffice() {
if (!SKUIUtil.isFGUIValid(this.gangInfoView)) {
console.warn("未找到面板");
return
}
FGUtil.getControl(this.gangInfoView, "takeOffice").selectedIndex = 1;
}
offtakeOffice() {
FGUtil.getControl(this.gangInfoView, "takeOffice").selectedIndex = 0;
}
bangPost(e : Event) {
var idx;
if (e.target && SKDataUtil.hasProperty(e.target, "job"))
idx = e.target["job"];
else {
console.warn("信息錯誤");
return;
}
GameModel.send("c2s_set_bangpost", {
masterid: GameModel.player.roleid,
memberid: this.gangRoleListData[this.selectRoleIdx].roleid,
postid: idx
})
this.offtakeOffice();
}
expelMember() {
var name = this.gangRoleListData[this.selectRoleIdx].name;
var roleid = this.gangRoleListData[this.selectRoleIdx].roleid;
if (GameModel.player.roleid == roleid) {
MsgAlert.addMsg("不能開除自己!")
return;
}
FGAlert.show(`確認開除${name}麼?`, () => {
FGAlert.hide();
}, () => {
FGAlert.hide();
GameModel.send('c2s_leavebang', {
roleid: roleid,
bangid: GameModel.player.bangid
});
GameModel.send('c2s_getbanginfo', {
roleid: GameModel.player.roleid,
bangid: GameModel.player.bangid
});
})
}
/**
* 打开帮派内政界面
*/
openGangManageView() {
if (!SKUIUtil.isFGUIValid(this.gangPanel)) return;
if (!SKUIUtil.isFGUIValid(this.gangManageView)) {
this.gangManageView = FGUtil.create("main_ui", "gang_manage_alert");
this.gangManageView.setPosition(20, 10);
FGUtil.getComponent(this.gangPanel, "alert/manage").addChild(this.gangManageView);
var leaveGangBtn = FGUtil.getButton(this.gangManageView, "leave");
leaveGangBtn.onClick(this.leaveGang, this);
var clearBtn = FGUtil.getButton(this.gangManageView, "clear");
clearBtn.onClick(this.clearApplyList, this);
var eventBtn = FGUtil.getButton(this.gangManageView, "n61");
eventBtn.onClick(this.showGangEvent, this);
var showRequireBtn = FGUtil.getButton(this.gangManageView, "n62");
showRequireBtn.onClick(this.showRequestList, this);
var requireList = FGUtil.getList(this.gangManageView, "applyList");
// 設置初始化方法
requireList.itemRenderer = this.initRequireItem.bind(this);
// 虛擬列表
requireList.setVirtual();
}
GameModel.send('c2s_getbanginfo', {
roleid: GameModel.player.roleid,
bangid: GameModel.player.bangid
});
}
initRequireItem(idx, obj : fairygui.GObject) {
var item = obj.asCom;
var info = this.requireListData[idx];
FGUtil.getLoader(item, "ava").texture = GameModel.getRoleHead(info.resid);
FGUtil.getLoader(item, "race").url = `ui://main_ui/icon_race${info.race}`;
FGUtil.getTextField(item, "player_name").text = info.name;
FGUtil.getRichTextField(item, "level").text = GameUtil.getReliveRichText(info.relive, info.level);
var agreeBtn = FGUtil.getButton(item, "n8");
var rejectBtn = FGUtil.getButton(item, "n9")
agreeBtn.node["roleid"] = info.roleid;
agreeBtn.node["opera"] = 1;
rejectBtn.node["roleid"] = info.roleid;
rejectBtn.node["opera"] = 0;
agreeBtn.onClick(this.applyJoinGang, this);
rejectBtn.onClick(this.applyJoinGang, this);
}
/**
* 操作入幫申請
*/
applyJoinGang(e : Event) {
var roleid, opera;
if (e.target && SKDataUtil.hasProperty(e.target, "roleid") && SKDataUtil.hasProperty(e.target, "opera")) {
roleid = e.target["roleid"];
opera = e.target["opera"];
} else {
MsgAlert.addMsg("信息錯誤!")
return;
}
if (this.job < 7)
GameModel.send("c2s_operbang", {
operation: opera,
roleid: roleid,
bangid: GameModel.player.bangid
})
else
MsgAlert.addMsg("暫無權限!")
}
/**
*
* @param race 種族
* @param sex 性別
*/
getRaceSex(race, sex) {
return `${ItemUtil.sexName[sex - 1]}${ItemUtil.raceName[race - 1]}`;
}
/**
* 脫離幫派
*/
leaveGang() {
FGAlert.show("確認脫離幫派麼?", () => {
FGAlert.hide();
}, () => {
FGAlert.hide();
FGUtil.dispose(this.gangPanel);
this.gangPanel = null;
this.closeAllView();
GameModel.send('c2s_leavebang', {
roleid: GameModel.player.roleid,
bangid: GameModel.player.bangid
});
})
}
/**
* 清空申請入幫列表
*/
clearApplyList() {
this.requireListData = [];
if (!SKUIUtil.isFGUIValid(this.gangManageView)) return;
FGUtil.getControl(this.gangManageView, "apply").selectedIndex = 0;
var requireList = FGUtil.getList(this.gangManageView, "applyList");
requireList.numItems = 0;
}
/**
* 關閉幫派所有子界面以及清空數據
*/
closeAllView() {
this.gangInfoData = null;
if (this.gangInfoView) {
FGUtil.dispose(this.gangInfoView);
this.gangInfoView = null;
}
if (this.gangManageView) {
FGUtil.dispose(this.gangManageView);
this.gangManageView = null;
}
this.gangRoleListData = [];
this.requireListData = [];
this.gangInfoData = null;
this.selectRoleIdx = -1;
}
/**
* 刷新幫派面板數據
*/
refreshGangPanel(data : any = null) {
this.gangInfoData = data;
if (!SKUIUtil.isFGUIValid(this.gangPanel)) return;
this.isMaster = data.info.masterid == GameModel.player.roleid
FGUtil.getTextField(this.gangPanel, "alert/title/title").text = data.info.name;
FGUtil.getControl(this.gangInfoView, "aim_notice/master").selectedIndex = this.isMaster ? 1 : 0;
var aim = data.info.aim ? data.info.aim : "無"
var notice = data.info.notice ? data.info.notice : "無"
FGUtil.getRichTextField(this.gangInfoView, "aim_notice/zongzhi/info/info").text = aim == "" ? "無" : aim;
FGUtil.getRichTextField(this.gangInfoView, "aim_notice/gonggao/info/info").text = notice == "" ? "無" : notice;
var page = FGUtil.getControl(this.gangPanel, "alert/page").selectedIndex;
if (page == 0) {
// 渲染幫派信息
this.refreshGangInfo(this.gangInfoData.rolelist);
}
if (page == 1) {
// 查找自己的加入時間和職位 !統計人數
var joinTime;
for (let i in data.rolelist) {
if (data.rolelist[i].roleid == GameModel.player.roleid) {
joinTime = data.rolelist[i].jointime;
this.job = data.rolelist[i].hasOwnProperty("bangpost") ? data.rolelist[i].bangpost : 7
break;
}
}
if (this.job < 7)
GameModel.send('c2s_getbangrequest', {
roleid: GameModel.player.roleid,
bangid: GameModel.player.bangid
});
this.gangInfoData.info.joinTime = joinTime;
// 渲染幫派內政
this.refreshGangManage(this.gangInfoData.info);
}
}
/**
* 刷新幫派信息界面
*/
refreshGangInfo(info : any = []) {
this.gangRoleListData = info;
if (!SKUIUtil.isFGUIValid(this.gangInfoView)) return;
var list = FGUtil.getList(this.gangInfoView, "n10");
list.numItems = info.length;
}
/**
* 回到幫派
*/
backGang() {
if (GameModel.player.bangid == 0) {
MsgAlert.addMsg("你沒有幫派");
return;
}
let comMapLogic = cc.find('Canvas/MapUI').getComponent('GameMapLogic');
comMapLogic.changeMap(3002);
}
/**
* 打開修煉面板
*/
openPracticePanel() {
if (!SKUIUtil.isFGUIValid(this.practicePanel)) {
this.practicePanel = FGUtil.create("main_ui", "gang_practice_panel");
FGUtil.root().addChild(this.practicePanel);
this.practicePanel.makeFullScreen();
}
var mask = FGUtil.getComponent(this.practicePanel, "mask");
var close = FGUtil.getButton(this.practicePanel, "alert/close");
this.pushCloseEvent(mask, this.practicePanel, () => { this.practiceData = {} });
this.pushCloseEvent(close, this.practicePanel, () => { this.practiceData = {} });
var upGradeBtn = FGUtil.getButton(this.practicePanel, "alert/n58");
upGradeBtn.onClick(this.openUpGradePanel, this);
var cleanBtn = FGUtil.getButton(this.practicePanel, "alert/n33");
cleanBtn.onClick(this.porpertyCancel, this);
var submitBtn = FGUtil.getButton(this.practicePanel, "alert/n40");
submitBtn.onClick(this.porpertySure, this);
var resetBtn = FGUtil.getButton(this.practicePanel, "alert/n57");
resetBtn.onClick(this.porpertyReset, this);
this.initPracticeData();
this.registerPracticeBtnEvent();
}
porpertyReset() {
if (GameModel.player.gameData.money < GameUtil.resetXiulian) {
MsgAlert.addMsg(`銀兩不足,重置需要消耗${GameUtil.resetXiulian}銀兩!`);
return;
}
FGAlert.show(`消耗${GameUtil.resetXiulian}銀兩重置修煉點數?`, () => {
FGAlert.hide();
}, () => {
FGAlert.hide();
GameModel.send('c2s_xiulian_point', {
roleid: GameModel.player.roleid,
type: 0,
info: '{}'
});
FGUtil.getControl(this.practicePanel, "alert/type").selectedIndex = 0;
})
}
porpertyCancel() {
var data = this.practiceData
data.dpoint = SKDataUtil.clone(data.dpointBase);
data.dpointT = {};
this.initPracticeData();
FGUtil.getControl(this.practicePanel, "alert/type").selectedIndex = 0;
}
porpertySure() {
var data = this.practiceData;
for (const key in data.dpointT) {
if (SKDataUtil.hasProperty(data.dpointT, key)) {
const num = data.dpointT[key];
if (num < 0) {
return;
}
}
}
GameModel.send('c2s_xiulian_point', {
roleid: GameModel.player.roleid,
type: 1,
info: JSON.stringify(data.dpointT)
});
FGUtil.getControl(this.practicePanel, "alert/type").selectedIndex = 0;
}
initPracticeData() {
var data = this.practiceData;
data.dpoint = SKDataUtil.clone(GameModel.player.gameData.addattr1);
data.dpointBase = SKDataUtil.clone(data.dpoint);
data.attr1 = GameModel.player.gameData.attr1;
data.xlevel = GameModel.player.gameData.xiulevel;
data.leftpoint = data.xlevel;
for (const key in data.dpoint) {
if (SKDataUtil.hasProperty(data.dpoint, key)) {
data.leftpoint -= data.dpoint[key];
}
}
if (data.leftpoint < 0) {
data.leftpoint = 0;
}
data.dpointT = {};
data.dshangxian = data.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT];
data.dfengyin = data.attr1[EAttrTypeL1.K_SEAL];
data.dhunlun = data.attr1[EAttrTypeL1.K_CONFUSION];
data.dhunshui = data.attr1[EAttrTypeL1.K_SLEEP];
data.dyiwang = data.attr1[EAttrTypeL1.K_FORGET];
data.dfeng = data.attr1[EAttrTypeL1.K_WIND];
data.dlei = data.attr1[EAttrTypeL1.K_THUNDER];
data.dshui = data.attr1[EAttrTypeL1.K_WATER];
data.dhuo = data.attr1[EAttrTypeL1.K_FIRE];
data.dguihuo = data.attr1[EAttrTypeL1.K_WILDFIRE];
data.dsanshi = data.attr1[EAttrTypeL1.K_BLOODRETURN];
data.ddu = data.attr1[EAttrTypeL1.K_POISON];
data.pxishou = data.attr1[EAttrTypeL1.PHY_GET];
this.refreshPractice();
}
/**
* 刷新修煉顯示
*/
refreshPractice() {
if (!SKUIUtil.isFGUIValid(this.practicePanel)) {
console.warn("未找到面板");
return;
}
var data = this.practiceData;
FGUtil.getTextField(this.practicePanel, "alert/level").text = data.leftpoint.toString();
FGUtil.getTextField(this.practicePanel, "alert/n55").text = `修煉LV.${data.xlevel}`;
var box = FGUtil.getComponent(this.practicePanel, "alert/addBox");
FGUtil.getTextField(box, "k1/num").text = data.dshangxian.toFixed(1) + '%';
FGUtil.getTextField(box, "k1/add/title").text = (data.dpoint[EAttrTypeL1.K_SEAL] == null ? 0 : data.dpoint[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT]);
FGUtil.getTextField(box, "k2/num").text = data.dfengyin.toFixed(1) + '%';
FGUtil.getTextField(box, "k2/add/title").text = (data.dpoint[EAttrTypeL1.K_SEAL] == null ? 0 : data.dpoint[EAttrTypeL1.K_SEAL]);
FGUtil.getTextField(box, "k3/num").text = data.dhunlun.toFixed(1) + '%';
FGUtil.getTextField(box, "k3/add/title").text = (data.dpoint[EAttrTypeL1.K_CONFUSION] == null ? 0 : data.dpoint[EAttrTypeL1.K_CONFUSION]);
FGUtil.getTextField(box, "k4/num").text = data.dhunshui.toFixed(1) + '%';
FGUtil.getTextField(box, "k4/add/title").text = (data.dpoint[EAttrTypeL1.K_SLEEP] == null ? 0 : data.dpoint[EAttrTypeL1.K_SLEEP]);
FGUtil.getTextField(box, "k5/num").text = data.dyiwang.toFixed(1) + '%';
FGUtil.getTextField(box, "k5/add/title").text = (data.dpoint[EAttrTypeL1.K_FORGET] == null ? 0 : data.dpoint[EAttrTypeL1.K_FORGET]);
FGUtil.getTextField(box, "k6/num").text = data.dfeng.toFixed(1) + '%';
FGUtil.getTextField(box, "k6/add/title").text = (data.dpoint[EAttrTypeL1.K_WIND] == null ? 0 : data.dpoint[EAttrTypeL1.K_WIND]);
FGUtil.getTextField(box, "k7/num").text = data.dlei.toFixed(1) + '%';
FGUtil.getTextField(box, "k7/add/title").text = (data.dpoint[EAttrTypeL1.K_THUNDER] == null ? 0 : data.dpoint[EAttrTypeL1.K_THUNDER]);
FGUtil.getTextField(box, "k8/num").text = data.dshui.toFixed(1) + '%';
FGUtil.getTextField(box, "k8/add/title").text = (data.dpoint[EAttrTypeL1.K_WATER] == null ? 0 : data.dpoint[EAttrTypeL1.K_WATER]);
FGUtil.getTextField(box, "k9/num").text = data.dhuo.toFixed(1) + '%';
FGUtil.getTextField(box, "k9/add/title").text = (data.dpoint[EAttrTypeL1.K_FIRE] == null ? 0 : data.dpoint[EAttrTypeL1.K_FIRE]);
FGUtil.getTextField(box, "k10/num").text = data.dguihuo.toFixed(1) + '%';
FGUtil.getTextField(box, "k10/add/title").text = (data.dpoint[EAttrTypeL1.K_WILDFIRE] == null ? 0 : data.dpoint[EAttrTypeL1.K_WILDFIRE]);
FGUtil.getTextField(box, "k11/num").text = data.dsanshi.toFixed(1) + '%';
FGUtil.getTextField(box, "k11/add/title").text = (data.dpoint[EAttrTypeL1.K_BLOODRETURN] == null ? 0 : data.dpoint[EAttrTypeL1.K_BLOODRETURN]);
FGUtil.getTextField(box, "k12/num").text = data.ddu.toFixed(1) + '%';
FGUtil.getTextField(box, "k12/add/title").text = (data.dpoint[EAttrTypeL1.K_POISON] == null ? 0 : data.dpoint[EAttrTypeL1.K_POISON]);
FGUtil.getTextField(box, "k13/num").text = data.pxishou.toFixed(1) + '%';
FGUtil.getTextField(box, "k13/add/title").text = (data.dpoint[EAttrTypeL1.PHY_GET] == null ? 0 : data.dpoint[EAttrTypeL1.PHY_GET]);
}
registerPracticeBtnEvent() {
var box = FGUtil.getComponent(this.practicePanel, "alert/addBox");
this.setPracticeKangBtnFunc('1', EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT, box);
this.setPracticeKangBtnFunc('2', EAttrTypeL1.K_SEAL, box);
this.setPracticeKangBtnFunc('3', EAttrTypeL1.K_CONFUSION, box);
this.setPracticeKangBtnFunc('4', EAttrTypeL1.K_SLEEP, box);
this.setPracticeKangBtnFunc('5', EAttrTypeL1.K_FORGET, box);
this.setPracticeKangBtnFunc('6', EAttrTypeL1.K_WIND, box);
this.setPracticeKangBtnFunc('7', EAttrTypeL1.K_THUNDER, box);
this.setPracticeKangBtnFunc('8', EAttrTypeL1.K_WATER, box);
this.setPracticeKangBtnFunc('9', EAttrTypeL1.K_FIRE, box);
this.setPracticeKangBtnFunc('10', EAttrTypeL1.K_WILDFIRE, box);
this.setPracticeKangBtnFunc('11', EAttrTypeL1.K_BLOODRETURN, box);
this.setPracticeKangBtnFunc('12', EAttrTypeL1.K_POISON, box);
this.setPracticeKangBtnFunc('13', EAttrTypeL1.PHY_GET, box);
}
setPracticeKangBtnFunc(name : string, type : number, box : fairygui.GComponent) {
var subBtn = FGUtil.getButton(box, `k${name}/add/sub`);
var addBtn = FGUtil.getButton(box, `k${name}/add/add`);
addBtn.node["datainfo"] = type;
addBtn.node["opertype"] = 0;
subBtn.node["datainfo"] = type;
subBtn.node["opertype"] = 1;
addBtn.node.on(cc.Node.EventType.TOUCH_START, this.propertyBtnClick.bind(this));
addBtn.asButton.node.on(cc.Node.EventType.TOUCH_END, this.propertyBtnClick.bind(this));
subBtn.node.on(cc.Node.EventType.TOUCH_START, this.propertyBtnClick.bind(this));
subBtn.asButton.node.on(cc.Node.EventType.TOUCH_END, this.propertyBtnClick.bind(this));
}
propertyBtnClick(e) {
var data = this.practiceData;
data.addOrSubNumber = LongPressSpeedAttr.OPERAINITNUM;
if (e.type == cc.Node.EventType.TOUCH_START) {
data.maxtiemcnt = LongPressSpeedAttr.MAXTIMECNT;
data.timecnt = 0;
data.currentBtn = e.target;
}
else if (e.type == cc.Node.EventType.TOUCH_END || e.type == cc.Node.EventType.TOUCH_CANCEL) {
data.timecnt = data.maxtiemcnt;
this.update();
data.currentBtn = null;
}
}
update() {
if (this.practiceData.currentBtn == null) {
return;
}
var data = this.practiceData;
data.timecnt += LongPressSpeedAttr.TIMECNTADD;
if (data.timecnt >= data.maxtiemcnt) {
if (data.maxtiemcnt > LongPressSpeedAttr.MINTIMECNT) {
data.maxtiemcnt -= LongPressSpeedAttr.TIMECNTSUB;
data.maxtiemcnt = Math.max(LongPressSpeedAttr.MINTIMECNT, data.maxtiemcnt)
}
data.timecnt = 0;
if (data.currentBtn.opertype == 0) {
this.propertyAddPoint(data.currentBtn.datainfo);
}
else if (data.currentBtn.opertype == 1) {
this.propertySubPoint(data.currentBtn.datainfo);
}
data.addOrSubNumber += LongPressSpeedAttr.OPERADDNUM;
}
}
propertyAddPoint(num) {
var data = this.practiceData;
if (data.leftpoint <= 0) {
return;
}
if (data.dpointT[num] == null) {
data.dpointT[num] = 0;
}
data.dpointT[num]++;
data.dpoint[num]++;
this.calculateProperty();
}
propertySubPoint(num) {
var data = this.practiceData;
if (data.dpointT[num] == null || data.dpointT[num] <= 0) {
return;
}
data.dpointT[num]--;
data.dpoint[num]--;
this.calculateProperty();
}
calculateProperty() {
FGUtil.getControl(this.practicePanel, "alert/type").selectedIndex = 1;
var data = this.practiceData;
data.leftpoint = data.xlevel;
for (const key in data.dpoint) {
if (SKDataUtil.hasProperty(data.dpoint, key)) {
data.leftpoint -= data.dpoint[key];
}
}
if (data.leftpoint < 0) {
data.leftpoint = 0;
}
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT)) && (data.dshangxian = data.attr1[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] + data.dpointT[EAttrTypeL1.K_SEAL_CONFUSION_SLEEP_FORGET_LIMIT] * 2.5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_SEAL)) && (data.dfengyin = data.attr1[EAttrTypeL1.K_SEAL] + data.dpointT[EAttrTypeL1.K_SEAL] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_CONFUSION)) && (data.dhunlun = data.attr1[EAttrTypeL1.K_CONFUSION] + data.dpointT[EAttrTypeL1.K_CONFUSION] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_SLEEP)) && (data.dhunshui = data.attr1[EAttrTypeL1.K_SLEEP] + data.dpointT[EAttrTypeL1.K_SLEEP] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_FORGET)) && (data.dyiwang = data.attr1[EAttrTypeL1.K_FORGET] + data.dpointT[EAttrTypeL1.K_FORGET] * 5);
if (data.dfengyin > data.dshangxian) {
data.dfengyin = data.dshangxian;
}
if (data.dhunlun > data.dshangxian) {
data.dhunlun = data.dshangxian;
}
if (data.dhunshui > data.dshangxian) {
data.dhunshui = data.dshangxian;
}
if (data.dyiwang > data.dshangxian) {
data.dyiwang = data.dshangxian;
}
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_WIND)) && (data.dfeng = data.attr1[EAttrTypeL1.K_WIND] + data.dpointT[EAttrTypeL1.K_WIND] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_THUNDER)) && (data.dlei = data.attr1[EAttrTypeL1.K_THUNDER] + data.dpointT[EAttrTypeL1.K_THUNDER] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_WATER)) && (data.dshui = data.attr1[EAttrTypeL1.K_WATER] + data.dpointT[EAttrTypeL1.K_WATER] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_FIRE)) && (data.dhuo = data.attr1[EAttrTypeL1.K_FIRE] + data.dpointT[EAttrTypeL1.K_FIRE] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_WILDFIRE)) && (data.dguihuo = data.attr1[EAttrTypeL1.K_WILDFIRE] + data.dpointT[EAttrTypeL1.K_WILDFIRE] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_BLOODRETURN)) && (data.dsanshi = data.attr1[EAttrTypeL1.K_BLOODRETURN] + data.dpointT[EAttrTypeL1.K_BLOODRETURN] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.K_POISON)) && (data.ddu = data.attr1[EAttrTypeL1.K_POISON] + data.dpointT[EAttrTypeL1.K_POISON] * 5);
(data.dpointT.hasOwnProperty(EAttrTypeL1.PHY_GET)) && (data.pxishou = data.attr1[EAttrTypeL1.PHY_GET] + data.dpointT[EAttrTypeL1.PHY_GET] * 4);
this.refreshPractice();
}
/**
* 天演臨時函數
*/
tianYanFunc() {
FGUtil.dispose(this.gangPanel);
this.gangPanel = null;
this.closeAllView();
FactionTalent.Instance.openFactionTalentPanel();
}
openUpGradePanel() {
if (!SKUIUtil.isFGUIValid(this.practiceUpGradePanel)) {
this.practiceUpGradePanel = FGUtil.create("main_ui", "gang_practice_up_panel");
FGUtil.root().addChild(this.practiceUpGradePanel);
this.practiceUpGradePanel.makeFullScreen();
}
var mask = FGUtil.getComponent(this.practiceUpGradePanel, "mask");
var close = FGUtil.getButton(this.practiceUpGradePanel, "alert/close");
this.pushCloseEvent(mask, this.practiceUpGradePanel);
this.pushCloseEvent(close, this.practiceUpGradePanel);
FGUtil.getButton(this.practiceUpGradePanel, "alert/n40").onClick(this.upgradeBtnClicked, this);
this.refreshUpPracticeGrade();
}
refreshUpPracticeGrade() {
if (!SKUIUtil.isFGUIValid(this.practiceUpGradePanel)) {
console.warn("未找到面板");
return;
}
var levelBar = FGUtil.getProgressBar(this.practiceUpGradePanel, "alert/n58");
levelBar.max = PracticeMgr.GetMaxPriactiveLevel(GameModel.player.relive);
levelBar.value = GameModel.player.gameData.xiulevel;
FGUtil.getTextField(levelBar, "title").fontSize = 20;
FGUtil.getTextField(this.practiceUpGradePanel, "alert/n81").text = PracticeMgr.GetUpdateYinLiang(GameModel.player.gameData.xiulevel);
FGUtil.getTextField(this.practiceUpGradePanel, "alert/n80").text = GameModel.player.gameData.bangscore;
}
upgradeBtnClicked() {
if (GameModel.player.gameData.bangscore <= PracticeMgr.GetUpdateYinLiang(GameModel.player.gameData.xiulevel)) {
MsgAlert.addMsg("幫貢不足");
return;
}
GameModel.send('c2s_xiulian_upgrade', {
roleid: GameModel.player.roleid,
score: PracticeMgr.GetUpdateYinLiang(GameModel.player.gameData.xiulevel)
});
}
/**
* 顯示幫派列表
*/
showGangList() {
FGUtil.dispose(this.gangPanel);
this.gangPanel = null;
this.closeAllView();
this.openGangListPanel(true);
}
/**
* 刷新幫派內政界面
*/
refreshGangManage(info : any = null) {
if (!SKUIUtil.isFGUIValid(this.gangManageView)) return;
if (info == null) return;
// FGUtil.getControl(this.gangManageView, "type").selectedIndex = info.masterid == GameModel.player.roleid ? 0 : 1
FGUtil.getControl(this.gangManageView, "type").selectedIndex = 0
FGUtil.getTextField(this.gangManageView, "gang_id").text = info.bangid.toString();
FGUtil.getTextField(this.gangManageView, "gang_level").text = `${info.banglevel}`;
FGUtil.getTextField(this.gangManageView, "gang_master").text = info.mastername;
FGUtil.getTextField(this.gangManageView, "gang_wei").text = `${info.cost}/天`;
FGUtil.getTextField(this.gangManageView, "gang_active").text = info.brisk;
var createTimeStr = new Date(info.createtime);
FGUtil.getTextField(this.gangManageView, "gang_create_time").text = createTimeStr.getFullYear() + '/' + (createTimeStr.getMonth() + 1) + '/' + createTimeStr.getDate();
var t = new Date(info.joinTime);
// 小時
var m = Math.floor((new Date().getTime() - t.getTime()) / 1000 / 60 / 60);
var day = Math.floor(m / 24)
FGUtil.getTextField(this.gangManageView, "gang_join_time").text = `${day <= 0 ? '' : day + '天'}${m % 24}小時`;
FGUtil.getRichTextField(this.gangManageView, "gang_num").text = info.rolenum.toString();
var expBar = FGUtil.getProgressBar(this.gangManageView, "n53");
expBar.max = info.upexp;
expBar.value = info.bangexp;
FGUtil.getTextField(expBar, "title").fontSize = 20;
if (info.bangexp >= info.upexp) {
FGUtil.getControl(this.gangManageView, "upBuild").selectedIndex = 1;
} else {
FGUtil.getControl(this.gangManageView, "upBuild").selectedIndex = 0;
}
FGUtil.getButton(this.gangManageView, "upLevel").onClick(this.upGangLevel, this);
}
refreshGangRequest(info : any = []) {
this.requireListData = info;
if (!SKUIUtil.isFGUIValid(this.gangManageView)) return;
if (this.requireListData.length != 0)
FGUtil.getControl(this.gangManageView, "apply").selectedIndex = 1;
var requireList = FGUtil.getList(this.gangManageView, "applyList");
requireList.numItems = this.requireListData.length;
}
showGangEvent() {
if (!SKUIUtil.isFGUIValid(this.gangManageView)) return;
FGUtil.getControl(this.gangManageView, "showList").selectedIndex = 0;
FGUtil.getRichTextField(this.gangManageView, "tip").text = "暫無事件";
}
showRequestList() {
if (!SKUIUtil.isFGUIValid(this.gangManageView)) return;
FGUtil.getControl(this.gangManageView, "apply").selectedIndex = 0;
FGUtil.getControl(this.gangManageView, "showList").selectedIndex = 1;
if (this.requireListData.length == 0)
FGUtil.getRichTextField(this.gangManageView, "tip").text = "沒有申請人";
else
FGUtil.getRichTextField(this.gangManageView, "tip").text = "";
}
upGangLevel() {
GameModel.send('c2s_bang_up', {
roleid: GameModel.player.roleid
});
}
/**
*
* @param type 1是宗旨 2是公告
* @returns
*/
openNoticePanel(type : number = 1) {
if (!this.isMaster) {
MsgAlert.addMsg("只有幫主才能修改!");
return;
}
if (!SKUIUtil.isFGUIValid(this.noticePanel)) {
this.noticePanel = FGUtil.create("main_ui", "gang_notice_panel");
FGUtil.getControl(this.noticePanel, "alert/no").selectedIndex = 1;
if (type == 1) {
FGUtil.getTextField(this.noticePanel, "alert/n32").text = "發送的宗旨所有人都可以看到噢~";
FGUtil.getTextField(this.noticePanel, "alert/tip").text = "宗旨內容";
FGUtil.getTextField(this.noticePanel, "alert/title/title").text = "幫派宗旨";
}
FGUtil.root().addChild(this.noticePanel);
this.noticePanel.makeFullScreen();
}
var mask = FGUtil.getComponent(this.noticePanel, "mask");
var close = FGUtil.getButton(this.noticePanel, "alert/close");
this.pushCloseEvent(mask, this.noticePanel);
this.pushCloseEvent(close, this.noticePanel);
if (type == 1)
FGUtil.getButton(this.noticePanel, "alert/change").onClick(this.changeAim, this);
if (type == 2)
FGUtil.getButton(this.noticePanel, "alert/change").onClick(this.changeNotice, this);
}
changeAim() {
if (!SKUIUtil.isFGUIValid(this.noticePanel)) return;
var content = FGUtil.getTextInput(this.noticePanel, "alert/edit").text
if (content == "") {
MsgAlert.addMsg("請輸入內容");
return;
}
GameModel.send("c2s_issue_affiche", {
roleid: GameModel.player.roleid,
type: 1,
content: content
})
FGUtil.dispose(this.noticePanel);
this.noticePanel = null;
}
changeNotice() {
if (!SKUIUtil.isFGUIValid(this.noticePanel)) return;
var content = FGUtil.getTextInput(this.noticePanel, "alert/edit").text
if (content == "") {
MsgAlert.addMsg("請輸入內容");
return;
}
GameModel.send("c2s_issue_affiche", {
roleid: GameModel.player.roleid,
type: 2,
content: content
})
FGUtil.dispose(this.noticePanel);
this.noticePanel = null;
}
/**
* 添加關閉事件
*/
pushCloseEvent(item : fairygui.GComponent, target : fairygui.GComponent, call : Function = null) {
item.clearClick();
item.onClick(() => {
call && call()
FGUtil.dispose(target);
target = null;
}, this)
}
}