------------------------------------------------ --作者: yangqf --日期: 2021-03-02 --文件: SwordMandateSystem.lua --模块: SwordMandateSystem --描述: 剑灵阁挂机系统 ------------------------------------------------ local L_RedPointCustomCondition = CS.Thousandto.Code.Logic.RedPointCustomCondition local L_RedPointFightPowerCondition = CS.Thousandto.Code.Logic.RedPointFightPowerCondition local L_ShowRedPointTime = 60 * 60 local SwordMandateSystem = { --同步数据的时间 SyncTime = 0, --当前挂机总时间 CurAllTime = 0, --是否展示红点 ShowRedPoint = false, --当前层数 CurLevel = 0, --进入副本时的层数 EnterCopyLevel = 0, --当前配置 CurCfg = nil, --配置的挂机最大时间 MaxTime = 0, --配置的单次奖励时间,单位为分钟 SingleAwardTime = 0, --单次快速收益奖励次数 QuickGetAwardCount = 0, --单次快速收益时长 QuickGetTime = 0, --快速收益剩余次数 QuickGetRemainCount = 0, --快速收益最大次数 QuickGetMaxCount = 0, --快速收益价格数据 QuickGetPrices = nil, --缓存跳关数据 CacheTiaoGuanData = nil, } --当前挂机总时间,客户端自增 function SwordMandateSystem:GetCurAllTime() local _allTime = Time.GetRealtimeSinceStartup() - self.SyncTime + self.CurAllTime if _allTime > self.MaxTime then _allTime = self.MaxTime end return _allTime end --设置是否显示hongd function SwordMandateSystem:SetShowRedPoint(value) if self.ShowRedPoint == value then return end self.ShowRedPoint = value if self.ShowRedPoint then GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.FlySwordMandate, 1, L_RedPointCustomCondition(true)) else GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.FlySwordMandate, 1) end GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVEMT_UPDATE_SWORDMANDATE) end --时间是否挂满了 function SwordMandateSystem:IsFullTime() return self.CurAllTime >= self.MaxTime end --初始化 function SwordMandateSystem:Initialize() local _gCfg = DataConfig.DataGlobal[GlobalName.Sword_Soul_MaxMandateTime] if _gCfg ~= nil then self.MaxTime = tonumber(_gCfg.Params) end _gCfg = DataConfig.DataGlobal[GlobalName.Sword_Soul_SingleRewordTime] if _gCfg ~= nil then self.SingleAwardTime = tonumber(_gCfg.Params) / 60 end _gCfg = DataConfig.DataGlobal[GlobalName.Sword_Soul_quicktimes] if _gCfg ~= nil then self.QuickGetAwardCount = tonumber(_gCfg.Params) self.QuickGetTime = self.QuickGetAwardCount * self.SingleAwardTime * 60 end --计算快速购买价格 local _vipPowerCfg = DataConfig.DataVipPower[36] if _vipPowerCfg ~= nil then self.QuickGetPrices = Utils.SplitNumber(_vipPowerCfg.VipPowerPrice, '_') end self.EnterCopyLevel = nil end --卸载 function SwordMandateSystem:UnInitialize() end --更新 function SwordMandateSystem:Update(dt) if self.SyncTime <= 0 then return end if Time.GetFrameCount() % 30 == 0 then self:SetShowRedPoint(self.CurAllTime >= L_ShowRedPointTime) end end --设置数据 function SwordMandateSystem:ResSwordSoulPannel(msg) self.CurLevel = msg.layer if self.EnterCopyLevel == nil then self.EnterCopyLevel = self.CurLevel end self.CurCfg = DataConfig.DataSwordSoulCopy[msg.layer] self.CurAllTime = msg.hookTime self.SyncTime = Time.GetRealtimeSinceStartup() self.QuickGetRemainCount = msg.remainCount self.QuickGetMaxCount = msg.maxCount GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.FlySwordMandate, 2) GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.FlySwordMandate, 2, L_RedPointFightPowerCondition(self.CurCfg.NeedFightPower)) if self.ShowRedPoint ~= (self.CurAllTime >= L_ShowRedPointTime) then self:SetShowRedPoint(self.CurAllTime >= L_ShowRedPointTime) else GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVEMT_UPDATE_SWORDMANDATE) end GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JLG_DATA_RESULT) end --快速收益返回 function SwordMandateSystem:ResQuickEarn(msg) self.QuickGetRemainCount = msg.remainCount GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVEMT_QUICL_SWORDMANDATE_RESULT, msg) end --进入剑灵阁副本 function SwordMandateSystem:OnEnterSoulCopy() self.EnterCopyLevel = self.CurLevel end --打开剑灵阁界面 function SwordMandateSystem:OnOpenSwordForm() self.EnterCopyLevel = self.CurLevel end --快速通关返回 function SwordMandateSystem:ResSkipSoulCopyResult(msg) local _oldLevel = self.CurLevel self.CurLevel = msg.layer self.CurCfg = DataConfig.DataSwordSoulCopy[msg.layer] GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.FlySwordMandate, 2) GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.FlySwordMandate, 2, L_RedPointFightPowerCondition(self.CurCfg.NeedFightPower)) if self.ShowRedPoint ~= (self.CurAllTime >= L_ShowRedPointTime) then self:SetShowRedPoint(self.CurAllTime >= L_ShowRedPointTime) else GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVEMT_UPDATE_SWORDMANDATE) end self.CacheTiaoGuanData = {_oldLevel, msg} --快速通关返回 GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JLG_TIAOGUAN_RESULT) end return SwordMandateSystem