PatFaceManager = {}; local this = PatFaceManager this.isFirstLog = 0--0当天第一次登陆 this.isLogin = false function this.Initialize() Game.GlobalEvent:AddEvent(GameEvent.PatFace.PatFaceSend, this.OnAddPatFaceData) end function this.SetisFirstLogVal(isDayFirst,setPatFaceFinishTabs) this.isFirstLog = isDayFirst --Log(" this.isFirstLog ".. this.isFirstLog) if this.isFirstLog == 0 then--是否是今天的第一次登陆 for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.LoginPosterConfig)) do if v.ShowType == 1 then--一天一清 if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") ~= "0" then RedPointManager.PlayerPrefsDeleteStr(v.Id.."PatFace") end elseif v.ShowType == 4 then--公会战 巅峰战 结束清 默认一天一轮回 if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") ~= "0" then RedPointManager.PlayerPrefsDeleteStr(v.Id.."PatFace") end end end else if setPatFaceFinishTabs and #setPatFaceFinishTabs > 0 then for i = 1, #setPatFaceFinishTabs do if setPatFaceFinishTabs[i].Type ~= 8 then if setPatFaceFinishTabs[i].ShowType ~= 2 then--触发就拍不用赋值 if RedPointManager.PlayerPrefsGetStr(setPatFaceFinishTabs[i].Id.."PatFace") == "0" then RedPointManager.PlayerPrefsSetStr(setPatFaceFinishTabs[i].Id.."PatFace","1") end end else--升级限时礼包特殊处理 if RedPointManager.PlayerPrefsGetStr(setPatFaceFinishTabs[i].Id..PlayerManager.level.."PatFace") == "0" then RedPointManager.PlayerPrefsSetStr(setPatFaceFinishTabs[i].Id..PlayerManager.level.."PatFace","1") end end end end end --3 类型就拍一次 end local patFaceAllData = {} function this.GetPatFaceAllDataTabs() if this.isLogin then return end patFaceAllData = {} for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.LoginPosterConfig)) do this.PatFaceSpecialMonitorOpenRules(v,patFaceAllData,1) end if patFaceAllData then table.sort(patFaceAllData, function(a,b) return a.Order < b.Order end) end return patFaceAllData end function this.PatFaceSpecialMonitorOpenRules(v,patFaceAllData,type,starUpGiftNum) --1等级 2关卡 3特劝等级 4功能开启时 5活动开启时 6公会战状态 7条件触发(事件) if v.OpenRules[1] == 1 then if PlayerManager.level >= v.OpenRules[2] and PlayerManager.level <= v.CloseRules[2] then this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) end elseif v.OpenRules[1] == 2 then local isPass1=FightPointPassManager.IsFightPointPass(v.OpenRules[2]) local isPass2=FightPointPassManager.IsFightPointPass(v.CloseRules[2]) if isPass1 and isPass2 == false then this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) end elseif v.OpenRules[1] == 3 then local vipLv = VipManager.GetVipLevel() if vipLv >= v.OpenRules[2] and vipLv <= v.CloseRules[2] then this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) end elseif v.OpenRules[1] == 4 then local isOpen = ActTimeCtrlManager.SingleFuncState(v.OpenRules[2]) if isOpen then this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) end elseif v.OpenRules[1] == 5 then --local activity = ConfigManager.GetConfigData(ConfigName.GlobalActivity,v.OpenRules[2]) --if activity then -- local activityId = ActivityGiftManager.IsActivityTypeOpen(activity.Type) -- if activityId then -- this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) -- end --end local activityId = ActivityGiftManager.IsActivityTypeOpen(v.OpenRules[2]) if activityId and activityId==42 then this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) elseif activityId and activityId==v.Values then this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) end elseif v.OpenRules[1] == 6 then --工会 this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) elseif v.OpenRules[1] == 7 then --巅峰战 this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) end end function this.PatFaceSpecialMonitor(v,patFaceAllData,type,starUpGiftNum) if v.Type == 1 then--十连抽特殊处理 if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" and RecruitManager.isTenRecruit == 0 then table.insert(patFaceAllData,v) end elseif v.Type == 2 then--异妖直购特殊处理 local conFigData = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, v.ShopId) if conFigData == nil then return end local shopItemData = OperatingManager.GetGiftGoodsInfo(conFigData.Type,v.ShopId) if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" and shopItemData and shopItemData.buyTimes <= 0 then table.insert(patFaceAllData,v) end elseif v.Type == 3 then--工会 local curGuildStage = GuildFightManager.GetCurFightStage() if PlayerManager.familyId ~= 0 then if v.OpenRules[2] == curGuildStage then---2 then if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" then Log(Language[10547]) table.insert(patFaceAllData,v) end end end elseif v.Type == 5 then--星级成长礼特殊处理 if starUpGiftNum then Log("星级成长礼特殊处理 starUpGiftNum == v.Star "..starUpGiftNum .." ".. v.Star) --Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceHaveGrowGift)--激活一次发一个 if starUpGiftNum >= v.Star then -- local conFigData = ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig, v.ShopId) -- if conFigData == nil then return end -- local shopItemData = OperatingManager.GetGiftGoodsInfo(conFigData.Type,v.ShopId) -- --shopItemData.startTime 大于零代表第一次开 需要拍脸 下次未购买并在时间内再次获得 shopItemData.startTime为零 -- --shopItemData.buyTimes <= 0 今天没有购买才会弹 -- --if shopItemData then -- -- Log(" PatFaceManager startTime buyTimes "..shopItemData.startTime.." "..shopItemData.buyTimes) -- --else -- -- Log("shopItemData 为nil") -- --end -- if shopItemData and shopItemData.startTime > 0 and shopItemData.buyTimes <= 0 and type == 2 then -- if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" then--商品未开启才会激活拍脸 -- table.insert(patFaceAllData,v) -- end -- end if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" then--商品未开启才会激活拍脸 table.insert(patFaceAllData,v) end end end elseif v.Type == 6 then--巅峰战 local curState = ArenaTopMatchManager.GetBaseData().battleState local battleStage = ArenaTopMatchManager.GetBaseData().battleStage --Log(" v.Values battleStage "..v.Values.." "..tostring(battleStage)) if v.OpenRules[2] == curState and type == 2 and battleStage >= v.Values then if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" then table.insert(patFaceAllData,v) end end elseif v.Type == 7 then--东海寻仙 if FindFairyManager.GetActivityTime() > 0 then if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" then table.insert(patFaceAllData,v) end end elseif v.Type == 8 then--升级限时礼包 local specialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig,51).Value local t = string.split(specialConfig,"#") local q = false for i = 0, 19 do local level = tonumber(t[1])+i*tonumber(t[2]) if PlayerManager.level == level then q =true end end if q then if RedPointManager.PlayerPrefsGetStr(v.Id..PlayerManager.level.."PatFace") == "0" then table.insert(patFaceAllData,v) end end else if RedPointManager.PlayerPrefsGetStr(v.Id.."PatFace") == "0" then table.insert(patFaceAllData,v) end end end function this.ShowBuyLaterDrop(msg) UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1) end --秒转换成文字对应时间 function this.GetTimeStrBySeconds(_seconds) return os.date("%Y.%m.%d", _seconds) end this.timer = Timer.New() --刷新倒计时显示 function this.RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeDown,str) if timeDown > 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(true) end if _timeTextExpert then if str then _timeTextExpert.text = str..this.TimeStampToDateString(timeDown) else _timeTextExpert.text = Language[10028]..this.TimeStampToDateString(timeDown) end end if this.timer then this.timer:Stop() this.timer = nil end this.timer = Timer.New(function() if _timeTextExpert then if str then _timeTextExpert.text = str..this.TimeStampToDateString(timeDown) else _timeTextExpert.text = Language[10028]..this.TimeStampToDateString(timeDown) end end if timeDown < 0 then if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end this.timer:Stop() this.timer = nil end timeDown = timeDown - 1 end, 1, -1, true) this.timer:Start() else if _timeTextExpertgo then _timeTextExpertgo:SetActive(false) end end end function this.TimeStampToDateString(second) local day = math.floor(second / (24 * 3600)) local minute = math.floor(second / 60) % 60 local sec = second % 60 local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600) return string.format(Language[10548],day, hour, minute, sec) end function this.GetGuildFightTime() local guildFightData = GuildFightManager.GetGuildFightData() if guildFightData then local startTime = guildFightData.startTime local curTime = GetTimeStamp() --Log("curTime - startTime "..curTime - startTime) return (curTime - startTime) <= 3 * 60 else return false end end --事件触发拍脸 (如五星成长礼) function this.OnAddPatFaceData(faceConFigType, starUpGiftNum) if this.isLogin then return end--上来就弹新关卡界面 所以不弹 if MapManager.isInMap or UIManager.IsOpen(UIName.BattlePanel) then return end--在关卡里 副本里不弹 patFaceAllData = {} local allTypeFaceConFig = ConfigManager.GetAllConfigsDataByKey(ConfigName.LoginPosterConfig,"Type",faceConFigType) -- LogPink("faceConFigType 1--------- "..#allTypeFaceConFig.." "..tostring(starUpGiftNum)) for i = 1, #allTypeFaceConFig do --this.PatFaceSpecialMonitor(allTypeFaceConFig[i],patFaceAllData,2,starUpGiftNum) this.PatFaceSpecialMonitorOpenRules(allTypeFaceConFig[i],patFaceAllData,2, starUpGiftNum) end --local v = ConfigManager.GetConfigData(ConfigName.LoginPosterConfig,faceConFigId) --this.PatFaceSpecialMonitor(v,patFaceAllData,2) -- LogPink("patFaceAllData 2--------- "..#patFaceAllData) if patFaceAllData and not GuideManager.IsFunctionGuideExist() then this.OpenPatFacePanel() end end this.patFaceCallList = Stack.New() function this.OpenPatFacePanel() --Log("#patFaceAllData 事件 " .. #patFaceAllData) if #patFaceAllData > 0 then this.patFaceCallList:Clear() this.patFaceCallList:Push(function() --Log("结束了!!!") Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSendFinish) end) for i = #patFaceAllData, 1, -1 do this.patFaceCallList:Push(function() PatFaceManager.SetisFirstLogVal(1, { patFaceAllData[i] }) UIManager.OpenPanel(UIName.PatFacePanel, patFaceAllData[i], function() local time2 = Timer.New(function() this.patFaceCallList:Pop()() end, 0.5) time2:Start() end) end) end this.patFaceCallList:Pop()() else Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSendFinish) end end return this