| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889 |
- local VoyageDataMgr = class("VoyageDataMgr", require("DataBase"))
- local VoyageAirShipData = require('Voyage/VoyageAirShipData')
- local CommonLogData = require('CommomLogData')
- local CreateActorSystem = require('CreateActorSystem')
- local REQ_GUILD_CD = 1000
- local AirShipSort = function (a, b)
- if a.endTime == b.endTime then
- if a.quality == b.quality then
- return a.uid < b.uid
- else
- return a.quality < b.quality
- end
- end
- return a.endTime < b.endTime
- end
- function VoyageDataMgr:ctor()
- self.lastSendMsgTimeMap = nil -- 发送消息的冷却时间,避免操作过快
- self.rpStatus = nil
- self.challengeNum = 0
- self.voyageNum = 0
- self.curAirShipId = 1
- self.notifyAirShipUpTip = false
- self.refreshAirShipResult = nil
- self:ClearLastAttackData()
- self.keepVoyageing = nil
- self:ClearViewListData()
- self.selfAirShipData = nil
- self.buyNum = 0
- self.buyNumCost = 0
- self.buyType = 2
- self.numLimit = 0
- self.challengeCountLimit = 0
- -- if self.selfAirShipCompleteTimer then
- -- self.selfAirShipCompleteTimer:Stop()
- -- self.selfAirShipCompleteTimer = nil
- -- end
- self:ClearLogData()
- end
- function VoyageDataMgr:Clear()
- self.lastSendMsgTimeMap = nil
- self.rpStatus = nil
- self.challengeNum = 0
- self.voyageNum = 0
- self.curAirShipId = 1
- self.notifyAirShipUpTip = false
- self.refreshAirShipResult = nil
- self:ClearLastAttackData()
- self.keepVoyageing = nil
- self:ClearViewListData()
- self.selfAirShipData = nil
- -- if self.selfAirShipCompleteTimer then
- -- self.selfAirShipCompleteTimer:Stop()
- -- self.selfAirShipCompleteTimer = nil
- -- end
- self:ClearLogData()
- end
- function VoyageDataMgr:Destroy()
- self.lastSendMsgTimeMap = nil
- self.rpStatus = nil
- self.challengeNum = nil
- self.voyageNum = nil
- self.curAirShipId = nil
- self.notifyAirShipUpTip = nil
- self.refreshAirShipResult = nil
- self:ClearLastAttackData()
- self.keepVoyageing = nil
- self:DisposeViewListData()
- self.selfAirShipData = nil
- -- if self.selfAirShipCompleteTimer then
- -- self.selfAirShipCompleteTimer:Stop()
- -- self.selfAirShipCompleteTimer = nil
- -- end
- self:ClearLogData()
- self:UnRegisterNetEvents()
- end
- function VoyageDataMgr:RegisterNetEvents()
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_DATA_NTF, self.OnVoyageSelfDataNtf, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_ACK, self.OnVoyageKeepAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_NTF, self.OnVoyageKeepNtf, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_REFRESH_TRIAL_TYPE_ACK, self.OnVoyageRefreshAirShipAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_ACK, self.OnVoyageTakeOffAirShipAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_REWARD_ACK, self.OnVoyageGetRewardAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_INFO_ACK, self.OnVoyageCheckInfoAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_CHALLENGE_ACK, self.OnVoyageChallengeAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_CHALLENGE_RESULT_ACK, self.OnVoyageChallengeResultAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_RANK_LIST_ACK, self.OnVoyageRankDatasAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_LOG_ACK, self.OnVoyageLogAck, self)
- ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_BUY_CHALLENGE_NUM_ACK ,self.OnBuyNumAck,self)
- end
- function VoyageDataMgr:UnRegisterNetEvents()
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_DATA_NTF)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_NTF)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_REFRESH_TRIAL_TYPE_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_REWARD_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_INFO_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_CHALLENGE_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_CHALLENGE_RESULT_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_RANK_LIST_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_LOG_ACK)
- ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_CROSS_YUAN_HANG_TRIAL_BUY_CHALLENGE_NUM_ACK )
- end
- function VoyageDataMgr:IsCanSend(key, cdTime)
- local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
- if not self.lastSendMsgTimeMap then
- self.lastSendMsgTimeMap = {}
- self.lastSendMsgTimeMap[key] = curTime
- return true
- end
- local lastTime = self.lastSendMsgTimeMap[key]
- if lastTime then
- local cd = cdTime or REQ_GUILD_CD
- if (curTime - lastTime) < cd then
- return false
- end
- end
- self.lastSendMsgTimeMap[key] = curTime
- return true
- end
- function VoyageDataMgr:OnVoyageSelfDataNtf(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_DATA_NTF " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- data = data.yuanhangtrial_data
- self:RefreshSelfVoyageData(data)
- end
- function VoyageDataMgr:RefreshSelfVoyageData(data)
- if not data then
- return
- end
- LogError("[wboy] RefreshSelfVoyageData " .. Inspect(data))
- local challengeNum = data.challenge_num or 0
- local voyageNum = data.trial_num or 0
- local curAirShipId = data.refresh_trial_type or 1
- local changed1 = (self.challengeNum ~= challengeNum)
- local changed2 = (self.voyageNum ~= voyageNum)
- local changed3 = (self.curAirShipId ~= curAirShipId)
- self.challengeNum = challengeNum
- self.voyageNum = voyageNum
- self.curAirShipId = curAirShipId
- self.buyNum = data.buy_num
- self.buyNumCost = data.buy_consume
- self.buyType = data.buy_type
- self:RefreshSelfAirShip(data.trial_data)
- self:RefNumimit()
- self:RefChallengeCount()
- if changed1 then
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_CHALLENGE_NUM_CHANGED)
- end
- if changed2 then
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_NUM_CHANGED)
- end
- if changed3 then
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_AIRSHIP_CHANGED)
- end
- if self.rpStatus == nil or self.rpStatus then
- local rpStatus = (self.voyageNum <self:GetNumLimit())
- self:SetRpStatus(rpStatus)
- end
- end
- function VoyageDataMgr:RefreshSelfAirShip(data)
- local changed = true
- if data and data.uid and data.uid ~= 0 then
- if self.selfAirShipData then
- self.selfAirShipData:SetData(data)
- if not self.selfAirShipData:IsChange() then
- changed = false
- end
- else
- self.selfAirShipData = VoyageAirShipData:new(data)
- end
- else
- if self.selfAirShipData then
- self.selfAirShipData = nil
- else
- changed = false
- end
- end
- if changed then
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_SELF_AIRSHIP_DATA_CHANGED)
- end
- if self.selfAirShipData and not self.selfAirShipData.awardReceived then
- if self.selfAirShipData:IsChangeEndTime() then
- -- local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
- -- local remindTime = (self.selfAirShipData.endTime - curTime) / 1000
- -- remindTime = type(remindTime) == "number" and remindTime or (#remindTime + 1)
- -- if not self.selfAirShipCompleteTimer then
- -- self.selfAirShipCompleteTimer = Timer.New(slot(self.CompleteSelfAirShip, self), remindTime, 1)
- -- else
- -- self.selfAirShipCompleteTimer.time = remindTime
- -- self.selfAirShipCompleteTimer.duration = remindTime
- -- self.selfAirShipCompleteTimer.loop = 1
- -- end
- end
- -- if self.selfAirShipCompleteTimer then
- -- if not self.selfAirShipCompleteTimer.running then
- -- self.selfAirShipCompleteTimer:Start()
- -- end
- -- end
- else
- -- if self.selfAirShipCompleteTimer then
- -- self.selfAirShipCompleteTimer:Stop()
- -- self.selfAirShipCompleteTimer = nil
- -- end
- -- self:CompleteSelfAirShip(true)
- end
- end
- -- function VoyageDataMgr:CompleteSelfAirShip(noRewards)
- -- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.VoyageCompleteReward, not noRewards)
- -- end
- function VoyageDataMgr:OnVoyageKeepAck(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- self:RefreshAirShipDatas(data.trial_view_list)
- end
- function VoyageDataMgr:OnVoyageKeepNtf(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_NTF " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- self:RefreshAirShipDatas(data.trial_view_list)
- end
- function VoyageDataMgr:RefreshAirShipDatas(list)
- local airShipDatas = self.airShipDatas
- local airShipDataMap = self.airShipDataMap
- local len = #airShipDatas
- local uid = nil
- local endTime = nil
- local airShipDataIdx = nil
- local airShipData = nil
- local needReset = false
- local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
- local selfuid = ManagerContainer.DataMgr.UserData:GetUserId()
- for _, value in pairs(list) do
- uid = value.uid
- endTime = value.end_time_stamp
- -- 超出一分钟的数据就不管了
- if (endTime - curTime) > 60000 and selfuid ~= uid then
- if airShipDataMap[uid] then
- airShipData = airShipDataMap[uid]
- airShipData:SetData(value)
- if airShipData:IsChangeEndTime() then
- needReset = true
- end
- else
- airShipData = VoyageAirShipData:new(value)
- len = len + 1
- airShipDatas[len] = airShipData
- airShipDataMap[uid] = airShipData
- needReset = true
- end
- end
- end
- if needReset then
- table.sort(airShipDatas, AirShipSort)
- end
- for i = len, 1, -1 do
- airShipData = airShipDatas[i]
- endTime = (airShipData.endTime - curTime)
- -- 超出一分钟的数据就不管了
- if endTime <= -60000 then
- table.remove(airShipDatas, i)
- airShipDataMap[airShipData.uid] = nil
- len = len - 1
- elseif endTime < 0 then
- -- 缓存数据过多,清理一下
- if len > 300 then
- table.remove(airShipDatas, i)
- airShipDataMap[airShipData.uid] = nil
- len = len - 1
- end
- else
- break
- end
- end
- end
- function VoyageDataMgr:OnVoyageRefreshAirShipAck(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_REFRESH_TRIAL_TYPE_ACK " .. Inspect(data))
- if not data then
- return
- end
- if not data.error or data.error == 0 then
- self.refreshAirShipResult = true
- elseif data.error == Enum.NetErrorCode.ERROR_CROSS_YUANHANGTRIAL_REFRESH_FAILED then
- self.refreshAirShipResult = false
- else
- self.refreshAirShipResult = false
- end
- end
- function VoyageDataMgr:OnVoyageTakeOffAirShipAck(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- -- self:RefreshSelfAirShip(data.trial_data)
- end
- function VoyageDataMgr:OnVoyageGetRewardAck(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_REWARD_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- CommonUtil.ACKShowRewardList(data.reward_list)
- end
- function VoyageDataMgr:OnVoyageCheckInfoAck(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_INFO_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- if not data.trial_data then
- return
- end
- self:RefreshAirShipDatas({data.trial_data})
- local uid = data.trial_data.uid
- local airShipData = self:GetAirShipDataByUid(uid)
- if airShipData then
- airShipData:SetName(CommonUtil.GetVaildNickName(data.nick_name))
- end
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_CHECK_AIRSHIP_CHANGED, uid)
- end
- function VoyageDataMgr:OnVoyageChallengeAck(data)
- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_CHALLENGE_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- local actorSystem = CreateActorSystem:new()
- actorSystem:ParseFightRoleInfo(data.fight_info)
- self:EnterBattle(data.challenge_uid, data.challenge_uid_end_time, actorSystem)
- end
- function VoyageDataMgr:OnVoyageChallengeResultAck(data)
- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_CHALLENGE_RESULT_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- self.lastBattleRewards = nil
- return
- end
- local rewards = {}
- local rewardLs = data.reward_list
- if rewardLs then
- for i = 1, #rewardLs do
- local rewardData = rewardLs[i]
- rewards[#rewards + 1] = {rewardData.key, rewardData.value}
- end
- end
- self.lastBattleRewards = rewards
- self.lastBattleScores = {data.old_score, data.new_score}
- if self.waitChallengeResultTimer then
- self.waitChallengeResultTimer:Stop()
- self.waitChallengeResultTimer = nil
- end
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.DOJO_CHALLENGE_RESULT_CHANGED)
- end
- function VoyageDataMgr:OnVoyageRankDatasAck(data)
- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_RANK_LIST_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- LogError("=== SC_CROSS_YUAN_HANG_TRIAL_RANK_LIST_ACK Error " .. Inspect(data))
- return
- end
- self.selfRank = data.self_rank
- self.selfScore = data.self_score
- local rankDatas = self.rankDatas
- if not rankDatas then
- rankDatas = {}
- self.rankDatas = rankDatas
- end
- local rankLs = data.rank_list
- local rank = nil
- for i = 1, #rankLs do
- rank = rankLs[i]
- rankDatas[rank.rank] = {
- rank = rank.rank,
- playerBrief = ProtocalDataNormal.ParsePlayerBriefInfo(rank.brief_info),
- score = rank.score
- }
- end
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_RANK_CHANGED)
- end
- function VoyageDataMgr:OnVoyageLogAck(data)
- -- LogError("[wboy] SC_CROSS_YUAN_HANG_TRIAL_LOG_ACK " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then
- return
- end
- if not self.logsData then
- self.logsData = CommonLogData:new()
- end
- local changed, startChanged, endChanged = self.logsData:SetLogs(data.log_list, data.is_end)
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_LOG_CHANGED, changed, startChanged, endChanged)
- end
- function VoyageDataMgr:SendKeepVoyageReq(isNew)
- -- if not self:IsCanSend(1) then
- -- return false
- -- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_REQ, { notify = (not isNew) })
- -- return true
- end
- function VoyageDataMgr:SendExitVoyageReq()
- -- if not self:IsCanSend(2) then
- -- return false
- -- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_VIEW_LIST_OUT_REQ)
- -- return true
- end
- function VoyageDataMgr:SendRefreshAirShipReq(upHighest)
- if not self:IsCanSend(3) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_REFRESH_TRIAL_TYPE_REQ, {force = upHighest})
- return true
- end
- function VoyageDataMgr:SendTakeOffAirShipReq()
- if not self:IsCanSend(4) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_REQ)
- return true
- end
- function VoyageDataMgr:SendGetRewardReq()
- if not self:IsCanSend(5) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_REWARD_REQ)
- return true
- end
- function VoyageDataMgr:SendCheckInfoReq(uid, endTime)
- if not self:IsCanSend(6) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_INFO_REQ, { trial_uid = uid, trial_end_time = endTime })
- return true
- end
- function VoyageDataMgr:SendChallengeReq(uid, endTime)
- if not self:IsCanSend(7) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_CHALLENGE_REQ, {challenge_uid = uid, challenge_uid_end_time = endTime})
- return true
- end
- function VoyageDataMgr:SendChallengeResultReq(uid, endTime, fightTime, isWin)
- if not self:IsCanSend(8) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_CHALLENGE_RESULT_REQ, {challenge_uid = uid, challenge_uid_end_time = endTime, fight_time = fightTime, win = isWin})
- return true
- end
- function VoyageDataMgr:SendGetVoyageRankDatasReq(startIdx)
- if not self:IsCanSend(9) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_RANK_LIST_REQ, { start_idx = startIdx })
- return true
- end
- function VoyageDataMgr:SendLogReq(logTime)
- if not self:IsCanSend(10) then
- return false
- end
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_LOG_REQ, { log_time = logTime })
- return true
- end
- function VoyageDataMgr:GetChallengeNum()
- return self.challengeNum
- end
- function VoyageDataMgr:GetVoyageNum()
- return self.voyageNum
- end
- function VoyageDataMgr:GetRpStatus()
- return self.rpStatus
- end
- function VoyageDataMgr:SetRpStatus(status)
- if self.rpStatus == status then
- return
- end
- self.rpStatus = status
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.VoyageCanChallage, status)
- end
- function VoyageDataMgr:GetCurAirShipId()
- return self.curAirShipId
- end
- function VoyageDataMgr:GetNotifyAirShipUpTip()
- return self.notifyAirShipUpTip
- end
- function VoyageDataMgr:SetNotifyAirShipUpTip(status)
- if self.notifyAirShipUpTip == status then
- return false
- end
- self.notifyAirShipUpTip = status
- return true
- end
- function VoyageDataMgr:GetRefreshAirShipResult()
- return self.refreshAirShipResult
- end
- function VoyageDataMgr:GetSelfAirShipData()
- return self.selfAirShipData
- end
- function VoyageDataMgr:SetKeepVoyageState(status)
- if self.keepVoyageing == status then
- return
- end
- self.keepVoyageing = status
- if status then
- if self.exitVoyageTimer then
- self.exitVoyageTimer:Stop()
- self.exitVoyageTimer = nil
- else
- self:SendKeepVoyageReq(true)
- self:ClearViewListData()
- end
- if not self.keepVoyageTimer then
- self.keepVoyageTimer = Timer.New(slot(self.SendKeepVoyageReq, self), 300, -1)
- else
- self.keepVoyageTimer.time = 300
- end
- if not self.keepVoyageTimer.running then
- self.keepVoyageTimer:Start()
- end
- else
- if self.keepVoyageTimer then
- self.keepVoyageTimer:Stop()
- self.keepVoyageTimer = nil
- end
- if not self.exitVoyageTimer then
- self.exitVoyageTimer = Timer.New(slot(self.ExitVoyage, self), 5, -1)
- else
- self.exitVoyageTimer.time = 5
- end
- if not self.exitVoyageTimer.running then
- self.exitVoyageTimer:Start()
- end
- end
- end
- function VoyageDataMgr:ExitVoyage()
- self:SendExitVoyageReq()
- self:ClearViewListData()
- self:ClearLogData()
- end
- function VoyageDataMgr:GetAirShipDatas()
- return self.airShipDatas
- end
- function VoyageDataMgr:GetAirShipDataByUid(uid)
- return self.airShipDataMap[uid]
- end
- function VoyageDataMgr:ClearViewListData()
- if self.keepVoyageTimer then
- self.keepVoyageTimer:Stop()
- end
- self.keepVoyageTimer = nil
- if self.exitVoyageTimer then
- self.exitVoyageTimer:Stop()
- end
- self.exitVoyageTimer = nil
- self.airShipDatas = {}
- self.airShipDataMap = {}
- end
- function VoyageDataMgr:DisposeViewListData()
- if self.keepVoyageTimer then
- self.keepVoyageTimer:Stop()
- end
- self.keepVoyageTimer = nil
- if self.exitVoyageTimer then
- self.exitVoyageTimer:Stop()
- end
- self.exitVoyageTimer = nil
- self.airShipDatas = nil
- self.airShipDataMap = nil
- end
- function VoyageDataMgr:GetSelfRank()
- return self.selfRank
- end
- function VoyageDataMgr:GetSelfScore()
- return self.selfScore
- end
- function VoyageDataMgr:GetRankDatas()
- return self.rankDatas
- end
- function VoyageDataMgr:ClearRankData()
- self.selfRank = nil
- self.selfScore = nil
- self.rankDatas = nil
- end
- function VoyageDataMgr:GetLogsData()
- return self.logsData
- end
- function VoyageDataMgr:ClearLogData()
- self.logsData = nil
- end
- ----------------------------------------- 战斗 -----------------------------------------
- function VoyageDataMgr:EnterBattle(attackUid, endTime, actorSystem)
- self:ClearLastAttackData()
- self.lastAttackUid = attackUid
- self.lastEndTime = endTime
- self.actorSystem = actorSystem
- ManagerContainer.LuaGameMgr:RefreshTeamData()
- self.matchFighterName = actorSystem:GetUserNickname()
- self.enemyActors = {}
- if actorSystem:GetPlayerActorParam() ~= nil then
- self.enemyActors[#self.enemyActors+1] = actorSystem:GetPlayerActorParam()
- end
- local fellowActors = actorSystem:GetFellowActorParam()
- if fellowActors ~= nil then
- for k,actor in pairs(fellowActors) do
- self.enemyActors[#self.enemyActors +1] = actor
- end
- end
- self.ourMembers = {}
- local actorData = ManagerContainer.LuaActorDataMgr:GetActorData(true, ManagerContainer.DataMgr.UserData:GetId())
- if actorData then
- self.ourMembers[#self.ourMembers + 1] = actorData
- end
- local list = ManagerContainer.DataMgr.PartnerData:GetPartnerDatas()
- if list ~= nil then
- for _,v in pairs(list) do
- if v.owned and v.isBattle then
- actorData = ManagerContainer.LuaActorDataMgr:GetActorData(false, v.configId)
- if actorData then
- self.ourMembers[#self.ourMembers + 1] = actorData
- end
- end
- end
- end
- local selfMaskDatas = nil
- local enemyPvPVal = actorSystem:GetSkillPvPVal()
- local OurPvPVal = ManagerContainer.DataMgr.UserData:GetCurrRoleSkillPress()
- local IsPresspoint,BuffId = ManagerContainer.CfgMgr:GetPresspointPvPCfg(OurPvPVal,enemyPvPVal)
- if BuffId > -1 then
- selfMaskDatas = {}
- selfMaskDatas[1] = GvGMark.New(BuffId, 1)
- end
- local limitedTime = self:GetLimitedTime()
- local battleEndCondList = System.Array.CreateInstance(Enum.TypeInfo.BattleEndCondition, 2)
- battleEndCondList[0] = BattleEndCondition.New(Constants.EndBattle_By_UndeadCount, Constants.ResultType_Normal)
- battleEndCondList[1] = BattleEndCondition.New(Constants.EndBattle_By_BattleTime, limitedTime, Constants.ResultType_Normal, false)
- ManagerContainer.LuaGameMgr:EnterVoyageBattle('scenes_test_pvp', self.ourMembers, self.enemyActors, limitedTime,selfMaskDatas,IsPresspoint,OurPvPVal+enemyPvPVal, battleEndCondList)
- end
- function VoyageDataMgr:BattleEnd(result)
- local battleTime = LuaBattleBridge.GetFightingTime()
- if battleTime < 0 then
- battleTime = 0
- else
- battleTime = Mathf.Ceil(battleTime)
- end
- self.lastBattleWin = result
- local isWin = (result == 1)
- if isWin then
- self:SendChallengeResultReq(self.lastAttackUid, self.lastEndTime, battleTime, isWin)
- if self.waitChallengeResultTimer then
- self.waitChallengeResultTimer.time = 5
- self.waitChallengeResultTimer.loop = 1
- else
- self.waitChallengeResultTimer = Timer.New(slot(self.ForceExitBattle, self), 5, 1)
- end
- if not self.waitChallengeResultTimer.running then
- self.waitChallengeResultTimer:Start()
- end
- end
- self.actorSystem = nil
- self.matchFighterName = nil
- self.enemyActors = nil
- self.ourMembers = nil
- end
- function VoyageDataMgr:ForceExitBattle()
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.DOJO_CHALLENGE_RESULT_CHANGED)
- end
- function VoyageDataMgr:GetMatchFighterName()
- return self.matchFighterName
- end
- function VoyageDataMgr:GetOurMembers()
- return self.ourMembers
- end
- function VoyageDataMgr:GetEnemyMembers()
- return self.enemyActors
- end
- function VoyageDataMgr:GetLimitedTime()
- return GlobalConfig.Instance:GetConfigIntValue(251)
- end
- function VoyageDataMgr:GetLastAttackUid()
- return self.lastAttackUid
- end
- function VoyageDataMgr:GetLastBattleRewards()
- return self.lastBattleRewards
- end
- function VoyageDataMgr:GetLastBattleScores()
- return self.lastBattleScores
- end
- function VoyageDataMgr:GetLastBattleWin()
- return self.lastBattleWin
- end
- function VoyageDataMgr:ClearLastAttackData()
- self.lastAttackUid = nil
- self.lastEndTime = nil
- self.lastBattleRewards = nil
- self.lastBattleScores = nil
- self.lastBattleWin = nil
- if self.waitChallengeResultTimer then
- self.waitChallengeResultTimer:Stop()
- self.waitChallengeResultTimer = nil
- end
- end
- function VoyageDataMgr:GetBuyNum()
- return self.buyNum
- end
- function VoyageDataMgr:GetBuyCost()
- return self.buyNumCost
- end
- function VoyageDataMgr:GetBuyType()
- return self.buyType
- end
- function VoyageDataMgr:GetBuyNumLimit()
- return GlobalConfig.Instance:GetConfigIntValue(364)
- end
- function VoyageDataMgr:RefNumimit()
- self.numLimit = GlobalConfig.Instance:GetConfigIntValue(323)
- end
- function VoyageDataMgr:RefChallengeCount()
- self.challengeCountLimit = GlobalConfig.Instance:GetConfigIntValue(325) + self.buyNum
- end
- function VoyageDataMgr:GetChallengeCountLimit()
- return self.challengeCountLimit
- end
- function VoyageDataMgr:GetNumLimit()
- return self.numLimit
- end
- function VoyageDataMgr:GetRewardByRank(rank)
- if rank == nil or rank == 0 then
- return nil
- end
- local rankRewardCfg = ManagerContainer.CfgMgr:GetYuanHangTrialRankCfg()
- for _, rankRewardItem in pairs(rankRewardCfg) do
- local rankLimit = rankRewardItem.YuanHangTrialRankCondition[1]
- --LogError(rank.."--------------------rankLimit-----"..Inspect(rankLimit))
- if rank == rankLimit[1] then
- return rankRewardItem.YuanHangTrialRankReward
- elseif rank >= rankLimit[1] and rank <= rankLimit[2] then
- return rankRewardItem.YuanHangTrialRankReward
- end
- end
- return nil
- end
- function VoyageDataMgr:OnBuyNumAck(data)
- LogError(" SC_CROSS_YUAN_HANG_TRIAL_BUY_CHALLENGE_NUM_ACK = " .. Inspect(data))
- if ManagerContainer.NetManager:IsErrorData(data) then return end
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.VOYAGE_CHALLENGE_COUNT_CHANGED)
- end
- function VoyageDataMgr:SendChallengeCountBuyReq()
-
- local buyNum = self:GetBuyNum()
-
- local buyNumLimit = self:GetBuyNumLimit()
- if (buyNumLimit - buyNum) <= 0 then
- LogError("购买次数达到上限")
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("312")
- return
- end
- local buyType = self:GetBuyType()
- local cost = self:GetBuyCost()
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIDojoBuyTimes, {cost, nil, self.SureBuyChallengeNumBtn, self,nil,buyType})
-
- end
- function VoyageDataMgr:SureBuyChallengeNumBtn()
- ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CROSS_YUAN_HANG_TRIAL_BUY_CHALLENGE_NUM_REQ , {})
- end
- return VoyageDataMgr
|