242 lines
8.4 KiB
Lua
242 lines
8.4 KiB
Lua
GuildManager = {}
|
||
local this = GuildManager
|
||
|
||
this.RecommandGuildList = {}
|
||
this.SearchGuildList = {}
|
||
this.MaxNumber = false
|
||
|
||
function GuildManager.Initialize()
|
||
|
||
end
|
||
|
||
-- 请求推荐公会列表
|
||
function GuildManager.RequestRecommandGuildList(page,func)
|
||
this.RecommandGuildList = {}
|
||
NetManager.RequestRecommandGuild(page,function(msg)
|
||
local len = #this.RecommandGuildList
|
||
for i, info in ipairs(msg.familyRecomandInfo) do
|
||
this.RecommandGuildList[len+i] = info
|
||
end
|
||
if #msg.familyRecomandInfo < 10 then
|
||
this.MaxNumber = true
|
||
else
|
||
this.MaxNumber = false
|
||
end
|
||
if func then func() end
|
||
end)
|
||
end
|
||
|
||
-- 请求搜索公会
|
||
function GuildManager.RequestSearchGuild(name, func)
|
||
NetManager.RequestSearchGuild(name, function(msg)
|
||
this.SearchGuildList = msg.familyRecomandInfo
|
||
if func then func() end
|
||
end)
|
||
end
|
||
|
||
-- 获取推荐列表数据
|
||
function GuildManager.GetRecommandGuildList()
|
||
return this.RecommandGuildList
|
||
end
|
||
|
||
-- 获取搜索列表数据
|
||
function GuildManager.GetSearchGuildList()
|
||
return this.SearchGuildList
|
||
end
|
||
|
||
-- 请求创建公会
|
||
function GuildManager.RequestCreateGuild(name, announce, func)
|
||
if not NameManager.CheckStringRight(name) then
|
||
PopupTipPanel.ShowTip("名称含有敏感字符")
|
||
return
|
||
end
|
||
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GUILD) then
|
||
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.GUILD))
|
||
return
|
||
end
|
||
NetManager.RequestCreateGuild(name, announce, function(msg)
|
||
MyGuildManager.SetMyGuildInfo(msg)
|
||
MyGuildManager.SetMyMemInfo(msg)
|
||
MyGuildManager.SetMyFeteInfo(msg)
|
||
MyGuildManager.InitAllData(function()
|
||
if func then func() end
|
||
end)
|
||
end)
|
||
end
|
||
|
||
-- 请求加入公会
|
||
function GuildManager.RequestJoinGuild(guildId, func)
|
||
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GUILD) then
|
||
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.GUILD))
|
||
return
|
||
end
|
||
NetManager.RequestJoinGuild(guildId, function(msg)
|
||
MyGuildManager.SetMyGuildInfo(msg.familyJoinIndicaion)
|
||
MyGuildManager.SetMyMemInfo(msg.familyJoinIndicaion)
|
||
MyGuildManager.InitAllData(function()
|
||
if func then func() end
|
||
end)
|
||
MyGuildManager.RefreshAidRedPot()
|
||
end)
|
||
end
|
||
|
||
-- 申请加入某个公会
|
||
function GuildManager.RequestApplyOneGuild(guildId, func)
|
||
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GUILD) then
|
||
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.GUILD))
|
||
return
|
||
end
|
||
NetManager.RequestApplyGuild({guildId}, function(msg)
|
||
this.ChangeGuildApplyStatus({guildId})
|
||
if func then func() end
|
||
end)
|
||
end
|
||
|
||
-- 申请加入好多公会(推荐和搜索)
|
||
function GuildManager.RequestApplyManyGuilds(guildIdList, func)
|
||
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.GUILD) then
|
||
PopupTipPanel.ShowTip(ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.GUILD))
|
||
return
|
||
end
|
||
NetManager.RequestApplyGuild(guildIdList, function(msg)
|
||
this.ChangeGuildApplyStatus(guildIdList)
|
||
if func then func() end
|
||
end)
|
||
end
|
||
|
||
-- 改变公会的申请状态
|
||
function this.ChangeGuildApplyStatus(guildIdList)
|
||
-- 推荐列表检测
|
||
for _, v in ipairs(this.RecommandGuildList) do
|
||
for _, guildId in ipairs(guildIdList) do
|
||
if v.familyBaseInfo.id == guildId then
|
||
v.isApply = GUILD_APPLY_STATUS.APPLY
|
||
break
|
||
end
|
||
end
|
||
end
|
||
-- 搜索列表检测
|
||
for _, v in ipairs(this.SearchGuildList) do
|
||
for _, guildId in ipairs(guildIdList) do
|
||
if v.familyBaseInfo.id == guildId then
|
||
v.isApply = GUILD_APPLY_STATUS.APPLY
|
||
break
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
-- 获取公会图腾资源名
|
||
function GuildManager.GetLogoResName(logoId)
|
||
logoId = (not logoId or logoId == 0) and GUILD_DEFAULT_LOGO or logoId
|
||
local logoList = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).TotemItem
|
||
if not logoList[logoId] then
|
||
return
|
||
end
|
||
return GetResourcePath(logoList[logoId])
|
||
end
|
||
|
||
|
||
--
|
||
local _TipList = {}
|
||
local _TipTimer = nil
|
||
local function _IsNeedShowTip()
|
||
return UIManager.IsOpen(UIName.MainPanel) or UIManager.IsOpen(UIName.GuildMainCityPanel)
|
||
end
|
||
function GuildManager.AddGuildTip(type, ...)
|
||
local isNeedShow = _IsNeedShowTip()
|
||
-- 如果在需要显示的界面,或者类型为加入(加入公会tip需要在返回主界面时显示,其他数据不在主界面直接丢弃),则保存数据并检测显示
|
||
if isNeedShow or type == GUILD_TIP_TYPE.JOIN then
|
||
-- 保存数据
|
||
table.insert(_TipList, {type, ...})
|
||
-- 按type类型排序,类型值小的优先显示
|
||
table.sort(_TipList, function(a, b)
|
||
return a[1] < b[1]
|
||
end)
|
||
-- 如果需要显示,并且没有timer运行中则检测数据开始显示
|
||
if isNeedShow and not _TipTimer then
|
||
this.CheckGuildTip()
|
||
end
|
||
end
|
||
end
|
||
function GuildManager.CheckGuildTip()
|
||
if #_TipList == 0 then return end
|
||
if not _TipTimer then
|
||
_TipTimer = Timer.New(function()
|
||
local tip = table.remove(_TipList, 1)
|
||
local tType = tip[1]
|
||
if tType == GUILD_TIP_TYPE.JOIN then
|
||
local guildName = tip[2]
|
||
MsgPanel.ShowTwo(string.format(Language[10915], guildName), nil, function()
|
||
JumpManager.GoJump(4001)
|
||
end, Language[10916],Language[10917])
|
||
elseif tType == GUILD_TIP_TYPE.POS then
|
||
local pos = tip[2]
|
||
local oldPos = tip[3]
|
||
if pos == GUILD_GRANT.MEMBER then
|
||
PopupTipPanel.ShowTip(oldPos == GUILD_GRANT.MASTER and Language[10918] or Language[10919])
|
||
else
|
||
PopupTipPanel.ShowTip(Language[10920]..GUILD_GRANT_STR[pos])
|
||
end
|
||
elseif tType == GUILD_TIP_TYPE.KICKOUT then
|
||
local uid = tip[2]
|
||
if uid == 0 then
|
||
PopupTipPanel.ShowTip(Language[10921])
|
||
else
|
||
PopupTipPanel.ShowTip(Language[10922])
|
||
end
|
||
elseif tType == GUILD_TIP_TYPE.REFUSE and PlayerManager.familyId == 0 then
|
||
local guildName = tip[2]
|
||
PopupTipPanel.ShowTip(string.format(Language[10923], guildName))
|
||
end
|
||
-- 判断是否需要继续显示,不需要显示了,清空后面所有数据
|
||
if not _IsNeedShowTip() then
|
||
_TipList = {}
|
||
end
|
||
-- 没有数据要显示了,关闭计时器
|
||
if #_TipList == 0 and _TipTimer then
|
||
_TipTimer:Stop()
|
||
_TipTimer = nil
|
||
end
|
||
end, 1, -1, true)
|
||
_TipTimer:Start()
|
||
end
|
||
end
|
||
function this.RefreshGuildAllRedState()
|
||
CheckRedPointStatus(RedPointType.Guild_Aid)
|
||
CheckRedPointStatus(RedPointType.Guild_AidBox)
|
||
CheckRedPointStatus(RedPointType.Guild_AidMy)
|
||
CheckRedPointStatus(RedPointType.Guild_Apply)
|
||
CheckRedPointStatus(RedPointType.Guild_DeathPos)
|
||
CheckRedPointStatus(RedPointType.Guild_Fete)
|
||
CheckRedPointStatus(RedPointType.Guild_House)
|
||
CheckRedPointStatus(RedPointType.Guild_House_Apply)
|
||
--CheckRedPointStatus(RedPointType.Guid_GetPackage)
|
||
--CheckRedPointStatus(RedPointType.Guid_SendPackage)
|
||
MyGuildManager.ReuqsetRedPackage()
|
||
--CheckRedPointStatus(RedPointType.Guild_RedPacket)
|
||
CheckRedPointStatus(RedPointType.Guild_Shop)
|
||
CheckRedPointStatus(RedPointType.Guild_Skill)
|
||
CheckRedPointStatus(RedPointType.Guild_Transcript)
|
||
CheckRedPointStatus(RedPointType.Guild_Boss)
|
||
CheckRedPointStatus(RedPointType.Guild_AidGuild)
|
||
CheckRedPointStatus(RedPointType.Gui)
|
||
CheckRedPointStatus(RedPointType.Guild_Shop)
|
||
|
||
end
|
||
|
||
function this.GetNextRecommendFamily(page,func)
|
||
if this.MaxNumber then return end
|
||
NetManager.RequestRecommandGuild(page,function (msg)
|
||
local len = #this.RecommandGuildList
|
||
for i, info in ipairs(msg.familyRecomandInfo) do
|
||
this.RecommandGuildList[len+i] = info
|
||
end
|
||
if #msg.familyRecomandInfo < 10 then
|
||
this.MaxNumber = true
|
||
end
|
||
if func then func() end
|
||
end)
|
||
end
|
||
|
||
return GuildManager |