Files
JJBB/Assets/Project/Script/Obj/MainPlayer/Obj_MainPlayer_Guild.cs
2024-08-23 15:49:34 +08:00

639 lines
24 KiB
C#
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.

/********************************************************************************
* 文件名: Obj_MainPlayer_Guild.cs
* 全路径: \Script\Obj\Obj_MainPlayer_Guild.cs
* 创建人: 李嘉
* 创建时间2014-04-22
*
* 功能说明游戏主角Obj的帮会逻辑部分
* 修改记录:
*********************************************************************************/
using UnityEngine;
using System.Collections;
using Games.LogicObj;
using System;
using Games.GlobeDefine;
using GCGame.Table;
using Games.Mission;
using Games.ChatHistory;
namespace Games.LogicObj
{
public partial class Obj_MainPlayer : Obj_OtherPlayer
{
//玩家的帮会相关标记位,做到申请过一次之后可以保存结果一段时间,减少网络流量
// private bool m_bNeedRequestGuildInfo = true; //是否需要请求个人帮会信息
// public bool NeedRequestGuildInfo
// {
// get { return m_bNeedRequestGuildInfo; }
// set { m_bNeedRequestGuildInfo = value; }
// }
// private bool m_bNeedRequestGuildList = true; //是否需要请求全服帮会列表
// public bool NeedRequestGuildList
// {
// get { return m_bNeedRequestGuildList; }
// set { m_bNeedRequestGuildList = value; }
// }
private bool m_bShowGuildNewReserveFlag = false; //是否显示新审批成员标志
public bool ShowGuildNewReserveFlag
{
get { return m_bShowGuildNewReserveFlag; }
set { m_bShowGuildNewReserveFlag = value; }
}
//更新帮会相关标记位
//private const int c_GuildRequestCoolDown = 30; //帮会信息更新间隔,包括帮会列表和帮会信息
private UInt64 m_CacheChangeMasterGuid = GlobeVar.INVALID_GUID; //缓存待禅让目标会员Guid
private UInt64 m_CacheKickMemberGuid = GlobeVar.INVALID_GUID; //缓存待踢出目标会员Guid
private UInt64 m_CacheJoinGuildGuid = GlobeVar.INVALID_GUID; //缓存待申请目标帮会Guid
private UInt64 m_CacheRespondGuildGuid = GlobeVar.INVALID_GUID; //缓存待响应目标帮会Guid
private int m_CacheReqLevelUpType = -1000; //缓存升级的建筑的类型
private bool m_CacheCancelJoinGuild = false; //缓存是否取消申请
//申请全服帮会列表
public void ReqGuildList(int respondType) //0帮会列表 1响应列表
{
CG_GUILD_REQ_LIST msg = (CG_GUILD_REQ_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_LIST);
msg.IsRespond = respondType;
msg.SendPacket();
}
//申请帮会信息
public void ReqGuildInfo(int infoType) //1帮会基础信息 2帮会成员列表 3帮会申请列表
{
CG_GUILD_REQ_INFO msg = (CG_GUILD_REQ_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_INFO);
msg.SetReqType( infoType);
msg.SendPacket();
}
public bool CreateLevelisOK(int level)
{
Tab_GuildOther other = TableManager.GetGuildOtherByID(0, 0);
return (other != null && level >= other.CreateNeedLevel);
}
//申请创建帮会
public void ReqCreateGuild(string guildName,string notice)
{
//if (notice.Length <= 0)
//{
// SendNoticMsg(false, "#{25119}");
// return;
//}
int lenName = GCGame.Utils.StrCharLength(guildName);
//int lenNotic = GCGame.Utils.StrCharLength(notice);
if (lenName > GlobeVar.MAX_GUILD_NAME || lenName < GlobeVar.MIN_GUILD_NAME)
{
SendNoticMsg(false, "#{25120}");
return;
}
//if (lenNotic > GlobeVar.MAX_GUILD_NOTICE || lenNotic < GlobeVar.MIN_GUILD_NOTICE)
//{
// SendNoticMsg(false, "#{25121}");
// return;
//}
//玩家等级判断
if (CreateLevelisOK(BaseAttr.Level)==false)
{
SendNoticMsg(false, "#{1771}"); //你的人物等级不足40级无法创建帮会
return;
}
//有帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid != GlobeVar.INVALID_GUID)
{
SendNoticMsg(false, "#{1772}"); //你已属于一个帮会,不能创建帮会
return;
}
CG_GUILD_CREATE msg = (CG_GUILD_CREATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_CREATE);
msg.GuildName = guildName;
msg.GuildNotice = notice;
msg.SendPacket();
}
//申请加入他人所在的帮会
public void ReqJoinOtherPlayerGuild(UInt64 PlayerGuid, string strPlayerName)
{
//玩家Guid判断
if (PlayerGuid == GlobeVar.INVALID_GUID)
{
return;
}
//玩家等级判断
if (BaseAttr.Level < GlobeVar.JOIN_GUILD_LEVEL)
{
Singleton<ObjManager>.GetInstance().MainPlayer.SendNoticMsg(false, "#{1780}"); //你的人物等级不足20级无法加入帮会
return;
}
CG_GUILD_JOIN_OTHERPLAYER msg = (CG_GUILD_JOIN_OTHERPLAYER)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_JOIN_OTHERPLAYER);
if (msg != null)
{
msg.UserGuid = PlayerGuid;
msg.UserName = strPlayerName;
msg.SendPacket();
}
//SendNoticMsg(false, "#{2340}");
}
//响应帮会
public void ReqRespondGuild(UInt64 guildGuid,string leaveTime,string name, bool isCancelJoin = false)
{
//玩家等级判断
if (BaseAttr.Level < GlobeVar.Respond_GUILD_LEVEL)
{
Singleton<ObjManager>.GetInstance().MainPlayer.SendNoticMsg(false, "#{1780}"); //你的人物等级不足20级无法创建帮会
return;
}
//只能同事申请一个帮会,将替换原来的请求,是否继续
m_CacheRespondGuildGuid = guildGuid;
m_CacheCancelJoinGuild = isCancelJoin;
if (isCancelJoin)
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25019}", name), "", MsgBoxRespondJoinGuildOK, MsgBoxRespondJoinGuildCancel);
}
else
{
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25018}",leaveTime,name), "", MsgBoxRespondJoinGuildOK, MsgBoxRespondJoinGuildCancel);
}
}
private void MsgBoxRespondJoinGuildOK()
{
CG_GUILD_JOIN msg = (CG_GUILD_JOIN)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_JOIN);
msg.GuildGuid = m_CacheRespondGuildGuid;
msg.IsCancel = (m_CacheCancelJoinGuild ? 1 : 0);
msg.IsRes = 1;
m_CacheCancelJoinGuild = false;
msg.SendPacket();
}
private void MsgBoxRespondJoinGuildCancel()
{
m_CacheRespondGuildGuid = GlobeVar.INVALID_GUID;
m_CacheCancelJoinGuild = false;
}
//申请加入帮会
public void ReqJoinGuild(UInt64 guildGuid,bool isCancelJoin = false)
{
//玩家等级判断
if (BaseAttr.Level < GlobeVar.JOIN_GUILD_LEVEL)
{
Singleton<ObjManager>.GetInstance().MainPlayer.SendNoticMsg(false, "#{1780}"); //你的人物等级不足20级无法创建帮会
return;
}
//只能同事申请一个帮会,将替换原来的请求,是否继续
m_CacheJoinGuildGuid = guildGuid;
m_CacheCancelJoinGuild = isCancelJoin;
MsgBoxReqJoinGuildOK();
//MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{1861}"), "", MsgBoxReqJoinGuildOK, MsgBoxReqJoinGuildCancel);
}
private void MsgBoxReqJoinGuildOK()
{
CG_GUILD_JOIN msg = (CG_GUILD_JOIN)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_JOIN);
msg.GuildGuid = m_CacheJoinGuildGuid;
msg.IsCancel = (m_CacheCancelJoinGuild?1:0);
m_CacheCancelJoinGuild = false;
msg.SendPacket();
}
private void MsgBoxReqJoinGuildCancel()
{
m_CacheJoinGuildGuid = GlobeVar.INVALID_GUID;
m_CacheCancelJoinGuild = false;
}
//邀请某个玩家加入帮会
public void ReqInviteGuild(UInt64 invitedGuid)
{
//被邀请者判断
if (invitedGuid == GlobeVar.INVALID_GUID)
{
return;
}
CG_GUILD_INVITE msg = (CG_GUILD_INVITE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_INVITE);
msg.InvitedGuid = invitedGuid;
msg.SendPacket();
}
//申请离开帮会
public void ReqLeavGuild()
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
//帮主离开为解散帮会,否则为帮众退出帮会
if (GameManager.gameManager.PlayerDataPool.IsGuildChief())
{
//解散帮会操作不可撤销,确定执行吗?
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{2359}"), "", MsgBoxLeaveGuildOK, null);
}
else
{
//你确认要退出{0}帮会吗?
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{1788}", GameManager.gameManager.PlayerDataPool.GuildInfo.GuildName),
"", MsgBoxLeaveGuildOK, null);
}
}
//离开帮会MessageBox确认
private void MsgBoxLeaveGuildOK()
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
CG_GUILD_LEAVE msg = (CG_GUILD_LEAVE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_LEAVE);
msg.Requester = GUID;
msg.SendPacket();
}
//任命会员职位
public void ReqCommisionGuildMember(UInt64 approver)
{
//目前只有帮主可以执行,改变只有两种,副帮主->普通帮众 and 普通帮众->副帮主
if (!GameManager.gameManager.PlayerDataPool.IsGuildChief())
{
return;
}
if (approver == GlobeVar.INVALID_GUID)
{
return;
}
GuildMember member;
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMemberList.TryGetValue(approver, out member))
{
if (member.IsValid())
{
if (member.Job == (int)GameDefine_Globe.GUILD_JOB.VICE_CHIEF)
{
ReqChangeGuildMemberJob(approver, (int)GameDefine_Globe.GUILD_JOB.MEMBER);
}
else if (member.Job == (int)GameDefine_Globe.GUILD_JOB.MEMBER)
{
ReqChangeGuildMemberJob(approver, (int)GameDefine_Globe.GUILD_JOB.VICE_CHIEF);
}
}
}
}
//修改会员权限
private UInt64 m_approverGuid = GlobeVar.INVALID_GUID;
private int m_jobID = GlobeVar.INVALID_ID;
public void ReqChangeGuildMemberJob(UInt64 approver, int nJobID)
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
//被修改者GUID判断
if (approver == GlobeVar.INVALID_GUID)
{
return;
}
//职位判断
if (nJobID < 0 || nJobID > (int)GameDefine_Globe.GUILD_JOB.MEMBER)
{
return;
}
m_approverGuid = approver;
m_jobID = nJobID;
//确定对该玩家进行任命?
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{3220}"), "", MsgBoxChangeGuildMemberJobOK, MsgBoxChangeGuildMemberJobCancel);
}
private void MsgBoxChangeGuildMemberJobOK()
{
//被修改者GUID判断
if (m_approverGuid == GlobeVar.INVALID_GUID)
{
return;
}
//职位判断
if (m_jobID < 0 || m_jobID > (int)GameDefine_Globe.GUILD_JOB.MEMBER)
{
return;
}
CG_GUILD_JOB_CHANGE msg = (CG_GUILD_JOB_CHANGE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_JOB_CHANGE);
msg.Approver = m_approverGuid;
msg.JobID = m_jobID;
msg.SendPacket();
}
private void MsgBoxChangeGuildMemberJobCancel()
{
m_approverGuid = GlobeVar.INVALID_GUID;
m_jobID = GlobeVar.INVALID_ID;
}
public bool IsPowerfull(int index)
{
return GCGame.Utils.IsGuildPowerFull(index);
}
public bool ReqSendMsgToAll(string message, int changeType)
{
//判断字符串的合法性
if (message.Length <= 0)
{
return false;
}
if (IsPowerfull(5) == false)
return true;
ChatHistoryItem item = new ChatHistoryItem();
item.CleanUp();
item.EChannel = GC_CHAT.CHATTYPE.CHAT_TYPE_FRIEND_GUILD;
item.ChatInfo = message;
GCGame.Utils.SendCGChatPak(item.ChatInfo, item);
return true;
}
//修改帮会公告
public void ReqChangeGuildNotice(string message,int changeType)
{
//判断字符串的合法性
if (message.Length <= 0)
{
return;
}
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
if (IsPowerfull(3) == false)
return;
CG_GUILD_REQ_CHANGE_NOTICE msg = (CG_GUILD_REQ_CHANGE_NOTICE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_CHANGE_NOTICE);
msg.ChangeInfo = message;
msg.ChangeType = changeType;
msg.SendPacket();
//为了避免实时刷新,这里暂时将帮会公告设置为修改后的。等待下次向服务器申请后即可再次被赋值
GameManager.gameManager.PlayerDataPool.GuildInfo.GuildNotice = message;
}
//批准待审批会员
public void ReqApproveGuildMember(UInt64 approver, int agree)
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
if (GCGame.Utils.IsGuildPowerFull(6) == false)
return;
CG_GUILD_APPROVE_RESERVE msg = (CG_GUILD_APPROVE_RESERVE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_APPROVE_RESERVE);
msg.Approver = approver;
msg.IsAgree = agree;
msg.SendPacket();
}
//踢出某个会员
public void ReqKickGuildMember(UInt64 kickedGuid)
{
if (kickedGuid == GlobeVar.INVALID_GUID)
{
return;
}
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
m_CacheKickMemberGuid = kickedGuid;
//确定将该玩家从帮会中除名?
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{2360}"), "", MsgBoxKickGuildMmeberOK, MsgBoxKickGuildMmeberCancel);
}
//帮会踢人MessageBox确认函数
private void MsgBoxKickGuildMmeberOK()
{
if (m_CacheKickMemberGuid == GlobeVar.INVALID_GUID)
{
return;
}
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
CG_GUILD_KICK msg = (CG_GUILD_KICK)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_KICK);
msg.Kicked = m_CacheKickMemberGuid;
msg.SendPacket();
m_CacheKickMemberGuid = GlobeVar.INVALID_GUID;
}
//帮会踢人MessageBox取消函数
private void MsgBoxKickGuildMmeberCancel()
{
m_CacheKickMemberGuid = GlobeVar.INVALID_GUID;
}
//禅让帮主
public void ReqChangeGuildMaster(UInt64 approver)
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
if(GCGame.Utils.IsGuildPowerFull(2) == false)
{
return;
}
//禅让和修改会员权限发同样消息包只是JobID固定为GUILD_JOB.CHIEF
if (approver == GlobeVar.INVALID_GUID)
{
return;
}
bool levelOK = CreateLevelisOK(GameManager.gameManager.PlayerDataPool.GuildInfo.GetMemberLevel(approver));
//目标等级是否达到40
if (levelOK == false)
{
//禅让目标的等级不得低于40级。
SendNoticMsg(false, "#{2362}");
return;
}
m_CacheChangeMasterGuid = approver;
//禅让帮主操作不可撤销,确定执行吗?
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{2361}"), "", MsgBoxChangeGuildMasterOK, MsgBoxChangeGuildMasterCancel);
}
//帮会禅让MessageBox确认函数
private void MsgBoxChangeGuildMasterOK()
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID ||
m_CacheChangeMasterGuid == GlobeVar.INVALID_GUID)
{
return;
}
//必须是帮主
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildChiefGuid != GUID)
{
return;
}
bool levelOK = CreateLevelisOK(GameManager.gameManager.PlayerDataPool.GuildInfo.GetMemberLevel(m_CacheChangeMasterGuid));
//目标等级是否达到40
if (levelOK == false)
{
//禅让目标的等级不得低于40级。
SendNoticMsg(false, "#{2362}");
return;
}
CG_GUILD_JOB_CHANGE msg = (CG_GUILD_JOB_CHANGE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_JOB_CHANGE);
msg.Approver = m_CacheChangeMasterGuid;
msg.JobID = (int)GameDefine_Globe.GUILD_JOB.CHIEF;
msg.SendPacket();
m_CacheChangeMasterGuid = GlobeVar.INVALID_GUID;
}
//帮会禅让MessageBox取消函数
private void MsgBoxChangeGuildMasterCancel()
{
m_CacheChangeMasterGuid = GlobeVar.INVALID_GUID;
}
//帮会升级 建筑升级等
public void ReqGuildLevelUp(Guild.BuildType type)
{
//无帮会无法申请
if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == GlobeVar.INVALID_GUID)
{
return;
}
if (IsPowerfull(8) == false)
return;
if(type == Guild.BuildType.guildInfo)
{
if(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevelCoolDown > Time.realtimeSinceStartup)
{
SendNoticMsg(false, "#{25081}");
return;
}
Tab_GuildLevelUp buildInfo = TableManager.GetGuildLevelUpByID(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel, 0);
Tab_GuildLevelUp buildInfo1 = TableManager.GetGuildLevelUpByID(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel + 1, 0);
if (buildInfo==null || buildInfo1==null)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25136}"));
return;
}
int needCost = buildInfo.ConsumeWealth;
int needTime = buildInfo.NeedTime;
m_CacheReqLevelUpType = (int)type;
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25035}", needCost, GCGame.Utils.GetTimeStr(needTime)), "", MsgReqGuildLevelUpOK, null);
}
else
{
int level = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(type);
int coolDown = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildCoolDown(type);
if(coolDown>Time.realtimeSinceStartup)
{
SendNoticMsg(false, "#{25082}");
return;
}
if (level == -1)
return;
Tab_GuildBuilding buildInfo = TableManager.GetGuildBuildingByID((int)type, level);
if (buildInfo == null)
{
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25136}"));
return;
}
int needCost = buildInfo.ConsumeWealth;
int needTime = buildInfo.NeedTime;
m_CacheReqLevelUpType = (int)type;
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25083}", needCost, GCGame.Utils.GetTimeStr(needTime)), "", MsgReqGuildLevelUpOK, null);
}
}
public void MsgReqGuildLevelUpOK()
{
if (m_CacheReqLevelUpType < -1)
return;
CG_GUILD_REQ_LEVELUP msg = (CG_GUILD_REQ_LEVELUP)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_LEVELUP);
msg.SetType((int)m_CacheReqLevelUpType);
msg.SendPacket();
m_CacheReqLevelUpType = -1000;
}
//回帮 (可以去别人帮会的地图)
public void BackGuildMap(ulong guildGuid)
{
var send = (CG_REQ_ENTER_GUILDMAP)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ENTER_GUILDMAP);
send.SetGuildGuid(guildGuid);
send.SendPacket();
if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain())
TeamEnterGuildMap();
}
//帮会联赛相关数据请求
public void GuildWarUnionInfoReq(CG_GUILD_UNION_MATCH_REQ.UNION_MATCH_REQ type,int param = 0)
{
CG_GUILD_UNION_MATCH_REQ send = (CG_GUILD_UNION_MATCH_REQ)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_UNION_MATCH_REQ);
send.SetType((int)type);
send.SetParam(param);
send.SendPacket();
}
// 是否是跑商状态
public bool IsInPaoShang()
{
if (GameManager.gameManager.MissionManager.IsHaveMissionNotFailedByType((int)MISSIONTYPE.MISSION_GUILDPAOSHANG))
{
return true;
}
return false;
}
}
}