SamsaraGame/assets/Script/ts/RoleMenuAlert.ts
2025-04-24 17:03:28 +08:00

216 lines
5.7 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import FGUtil from "./gear_2.3.4/fgui/FGUtil";
import GameUtil from "./core/GameUtil";
import SKDataUtil from "./gear_2.3.4/util/SKDataUtil";
import SkillUtil from "./game/skill/core/SkillUtil";
import GameModel from "./core/GameModel";
import FGAlert from "./gear_2.3.4/fgui/FGAlert";
import { BattleType } from "./game/battle/Battle";
import MsgAlert from "./game/msg/MsgAlert";
import { HeadBorderUtil } from "./appearance/HeadBorderUtil";
export default class RoleInfoAlert {
private static Instance = new RoleInfoAlert();
main : fgui.GComponent;
static pInfo : any = null;
static show(info : any, isChat : boolean = false) {
this.Instance.show(info, isChat);
}
static menuList = [
"決 殺",
"戰 鬥",
"切 磋",
"聊 天",
"好友空間",
"加入隊伍",
"邀請入隊",
"添加好友",
"拜訪家園",
"邀請入幫",
"拜 師",
"邀請固定隊",
"加入黑名單",
"舉 報",
]
show(info : any, isChat : boolean = false) {
if (GameModel.player.getLogic().isBing) {
MsgAlert.addMsg("冰凍中,不可進行操作")
return
}
if (GameModel.player.mapid == 1213) {
return
}
RoleInfoAlert.pInfo = info
FGUtil.dispose(this.main);
this.main = FGUtil.create("main_ui", "playerMenu_panel");
let alert = FGUtil.getComponent(this.main, "alert");
FGUtil.getComponent(this.main, "mask").onClick(this.hide, this);
FGUtil.getLoader(alert, "head").texture = GameModel.getRoleHead(info.resid);
var headid = info.portrait;
headid = headid ? headid : 0;
this.setHeadBorder(headid);
FGUtil.getTextField(alert, "level").text = info.level;
FGUtil.getTextField(alert, "id").text = `編號${info.roleid}`;
FGUtil.getTextField(alert, "name").text = info.name;
if (info.bangname)
FGUtil.getTextField(alert, "gang").text = `幫派:${info.bangname}`;
else
FGUtil.getTextField(alert, "gang").text = "";
let list = FGUtil.getList(alert, "list");
list.removeChildren();
for (let i in RoleInfoAlert.menuList) {
var word = RoleInfoAlert.menuList[i];
if (isChat && word == "決 殺") {
continue;
}
if (isChat && word == "切 磋") {
continue;
}
if (word != "決 殺" && GameModel.player.mapid == 4004) {
continue;
}
if (word == "決 殺" && GameModel.player.mapid != 4004) {
continue;
}
if (GameModel.player.mapid == 3001 && (word != "戰 鬥" && word != "加入隊伍" && word != "邀請入隊")) {
continue;
}
if (word == "戰 鬥" && GameModel.player.mapid != 3001) {
continue;
}
if (word == "戰 鬥" && GameModel.player.bangname == info.bangname) {
continue;
}
if (word == "加入隊伍") {
if (GameModel.player.teamid > 0 || info.teamid <= 0)
continue;
if (GameModel.player.mapid == 3001 && GameModel.player.bangname != info.bangname) {
continue;
}
}
if (word == "邀請入隊") {
if (!GameModel.player.isleader || GameModel.player.teamid == 0)
continue;
if (GameModel.player.mapid == 3001 && GameModel.player.bangname != info.bangname) {
continue;
}
}
var item = list.addItem().asCom;
FGUtil.getTextField(item, "title").text = word;
item.node["wordType"] = word;
item.onClick(this.clickMenu, this)
}
FGUtil.root().addChild(this.main);
this.main.makeFullScreen();
}
static hide() {
this.Instance.hide();
}
hide() {
FGUtil.dispose(this.main);
this.main = null;
}
clickMenu(e : Event) {
if (!SKDataUtil.hasProperty(e.target, "wordType")) return;
var word = e.target["wordType"]
if (word == "決 殺") {
let teamId = RoleInfoAlert.pInfo.teamid;
GameModel.notice.addMsg(1, '是否發起決殺? ', () => {
GameModel.send('c2s_sat_challenge', {
rivalTeamId: teamId
});
RoleInfoAlert.hide();
}, () => { });
}
else if (word == "戰 鬥") {
let roleId = RoleInfoAlert.pInfo.roleid;
GameModel.send('c2s_faction_combat', {
enemyRoleId: roleId
});
RoleInfoAlert.hide();
}
else if (word == "切 磋") {
let roleId = RoleInfoAlert.pInfo.roleid;
FGAlert.show(`一定要和他拼個你死我活嗎?\n[color=#ff0000]野外決鬥每擊敗一個玩家被抓捕後將失去30分鐘自由遊戲時間決鬥死亡將會扣除2億經驗是否繼續[/color]`, () => {
FGAlert.hide();
}, () => {
FGAlert.hide();
RoleInfoAlert.hide();
GameModel.send('c2s_pk', {
troleid: roleId,
type: BattleType.Force
});
});
}
else if (word == "加入隊伍") {
GameModel.send('c2s_requst_team', {
roleid: GameModel.player.roleid,
teamid: RoleInfoAlert.pInfo.teamid
});
RoleInfoAlert.hide();
}
else if (word == "邀請入隊") {
GameModel.send('c2s_team_invite', {
toroleid: RoleInfoAlert.pInfo.roleid,
});
RoleInfoAlert.hide();
}
else if (word == "添加好友") {
GameModel.send('c2s_add_friend', {
roleid: RoleInfoAlert.pInfo.roleid
});
RoleInfoAlert.hide();
}
else {
MsgAlert.addMsg("暫未開放")
}
}
setHeadBorder(headBorderId) {
var borderCom = FGUtil.getComponent(this.main, "alert/border");
var data = HeadBorderUtil.getBorderData(headBorderId);
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;
}
}