| | |
| | | using System;
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
| | | {
|
| | | // 申请的公会列表
|
| | | private List<int> m_FairyRequesteds = new List<int>();
|
| | | // 公会附加数据,按类型存储
|
| | | // 公会自定义记录附加数据,按类型存储
|
| | | // 公会ID, 类型ID, 数据
|
| | | public Dictionary<int, Dictionary<int, HA513_tagMCFamilyActionInfo.tagMCFamilyAction[]>> familyActions = new Dictionary<int, Dictionary<int, HA513_tagMCFamilyActionInfo.tagMCFamilyAction[]>>();
|
| | | public event Action<int, int> FamilyActionInfoEvent;
|
| | | public event Action<int, int> FamilyActionInfoEvent; //公会自定义记录, 其他功能从这获取
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | |
| | | {
|
| | | m_FairyRequesteds.Clear();
|
| | | familyActions.Clear();
|
| | | guildChanged = false;
|
| | | applyList.Clear();
|
| | | PlayerDatas.Instance.fairyData.ClearData();
|
| | | }
|
| | |
|
| | |
|
| | |
| | | familyActions.Clear();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | #region 发包
|
| | | public void SendKickFairy(uint playerID)
|
| | | {
|
| | | var pak = new CA605_tagCMDeleteFamilyMember();
|
| | | pak.MemberID = playerID;
|
| | | GameNetSystem.Instance.SendInfo(pak);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | //申请/撤销 加入公会
|
| | | public void SendApplyFairy(uint id, int type)
|
| | | {
|
| | | if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Fairy, true))
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (PlayerDatas.Instance.fairyData.HasFairy)
|
| | | {
|
| | | ServerTipDetails.DisplayNormalTip(Language.Get("HasFairyTip"));
|
| | | return;
|
| | | }
|
| | | CA602_tagCMRequesJoinFamily rqPack = new CA602_tagCMRequesJoinFamily();
|
| | | rqPack.Type = (byte)type;
|
| | | rqPack.TagFamilyID = id;
|
| | | GameNetSystem.Instance.SendInfo(rqPack);
|
| | | }
|
| | | #endregion
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
| | | // 职位: 0-成员,1-精英,2-副盟主,3-盟主
|
| | | public Dictionary<int, int> guildWorkToLevel = new Dictionary<int, int>();
|
| | |
|
| | | //退出惩罚
|
| | | public int[] quitGuildPunishTime;
|
| | | public int[] beQuitGuildPunishTime;
|
| | | public int quitGuildPunishMoneyType;
|
| | | public int[] quitGuildPunishMoney;
|
| | | public int[] beQuitGuildPunishMoney;
|
| | |
|
| | | //改名
|
| | | public int renameFairyNameCD;
|
| | | public int renameFairyNameCost;
|
| | | public int renameFairyNameMoneyType;
|
| | |
|
| | | void ParseConfig()
|
| | | {
|
| | | var config = FuncConfigConfig.Get("CreateFamily");
|
| | |
| | | config = FuncConfigConfig.Get("FamilyPower");
|
| | | guildWorkToLevel = ConfigParse.ParseIntDict(config.Numerical1);
|
| | |
|
| | | config = FuncConfigConfig.Get("FamilyLeave");
|
| | | quitGuildPunishTime = JsonMapper.ToObject<int[]>(config.Numerical1);
|
| | | beQuitGuildPunishTime = JsonMapper.ToObject<int[]>(config.Numerical2);
|
| | | quitGuildPunishMoneyType = int.Parse(config.Numerical3);
|
| | | quitGuildPunishMoney = JsonMapper.ToObject<int[]>(config.Numerical4);
|
| | | beQuitGuildPunishMoney = JsonMapper.ToObject<int[]>(config.Numerical5);
|
| | |
|
| | | config = FuncConfigConfig.Get("FamilyRename");
|
| | | renameFairyNameCD = int.Parse(config.Numerical2);
|
| | | var arr = ConfigParse.GetMultipleStr<int>(config.Numerical1);
|
| | | renameFairyNameCost = arr[0];
|
| | | renameFairyNameMoneyType = arr[1];
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | |
|
| | |
|
| | | //我的请求加入公会的列表
|
| | | public event Action MyRequestJoinEvent;
|
| | | public void UpdateFairyRequested(HA501_tagMCNotifyRequestJoinFamilyInfo _package)
|
| | | {
|
| | | m_FairyRequesteds.Clear();
|
| | |
| | | {
|
| | | m_FairyRequesteds.Add((int)_package.RequestJoinFamilyIDList[i]);
|
| | | }
|
| | | MyRequestJoinEvent?.Invoke();
|
| | | }
|
| | |
|
| | |
|
| | | public bool FairyRequested(int _fairyId)
|
| | | public bool IsGuildRequested(int _fairyId)
|
| | | {
|
| | | return m_FairyRequesteds.Contains(_fairyId);
|
| | | }
|
| | |
| | |
|
| | |
|
| | |
|
| | | #region 仙盟名限制
|
| | | #region 创建公会 改名
|
| | | public bool CheckFairyNameLimit(string _name, out int errorCode)
|
| | | {
|
| | | errorCode = 0;
|
| | |
| | | errorCode = 1;
|
| | | return false;
|
| | | }
|
| | | if (UIHelper.IsNumeric(_name))
|
| | | {
|
| | | errorCode = 2;
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | switch (_errorCode)
|
| | | {
|
| | | case 0:
|
| | | //空
|
| | | SysNotifyMgr.Instance.ShowTip("FamilyNameChangeNoNull");
|
| | | break;
|
| | | case 1:
|
| | | SysNotifyMgr.Instance.ShowTip("FamilyNameChangeUnlegal");
|
| | | // 脏字
|
| | | SysNotifyMgr.Instance.ShowTip("NameSensitive");
|
| | | break;
|
| | | case 2:
|
| | | // 不能纯数字
|
| | | SysNotifyMgr.Instance.ShowTip("NameError3");
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | });
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | int GetJoinCD()
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.leaveFamilyTime == 0)
|
| | | return 0;
|
| | | var quitType = PlayerDatas.Instance.baseData.leaveGuildInfo % 10;
|
| | | int quitCount = 0;
|
| | | int punishTime = 0;
|
| | | if (quitType == 0)
|
| | | {
|
| | | //被踢
|
| | | quitCount = PlayerDatas.Instance.baseData.leaveGuildInfo / 10 % 10;
|
| | | if (beQuitGuildPunishTime.Length != 0)
|
| | | punishTime = beQuitGuildPunishTime[Math.Min(quitCount, beQuitGuildPunishTime.Length - 1)];
|
| | | }
|
| | | else if (quitType == 1)
|
| | | {
|
| | | //主动退出
|
| | | quitCount = PlayerDatas.Instance.baseData.leaveGuildInfo / 100;
|
| | | if (quitGuildPunishTime.Length != 0)
|
| | | punishTime = quitGuildPunishTime[Math.Min(quitCount, quitGuildPunishTime.Length - 1)];
|
| | | }
|
| | |
|
| | | return TimeUtility.AllSeconds - PlayerDatas.Instance.baseData.leaveFamilyTime - punishTime * 60;
|
| | | }
|
| | |
|
| | |
|
| | | // 创建公会
|
| | | public void CreateGuild(string name, int emblemID, string emblemWord)
|
| | | {
|
| | | var cdSeconds = GetJoinCD();
|
| | | if (cdSeconds > 0)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GuildSys4", TimeUtility.SecondsToHMSEx(cdSeconds));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!UIHelper.CheckMoneyCount(createMoneyType, createFairyCost, 2))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (emblemWord.Length > 1)
|
| | | {
|
| | | //预制体输入框限制,不限任意字符都只能输入1个字
|
| | | return;
|
| | | }
|
| | |
|
| | | int error;
|
| | |
|
| | | //获取name的字节长度,name可能是中文 或者其他占用3个字符的符号
|
| | | if (!UIHelper.SatisfyNameLength(name, out error))
|
| | | {
|
| | | // TODO 暂时按中文长度提示, 不同语言可根据情况修改
|
| | | if (error == 1)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("NameError2", 7);
|
| | | return;
|
| | | }
|
| | | else if (error == 2)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("NameError1", 2);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!CheckFairyNameLimit(name, out error))
|
| | | {
|
| | | ShowFairyNameErrorTip(error);
|
| | | return;
|
| | | }
|
| | |
|
| | | var pack = new CA604_tagCMCreateFamily();
|
| | | pack.Name = name;
|
| | | pack.EmblemID = (ushort)emblemID;
|
| | | pack.EmblemWord = emblemWord;
|
| | | GameNetSystem.Instance.SendInfo(pack);
|
| | |
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | |
|
| | |
|
| | |
|
| | |
|
| | | // 公会自定义记录
|
| | | public void UpdateFamilyAction(HA513_tagMCFamilyActionInfo _package)
|
| | | {
|
| | |
|
| | |
| | | }
|
| | | var pack = new CA620_tagCMViewFamilyPage();
|
| | |
|
| | | if (!string.IsNullOrEmpty(msg) && UIHelper.IsNumeric(msg))
|
| | | {
|
| | | msg = DecryptGuildID(msg);
|
| | | }
|
| | |
|
| | | pack.Msg = msg;
|
| | | pack.MsgLen = (byte)msg.Length;
|
| | | pack.PageIndex = (byte)pageIndex;
|
| | |
| | | public static void SetFairyViewData(FairyData data, HA523_tagMCFamilyViewList.tagMCFamilyView view)
|
| | | {
|
| | | data.Rank = view.Rank;
|
| | | data.FamilyID = view.FamilyID;
|
| | | data.FamilyID = (int)view.FamilyID;
|
| | | data.FamilyName = view.FamilyName;
|
| | | data.LeaderID = view.LeaderID;
|
| | | data.LeaderID = (int)view.LeaderID;
|
| | | data.LeaderName = view.LeaderName;
|
| | | data.FamilyLV = view.FamilyLV;
|
| | | data.JoinReview = view.JoinReview;
|
| | | data.JoinLVMin = view.JoinLVMin;
|
| | | data.ServerID = view.ServerID;
|
| | | data.EmblemID = view.EmblemID;
|
| | | data.ServerID = (int)view.ServerID;
|
| | | data.EmblemID = (int)view.EmblemID;
|
| | | data.EmblemWord = view.EmblemWord;
|
| | | data.totalFightPower = view.FightPowerEx * Constants.ExpPointValue + view.FightPower;
|
| | | data.MemberCount = view.MemberCount;
|
| | |
| | | {
|
| | | FairyApply apply = new FairyApply();
|
| | | apply.Name = vNetData.ReqJoinList[i].Name;
|
| | | apply.PlayerID = vNetData.ReqJoinList[i].PlayerID;
|
| | | apply.ReqTime = vNetData.ReqJoinList[i].ReqTime;
|
| | | apply.PlayerID = (int)vNetData.ReqJoinList[i].PlayerID;
|
| | | apply.ReqTime = (int)vNetData.ReqJoinList[i].ReqTime;
|
| | | apply.LV = vNetData.ReqJoinList[i].LV;
|
| | | apply.Job = vNetData.ReqJoinList[i].Job;
|
| | | apply.RealmLV = vNetData.ReqJoinList[i].RealmLV;
|
| | | apply.Face = vNetData.ReqJoinList[i].Face;
|
| | | apply.FacePic = vNetData.ReqJoinList[i].FacePic;
|
| | | apply.TitleID = vNetData.ReqJoinList[i].TitleID;
|
| | | apply.Face = (int)vNetData.ReqJoinList[i].Face;
|
| | | apply.FacePic = (int)vNetData.ReqJoinList[i].FacePic;
|
| | | apply.TitleID = (int)vNetData.ReqJoinList[i].TitleID;
|
| | | apply.FightPower = vNetData.ReqJoinList[i].FightPower + vNetData.ReqJoinList[i].FightPowerEx * Constants.ExpPointValue;
|
| | | apply.ServerID = vNetData.ReqJoinList[i].ServerID;
|
| | | apply.ServerID = (int)vNetData.ReqJoinList[i].ServerID;
|
| | | apply.IsOnLine = vNetData.ReqJoinList[i].IsOnLine;
|
| | | applyList.Add(apply);
|
| | | }
|
| | |
| | | {
|
| | | return applyList;
|
| | | }
|
| | |
|
| | | //type 0申请/1撤销 加入公会
|
| | | //id 0 代表一键加入
|
| | | public void SendApplyGuild(int id, int type)
|
| | | {
|
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Fairy, true))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (PlayerDatas.Instance.fairyData.HasFairy)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_85890");
|
| | | return;
|
| | | }
|
| | |
|
| | | if (type == 0)
|
| | | {
|
| | | var cdSeconds = GetJoinCD();
|
| | | if (cdSeconds > 0)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GuildSys2", TimeUtility.SecondsToHMSEx(cdSeconds));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (id != 0 && guildsDict.ContainsKey(id))
|
| | | {
|
| | | if (guildsDict[id].MemberCount >= FamilyConfig.Get(guildsDict[id].FamilyLV).MemberMax)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("jiazu_lhs_202580");
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | CA602_tagCMRequesJoinFamily rqPack = new CA602_tagCMRequesJoinFamily();
|
| | | rqPack.Type = (byte)type;
|
| | | rqPack.TagFamilyID = (uint)id;
|
| | | GameNetSystem.Instance.SendInfo(rqPack);
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | //0 加入,1 申请 2 已申请
|
| | | public int GetRequestState(FairyData guildInfo)
|
| | | {
|
| | | if (IsGuildRequested(guildInfo.FamilyID))
|
| | | {
|
| | | return 2;
|
| | | }
|
| | |
|
| | | if (guildInfo.JoinReview != 0)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | |
|
| | | public bool guildChanged = false;
|
| | | //公会数据变化,请求新的公会信息,如在打开公会列表时请求,其他功能根据自身情况请求
|
| | | public void UpdateGuildDataChangeMark(HA521_tagMCFamilyChange netPack)
|
| | | {
|
| | | if (netPack.Type > 0)
|
| | | {
|
| | | guildChanged = true;
|
| | | }
|
| | | }
|
| | |
|
| | | public void RequestGuildData()
|
| | | {
|
| | | if (guildChanged)
|
| | | {
|
| | | guildChanged = false;
|
| | | var pack = new CA626_tagCMGetFamilyInfo();
|
| | | GameNetSystem.Instance.SendInfo(pack);
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | public void SendKickFairy(uint playerID)
|
| | | {
|
| | | var pak = new CA605_tagCMDeleteFamilyMember();
|
| | | pak.MemberID = playerID;
|
| | | GameNetSystem.Instance.SendInfo(pak);
|
| | | }
|
| | |
|
| | |
|
| | | #region 加密数字
|
| | |
|
| | | //1. 将数字补充到10位,不足补0
|
| | | //2. 将每个位的数字结合索引 映射到映射表中
|
| | | //3. 将映射后的数字拼接成字符串
|
| | | //4. 另外一个解密函数,将字符串还原成数字
|
| | |
|
| | | int[] map = { 5, 2, 9, 1, 8, 3, 7, 0, 6, 4 };
|
| | | int[] reverseMap;
|
| | |
|
| | | public string EncryptGuildID(int num)
|
| | | {
|
| | | if (num < 0)
|
| | | {
|
| | | Debug.LogError("Invalid number: " + num);
|
| | | return "";
|
| | | }
|
| | |
|
| | | string str = num.ToString().PadLeft(10, '0');
|
| | | StringBuilder result = new StringBuilder();
|
| | |
|
| | | for (int i = 0; i < str.Length; i++)
|
| | | {
|
| | | int digit = int.Parse(str[i].ToString());
|
| | | int encryptedDigit = map[(digit + i) % 10]; // 结合位置查表
|
| | | result.Append(encryptedDigit);
|
| | | }
|
| | | return "6" + result.ToString();
|
| | | }
|
| | |
|
| | | public string DecryptGuildID(string encryptedStr)
|
| | | {
|
| | | if (string.IsNullOrEmpty(encryptedStr) || encryptedStr.Length != 11)
|
| | | {
|
| | | // Debug.LogError("Invalid encrypted string: " + encryptedStr);
|
| | | SysNotifyMgr.Instance.ShowTip("GuildSys6");
|
| | | return "";
|
| | | }
|
| | | |
| | | encryptedStr = encryptedStr.Substring(1);
|
| | |
|
| | | if (reverseMap.IsNullOrEmpty())
|
| | | {
|
| | | reverseMap = new int[10];
|
| | | reverseMap = GenerateReverseMap(map);
|
| | | }
|
| | | StringBuilder originalStr = new StringBuilder();
|
| | |
|
| | | for (int i = 0; i < encryptedStr.Length; i++)
|
| | | {
|
| | | int encryptedDigit = int.Parse(encryptedStr[i].ToString());
|
| | | int originalDigit = (reverseMap[encryptedDigit] - i + 10) % 10; // 反向查表并调整位置
|
| | | originalStr.Append(originalDigit);
|
| | | }
|
| | | return originalStr.ToString().TrimStart('0'); // 去除前导零
|
| | | }
|
| | | |
| | | |
| | | int[] GenerateReverseMap(int[] map)
|
| | | {
|
| | | for (int i = 0; i < map.Length; i++)
|
| | | {
|
| | | reverseMap[map[i]] = i; // 反向映射:map[i] -> i
|
| | | }
|
| | | return reverseMap;
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | | } |