LuaBattleMgr.lua 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501
  1. local LuaBattleMgr = class("LuaBattleMgr")
  2. local RoleViewSystem = require("RoleViewSystem")
  3. local NextMapState =
  4. {
  5. None = 0, -- 不需要进入下一地图
  6. WaitServer = 1, -- 客户端表现走到需要表现进入下一地图,而服务器消息还未下发
  7. WaitShow = 2, -- 服务端消息需要进入下一地图,而等待客户端表现
  8. }
  9. local firstLevelId = 10001
  10. local battleStateTimer
  11. local reconnected = false
  12. local CompetitionRefreshLevelLimit
  13. function LuaBattleMgr:ctor()
  14. self.rageLeftTime = 0;
  15. self.rageLeftTimeTimer = nil;
  16. self.lastInComeTime = 0; --上次领取收益时间
  17. self.rewardNum = 0 --累计奖励次数
  18. self.curLevelId = 0; --当前关卡id
  19. self.curMapId = 0; --当前地图id
  20. self.lastLevelId = 0; --当前关卡id
  21. self.lastMapId = 0; --当前地图id
  22. self.lastMapRewardCount = 0;
  23. self.mapRewardCount = 0; --当前未领取次数
  24. self.rewardItemList = nil;
  25. self.accumIncomeTime = 0;
  26. self.maxEvilExp = 0; --魔魂值上限
  27. self.difficulty = 0 -- 普通模式
  28. self.maxInComeTime = 0 --最大可累计的收益时间
  29. self.maxQuickBattleTimes = 0;
  30. self.usedQuickBattleTimes = 0;
  31. self.nextMapState = NextMapState.None
  32. self.needEnterNextMap = false -- 客户端表现已到,等待服务器进入下一个地图的消息
  33. self.waitEnterNextMap = false -- 服务器消息已到,等待进入下一个地图中 (有其它切换地图的表现,则真正切换地图需要等待)
  34. self.bKillBoss = false
  35. self.isBattling = false
  36. self.lastMapRankPercent = 0
  37. self.LastStartOnlineTime = 0--上次时间
  38. self.LastTotalOnlineTime = 0--上次累计时间
  39. self.CurTotalOnlineTime = 0 --本地累计时间
  40. self.LastOnlineRewardId = 0--上一次领取的奖励ID
  41. self.IsOverTime = false
  42. self.isAutochallenge = false
  43. --初始化 资源效率 默认取第一个关卡的效率
  44. local levelData = ManagerContainer.CfgMgr:GetLevelDataById(firstLevelId)
  45. self.lastLevelZeny = levelData.ZenyOl;
  46. self.lastLevelExp = levelData.BaseExpOl;
  47. self.lastLevelPartnerExp = levelData.ParterOl;
  48. self.lastLevelCruise = levelData.CruiseOl;
  49. self.roleViewSystem = RoleViewSystem:new()
  50. self:RegisterNetEvents();
  51. end
  52. function LuaBattleMgr:SetBattleMode(mode)
  53. self.difficulty = mode
  54. end
  55. function LuaBattleMgr:GetBattleMode()
  56. return self.difficulty
  57. end
  58. function LuaBattleMgr:GetLastMapRankPercent()
  59. return self.lastMapRankPercent
  60. end
  61. function LuaBattleMgr:SetLastMapRankPercent(val)
  62. self.lastMapRankPercent = val
  63. end
  64. function LuaBattleMgr:Destroy()
  65. if self.roleViewSystem then
  66. self.roleViewSystem:Dispose()
  67. end
  68. self.roleViewSystem = nil
  69. if tolua.getpeer(self) ~= nil then
  70. tolua.setpeer(self, nil)
  71. end
  72. end
  73. function LuaBattleMgr:RegisterNetEvents()
  74. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_INCOME_ACK,self.OnBattleIncomeAck,self)
  75. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_BOSS_REWARD_ACK,self.OnBossRewardAck,self)
  76. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_BATTLE_DATA_CHANGE_NTF,self.OnBattleDataChangeNtf,self)
  77. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_QUICK_BATTLE_INCOME_ACK,self.OnQuickBattleIncomeAck,self)
  78. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_BATTLE_BOSS_FIGHT_ACK,self.OnChallengeBossFightAck,self)
  79. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_BATTLE_RECORD_DETAIL_SAVE_NTF,self.OnBattleRecordDetalSaveNtf,self)
  80. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_BATTLE_RECORD_ACK,self.OnBattleRecordAck,self)
  81. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_PLAYER_BATTLE_RECORD_DETAIL_ACK,self.OnBattleRecordDetailAck,self)
  82. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_MAP_LEVEL_TYPE_CHANGE_ACK,self.OnChangeMapLevelTypeAct,self)
  83. --在线奖励
  84. self:RegisterOnlineRecordNet()
  85. end
  86. ------------------------------------------------------在线奖励
  87. --GetState
  88. function LuaBattleMgr:GetOnlineState()
  89. local IsFinished = self:IsFinishedOnlineTime()
  90. if IsFinished then
  91. local IsOver = self:IsOverOnlineDay()--是否领完当天
  92. if IsOver then
  93. return Enum.EnumOnineState.ToDayFinished
  94. else
  95. return Enum.EnumOnineState.Receive
  96. end
  97. else
  98. return Enum.EnumOnineState.RunTime
  99. end
  100. end
  101. --注册在线奖励
  102. function LuaBattleMgr:RegisterOnlineRecordNet()
  103. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_ONLINE_TIME_REWARD_ACK,self.OnOnLineTimeRecordAck,self)
  104. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_ONLINE_TIME_REWARD_NTF,self.OnOnLineTimeRecordNtf,self)
  105. end
  106. --移除在线奖励
  107. function LuaBattleMgr:UnRegisterOnlineRecordNet()
  108. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_ONLINE_TIME_REWARD_ACK)
  109. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_ONLINE_TIME_REWARD_NTF)
  110. end
  111. --请求领取在线奖励
  112. function LuaBattleMgr:SendOnlineTimeRecord()
  113. --金币是否足够
  114. if self:GetOnlineState() == Enum.EnumOnineState.ToDayFinished then
  115. return
  116. end
  117. if self:GetOnlineState() == Enum.EnumOnineState.Receive or self:IsCanUseGoldOnline() then
  118. --LogError("Send Record")
  119. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_ONLINE_TIME_REWARD_REQ, {})
  120. end
  121. end
  122. --在线奖励返回
  123. function LuaBattleMgr:OnOnLineTimeRecordAck(data)
  124. --LogError(Inspect(data))
  125. -- int32 error = 1; //错误码
  126. -- repeated KeyValueType reward_item_list = 2; //奖励物品
  127. --show item
  128. end
  129. --在线奖励变化
  130. function LuaBattleMgr:OnOnLineTimeRecordNtf(data)
  131. --LogError(Inspect(data))
  132. self:SyncOnlineTime(data)
  133. end
  134. function LuaBattleMgr:SyncOnlineTime(role_base)
  135. if role_base then
  136. --local Onlinetime = ManagerContainer.LuaTimerMgr:ParseSeconds2Time(role_base.total_online_time)
  137. --LogError("OnlineTime"..Onlinetime)
  138. --LogError("RewardId"..tostring(role_base.online_reward_id))
  139. self.LastStartOnlineTime = role_base.online_stamp / 1000
  140. self.LastStartOnlineTime = type(self.LastStartOnlineTime) == "number" and self.LastStartOnlineTime or #self.LastStartOnlineTime
  141. self.LastTotalOnlineTime = role_base.total_online_time
  142. self.LastOnlineRewardId = role_base.online_reward_id
  143. end
  144. if self.LastOnlineRewardId <= 0 then --当天未领取 计算领取上一期领取ID
  145. local OnlineDay = self:GetTotalDay() + 1 --注册当天就算1天
  146. local Pre_reward_id = self:GetPreDayIdx(OnlineDay)
  147. self.StartOnlineIdx = Pre_reward_id
  148. else
  149. self.StartOnlineIdx = self.LastOnlineRewardId
  150. end
  151. --LogError("Sync = "..tostring(self.StartOnlineIdx))
  152. self.CurTotalOnlineTime = 0
  153. self.IsOverTime = false
  154. self:UpdateOnlineTime()
  155. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_REFRESH_ONLINETIME_CHANGESTATE);
  156. if not self:IsFinishedOnlineTime() then
  157. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.OnlineRewards, false)
  158. end
  159. end
  160. function LuaBattleMgr:FinishedOnlineTime()
  161. self.IsOverTime = true
  162. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.OnlineRewards, true)
  163. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_REFRESH_ONLINETIME_CHANGESTATE);
  164. end
  165. --是否可以领取当前
  166. function LuaBattleMgr:IsFinishedOnlineTime()
  167. return self.IsOverTime
  168. end
  169. --获取online数据 根据天数
  170. function LuaBattleMgr:GetDayOnlineData(Day)
  171. local CurDay = Day
  172. if CurDay == 0 then
  173. CurDay = 1
  174. end
  175. local cfgRwards = ManagerContainer.CfgMgr:GetOnlineRwards()
  176. local tbRwards = {}
  177. for i=1,#cfgRwards do
  178. if cfgRwards[i].Day == CurDay then
  179. table.insert(tbRwards,cfgRwards[i])
  180. end
  181. end
  182. --未取到 取最后表最后一天
  183. if #tbRwards <= 0 then
  184. return self:GetLastOnlineRwards()
  185. end
  186. return tbRwards
  187. end
  188. --获取上一次领取ID根据天数
  189. function LuaBattleMgr:GetPreDayIdx(CurDay)
  190. local tbRwards = self:GetDayOnlineData(CurDay)
  191. if tbRwards then
  192. if #tbRwards >= 1 then
  193. return tbRwards[1].Id - 1
  194. end
  195. end
  196. return 0
  197. end
  198. --是否领取完当天
  199. function LuaBattleMgr:IsOverOnlineDay()
  200. if self.LastOnlineRewardId <= 0 then
  201. return false
  202. end
  203. local cfgRwards = ManagerContainer.CfgMgr:GetOnlineRwards()
  204. local OverDay = cfgRwards[self.LastOnlineRewardId].Day
  205. local LastId = self.LastOnlineRewardId + 1
  206. if LastId > #cfgRwards then --超出 结束
  207. return true
  208. end
  209. for i=LastId,#cfgRwards do
  210. if cfgRwards[i].Day == OverDay then
  211. return false
  212. end
  213. end
  214. return true
  215. end
  216. function LuaBattleMgr:UpdateOnlineTime()
  217. if nil == self.IsOverTime or self.IsOverTime then
  218. return true,ManagerContainer.LuaTimerMgr:ParseSeconds2Time(0)
  219. end
  220. local LastStartTime = self.LastStartOnlineTime - self.LastTotalOnlineTime
  221. local CurTime = ManagerContainer.LuaTimerMgr:GetTimeSecond()
  222. local totaTime = self:GetNextTotalOnlineTime() - self.LastTotalOnlineTime --剩余秒数
  223. if totaTime <= 0 then
  224. totaTime = 0
  225. end
  226. local finishlTime = self.LastStartOnlineTime + totaTime --结束时间
  227. local DeltaTime = finishlTime - CurTime
  228. if self:IsOverOnlineDay() then
  229. DeltaTime = 0
  230. end
  231. if DeltaTime <= 0 then
  232. DeltaTime = 0
  233. self:FinishedOnlineTime()
  234. end
  235. local str = tostring(math.modf(DeltaTime/60))..I18N.T("MINS")..tostring(DeltaTime%60)..I18N.T("S")
  236. --local str = ManagerContainer.LuaTimerMgr:ParseSeconds2Time(DeltaTime)
  237. -- local strCur = ManagerContainer.LuaTimerMgr:ParseTimeStamp2Format(CurTime, "%H:%M")
  238. -- local strLast = ManagerContainer.LuaTimerMgr:ParseTimeStamp2Format(LastTime, "%H:%M")
  239. -- LogError(strCur)
  240. -- LogError(strLast)
  241. return false,str
  242. end
  243. --累计创角天数获取
  244. function LuaBattleMgr:GetTotalDay()
  245. local CreateTime = ManagerContainer.DataMgr.UserData:GetCreateTime()
  246. CreateTime = CreateTime / 1000
  247. CreateTime = type(CreateTime) == "number" and CreateTime or #CreateTime
  248. local TotalTime = tonumber(self.LastStartOnlineTime) - tonumber(CreateTime)
  249. local DeltaD = math.modf(TotalTime/3600/24)
  250. local DeltaS = TotalTime - DeltaD*3600*24
  251. --获取注册时间戳小时
  252. local CreateHour = tonumber(ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%H",CreateTime))
  253. --下一天时间戳计算
  254. local NextDayTime = tonumber(CreateTime) --小于5点 求当天5点时间戳
  255. if CreateHour > 5 then --大于5点 求下一天5点时间戳
  256. NextDayTime = tonumber(CreateTime) + 24 * 3600
  257. end
  258. local Y = tonumber(ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%Y",NextDayTime))
  259. local M = tonumber(ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%m",NextDayTime))
  260. local D = tonumber(ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%d",NextDayTime))
  261. local Data = {year=Y, month=M, day=D, hour=5, minute=0, second=0}
  262. local DayEndStamp = ManagerContainer.LuaTimerMgr:GetTime2StampS(Data)
  263. --注册当天距离第二天总秒
  264. local TotalEndTime = DayEndStamp - CreateTime
  265. ---剩余秒数 是否大于第二天总秒数
  266. if DeltaS > TotalEndTime then --剩余时间是否过了凌晨5点 过了+1天
  267. DeltaD = DeltaD + 1
  268. end
  269. -- LogError("DeltaD"..tostring(DeltaD))
  270. -- LogError("DeltaS"..tostring(DeltaS))
  271. -- LogError("CreateDay"..ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%Y-%m-%d %H:%M:%S",CreateTime))
  272. -- LogError("CreateDay"..ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%Y-%m-%d %H:%M:%S",DayEndStamp))
  273. -- LogError("LastStartOnlineTime"..ManagerContainer.LuaTimerMgr:Getstamp2TimeH("%Y-%m-%d %H:%M:%S",self.LastStartOnlineTime))
  274. -- LogError(tostring(DeltaD))
  275. return DeltaD
  276. end
  277. --最后一天数据
  278. function LuaBattleMgr:GetLastOnlineRwards()
  279. local tbRwards = {}
  280. local cfgRwards = ManagerContainer.CfgMgr:GetOnlineRwards()
  281. local OverDay = cfgRwards[#cfgRwards].Day
  282. for i=1,#cfgRwards do
  283. if cfgRwards[i].Day == OverDay then
  284. table.insert(tbRwards,cfgRwards[i])
  285. end
  286. end
  287. return tbRwards
  288. end
  289. --获取ID的天数数据
  290. function LuaBattleMgr:GetOnlineRwardsById(Id)
  291. local tbRwards = {}
  292. local cfgRwards = ManagerContainer.CfgMgr:GetOnlineRwards()
  293. if Id > #cfgRwards then --ID超出 获取超出后一天数据
  294. return self:GetLastOnlineRwards()
  295. end
  296. -- LogError("GetOnlineRwardsById"..tostring(Id))
  297. -- LogError(Inspect(cfgRwards[Id]))
  298. local OverDay = cfgRwards[Id].Day
  299. for i=1,#cfgRwards do
  300. if cfgRwards[i].Day == OverDay then
  301. table.insert(tbRwards,cfgRwards[i])
  302. end
  303. end
  304. return tbRwards
  305. end
  306. --下一个数据时间 跟 奖励
  307. function LuaBattleMgr:GetNextTotalOnlineTime()
  308. local cfgRwards = ManagerContainer.CfgMgr:GetOnlineRwards()
  309. local TotalTime = 0
  310. local Rewards = {}
  311. if cfgRwards then
  312. local NextId = self.StartOnlineIdx + 1
  313. local Cfg = self:GetOnlineRwardsById(NextId)
  314. if Cfg then
  315. for i = 1,#Cfg do
  316. if NextId > #cfgRwards then --超出范围 取最后一天第1个开始
  317. TotalTime = Cfg[1].Time
  318. Rewards = Cfg[1].Rewards
  319. else--未超出范围 累计获取时间
  320. if Cfg[i].Id == NextId then
  321. --不累计
  322. --TotalTime = TotalTime + Cfg[i].Time --* 60
  323. TotalTime = Cfg[i].Time
  324. Rewards = Cfg[i].Rewards
  325. end
  326. end
  327. end
  328. end
  329. end
  330. return TotalTime + 3,Rewards --3秒延迟 防止服务器时间差
  331. end
  332. --是否可以用金币加速当前
  333. function LuaBattleMgr:IsCanUseGoldOnline()
  334. local Goldcount = CommonUtil.GetOwnResCountByItemId(Enum.ItemType.Diamond)
  335. local NeedItem = self:GetOnlineTimeGlod()
  336. if NeedItem <= Goldcount then
  337. return true
  338. end
  339. return false
  340. end
  341. --获取领取当前金币数据
  342. function LuaBattleMgr:GetOnlineTimeGlod()
  343. local cfgRwards = ManagerContainer.CfgMgr:GetOnlineRwards()
  344. local GoldNum = 0
  345. if cfgRwards then
  346. local NextId = self.StartOnlineIdx +1
  347. local Cfg = self:GetOnlineRwardsById(NextId)
  348. if Cfg then
  349. for i = 1,#Cfg do
  350. if Cfg[i].Id == NextId then
  351. GoldNum = Cfg[i].SpeedUp
  352. end
  353. end
  354. end
  355. end
  356. return GoldNum
  357. end
  358. -------------------------------------------------------------------
  359. function LuaBattleMgr:UnRegisterNetEvents()
  360. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_INCOME_ACK)
  361. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_BOSS_REWARD_ACK)
  362. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_PLAYER_BATTLE_DATA_CHANGE_NTF)
  363. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_QUICK_BATTLE_INCOME_ACK)
  364. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_BATTLE_BOSS_FIGHT_ACK)
  365. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_MAP_LEVEL_TYPE_CHANGE_ACK)
  366. self:UnRegisterOnlineRecordNet()
  367. end
  368. function LuaBattleMgr:SendChallengeBossReq()
  369. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_BATTLE_BOSS_FIGHT_REQ, {})
  370. end
  371. function LuaBattleMgr:OnChallengeBossFightAck(data)
  372. LogError("=========OnChallengeBossFightAck========"..Inspect(data))
  373. if data.error == Enum.NetErrorCode.ERROR_OK then
  374. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Challenge_Boss_Fight_ACK,data.factor_list)
  375. else
  376. if data.left_cd_time > 0 then
  377. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BATTLE_CHALLENGE_TIME_REFRESH, data.left_cd_time)
  378. end
  379. end
  380. end
  381. function LuaBattleMgr:SendChangeMapLevelTypeReq(type)
  382. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_MAP_LEVEL_TYPE_CHANGE_REQ, {type = type})
  383. end
  384. function LuaBattleMgr:OnChangeMapLevelTypeAct(data)
  385. LogError("========OnChangeMapLevelTypeAct=====模式變化請求回復=="..Inspect(data))
  386. end
  387. function LuaBattleMgr:SendQuickBattleReq()
  388. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_QUICK_BATTLE_INCOME_REQ, {})
  389. end
  390. function LuaBattleMgr:SendBattleIncomeReq()
  391. local _isOverFlow, _evilExp = self:JudgeEvilExpOverFlow();
  392. if _isOverFlow then
  393. ManagerContainer.LuaUIMgr:ShowMessageBox("EvilOverFlowTips",{_evilExp, self.maxEvilExp},nil,self,self.CSPlayerIncomeReq,nil)
  394. else
  395. self:CSPlayerIncomeReq();
  396. end
  397. end
  398. function LuaBattleMgr:OnBattleIncomeAck(playerIncomeAck)
  399. if playerIncomeAck.error == 0 then
  400. self.rewardItemList = playerIncomeAck.item_list
  401. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BATTLE_INCOME_ACK,0);
  402. end
  403. end
  404. function LuaBattleMgr:OnQuickBattleIncomeAck(playerIncomeAck)
  405. if playerIncomeAck.error == 0 then
  406. self.rewardItemList = playerIncomeAck.item_list
  407. local itemIcons = {};
  408. for i =1, #self.rewardItemList do
  409. local item = self.rewardItemList[i];
  410. if item.key >= 100 then
  411. local itemCfg = ManagerContainer.CfgMgr:GetItemById(item.key)
  412. if itemCfg~= nil then
  413. itemIcons[#itemIcons+1] = itemCfg.Icon
  414. end
  415. end
  416. end
  417. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleReward,1)
  418. end
  419. end
  420. function LuaBattleMgr:GetRewardCnt(type)
  421. if self.rewardItemList == nil then
  422. return 0
  423. end
  424. for i =1, #self.rewardItemList do
  425. local item = self.rewardItemList[i];
  426. if item.key == type then
  427. return item.value;
  428. end
  429. end
  430. return 0;
  431. end
  432. function LuaBattleMgr:SendBossRewardReq(killedBossTime,recordTimeStamp)
  433. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_BOSS_REWARD_REQ, {challenge_time = killedBossTime,map_id =self.curMapId ,map_level=self.curLevelId,record_time_stamp=recordTimeStamp})
  434. end
  435. function LuaBattleMgr:OnBossRewardAck(playerBossRewardAck)
  436. LogError("OnBossRewardAck -- " .. Inspect(playerBossRewardAck))
  437. if battleStateTimer then
  438. ManagerContainer.LuaTimerMgr:RemoveTimer(battleStateTimer)
  439. battleStateTimer = nil
  440. end
  441. if playerBossRewardAck.error == 0 then
  442. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIChat)
  443. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattle)
  444. self.rewardItemList = playerBossRewardAck.item_list
  445. if self:IsNewMap() then
  446. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleBossBox)
  447. else
  448. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleWin)
  449. end
  450. else
  451. -- LogError("----------------OnBattleIncomeAck---- " .. playerBossRewardAck.error)
  452. self:ClearRageTimer()
  453. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BATTLE_FAILED);
  454. end
  455. end
  456. function LuaBattleMgr:OnBattleDataChangeNtf(data)
  457. self:OnBattleDataChange(data,false)
  458. end
  459. function LuaBattleMgr:OnBattleDataChange(data,IsShowEnterNextMap)
  460. self:SetBattleData(data,false,IsShowEnterNextMap)
  461. LogError("OnBattleDataChangeNtf -- " .. Inspect(data))
  462. -- LogError("self.lastInComeTime -- " .. self.lastInComeTime)
  463. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_REFRESH_REWARD_TIME);
  464. end
  465. function LuaBattleMgr:GetRewardMapCount()
  466. return self.lastMapRewardCount
  467. end
  468. -- 模擬數據
  469. function LuaBattleMgr:GetSimulationBattleData(mapId,mapLv)
  470. return {
  471. last_income_time = self.lastInComeTime,
  472. map_id = mapId,
  473. map_level = mapLv,
  474. max_income_time = 216000000,
  475. quick_battle = {
  476. day_times = self.usedQuickBattleTimes,
  477. draw_time = 1728939602,
  478. max_times = self.maxQuickBattleTimes
  479. },
  480. reward_map_count = self.mapRewardCount
  481. }
  482. end
  483. function LuaBattleMgr:SetBattleData(data,first,IsShowEnterNextMap)
  484. local preMapId = self.curMapId;
  485. self.lastLevelId = self.curLevelId
  486. self.lastMapId = self.curMapId
  487. self.lastInComeTime = data.last_income_time
  488. self.curMapId = data.map_id
  489. self.curLevelId = data.map_level
  490. if first then
  491. CompetitionRefreshLevelLimit = GlobalConfig.Instance:GetConfigIntValue(248)
  492. ManagerContainer.UIFuncUnlockMgr:SetLoggedinLevelId(self:GetCurLevelUniqueId())
  493. end
  494. self.lastMapRewardCount = self.mapRewardCount
  495. self.mapRewardCount = data.reward_map_count
  496. local rewardIntervalTime = GlobalConfig.Instance:GetConfigIntValue(47)
  497. local passedTime = ManagerContainer.LuaGameMgr:CalcPassedTime(self.lastInComeTime) / 1000
  498. if passedTime >= self.maxInComeTime then
  499. passedTime = self.maxInComeTime
  500. end
  501. self.maxRewardNum = self.maxInComeTime / rewardIntervalTime
  502. self.rewardNum = CommonUtil.GetPreciseDecimal(math.floor(passedTime / rewardIntervalTime),0)
  503. self.leftRewardTime = rewardIntervalTime - (passedTime - self.rewardNum*rewardIntervalTime)
  504. if self.leftRewardTime <= 0 or self.leftRewardTime > rewardIntervalTime then
  505. self.leftRewardTime = rewardIntervalTime
  506. end
  507. if data.quick_battle ~= nil then
  508. if data.quick_battle.max_times ~= nil then
  509. self.maxQuickBattleTimes = data.quick_battle.max_times
  510. end
  511. if data.quick_battle.day_times ~= nil then
  512. self.usedQuickBattleTimes = data.quick_battle.day_times
  513. end
  514. end
  515. ManagerContainer.LuaGameMgr:SetMapLevelId(self.curMapId,self.curLevelId);
  516. if preMapId > 0 and preMapId~= self.curMapId then
  517. if self.nextMapState == NextMapState.WaitServer then
  518. self:ShowEnterNextMap()
  519. return
  520. elseif IsShowEnterNextMap then
  521. self:EnterToTargetMap()
  522. return
  523. end
  524. self.nextMapState = NextMapState.WaitShow
  525. end
  526. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_LEVEL_CHANGED)
  527. end
  528. function LuaBattleMgr:IsNewMap()
  529. return self.curMapId > self.lastMapId
  530. end
  531. function LuaBattleMgr:StartSyncServerTimeTimer()
  532. if self.timerId ~= nil then
  533. return
  534. end
  535. ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_GET_SERVER_TIME_ACK,self.OnUpdateServerTimeAck,self)
  536. self.timerId = ManagerContainer.LuaTimerMgr:AddTimer(60000, -1, self, self.SendGetServerTimeReq, nil)
  537. end
  538. function LuaBattleMgr:SendGetServerTimeReq()
  539. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_GET_SERVER_TIME_REQ, {})
  540. end
  541. function LuaBattleMgr:SetReconnected(result)
  542. reconnected = result
  543. end
  544. function LuaBattleMgr:OnUpdateServerTimeAck(timeAck)
  545. ManagerContainer.LuaTimerMgr:SyncServerTime(timeAck.server_time)
  546. --每分钟判断
  547. ManagerContainer.DataMgr.RankActivitiesMgr:CheckRancActivityOpenTime()
  548. ManagerContainer.DataMgr.RuneShopDataMgr:CheckAirShipActivityOpenTime()
  549. ManagerContainer.DataMgr.CompetitionData:UpdateCompetitionTime()
  550. ManagerContainer.DataMgr.ActsDataMgr:UpdateActsEndTime()
  551. if reconnected then
  552. reconnected = false
  553. self:RefreshRewardNum()
  554. end
  555. end
  556. function LuaBattleMgr:StopSyncServerTimeTimer()
  557. ManagerContainer.NetManager:UnRegisterPbIdCallback(ProtoMsgId.SC_GET_SERVER_TIME_ACK)
  558. if self.timerId~= nil then
  559. ManagerContainer.LuaTimerMgr:RemoveTimer(self.timerId)
  560. self.timerId = nil
  561. end
  562. end
  563. --收益累积时长
  564. function LuaBattleMgr:AccumIncomeTime()
  565. local passedTime = ManagerContainer.LuaGameMgr:CalcPassedTime(self.lastInComeTime);
  566. return passedTime;
  567. end
  568. function LuaBattleMgr:MaxInComeTime()
  569. return self.maxInComeTime
  570. end
  571. function LuaBattleMgr:GetIncomeInfo()
  572. return self.leftRewardTime, self.rewardNum
  573. end
  574. function LuaBattleMgr:RefreshRewardNum()
  575. local rewardIntervalTime = GlobalConfig.Instance:GetConfigIntValue(47)
  576. local passedTime = ManagerContainer.LuaGameMgr:CalcPassedTime(self.lastInComeTime) / 1000
  577. if passedTime >= self.maxInComeTime then
  578. passedTime = self.maxInComeTime
  579. end
  580. self.rewardNum = CommonUtil.GetPreciseDecimal(math.floor(passedTime / rewardIntervalTime),0)
  581. self.leftRewardTime = rewardIntervalTime - (passedTime - self.rewardNum*rewardIntervalTime)
  582. if self.leftRewardTime <= 0 or self.leftRewardTime > rewardIntervalTime then
  583. self.leftRewardTime = rewardIntervalTime
  584. end
  585. end
  586. function LuaBattleMgr:OnRefreshRewardTime()
  587. self:RefreshRewardNum()
  588. --self.leftRewardTime = self.leftRewardTime - 1
  589. if self.leftRewardTime <= 0 then
  590. self.leftRewardTime = GlobalConfig.Instance:GetConfigIntValue(47)
  591. self.rewardNum = self.rewardNum + 1
  592. if self.rewardNum > self.maxRewardNum then
  593. self.rewardNum = self.maxRewardNum
  594. end
  595. end
  596. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_REFRESH_REWARD_TIME);
  597. end
  598. function LuaBattleMgr:StartAutoChallenge()
  599. if not self.isAutochallenge then
  600. return
  601. end
  602. local sec = GlobalConfig.Instance:GetConfigIntValue(311)
  603. if sec < 0 then
  604. sec = 0
  605. end
  606. if not self.autoChallengeTimer then
  607. self.autoChallengeTimer = Timer.New(function()
  608. self:AutoChallenge()
  609. end, sec, 1)
  610. else
  611. self.autoChallengeTimer:Reset(function()
  612. self:AutoChallenge()
  613. end, sec, 1)
  614. end
  615. if not self.autoChallengeTimer.running then
  616. self.autoChallengeTimer:Start()
  617. end
  618. end
  619. function LuaBattleMgr:AutoChallenge()
  620. if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIBattle) then
  621. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_CHALLENGE_AUTO)
  622. end
  623. end
  624. function LuaBattleMgr:StopAutoChallenge(force)
  625. if self.autoChallengeTimer then
  626. self.autoChallengeTimer:Stop()
  627. self.autoChallengeTimer = nil
  628. end
  629. if self.isAutochallenge then
  630. self.isAutochallenge = false
  631. if force then
  632. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("stopautobattle")
  633. end
  634. end
  635. end
  636. function LuaBattleMgr:GetAutoChallengeState()
  637. return self.isAutochallenge
  638. end
  639. function LuaBattleMgr:SetAutoChallengeState(value)
  640. self.isAutochallenge = value
  641. end
  642. --boss出生
  643. function LuaBattleMgr:OnBossSpawned(bossActor,bossName,life,maxLife,skillParam,isPlayRecord)
  644. self.bKillBoss = true
  645. --boos 展示等级设置为当前关卡Turn
  646. local curLevel = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  647. local levelData = ManagerContainer.CfgMgr:GetLevelDataById(curLevel)
  648. bossActor.ShowLevel = levelData.Turn
  649. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BOSS_SPAWNED,bossActor,bossName,life,maxLife,skillParam,isPlayRecord)
  650. end
  651. function LuaBattleMgr:OnCloneNewBoss(bossName,life,maxLife,skillParam)
  652. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_CLONE_NEW_BOSS,bossName,life,maxLife,skillParam)
  653. end
  654. -- 开始战斗
  655. function LuaBattleMgr:OnFightingStart(killingBoss)
  656. Log("=======OnFightingStart===开始战斗=============")----------困難模式 加入Debug 屬性削減
  657. self.isBattling = true
  658. if killingBoss then
  659. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_FIGHTING_START)
  660. end
  661. end
  662. --清空战斗统计日志
  663. function LuaBattleMgr:ClearBattleLog()
  664. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_CLEAR_New_BattleLog)
  665. end
  666. function LuaBattleMgr:GetFightState()
  667. return self.isBattling
  668. end
  669. function LuaBattleMgr:GetBossFightState()
  670. return self.bKillBoss
  671. end
  672. -- 战斗胜利
  673. function LuaBattleMgr:OnBattleWin(killboss, killBossTime, mapId, levelId, isPlayRecord, recordTimeStamp)
  674. self:CloseBattleStatistics()
  675. self.isBattling = false
  676. if killboss then
  677. self.bKillBoss = false
  678. if not isPlayRecord then --
  679. if self.curMapId == mapId and self.curLevelId == levelId and self.difficulty == 0 then
  680. self:SendBossRewardReq(killBossTime,recordTimeStamp)
  681. else
  682. LogError('[wboy] curMapId : ' .. tostring(self.curMapId) .. ' curMapId : ' .. tostring(self.curLevelId) .. ' mapId : ' .. tostring(mapId) .. ' levelId : ' .. tostring(levelId))
  683. end
  684. battleStateTimer = ManagerContainer.LuaTimerMgr:AddTimer(5000, 1,self,self.BattleStateRefresh,nil);
  685. end
  686. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_BATTLE_NORMAL_NTF)
  687. local levelId = self:GetCurLevelUniqueId()
  688. if levelId >= CompetitionRefreshLevelLimit then
  689. ManagerContainer.DataMgr.CompetitionData:SetRefreshSeasonState(true)
  690. ManagerContainer.DataMgr.CompetitionData:QueryCurCompetitionReq(true)
  691. end
  692. ManagerContainer.DataMgr.RankActivitiesMgr:QueryCurRankActivityData(Enum.RankActivitiesType.MapProgress)
  693. end
  694. self:ClearRageTimer()
  695. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BATTLE_WIN);
  696. end
  697. function LuaBattleMgr:BattleStateRefresh()
  698. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.GOT_ANIM_TYPE_END_NOTIFY, Enum.ItemIEnterType.BattleWin)
  699. end
  700. --战斗失败
  701. function LuaBattleMgr:OnBattleFailed(killboss,isPlayRecord)
  702. self:CloseBattleStatistics()
  703. self.isBattling = false
  704. self.bKillBoss = false
  705. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_BATTLE_NORMAL_NTF)
  706. self:ClearRageTimer()
  707. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BATTLE_FAILED,killboss,isPlayRecord);
  708. self:StopAutoChallenge(true)
  709. end
  710. --强制巡游战斗失败
  711. function LuaBattleMgr:OnForceBattleFailed(killboss,isPlayRecord)
  712. self:CloseBattleStatistics()
  713. self.isBattling = false
  714. self.bKillBoss = false
  715. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_BATTLE_NORMAL_NTF)
  716. self:ClearRageTimer()
  717. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_FORCEBATTLE_FAILED,killboss,isPlayRecord);
  718. end
  719. function LuaBattleMgr:CloseBattleStatistics()
  720. if self.bKillBoss then
  721. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIBattleStatistics)
  722. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIBattleBossTips)
  723. end
  724. end
  725. function LuaBattleMgr:ShowErrorQuitBattleMsgBox()
  726. ManagerContainer.LuaUIMgr:ShowOkMessageBox("ErrorQuitBattleTip",self.QuitBattleMsgOk)
  727. end
  728. function LuaBattleMgr:QuitBattleMsgOk()
  729. LuaBattleBridge.SkipReplay()
  730. end
  731. function LuaBattleMgr:CloseErrorQuitBattleMsgBox()
  732. ManagerContainer.LuaUIMgr:CloseOkMessageBox("ErrorQuitBattleTip")
  733. end
  734. function LuaBattleMgr:ShowAntiCheatMsgBox(nType)
  735. --上报使用外挂
  736. self:SendAntiCheat(nType)
  737. ManagerContainer.LuaUIMgr:ShowOkMessageBox("AntiCheatMsg",self.AntiCheatQuitGameMsgOk)
  738. end
  739. function LuaBattleMgr:SendAntiCheat(nType)
  740. --上报使用外挂
  741. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_ANTI_CHEAT_REQ, { cheat_type = nType})
  742. end
  743. function LuaBattleMgr:AntiCheatQuitGameMsgOk()
  744. ManagerContainer.NetManager:ResetNetMgr()
  745. ManagerContainer.LuaGameMgr:QuitGame()
  746. end
  747. function LuaBattleMgr:CloseAntiCheatMsgBox()
  748. ManagerContainer.LuaUIMgr:CloseOkMessageBox("AntiCheatMsg")
  749. end
  750. function LuaBattleMgr:GetCurLevelUniqueId()
  751. return self.curMapId*10000 + self.curLevelId
  752. end
  753. function LuaBattleMgr:GetLastLevelUniqueId()
  754. return self.lastMapId*10000 + self.lastLevelId
  755. end
  756. function LuaBattleMgr:GetLastMapIdAndLvId()
  757. return self.lastMapId,self.lastLevelId
  758. end
  759. --下一关卡
  760. function LuaBattleMgr:OnBattleNewWave(levelName)
  761. self.nextMapState = NextMapState.None
  762. -- if ManagerContainer.UIFuncUnlockMgr:NeedOpenFuncCurLevelStart(self:GetCurLevelUniqueId()) then
  763. -- --功能解锁
  764. -- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FUNCLOCK_OPEN_NTF)
  765. -- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_BATTLE_FUNC_OPEN_NTF);
  766. -- else
  767. -- self.closeLevelNameTimer = ManagerContainer.LuaTimerMgr:AddTimer(GlobalConfig.Instance:GetConfigFloatValue(79)*1000, 1,self,self.OnCloseLevelName,nil);
  768. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_NEXT_BATTLE,levelName);
  769. -- end
  770. end
  771. function LuaBattleMgr:OnCloseLevelName()
  772. self.closeLevelNameTimer = nil;
  773. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_HIDE_LEVEL_NAME);
  774. end
  775. --继续同一关战斗
  776. function LuaBattleMgr:OnContinueBattle()
  777. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_CONTINUE_BATTLE);
  778. ----如果还是处于第一关 且 强制引导战斗没成功 则继续强制引导战斗
  779. --local curLevelId = self:GetCurLevelUniqueId()
  780. --if curLevelId == 10001 then
  781. -- ManagerContainer.ForceGuideMgr:GuideBossBattle()
  782. --end
  783. end
  784. function LuaBattleMgr:OnShowBossRage(vis)
  785. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHOW_BOSS_RAGE)
  786. end
  787. --狂暴剩余时间
  788. function LuaBattleMgr:OnShowBossRageLeftTime(leftTime)
  789. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHOW_BOSS_RAGE_LEFTTIME,leftTime);
  790. end
  791. --boss进入狂暴
  792. function LuaBattleMgr:OnBossInRage()
  793. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BOSS_IN_RAGE);
  794. end
  795. function LuaBattleMgr:OnBattleStartStory(levelId, storyId)
  796. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UISTORY_CONDITION_TRIGGER, Enum.UIStoryCondType.FirstSceneEnter, levelId, storyId)
  797. end
  798. --战斗结束
  799. function LuaBattleMgr:OnBattleEnd(killBoss,killBossTime,win,isPlayRecord)
  800. self.lastLevelZeny = self:CurLevelZeny()
  801. self.lastLevelExp = self:CurLevelExp()
  802. self.lastLevelPartnerExp = self:CurLevelParnterExp()
  803. self.lastLevelCruise = self:CurLevelCruise()
  804. if killBoss then
  805. --self.bKillBoss = false
  806. if not isPlayRecord then
  807. --ManagerContainer.DataMgr.BigMapData:SendGetData()
  808. end
  809. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BOSS_Battle_End,isPlayRecord)
  810. self:OnBattleUIVis(true)
  811. end
  812. end
  813. ------------------战斗录像相关----------------------------------------
  814. function LuaBattleMgr:SendBattleDetailReq(battleRecordUid,battleTime,fightPower)
  815. self.curReqBattleRecordId = battleRecordUid
  816. self.cacheRecordBattleTime = battleTime
  817. self.cacheRecordFightPower = fightPower
  818. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_BATTLE_RECORD_DETAIL_REQ, {battle_record_uid = battleRecordUid})
  819. end
  820. function LuaBattleMgr:OnBattleRecordDetailAck(pkg)
  821. -- LogError(Inspect(pkg))
  822. if pkg.error == 0 then
  823. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Fetch_BattleRecord_Success,pkg.battle_record_uid,pkg.battle_record)
  824. ManagerContainer.LuaGameMgr:SetGameSpeed(ManagerContainer.LuaGameMgr.GameSpeed)
  825. self:StopAutoChallenge(true)
  826. end
  827. end
  828. function LuaBattleMgr:GetCacheRecordInfo()
  829. return self.cacheRecordBattleTime, self.cacheRecordFightPower
  830. end
  831. function LuaBattleMgr:OnBattleRecordDetalSaveNtf(pkg)
  832. --LogError("OnBattleRecordDetalSaveNtf Save")
  833. local battleRecordUid = pkg.battle_record_uid
  834. local battleTimeStamp = pkg.record_time_stamp
  835. local battleRecordStr = LuaBattleBridge.GetBattleRecord(battleTimeStamp)
  836. if battleRecordStr ~= nil and battleRecordStr~="" then
  837. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_BATTLE_RECORD_DETAIL_SAVE_REQ, {battle_record_uid = battleRecordUid, battle_record = battleRecordStr})
  838. end
  839. end
  840. function LuaBattleMgr:OnBattleRecordAck(pkg)
  841. if pkg.error == 0 then
  842. if #pkg.record_list > 0 then
  843. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleReplay,pkg.record_list)
  844. else
  845. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("NullBattleReport")
  846. end
  847. end
  848. end
  849. -------------------------------------------------------------------------
  850. function LuaBattleMgr:OnReplayEnd()
  851. self:CloseBattleStatistics()
  852. self.isBattling = false
  853. self.bKillBoss = false
  854. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_BATTLE_NORMAL_NTF)
  855. self:ClearRageTimer()
  856. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BATTLE_WIN);
  857. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIDojoExit,true)
  858. end
  859. function LuaBattleMgr:GetBossFightStatus()
  860. return self.bKillBoss
  861. end
  862. function LuaBattleMgr:ClearRageTimer()
  863. if self.rageLeftTimeTimer ~= nil then
  864. ManagerContainer.LuaTimerMgr:RemoveTimer(self.rageLeftTimeTimer);
  865. self.rageLeftTimeTimer = nil;
  866. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_BOSS_IN_RAGE);
  867. end
  868. end
  869. --bIsForce 强制结束战斗 设置属性
  870. function LuaBattleMgr:SetTeamData(ignore,bIsForce)
  871. local teamData = ManagerContainer.DataMgr.UserData:GetTeamData(ignore);
  872. if teamData == nil then return end
  873. ManagerContainer.LuaGameMgr:SetTeamData(teamData,{bIsForce})
  874. ManagerContainer.LuaActorAttributeMgr:SyncServerActorDataToLocal()
  875. end
  876. --更新技能数据
  877. function LuaBattleMgr:UpdateTeamSkills()
  878. local usersSkills = {}
  879. local heroId = ManagerContainer.DataMgr.UserData:GetId()
  880. local skillData = ManagerContainer.DataMgr.UserData:GetSkillData(heroId)
  881. local skills = skillData and skillData:GetUsedSkills() or {}
  882. local heroData = CommonUtil.GetHeroLogicDataByUid(1)
  883. CommonUtil.ReplaceBattleSkillBySkillEquip(heroData, skills)
  884. usersSkills[#usersSkills+1] = {
  885. uid = heroId,
  886. skills = skills,
  887. }
  888. local list = ManagerContainer.DataMgr.PartnerData:GetBattlePartnerDatas(true)
  889. if list ~= nil then
  890. for _,v in pairs(list) do
  891. skillData = ManagerContainer.DataMgr.UserData:GetSkillData(v.uid)
  892. local skills = skillData and skillData:GetUsedSkills() or {}
  893. CommonUtil.ReplaceBattleSkillBySkillEquip(v, skills)
  894. usersSkills[#usersSkills + 1] = {uid = v.uid, skills = skills }
  895. end
  896. end
  897. ManagerContainer.LuaGameMgr:UpdateTeamSkills(usersSkills);
  898. end
  899. function LuaBattleMgr:NotifyEnterNextMapStart()
  900. if self.nextMapState == NextMapState.WaitShow then
  901. self:ShowEnterNextMap()
  902. return
  903. end
  904. self.nextMapState = NextMapState.WaitServer
  905. end
  906. function LuaBattleMgr:NotifyEnterNextMapEnd()
  907. if ManagerContainer.FSMMgr:IsBattleState() then
  908. -- 在战斗场景中,才走大地图过图效果
  909. self:OnEnterNextMap()
  910. end
  911. end
  912. function LuaBattleMgr:NotifyVipLvChanged()
  913. self.maxInComeTime = GlobalConfig.Instance:GetConfigIntValue(48)
  914. self.maxQuickBattleTimes = GlobalConfig.Instance:GetConfigIntValue(240)
  915. local vipLv = ManagerContainer.DataMgr.UserData:GetVipLv()
  916. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
  917. if vipCfg then
  918. self.maxInComeTime = self.maxInComeTime + tonumber(vipCfg.HangupDuration)
  919. self.maxQuickBattleTimes = self.maxQuickBattleTimes + tonumber(vipCfg.HangupTimes)
  920. end
  921. end
  922. function LuaBattleMgr:ShowEnterNextMap()
  923. if ManagerContainer.FSMMgr:IsBattleState() then
  924. -- 在战斗场景中,才走大地图过图效果
  925. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIWorldMap, true)
  926. end
  927. end
  928. function LuaBattleMgr:EnterToTargetMap()
  929. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIWorldMap, true)
  930. end
  931. -- 创建主角形象
  932. function LuaBattleMgr:CreateRoleView()
  933. if self.roleViewSystem then
  934. local userData = ManagerContainer.DataMgr.UserData
  935. local heroData = userData:GetMainRoleData()
  936. self.roleViewSystem:RefreshView(Enum.RoleInEnvType.Battle, userData:GetUserRoleId(), userData:GetViewData(), nil, self, self.CreateRoleViewComplete)
  937. end
  938. end
  939. -- 完成主角创建
  940. function LuaBattleMgr:CreateRoleViewComplete(gameObject)
  941. ManagerContainer.LuaGameMgr:CreateRoleViewComplete(gameObject)
  942. end
  943. -- 通知战斗需要更新主角新形象
  944. function LuaBattleMgr:NotifyRefreshRoleView()
  945. self.waitingRefreshRole = true
  946. ManagerContainer.LuaGameMgr:NotifyRefreshRoleView()
  947. end
  948. function LuaBattleMgr:GetWaitingRefreshRoleState()
  949. return self.waitingRefreshRole == true
  950. end
  951. -- 刷新主角形象
  952. function LuaBattleMgr:RefreshRoleView()
  953. if self.roleViewSystem then
  954. local userData = ManagerContainer.DataMgr.UserData
  955. local heroData = userData:GetMainRoleData()
  956. self.roleViewSystem:RefreshView(Enum.RoleInEnvType.Battle, userData:GetUserRoleId(), userData:GetViewData(), nil, self, self.RefreshRoleViewComplete)
  957. end
  958. end
  959. -- 完成主角形象更新
  960. function LuaBattleMgr:RefreshRoleViewComplete(gameObject, isNewModel)
  961. self.waitingRefreshRole = false
  962. ManagerContainer.LuaGameMgr:RefreshRoleViewComplete(gameObject, isNewModel)
  963. self:NotifyLoadingStatusEnd(Enum.BattleBtnState.RoleModel)
  964. end
  965. function LuaBattleMgr:RecycleRoleView()
  966. if self.roleViewSystem then
  967. self.roleViewSystem:Recycle()
  968. end
  969. end
  970. -- function LuaBattleMgr:NotifyRefreshUpRoleLvEffect()
  971. -- self:NotifyRefreshUpLvEffect('Common/FX_Scene_LV_UP')
  972. -- end
  973. -- function LuaBattleMgr:NotifyRefreshUpJobLvEffect()
  974. -- self:NotifyRefreshUpLvEffect('Common/FX_Scene_LV_UP')
  975. -- end
  976. -- function LuaBattleMgr:NotifyRefreshUpLvEffect(effectName)
  977. -- if not self.roleViewSystem then return end
  978. -- local roleGo = self.roleViewSystem:GetGameObject()
  979. -- if tolua.isnull(roleGo) then return end
  980. -- local timeStamp = Time.GetTimestamp()
  981. -- if not self.upLvEffectCDs then
  982. -- self.upLvEffectCDs = {}
  983. -- end
  984. -- local upLvEffectCD = self.upLvEffectCDs[effectName] or (timeStamp - 2)
  985. -- -- 1秒内不出现两次升级特效
  986. -- if timeStamp - upLvEffectCD <= 1 then
  987. -- return
  988. -- end
  989. -- self.upLvEffectCDs[effectName] = timeStamp
  990. -- ManagerContainer.ResMgr:GetGOFromPool(Constants.EffectPath, effectName, function(go)
  991. -- if ManagerContainer.FSMMgr:IsBattleState() then
  992. -- self:UpLvEffectShow(go, effectName)
  993. -- end
  994. -- end)
  995. -- end
  996. -- --- 显示升级特效
  997. -- function LuaBattleMgr:UpLvEffectShow(go, effectName)
  998. -- if not go then return end
  999. -- if self.roleViewSystem then
  1000. -- local roleGo = self.roleViewSystem:GetGameObject()
  1001. -- if not tolua.isnull(roleGo) then
  1002. -- local link = roleGo.transform:Find('foot_point')
  1003. -- if not tolua.isnull(link) then
  1004. -- go.transform.parent = link
  1005. -- go.transform.localPosition = Vector3.zero
  1006. -- go.transform.localRotation = Quaternion.identity
  1007. -- go.transform.localScale = Vector3.one
  1008. -- local upLvEffects = self.upLvEffects
  1009. -- if not upLvEffects then
  1010. -- upLvEffects = {}
  1011. -- self.upLvEffects = upLvEffects
  1012. -- end
  1013. -- local info = {}
  1014. -- info.effectName = effectName
  1015. -- info.timerId = ManagerContainer.LuaTimerMgr:AddTimer(2000, 1, self, self.UpLvEffectHide, {go = go})
  1016. -- upLvEffects[go] = info
  1017. -- return
  1018. -- end
  1019. -- LogError('Link Point : foot_point is not Find')
  1020. -- end
  1021. -- end
  1022. -- -- 出现问题,直接回收掉效果,直接回收掉升级特效
  1023. -- ManagerContainer.ResMgr:RecycleGO(Constants.EffectPath, effectCfg.Effect, go)
  1024. -- end
  1025. -- --- 升级特效播放完成,需要回收掉
  1026. -- function LuaBattleMgr:UpLvEffectHide(timerId, params)
  1027. -- local go = params.go
  1028. -- if not go then return end
  1029. -- local upLvEffects = self.upLvEffects
  1030. -- if not upLvEffects then return end
  1031. -- local info = upLvEffects[go]
  1032. -- local timeId = info.timerId
  1033. -- local effectName = info.effectName
  1034. -- if timeId ~= timerId then
  1035. -- LogError('timeId is error, cur : ' .. tostring(timeId) .. ' cbTimerId : ' .. tostring(timerId))
  1036. -- end
  1037. -- if timeId then
  1038. -- ManagerContainer.LuaTimerMgr:RemoveTimer(timeId)
  1039. -- timeId = nil
  1040. -- end
  1041. -- upLvEffects[go] = nil
  1042. -- ManagerContainer.ResMgr:RecycleGO(Constants.EffectPath, effectName, go)
  1043. -- end
  1044. -- --- 回收所有显示的升级特效
  1045. -- function LuaBattleMgr:RecycleUpLvEffect()
  1046. -- local upLvEffects = self.upLvEffects
  1047. -- if not upLvEffects then return end
  1048. -- for go, info in pairs(upLvEffects) do
  1049. -- local timeId = info.timerId
  1050. -- local effectName = info.effectName
  1051. -- if timeId then
  1052. -- ManagerContainer.LuaTimerMgr:RemoveTimer(timeId)
  1053. -- timeId = nil
  1054. -- end
  1055. -- ManagerContainer.ResMgr:RecycleGO(Constants.EffectPath, effectName, go)
  1056. -- end
  1057. -- self.upLvEffects = nil
  1058. -- self.upLvEffectCDs = nil
  1059. -- end
  1060. function LuaBattleMgr:OnShowBossWarning()
  1061. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHOW_BOSS_WARNING,true);
  1062. ManagerContainer.LuaTimerMgr:AddTimer(3000, 1,self,self.OnHideBossWarningTimer,nil);
  1063. end
  1064. function LuaBattleMgr:OnHideBossWarningTimer()
  1065. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHOW_BOSS_WARNING,false);
  1066. end
  1067. function LuaBattleMgr:OnEnterNextMap()
  1068. self.bKillBoss = false
  1069. self.nextMapState = NextMapState.None
  1070. ManagerContainer.LuaGameMgr:OpenLoading(Enum.UIPageName.UILoading)
  1071. ManagerContainer.FSMMgr:ChangeState(Enum.StateEnum.LoadingState.stateId, SceneType.NormalBattleScene)
  1072. end
  1073. function LuaBattleMgr:CurLevelExp()
  1074. return LuaBattleBridge.GetCurLevelExp();
  1075. end
  1076. function LuaBattleMgr:CurLevelParnterExp()
  1077. return LuaBattleBridge.GetCurLevelParnterExp();
  1078. end
  1079. function LuaBattleMgr:CurLevelGold()
  1080. return LuaBattleBridge.GetCurLevelGold();
  1081. end
  1082. function LuaBattleMgr:CurLevelCruise()
  1083. return LuaBattleBridge.GetCurLevelCruise();
  1084. end
  1085. function LuaBattleMgr:CurLevelEvil()
  1086. return LuaBattleBridge.GetCurLevelEvil()
  1087. end
  1088. function LuaBattleMgr:CurLevelZeny()
  1089. return LuaBattleBridge.GetCurLevelZeny()
  1090. end
  1091. function LuaBattleMgr:CurLevelName()
  1092. return LuaBattleBridge.GetCurLevelName();
  1093. end
  1094. function LuaBattleMgr:SetRewardDropPos(dropPos)
  1095. LuaBattleBridge.SetRewardDropPos(dropPos)
  1096. end
  1097. function LuaBattleMgr:Enter()
  1098. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.ROLE_JOB_CHANGE_SUCCESS, self, self.NotifyRefreshRoleView)
  1099. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.FASHION_WEAR_CHANGE, self, self.NotifyRefreshRoleView)
  1100. -- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.ROLE_LV_CHANGED, self, self.NotifyRefreshUpRoleLvEffect)
  1101. -- ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.JOB_LV_CHANGED, self, self.NotifyRefreshUpJobLvEffect)
  1102. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.BIGMAP_ENTER_NEXTMAP_START, self, self.NotifyEnterNextMapStart)
  1103. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.BIGMAP_ENTER_NEXTMAP_END, self, self.NotifyEnterNextMapEnd)
  1104. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.VIP_LV_CHANGED, self, self.NotifyVipLvChanged)
  1105. self:NotifyVipLvChanged()
  1106. self.bKillBoss = false
  1107. --ManagerContainer.DataMgr.BigMapData:SendGetData()
  1108. self:StartSyncServerTimeTimer()
  1109. if self.rewardTimeTimerId == nil then
  1110. self.rewardTimeTimerId = ManagerContainer.LuaTimerMgr:AddTimer(1000, -1, self, self.OnRefreshRewardTime, nil)
  1111. end
  1112. local mainActor = ManagerContainer.LuaActorDataMgr:GetHeroActorData(1)
  1113. if mainActor ~= nil then
  1114. mainActor.Name = ManagerContainer.DataMgr.UserData:GetUserNickname()
  1115. end
  1116. self.isAutochallenge = false
  1117. end
  1118. function LuaBattleMgr:Exit()
  1119. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.ROLE_JOB_CHANGE_SUCCESS, self, self.NotifyRefreshRoleView)
  1120. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.FASHION_WEAR_CHANGE, self, self.NotifyRefreshRoleView)
  1121. -- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.ROLE_LV_CHANGED, self, self.NotifyRefreshUpRoleLvEffect)
  1122. -- ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.JOB_LV_CHANGED, self, self.NotifyRefreshUpJobLvEffect)
  1123. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.BIGMAP_ENTER_NEXTMAP_START, self, self.NotifyEnterNextMapStart)
  1124. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.BIGMAP_ENTER_NEXTMAP_END, self, self.NotifyEnterNextMapEnd)
  1125. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.VIP_LV_CHANGED, self, self.NotifyVipLvChanged)
  1126. -- ManagerContainer.LuaBattleMgr:RecycleUpLvEffect()
  1127. ManagerContainer.LuaBattleMgr:RecycleRoleView()
  1128. if self.rewardTimeTimerId~= nil then
  1129. ManagerContainer.LuaTimerMgr:RemoveTimer(self.rewardTimeTimerId)
  1130. self.rewardTimeTimerId = nil
  1131. end
  1132. self.isAutochallenge = false
  1133. end
  1134. function LuaBattleMgr:SendBattleRecordReq()
  1135. ManagerContainer.LuaGameMgr:SendBattleRecordReq(100,{self.curMapId,self.curLevelId})
  1136. end
  1137. function LuaBattleMgr:GetFightersPos()
  1138. return LuaBattleBridge.GetFightersPos();
  1139. end
  1140. function LuaBattleMgr:GetCurMapId()
  1141. return self.curMapId
  1142. end
  1143. function LuaBattleMgr:GetCurMapAndLevel()
  1144. return self.curMapId, self.curLevelId
  1145. end
  1146. function LuaBattleMgr:MaxQuickBattleTimes()
  1147. return self.maxQuickBattleTimes
  1148. end
  1149. function LuaBattleMgr:UsedQuickBattleTimes()
  1150. return self.usedQuickBattleTimes
  1151. end
  1152. function LuaBattleMgr:GetCurrentLevelData()
  1153. return ManagerContainer.CfgMgr:GetLevelDataById(self:GetCurLevelUniqueId())
  1154. end
  1155. function LuaBattleMgr:OnLoadBegin()
  1156. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Loading_Begin);
  1157. -- LogError("LuaBattleMgr:OnLoadBegin")
  1158. end
  1159. function LuaBattleMgr:OnLoadProgress(progress)
  1160. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Loading_Progress,progress);
  1161. -- LogError("LuaBattleMgr:OnLoadProgress:" .. progress)
  1162. end
  1163. function LuaBattleMgr:OnLoadComplete()
  1164. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Loading_Complete);
  1165. -- LogError("LuaBattleMgr:OnLoadComplete")
  1166. end
  1167. function LuaBattleMgr:OnFighterCastSkill(skillParam)
  1168. if skillParam.isBoss then
  1169. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Boss_Skill,skillParam)
  1170. else
  1171. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Cast_Skill,skillParam)
  1172. end
  1173. end
  1174. function LuaBattleMgr:OnShowBossBuff(actorId,isBoss,buffIcon,num,isPlayeRecord)
  1175. if isBoss then
  1176. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Boss_Buff,buffIcon,num)
  1177. else
  1178. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Player_Buff,actorId, buffIcon,num)
  1179. end
  1180. end
  1181. function LuaBattleMgr:OnRemoveBossBuff(actorId,isBoss,buffIcon)
  1182. if isBoss then
  1183. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Boss_Remove_Buff,buffIcon)
  1184. else
  1185. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Remove_Player_Buff, actorId, buffIcon)
  1186. end
  1187. end
  1188. function LuaBattleMgr:OnFighterLifeChanged(isBoss,actorId,life,maxLife)
  1189. if isBoss then
  1190. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Boss_Life,life,maxLife)
  1191. else
  1192. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Fighter_Life,actorId,life,maxLife)
  1193. end
  1194. end
  1195. function LuaBattleMgr:OnFighterEnergyChanged(actorId,sp,maxSp)
  1196. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Fighter_Sp,actorId,sp,maxSp)
  1197. end
  1198. function LuaBattleMgr:OnRefreshSkillCD(isBoss,actorId,leftTime,totalTime)
  1199. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_Skill_CD,isBoss,actorId,leftTime,totalTime)
  1200. -- LogError("--------------------------------------------isBoss = " .. tostring(isBoss) .. " actorId = " .. actorId .. " leftTime = " .. leftTime .. " totalTime = " .. totalTime)
  1201. end
  1202. function LuaBattleMgr:OnBattleUIVis(vis)
  1203. if vis then
  1204. --ManagerContainer.LuaUIMgr:Show(Enum.UIPageName.UIBattle)
  1205. --ManagerContainer.LuaUIMgr:Show(Enum.UIPageName.UIMain)
  1206. else
  1207. --ManagerContainer.LuaUIMgr:Hide(Enum.UIPageName.UIBattle)
  1208. --ManagerContainer.LuaUIMgr:Hide(Enum.UIPageName.UIMain)
  1209. end
  1210. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Battle_UI_VISIBLE,vis)
  1211. end
  1212. function LuaBattleMgr:OnRefreshBattleOutput()
  1213. -- if self.logList == nil or #self.logList == 0 then
  1214. -- return
  1215. -- end
  1216. -- self.logList[#self.logList+1] = logStr
  1217. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Add_New_BattleLog)
  1218. end
  1219. -- function LuaBattleMgr:InitBattleOutputList()
  1220. -- self.logList = {}
  1221. -- local battleLogList = LuaBattleBridge.GetBattleLog()
  1222. -- if battleLogList ~= nil then
  1223. -- for i = 1, battleLogList.Count do
  1224. -- self.logList[#self.logList+1] = battleLogList[i-1]
  1225. -- end
  1226. -- end
  1227. -- return self.logList
  1228. -- end
  1229. -- function LuaBattleMgr:GetBattleLogList()
  1230. -- return self.logList
  1231. -- end
  1232. function LuaBattleMgr:NotifyLoadingStatus(status)
  1233. self.battleLoadingState = status
  1234. end
  1235. function LuaBattleMgr:NotifyLoadingStatusEnd(status)
  1236. self.battleLoadingState = nil
  1237. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BATTLE_LOADING_COMPELETED)
  1238. end
  1239. function LuaBattleMgr:GetBattleLoadingState()
  1240. local statusIdx
  1241. local state, text = self:GetWaitingRefreshRoleState()
  1242. if not state then
  1243. statusIdx = self.battleLoadingState
  1244. else
  1245. statusIdx = Enum.BattleBtnState.RoleModel
  1246. end
  1247. if statusIdx == Enum.BattleBtnState.Skill then
  1248. text = "Challenging4"
  1249. elseif statusIdx == Enum.BattleBtnState.Fellow then
  1250. text = "Challenging3"
  1251. elseif statusIdx == Enum.BattleBtnState.Pet then
  1252. text = "Challenging3"
  1253. elseif statusIdx == Enum.BattleBtnState.RoleModel then
  1254. text = "Challenging2"
  1255. end
  1256. return statusIdx, text
  1257. end
  1258. --判断当前时间如果领取挂机奖励的话,魔魂值是否会溢出,返回值第一个是是否溢出,第二个是领取之前的值
  1259. function LuaBattleMgr:JudgeEvilExpOverFlow()
  1260. local _leftTime, _num = ManagerContainer.LuaBattleMgr:GetIncomeInfo()
  1261. local _curLvEvilExp = ManagerContainer.LuaBattleMgr:CurLevelEvil(); --每分钟挂机获得的魔魂值
  1262. local _evilExp = ManagerContainer.DataMgr.UserData:GetEvilExp();
  1263. local _rewardIntervalTimeM = GlobalConfig.Instance:GetConfigIntValue(47) / 60;
  1264. local _nexEvilExp = _evilExp + _curLvEvilExp * _rewardIntervalTimeM * _num;
  1265. if self.maxEvilExp == 0 then
  1266. self.maxEvilExp = GlobalConfig.Instance:GetConfigIntValue(158);
  1267. end
  1268. local _isOverFlow = _nexEvilExp > self.maxEvilExp;
  1269. return _isOverFlow, _evilExp;
  1270. end
  1271. function LuaBattleMgr:CSPlayerIncomeReq()
  1272. self.accumIncomeTime = ManagerContainer.LuaBattleMgr:AccumIncomeTime();
  1273. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_PLAYER_INCOME_REQ, {})
  1274. self:ReportIncomeRecord(true)
  1275. end
  1276. function LuaBattleMgr:ReportIncomeRecord(success)
  1277. if not SDKMgr.Instance:IsReportAction() then
  1278. return
  1279. end
  1280. local datas = System.Collections.Generic.Dictionary_object_object()
  1281. datas:Add('event', 'mj_online_rewards')
  1282. datas:Add('is_achieve', 1)
  1283. SDKMgr.Instance:ReportAction(datas)
  1284. end
  1285. function LuaBattleMgr:RefreshStatistics()
  1286. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_Refresh_BattleStatistics)
  1287. end
  1288. function LuaBattleMgr:HeroChangeProfessionSuccess()
  1289. ManagerContainer.DataMgr.UserData:RoleChangeJobAttrSuccess()
  1290. end
  1291. return LuaBattleMgr;