UIBattleView.lua 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616
  1. local UIBattleView = require("UIBattle/UIBattleView_Generate")
  2. local UIChatRoot = require("UIChat/UIChatRoot")
  3. local BattleBossBloodPart = require("UIBattle/BattleBossBloodPart")
  4. local BattleHeadsBoxPart = require("UIBattle/BattleHeadsBoxPart")
  5. local BattleStatisticsPart = require("UIBattle/BattleStatisticsPart")
  6. local BattleReplayControlPart = require("UIBattle/BattleReplayControlPart")
  7. local LoopType = DG.Tweening.LoopType
  8. local NewBattleChatPart = require("UIBattle/NewBattleChatPart")
  9. local UIMainCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIMain)
  10. local updateHandle
  11. local needRefreshMinimap = false
  12. local minimapCurTime = 0
  13. local minimapInterTime = 0.1
  14. local curSelectedData
  15. local stageGoalGridSpacing = {Vector2.New(0, 0), Vector2.New(-10, 0), Vector2.New(-20, 0)}
  16. local newStageCompeleted = false
  17. local levelIncreaseTimer
  18. local increaseIdx
  19. local bBossStage = false
  20. local bBoxState = false
  21. local bossFightCDRemainTime = 0
  22. local curRemainSecond = 0
  23. local bossMaskTimer
  24. local chatDisplayDurationTime
  25. local chatHideTimer
  26. local windowREPos
  27. local pageToggleData = {}
  28. function UIBattleView:OnAwake(data)
  29. self.controller = require("UIBattle/UIBattleCtr"):new()
  30. self.controller:Init(self)
  31. self.controller:SetData(data)
  32. end
  33. function UIBattleView:FillContent(data, uiBase)
  34. self.uiBase = uiBase
  35. local gameObject = self.uiBase:GetRoot()
  36. if gameObject ~= nil then
  37. self.gameObject = gameObject
  38. self.transform = gameObject.transform
  39. end
  40. self:InitGenerate(self.transform, data)
  41. if not updateHandle then
  42. updateHandle = UpdateBeat:CreateListener(self.Update, self)
  43. end
  44. UpdateBeat:AddListener(updateHandle)
  45. self.RewardBoxBtnPos = CommonUtil.ConvertUIPos2ScreenPos(self.RewardBoxBtn.transform.position)
  46. self.RewardBoxBtnPos.y =self.RewardBoxBtnPos.y;
  47. self:InitComs();
  48. self:Init()
  49. needRefreshMinimap = true
  50. self.MapRootGo:SetActive(true)
  51. --self.ProfitBoxGo:SetActive(true)
  52. end
  53. function UIBattleView:InitComs()
  54. -- self.levelNameGo:SetActive(false);
  55. self.exploringTrans:SetActive(false);
  56. self.rageBoxGo:SetActive(false);
  57. self.battleFailGo:SetActive(false);
  58. end
  59. function UIBattleView:Init()
  60. self.statTime1 = GlobalConfig.Instance:GetConfigIntValue(53) * 60000;
  61. self.statTime2 = GlobalConfig.Instance:GetConfigIntValue(54) * 60000;
  62. self.statTime3 = GlobalConfig.Instance:GetConfigIntValue(55) * 60000;
  63. self.statTime4 = GlobalConfig.Instance:GetConfigIntValue(56) * 60000;
  64. self.maxCruise = 10000;
  65. self.challengeAnimName = "BtnBoss1"
  66. self.controller:InitHeroData()
  67. self.recordSpeed = 1;
  68. self:OnRefreshEarnings();
  69. self:OnRefreshRewardTime();
  70. self:LoadMinimap()
  71. self:InitCruise()
  72. --self:RefreshChatBg()
  73. --self:RefreshStageGoalUI()
  74. --self:InitWorldChat()
  75. local openStatus = ManagerContainer.UIFuncUnlockMgr:GetNeedDisplayNewFuncStatus()
  76. if openStatus then
  77. self:FuncOpen1()
  78. else
  79. self.newOpen:SetActive(false)
  80. end
  81. self.btnAuto:SetActive(false)
  82. self:InitMinimapGoes()
  83. local curChatType = self.controller:GetChatChannelType()
  84. self.controller:SetChatChannelType(curChatType)
  85. --self:SetToggleGroupStatus(curChatType)
  86. if self.BossBloodPart == nil then
  87. self.BossBloodPart = BattleBossBloodPart:new()
  88. end
  89. if self.HeadsBoxPart == nil then
  90. self.HeadsBoxPart = BattleHeadsBoxPart:new()
  91. end
  92. if self.StatisticsPart == nil then
  93. self.StatisticsPart = BattleStatisticsPart:new()
  94. end
  95. if self.battleReplayPart == nil then
  96. self.battleReplayPart = BattleReplayControlPart:new()
  97. end
  98. if self.NewBattleChatPart == nil then
  99. self.NewBattleChatPart = NewBattleChatPart:new()
  100. end
  101. self.NewBattleChatPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/NewBattleChat"),true,self.btnChat)
  102. self.BossBloodPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleBossBlood"))
  103. self.HeadsBoxPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleHeadsBox"))
  104. self.StatisticsPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleStatistics"))
  105. self.battleReplayPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleReplayControl"))
  106. self.BossBloodPart:Hide()
  107. self.HeadsBoxPart:Hide()
  108. self.StatisticsPart:Hide()
  109. self.battleReplayPart:Hide()
  110. self.chatView:SetActive(true)
  111. self.battleLogView:SetActive(false)
  112. self:RestoreSpeed()
  113. windowREPos = self.windowEnvelope.transform.position
  114. self:OnRedEnvelopeRemainTimeRefresh()
  115. self:RefreshOnlineRecordBtn()
  116. end
  117. function UIBattleView:InitMinimapGoes()
  118. self.miniMapGoes = {}
  119. self.miniMapGoes[#self.miniMapGoes+1] = self.minimap.rectTransform
  120. for idx=1,6 do
  121. self.miniMapGoes[#self.miniMapGoes+1] = self["enemy"..idx].rectTransform
  122. end
  123. end
  124. ------------------在线奖励
  125. --刷新时间
  126. function UIBattleView:RefreshOnlineTime()
  127. if nil == self.OnlineRewards then
  128. return
  129. end
  130. --临时处理 之后改为多解锁条件
  131. local IsActive = self.OnlineRewards.activeInHierarchy
  132. local IsBossFight = ManagerContainer.LuaBattleMgr:GetBossFightState()
  133. if IsBossFight then
  134. if IsActive then
  135. self.OnlineRewards:SetActive(false)
  136. end
  137. else
  138. local unlockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(70)
  139. if unlockState and not IsActive then
  140. self.OnlineRewards:SetActive(true)
  141. self:RefreshOnlineRecordBtn(true)
  142. end
  143. end
  144. self:RefreshOnlineAnimRecord()
  145. local bIsOver,strTime = ManagerContainer.LuaBattleMgr:UpdateOnlineTime()
  146. if not bIsOver then
  147. self.btnOnlineRewards.OnlineTimeLbl.text.text = strTime
  148. end
  149. end
  150. --刷新按钮
  151. function UIBattleView:RefreshOnlineDownBtn(state)
  152. self.btnOnlineRewards.times:SetActive(false)
  153. self.btnOnlineRewards.getRewards:SetActive(false)
  154. self.btnOnlineRewards.tomorrow:SetActive(false)
  155. if state == Enum.EnumOnineState.RunTime then
  156. self.btnOnlineRewards.times:SetActive(true)
  157. elseif state == Enum.EnumOnineState.Receive then
  158. self.btnOnlineRewards.getRewards:SetActive(true)
  159. elseif state == Enum.EnumOnineState.ToDayFinished then
  160. self.btnOnlineRewards.tomorrow:SetActive(true)
  161. end
  162. end
  163. --刷新领取道具
  164. function UIBattleView:RefreshOnlineItem(state)
  165. local ItemId = nil
  166. local ItemCount = nil
  167. local Time,tbRwards = ManagerContainer.LuaBattleMgr:GetNextTotalOnlineTime()
  168. --LogError(Inspect(tbRwards))
  169. if tbRwards then
  170. ItemId = tbRwards[1][1]
  171. ItemCount = tbRwards[1][2]
  172. end
  173. if nil ~= ItemId then
  174. local ItemObj = self.OnlineRewards.iconSmallItem
  175. CommonUtil.SetRewardItemData(self,ItemId,ItemObj,ItemCount, self.OnClickItem)
  176. end
  177. self:RefreshOnlineAnimRecord()
  178. end
  179. --点击道具
  180. function UIBattleView:OnClickItem(btn,params)
  181. local state = ManagerContainer.LuaBattleMgr:GetOnlineState()
  182. if state == Enum.EnumOnineState.Receive then
  183. self:OnClickOnlineRecord()
  184. else
  185. local logicData = params[0]
  186. ManagerContainer.LuaUIMgr:OpenTips(logicData)
  187. end
  188. end
  189. --刷新奖励
  190. function UIBattleView:RefreshOnlineRecordBtn()
  191. local state = ManagerContainer.LuaBattleMgr:GetOnlineState()
  192. self:RefreshOnlineDownBtn(state)
  193. self:RefreshOnlineItem(state)
  194. end
  195. --获取在线奖励点击
  196. function UIBattleView:OnClickOnlineRecord()
  197. local state = ManagerContainer.LuaBattleMgr:GetOnlineState()
  198. if state == Enum.EnumOnineState.Receive then
  199. ManagerContainer.LuaBattleMgr:SendOnlineTimeRecord()
  200. elseif state == Enum.EnumOnineState.RunTime then
  201. --是否消耗金币
  202. local NeedItem = ManagerContainer.LuaBattleMgr:GetOnlineTimeGlod()
  203. local data = {"OnLineUseGold", {tostring(NeedItem)}, nil, self, self.SureOpenTipsWnd}
  204. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UINoticeTips, data)
  205. elseif state == Enum.EnumOnineState.ToDayFinished then
  206. end
  207. end
  208. function UIBattleView:RefreshOnlineAnimRecord()
  209. local state = ManagerContainer.LuaBattleMgr:GetOnlineState()
  210. local strAnim = nil
  211. if state == Enum.EnumOnineState.Receive then
  212. strAnim = "RewardsShow"
  213. else
  214. strAnim = "RewardsKeep"
  215. end
  216. self:PlayAniRun(self.OnlineRewards.rewardsAnim.animator,strAnim)
  217. end
  218. function UIBattleView:PlayAniRun(Animator,AniName)
  219. if Animator then
  220. local showStateInfo = Animator:GetCurrentAnimatorStateInfo(0)
  221. if showStateInfo then
  222. local IsPlay = showStateInfo:IsName(AniName)
  223. if not IsPlay then
  224. Animator:Play(AniName)
  225. end
  226. end
  227. end
  228. end
  229. --提示 道具不足金币转换确定
  230. function UIBattleView:SureOpenTipsWnd()
  231. local IsCanUse = ManagerContainer.LuaBattleMgr:IsCanUseGoldOnline()
  232. if IsCanUse then
  233. ManagerContainer.LuaBattleMgr:SendOnlineTimeRecord()
  234. else
  235. self:PopErrorTips('SeasonLackGold')
  236. end
  237. end
  238. --Error弹窗
  239. function UIBattleView:PopErrorTips(Key)
  240. if not ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIErrorTips) then
  241. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIErrorTips, {errorId=Key}, nil, nil, nil, Enum.UISibling[Enum.UIType.Top + 1] + 11)
  242. else
  243. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.ERROR_DESC_DISPLAY, {errorId=Key})
  244. end
  245. end
  246. function UIBattleView:OnRefreshOnlineState()
  247. self:RefreshOnlineRecordBtn()
  248. end
  249. ----------------------------
  250. function UIBattleView:Update()
  251. self:RefreshOnlineTime()
  252. if bossFightCDRemainTime > 0 then
  253. bossFightCDRemainTime = bossFightCDRemainTime - Time.unscaledDeltaTime
  254. if bossFightCDRemainTime <= 0 then
  255. bossFightCDRemainTime = 0
  256. self.challengeAnimName = bBossStage and "BtnBoss3" or "BtnBoss1"
  257. else
  258. local remain = math.ceil(bossFightCDRemainTime)
  259. --if remain ~= curRemainSecond then
  260. curRemainSecond = remain
  261. if self.btnChallenge then
  262. self.btnChallenge.remainCDTime.text.text = I18N.SetLanguageValue("FightCD", curRemainSecond)
  263. end
  264. --end
  265. self.challengeAnimName = bBossStage and "BtnBoss3" or "BtnBoss4"
  266. end
  267. if self.btnBossAnimator then
  268. self.btnBossAnimator.animator:Play(self.challengeAnimName)
  269. end
  270. end
  271. if not needRefreshMinimap then
  272. return
  273. end
  274. minimapCurTime = minimapCurTime + Time.unscaledDeltaTime
  275. if minimapCurTime >= minimapInterTime then
  276. minimapCurTime = 0
  277. self:RefreshMinimapInfo()
  278. end
  279. end
  280. function UIBattleView:AddEventListener()
  281. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BOSS_SPAWNED,self,self.OnBossSpawned);
  282. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_Refresh_Boss_Dead,self,self.OnBossDead);
  283. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BATTLE_WIN,self,self.OnBattleWin);
  284. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BATTLE_FAILED,self,self.OnBattleFailed);
  285. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_FORCEBATTLE_FAILED,self,self.OnForceBattleFailed);
  286. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BATTLE_ERROR,self,self.OnBattleFailed);
  287. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_NEXT_BATTLE, self,self.OnBattleNewWave);
  288. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CONTINUE_BATTLE, self,self.OnContinueBattle);
  289. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SHOW_BOSS_RAGE,self, self.OnShowBossRage)
  290. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SHOW_BOSS_RAGE_LEFTTIME, self,self.OnShowBossRageLeftTime);
  291. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_REFRESH_RAGE_LEFTTIME, self,self.RefreshRageTime);
  292. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BOSS_IN_RAGE, self,self.OnBossInRage);
  293. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_HIDE_LEVEL_NAME, self,self.OnHideLevelName);
  294. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SHOW_BOSS_WARNING,self,self.OnShowBossWarning);
  295. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_REFRESH_REWARD_TIME,self,self.OnRefreshRewardTime);
  296. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BATTLE_INCOME_ACK,self,self.OnBattleIncomeAck);
  297. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CRUISE_CHANGED,self,self.RefreshCruise);
  298. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_BOSS_Battle_End,self,self.BossBattleEnd);
  299. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.UI_BATTLE_FUNC_OPEN_NTF, self, self.FuncOpen)
  300. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.UI_BATTLE_NORMAL_NTF, self, self.ShowBattleNormalUI)
  301. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GOT_ANIM_TYPE_END_NOTIFY, self, self.PopGotAnimEnd)
  302. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.NEW_LEVEL_INCREASE_NTF, self, self.NewLevelIncrease)
  303. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.BATTLE_WIN_CLOSE, self, self.RewardBoxRefresh)
  304. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.BATTLE_LOADING_COMPELETED, self, self.BattleLoadingCompeleted)
  305. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_Challenge_Boss_Fight_ACK, self, self.OnChallengeBossAck)
  306. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.CLOSE_NEW_FUNC_PAGE, self, self.OnCloseNewOpen)
  307. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.BATTLE_CHALLENGE_TIME_REFRESH, self, self.OnRefreshBossChallengeTime)
  308. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CHALLENGE_AUTO, self, self.OnStartAutoChallenge)
  309. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.RED_ENVELOPE_REMAIN_TIME_REFRESH, self, self.OnRedEnvelopeRemainTimeRefresh)
  310. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_REFRESH_ONLINETIME_CHANGESTATE, self, self.OnRefreshOnlineState)
  311. self.uiBase:AddUIEventHandlerClickListener(self.uIEventHandler, function (go)
  312. self:OnAutoChallengeClickEvent()
  313. end)
  314. end
  315. function UIBattleView:RemoveEventListener()
  316. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  317. end
  318. function UIBattleView:OnPlayerQuery()
  319. self.controller:SendPlayerQuery(curSelectedData.uid)
  320. self.funcbg:SetActive(false)
  321. end
  322. function UIBattleView:AddUIEventListener()
  323. self.uiBase:AddButtonEventListener(self.btnChallenge.button,self, self.OnClickChallengeBtn)
  324. self.uiBase:AddButtonEventListener(self.ReceiveGo.button,self,self.OnClickRewardBtn)
  325. self.uiBase:AddButtonEventListener(self.quickBattleBtn.button,self,self.OnClickQuickBtn)
  326. self.uiBase:AddButtonEventListener(self.miniMapBg.button,self,self.OnClickMiniMap)
  327. self.uiBase:AddButtonEventListener(self.btnOnlineRewards.button,self,self.OnClickOnlineRecord)
  328. -- self.uiBase:AddButtonEventListener(self.btnCruise.button,self,self.OnClickCruiseBtn)
  329. --self.uiBase:AddButtonEventListener(self.btnStageGoal.button, self, self.AwardOrJumpStageGoal)
  330. self.uiBase:AddButtonEventListener(self.newOpen.alpha.button, self, self.OnCloseNewOpen)
  331. self.uiBase:AddButtonEventListener(self.btnwarlog.button, self, self.OnClickBattleRecordBtn)
  332. self.uiBase:AddButtonEventListener(self.btnStatistics.button, self, self.OnClickBattleStatisticsBtn)
  333. self.uiBase:AddButtonEventListener(self.btnAuto.button, self, self.OnClickAutoChallenge)
  334. --self.uiBase:AddToggleEventListener(self.togworld.toggle, self, self.OnValueChangedToggle, 1)
  335. --self.uiBase:AddToggleEventListener(self.togguild.toggle, self, self.OnValueChangedToggle, 2)
  336. --self.uiBase:AddToggleEventListener(self.togsystem.toggle, self, self.OnValueChangedToggle, 3)
  337. --self.uiBase:AddToggleEventListener(self.togwarlog.toggle, self, self.OnValueChangedToggle, 4)
  338. self.BossBloodPart:AddUIEventListener()
  339. self.HeadsBoxPart:AddUIEventListener()
  340. self.StatisticsPart:AddUIEventListener()
  341. self.battleReplayPart:AddUIEventListener()
  342. self.NewBattleChatPart:AddUIEventListener()
  343. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnNormalREClick)
  344. self.uiBase:AddButtonUniqueEventListener(self.windowEnvelope.button, self, self.OnHideWindowsEnvelope)
  345. self.uiBase:AddButtonUniqueEventListener(self.difficultBtn.button, self, self.OnClickDifficultBtn)
  346. end
  347. function UIBattleView:OnClickDifficultBtn()
  348. ManagerContainer.LuaBattleMgr:SendChangeMapLevelTypeReq(1)
  349. -- local mapMode = ManagerContainer.LuaBattleMgr:GetBattleMode() == Enum.MapModeType.Difficulty and Enum.MapModeType.Simple or Enum.MapModeType.Difficulty
  350. -- local targetLV = 1
  351. -- local targetMap = 1
  352. -- if mapMode == Enum.MapModeType.Difficulty then
  353. -- targetLV = 5
  354. -- targetMap = 2
  355. -- else --==Enum.MapModeType.Simple
  356. -- targetMap,targetLV = ManagerContainer.LuaBattleMgr:GetLastMapIdAndLvId()
  357. -- end
  358. -- ManagerContainer.LuaBattleMgr:SetBattleMode(mapMode)
  359. -- local data = ManagerContainer.LuaBattleMgr:GetSimulationBattleData(targetMap,targetLV)
  360. -- ManagerContainer.LuaBattleMgr:OnBattleDataChange(data,true)
  361. end
  362. function UIBattleView:OnHide()
  363. self.newFunc = nil
  364. self:DisposeNewLevelIncrease()
  365. self.recordSpeed = ManagerContainer.LuaGameMgr:GetGameSpeed();
  366. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  367. needRefreshMinimap = false
  368. if self.inited then
  369. self.chatView:SetActive(false)
  370. end
  371. if chatHideTimer then
  372. ManagerContainer.LuaTimerMgr:RemoveTimer(chatHideTimer)
  373. chatHideTimer = nil
  374. end
  375. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  376. end
  377. function UIBattleView:OnShow()
  378. ManagerContainer.LuaGameMgr:SetGameSpeed(self.recordSpeed)
  379. self:InitComs();
  380. self:OnRefreshEarnings();
  381. self:LoadMinimap()
  382. self:InitCruise()
  383. --self:RefreshChatBg()
  384. if self.btnBossAnimator.activeInHierarchy then
  385. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  386. end
  387. self:OnRefreshRewardTime();
  388. --self:RefreshStageGoalUI()
  389. local result = ManagerContainer.UIFuncUnlockMgr:GetNeedDisplayNewFuncStatus()
  390. if result then
  391. self:FuncOpen1()
  392. else
  393. self.newOpen:SetActive(false)
  394. end
  395. self.btnAuto:SetActive(false)
  396. needRefreshMinimap = true
  397. --self.chatView:SetActive(true)
  398. --self.battleLogView:SetActive(false)
  399. self.battleRootNew:SetActive(true)
  400. --self:HandleChatToggleBtns(1)
  401. if not ManagerContainer.LuaBattleMgr:GetBossFightState() then
  402. self.MapRootGo:SetActive(true)
  403. end
  404. self:RefreshOnlineRecordBtn()
  405. end
  406. function UIBattleView:OnClose()
  407. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  408. if updateHandle ~= nil then
  409. UpdateBeat:RemoveListener(updateHandle)
  410. updateHandle = nil
  411. end
  412. self.logList = nil
  413. if chatHideTimer then
  414. ManagerContainer.LuaTimerMgr:RemoveTimer(chatHideTimer)
  415. chatHideTimer = nil
  416. end
  417. if self.inited then
  418. self.battleLogView.loopVerticalScrollRect:SetUpdateCellCallback(nil,nil)
  419. -- self:ClearBattleSkillTimer()
  420. if self.openRewardTimer ~= nil then
  421. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer);
  422. self.openRewardTimer = nil
  423. end
  424. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  425. self.controller:SetChatChannelType(nil)
  426. end
  427. if self.BossBloodPart ~= nil then
  428. self.BossBloodPart:Dispose()
  429. self.BossBloodPart = nil
  430. end
  431. if self.HeadsBoxPart ~= nil then
  432. self.HeadsBoxPart:Dispose()
  433. self.HeadsBoxPart = nil
  434. end
  435. if self.StatisticsPart ~= nil then
  436. self.StatisticsPart:Dispose()
  437. self.StatisticsPart = nil
  438. end
  439. if self.battleReplayPart ~= nil then
  440. self.battleReplayPart:Dispose()
  441. self.battleReplayPart = nil
  442. end
  443. if self.NewBattleChatPart ~= nil then
  444. self.NewBattleChatPart:Dispose()
  445. self.NewBattleChatPart = nil
  446. end
  447. pageToggleData = nil
  448. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  449. self.uIEventHandler:RemoveListener()
  450. end
  451. function UIBattleView:RefreshStageGoalUI(newProgress)
  452. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  453. self.btnStageGoal:SetActive(curGoal ~= nil and curGoal.taskId <= ManagerContainer.CfgMgr:LastTargetTaskId() and curGoal.state <= 1)
  454. if curGoal ~= nil then
  455. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  456. if goalCfgData == nil then
  457. return
  458. end
  459. local max = 0
  460. for _,v in pairs(CommonUtil.DeserializeCfgItemList(goalCfgData.TargetTaskCondition)) do
  461. max = max + v[#v]
  462. end
  463. local progress = ManagerContainer.DataMgr.StageGoalData:GetCurGoalDataProgress()
  464. local isCompleted = progress == max
  465. local func
  466. if not isCompleted then
  467. self.btnStageGoal.state:SetActive(false)
  468. func = self.ShowItemTips
  469. else
  470. if not newProgress then
  471. self.btnStageGoal.state:SetActive(true)
  472. func = self.AwardGoal
  473. else
  474. self.btnStageGoal.state:SetActive(false)
  475. func = self.ShowItemTips
  476. end
  477. end
  478. local data = {cfgId = goalCfgData.TargetReward[1][1], num = goalCfgData.TargetReward[1][2]}
  479. CommonUtil.UpdateItemPrefab(self, self.btnStageGoal.iconItem, data, Enum.ItemIEnterType.Bag, self, func)
  480. if max < 4 then
  481. self.btnStageGoal.points.gridLayoutGroup.spacing = stageGoalGridSpacing[1]
  482. elseif max == 4 then
  483. self.btnStageGoal.points.gridLayoutGroup.spacing = stageGoalGridSpacing[2]
  484. elseif max == 5 then
  485. self.btnStageGoal.points.gridLayoutGroup.spacing = stageGoalGridSpacing[3]
  486. end
  487. for i = 1, Constant.StageGoalMaxPoints do
  488. self["point"..i]:SetActive(i <= max)
  489. if i <= max then
  490. self["point"..i].light.animator:Play(i < progress and "CupKeep" or "CupEmpty")
  491. if newProgress then
  492. newStageCompeleted = newProgress
  493. else
  494. if i == progress then
  495. self["point"..i].light.animator:Play("CupKeep")
  496. end
  497. end
  498. end
  499. end
  500. end
  501. end
  502. function UIBattleView:NewStageCompletedNtf()
  503. if newStageCompeleted then
  504. newStageCompeleted = false
  505. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  506. if curGoal ~= nil then
  507. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  508. if goalCfgData == nil then
  509. return
  510. end
  511. local max = 0
  512. for _,v in pairs(CommonUtil.DeserializeCfgItemList(goalCfgData.TargetTaskCondition)) do
  513. max = max + v[#v]
  514. end
  515. if curGoal.state == Enum.TaskStateType.CompletedAndNoReceive then
  516. self.btnStageGoal.state:SetActive(true)
  517. local func = self.AwardGoal
  518. local data = {cfgId = goalCfgData.TargetReward[1][1], num = goalCfgData.TargetReward[1][2]}
  519. CommonUtil.UpdateItemPrefab(self, self.btnStageGoal.iconItem, data, Enum.ItemIEnterType.Bag, self, func)
  520. end
  521. local progress = ManagerContainer.DataMgr.StageGoalData:GetCurGoalDataProgress()
  522. for i = 1, Constant.StageGoalMaxPoints do
  523. if i == progress then
  524. self["point"..i].light.animator:Play("CupShow")
  525. end
  526. end
  527. end
  528. end
  529. end
  530. function UIBattleView:StageGoalAwarded(list)
  531. if #list == 0 then
  532. -- LogError("no item")
  533. return
  534. end
  535. local data = {cfgId = list[1].key, num = list[1].value}
  536. local data1 = {list = {data}, startPoses = {self.btnStageGoal.iconItem.transform.position}, enterType = Enum.ItemIEnterType.StageGoal}
  537. ManagerContainer.LuaUIMgr:POPGotAnimNotice(data1)
  538. self:RefreshStageGoalUI()
  539. end
  540. function UIBattleView:AwardOrJumpStageGoal(button, params)
  541. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  542. if curGoal ~= nil then
  543. if curGoal.state ~= 1 then
  544. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  545. local data = ManagerContainer.CfgMgr:GetUIJumpData(goalCfgData.SkipInterface)
  546. if data == nil then return end
  547. ManagerContainer.UIJumpMgr:CreateJumpTask(data)
  548. else
  549. self:AwardGoal()
  550. end
  551. end
  552. end
  553. function UIBattleView:AwardGoal()
  554. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  555. if curGoal ~= nil then
  556. if curGoal.state ~= 1 then
  557. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  558. local data = {cfgId = goalCfgData.TargetReward[1][1], num = goalCfgData.TargetReward[1][2]}
  559. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIItemTips, data)
  560. ManagerContainer.LuaUIMgr:OpenTips(data)
  561. else
  562. self.stageGoalNtf:SetActive(false)
  563. self.controller:SendGetMainTaskRewardReq()
  564. end
  565. end
  566. end
  567. function UIBattleView:ShowItemTips(button, params)
  568. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIItemTips, params[0])
  569. local data = params[0]
  570. ManagerContainer.LuaUIMgr:OpenTips(data)
  571. end
  572. function UIBattleView:OnDispose()
  573. self.battleLoadingState = nil
  574. self.chatView.loopListView:Dispose()
  575. self:DisposeNewLevelIncrease()
  576. if bossMaskTimer ~= nil then
  577. ManagerContainer.LuaTimerMgr:RemoveTimer(bossMaskTimer)
  578. bossMaskTimer = nil
  579. end
  580. needRefreshMinimap = false
  581. self.miniMapGoes = nil
  582. if updateHandle ~= nil then
  583. UpdateBeat:RemoveListener(updateHandle)
  584. updateHandle = nil
  585. end
  586. DG.Tweening.DOTween.Kill(self.transform)
  587. self.battleLogView.uIEventTriggerListener.onPointerUp = nil
  588. self.battleLogView.uIEventTriggerListener.onClick = nil
  589. UIMainCtr = nil
  590. end
  591. function UIBattleView:OnClickQuickBtn()
  592. if self.controller:IsUnlockQuickBattle() then
  593. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIQuickBattle)
  594. else
  595. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(self.controller:UnlockQuickBattleCondition())
  596. end
  597. end
  598. function UIBattleView:OnClickRewardBtn()
  599. if bBossStage then
  600. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting2")
  601. return
  602. else
  603. ManagerContainer.LuaBattleMgr:SendBattleIncomeReq()
  604. end
  605. self.RewardBoxBtn.animator:Play("ChestPressedNew");
  606. end
  607. function UIBattleView:OnAutoChallengeClickEvent()
  608. if ManagerContainer.LuaBattleMgr:GetAutoChallengeState() and not bBossStage then
  609. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  610. end
  611. end
  612. function UIBattleView:OnStartAutoChallenge()
  613. if not ManagerContainer.LuaBattleMgr:GetAutoChallengeState() then
  614. return
  615. end
  616. self:DisposeNewLevelIncrease()
  617. if bBossStage then
  618. return;
  619. end
  620. if bossFightCDRemainTime > 0 then
  621. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  622. return;
  623. end
  624. local roleLv = ManagerContainer.DataMgr.UserData:GetRoleLv()
  625. local challengeLv = LuaBattleBridge.GetCurLevelChallengeLv()
  626. if roleLv < challengeLv then
  627. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  628. return
  629. end
  630. local jobLv = ManagerContainer.DataMgr.UserData:GetJobLv()
  631. local maxJobLv = ManagerContainer.DataMgr.UserData:GetJobMaxLevel()
  632. local jobStage = ManagerContainer.DataMgr.UserData:GetJobStage()
  633. if jobStage<3 and jobLv>= maxJobLv then
  634. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  635. return
  636. end
  637. --self.challengeAnimName = "BtnBoss2"
  638. --
  639. --if self.btnBossAnimator.activeInHierarchy then
  640. -- self.btnBossAnimator.animator:Play(self.challengeAnimName);
  641. --end
  642. local battleLoadingState,text = ManagerContainer.LuaBattleMgr:GetBattleLoadingState()
  643. if battleLoadingState then
  644. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  645. return
  646. end
  647. self:StartBattleBoss()
  648. end
  649. function UIBattleView:OnClickChallengeBtn(btn)
  650. self:DisposeNewLevelIncrease()
  651. local Levelmaxlvid = GlobalConfig.Instance:GetConfigIntValue(363)
  652. if(ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId() >= Levelmaxlvid) then
  653. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("289")
  654. return
  655. end
  656. if bBossStage then
  657. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting1")
  658. return;
  659. end
  660. if bossFightCDRemainTime > 0 then
  661. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam("FightCD", math.ceil(bossFightCDRemainTime))
  662. return;
  663. end
  664. --======删除 等级限制==============================================
  665. local roleLv = ManagerContainer.DataMgr.UserData:GetRoleLv()
  666. local challengeLv = LuaBattleBridge.GetCurLevelChallengeLv()
  667. if roleLv < challengeLv then
  668. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.SetLanguageValue("LevelLimit", challengeLv))
  669. return
  670. end
  671. local jobLv = ManagerContainer.DataMgr.UserData:GetJobLv()
  672. local maxJobLv = ManagerContainer.DataMgr.UserData:GetJobMaxLevel()
  673. local jobStage = ManagerContainer.DataMgr.UserData:GetJobStage()
  674. if jobStage<3 and jobLv>= maxJobLv then
  675. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.T("JobLimit"))
  676. return
  677. end
  678. --======删除 等级限制==============================================
  679. --self.challengeAnimName = "BtnBoss2"
  680. --
  681. --if self.btnBossAnimator.activeInHierarchy then
  682. -- self.btnBossAnimator.animator:Play(self.challengeAnimName);
  683. --end
  684. local battleLoadingState,text = ManagerContainer.LuaBattleMgr:GetBattleLoadingState()
  685. if battleLoadingState then
  686. self.battleLoadingState = battleLoadingState
  687. self.btnChallenge.battleState.text.text = I18N.T(text)
  688. return
  689. end
  690. self:StartBattleBoss()
  691. end
  692. function UIBattleView:StartBattleBoss()
  693. local levelCfgId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  694. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(levelCfgId)
  695. if levelCfgData and levelCfgData.BossKey ~= "" then
  696. ManagerContainer.DataMgr.ChatData:AddLocalNewSystemData(levelCfgData.BossKey)
  697. end
  698. ManagerContainer.LuaBattleMgr:SendChallengeBossReq()
  699. end
  700. function UIBattleView:OnChallengeBossAck(factorList)
  701. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  702. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  703. bossFightCDRemainTime = levelCfgData.FightCD
  704. ManagerContainer.LuaUIMgr:OpenInputMask(9500)
  705. bBossStage = true
  706. bBoxState = true
  707. local battleFactors = System.Array.CreateInstance(Enum.TypeInfo.ValType, #factorList)
  708. for i = 1, #factorList do
  709. local factor = ValType.New(factorList[i].key,factorList[i].value)
  710. battleFactors[i-1] = factor
  711. end
  712. local teams = ManagerContainer.DataMgr.UserData:GetTeamData(true)
  713. for i = 1 , #teams do
  714. local actor = ManagerContainer.LuaActorDataMgr:GetActorsById(teams[i].uid,teams[i].id)
  715. --增加对应压制mark
  716. ManagerContainer.DataMgr.UserData:SetActorPveMark(teams[i].uid,actor)
  717. end
  718. LuaBattleBridge.ClickChallegeBoss(battleFactors);
  719. self.btnAuto:SetActive(Constant.OpenPay or false)
  720. local autoCState = ManagerContainer.LuaBattleMgr:GetAutoChallengeState()
  721. if autoCState then
  722. self.autoAnim.animator:Play("AutoIn")
  723. else
  724. self.autoAnim.animator:Play("AutoKeep")
  725. end
  726. end
  727. function UIBattleView:OnRefreshBossChallengeTime(time)
  728. bossFightCDRemainTime = time
  729. end
  730. function UIBattleView:BattleLoadingCompeleted()
  731. self.btnChallenge.battleState.text.text = I18N.T("BtnChallengeBOSS")
  732. if self.battleLoadingState then
  733. self.battleLoadingState = nil
  734. --self:StartBattleBoss()
  735. end
  736. end
  737. function UIBattleView:OnClickMiniMap()
  738. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBigMap, {id = ManagerContainer.LuaBattleMgr:GetCurMapId()})
  739. end
  740. function UIBattleView:OnBossDead()
  741. self.rageBoxGo:SetActive(false)
  742. end
  743. function UIBattleView:OnBossSpawned(bossActor,bossName,life,maxLife,skillParam,isPlayRecord)
  744. if bossMaskTimer ~= nil then
  745. ManagerContainer.LuaTimerMgr:RemoveTimer(bossMaskTimer)
  746. bossMaskTimer = nil
  747. end
  748. bossMaskTimer = ManagerContainer.LuaTimerMgr:AddTimer(1500, 1, self, self.CloseInputMask, nil)
  749. self.exploringTrans:SetActive(false);
  750. if self.btnBossAnimator ~= nil then
  751. self.challengeAnimName = "BtnBoss3"
  752. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  753. end
  754. self.quickBattleBtn.button.interactable = false
  755. if self.openRewardTimer~=nil then
  756. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer)
  757. self.openRewardTimer = nil;
  758. end
  759. self:OnHideLevelName()
  760. self:SetBossBattleInfo()
  761. self.StatisticsPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  762. self.BossBloodPart:Show(bossActor,bossName,life,maxLife,skillParam)
  763. self.HeadsBoxPart:Show()
  764. self.StatisticsPart:Show(BattleMode.Normal,BattleSubMode.None)
  765. if isPlayRecord then
  766. self.battleReplayPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  767. self.battleReplayPart:Show(ManagerContainer.LuaBattleMgr:GetCurrentLevelData().Name)
  768. self.battleRootNew:SetActive(false)
  769. end
  770. self.dragBg:SetActive(false)
  771. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIBattleReward)
  772. self:DisposeNewLevelIncrease()
  773. ManagerContainer.LuaGameMgr:SetGameSpeed(ManagerContainer.LuaGameMgr.GameSpeed)
  774. end
  775. function UIBattleView:CloseInputMask()
  776. ManagerContainer.LuaUIMgr:CloseInputMask()
  777. end
  778. function UIBattleView:BossBattleEnd(isPlayRecord)
  779. self.dragBg:SetActive(true)
  780. bBossStage = false
  781. bBoxState = false
  782. self:RefreshRedEnvelope()
  783. self:PlayChallengeBtnNormalAnim()
  784. if isPlayRecord then
  785. self.battleReplayPart:Hide()
  786. self.battleRootNew:SetActive(true)
  787. end
  788. self.btnAuto:SetActive(false)
  789. end
  790. function UIBattleView:SetBossBattleInfo()
  791. self.centerNode:SetActive(false)
  792. self.MapRootGo:SetActive(false)
  793. self.btnwarlog:SetActive(false)
  794. self.btnStatistics:SetActive(false)
  795. self:RefreshRedEnvelope()
  796. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BOSS_BATTLE_STATUS,true)
  797. end
  798. local remainTime = 2
  799. function UIBattleView:RefreshRedEnvelope()
  800. if not Constant.OpenPay then
  801. self.btnRedEnvelope:SetActive(false)
  802. self.windowEnvelope:SetActive(false)
  803. return
  804. end
  805. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  806. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  807. local reActItem = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(Enum.ActivityType.ACTIVITY_TYPE_CASH_SHOP)
  808. local state = reActItem and reActItem:IsUnlocked() and reActItem:IsOpened() and not reActItem:IsOutofDate()
  809. self.btnRedEnvelope:SetActive(state)
  810. self.windowEnvelope:SetActive(false)
  811. if state then
  812. if bBossStage then
  813. self:OnShowWindowsEnvelope()
  814. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnBattleREClick)
  815. else
  816. self:OnHideWindowsEnvelope()
  817. self:OnRedEnvelopeRemainTimeRefresh()
  818. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnNormalREClick)
  819. end
  820. else
  821. if self.btnRedEnvelope.activeSelf then
  822. self.btnRedEnvelope:SetActive(false)
  823. end
  824. if self.windowEnvelope.activeSelf then
  825. self.windowEnvelope:SetActive(false)
  826. end
  827. end
  828. end
  829. function UIBattleView:OnHideWindowsEnvelope()
  830. self.windowEnvelope.transform:DOMove(self.btnRedEnvelope.transform.position, 0.3):SetEase(DG.Tweening.Ease.InQuint)
  831. self.windowEnvelope.transform:DOScale(0, 0.3):SetEase(DG.Tweening.Ease.InQuint):OnComplete(function()
  832. self.windowEnvelope:SetActive(false)
  833. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  834. self.btnRedEnvelope:SetActive(true)
  835. end)
  836. end
  837. function UIBattleView:OnShowWindowsEnvelope()
  838. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  839. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  840. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  841. if levelCfgData.Cash == 0 then
  842. self.btnRedEnvelope:SetActive(false)
  843. self.windowEnvelope:SetActive(false)
  844. return
  845. end
  846. self.windowEnvelope.transform.localScale = Vector3.zero
  847. self.windowEnvelope.cashNumber.text.text = levelCfgData.Cash
  848. self.windowEnvelope.textRank.uILocalizeScript:SetContentAndValues("CashReward01", {levelCfgData.PassNum})
  849. self.btnRedEnvelope:SetActive(false)
  850. self.windowEnvelope:SetActive(true)
  851. self.windowEnvelope.transform.position = self.btnRedEnvelope.transform.position
  852. self.windowEnvelope.transform:DOMove(windowREPos, 0.3):SetEase(DG.Tweening.Ease.OutQuint)
  853. self.windowEnvelope.transform:DOScale(1, 0.3):SetEase(DG.Tweening.Ease.OutBounce):OnComplete(function()
  854. remainTime = 2
  855. self.windowEnvelope.text.text.text = string.formatbykey("CashReward03", remainTime)
  856. self.windowEnvelope.transform:DOScale(1, 1):SetLoops(2):OnStepComplete(function ()
  857. remainTime = remainTime - 1
  858. self.windowEnvelope.text.text.text = string.formatbykey("CashReward03", remainTime)
  859. if remainTime == 0 then
  860. self.windowEnvelope.transform:DOMove(self.btnRedEnvelope.transform.position, 0.3):SetEase(DG.Tweening.Ease.InQuint)
  861. self.windowEnvelope.transform:DOScale(0, 0.3):SetEase(DG.Tweening.Ease.InQuint):OnComplete(function()
  862. self.windowEnvelope:SetActive(false)
  863. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  864. self.btnRedEnvelope:SetActive(true)
  865. end)
  866. end
  867. end)
  868. end)
  869. end
  870. function UIBattleView:OnRedEnvelopeRemainTimeRefresh()
  871. if not Constant.OpenPay then
  872. self.btnRedEnvelope:SetActive(false)
  873. self.windowEnvelope:SetActive(false)
  874. return
  875. end
  876. local reActItem = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(Enum.ActivityType.ACTIVITY_TYPE_CASH_SHOP)
  877. local state = reActItem and reActItem:IsUnlocked() and reActItem:IsOpened() and not reActItem:IsOutofDate()
  878. self.btnRedEnvelope:SetActive(state)
  879. if not state then
  880. self.windowEnvelope:SetActive(false)
  881. return
  882. end
  883. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  884. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  885. if levelCfgData.Cash == 0 and bBossStage then
  886. if self.btnRedEnvelope.activeSelf then
  887. self.btnRedEnvelope:SetActive(false)
  888. end
  889. if self.windowEnvelope.activeSelf then
  890. self.windowEnvelope:SetActive(false)
  891. end
  892. return
  893. end
  894. local leftSeconds = reActItem:LeftTime()
  895. if leftSeconds > 0 then
  896. if leftSeconds <= 60 then
  897. self.btnRedEnvelope.text.text.text = I18N.T("LessOneMinu")
  898. else
  899. local time = DateTimeUtil.convertSeconds2TimeStr1(leftSeconds, true, false)
  900. self.btnRedEnvelope.text.text.text = time
  901. end
  902. else
  903. if self.btnRedEnvelope.activeSelf then
  904. self.btnRedEnvelope:SetActive(false)
  905. end
  906. if self.windowEnvelope.activeSelf then
  907. self.windowEnvelope:SetActive(false)
  908. end
  909. end
  910. end
  911. function UIBattleView:OnBattleREClick()
  912. self:OnShowWindowsEnvelope()
  913. end
  914. function UIBattleView:OnNormalREClick()
  915. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIREShop, nil, self.uiData.id)
  916. end
  917. function UIBattleView:ShowBattleNormalUI()
  918. if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIBattle) then
  919. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BOSS_BATTLE_STATUS,false)
  920. end
  921. self.transform:DOScale(1, 0.8):OnComplete(function ()
  922. self:ShowBattleNormalUI1()
  923. end)
  924. end
  925. function UIBattleView:ShowBattleNormalUI1()
  926. --self.bottomNode:SetActive(true)
  927. self.centerNode:SetActive(true)
  928. --self.ProfitBoxGo:SetActive(true)
  929. if not ManagerContainer.LuaBattleMgr:GetBossFightState() then
  930. self.MapRootGo:SetActive(true)
  931. end
  932. self.btnwarlog:SetActive(true)
  933. self.btnStatistics:SetActive(true)
  934. -- self:OnValueChangedToggle(nil,1, true)
  935. end
  936. function UIBattleView:OnContinueBattle()
  937. bBoxState = false
  938. self.battleFailGo:SetActive(false);
  939. self:PlayRewardNormalAnim();
  940. end
  941. function UIBattleView:OnBattleWin()
  942. self:RestoreSpeed()
  943. self.BossBloodPart:Hide()
  944. self.HeadsBoxPart:Hide()
  945. self.StatisticsPart:Hide()
  946. self.rageBoxGo:SetActive(false)
  947. end
  948. function UIBattleView:OnBattleFailed(killboss,isPlayRecord)
  949. self:RestoreSpeed()
  950. -- self.battleFailGo:SetActive(true);
  951. self.BossBloodPart:Hide()
  952. self.HeadsBoxPart:Hide()
  953. self.StatisticsPart:Hide()
  954. self.rageBoxGo:SetActive(false)
  955. self:PlayChallengeBtnNormalAnim()
  956. self:PlayRewardNormalAnim()
  957. if killboss and (not isPlayRecord) then
  958. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIClimbingTowerBattleFailed,Enum.UIPageName.UIBattle)
  959. else
  960. self.battleFailGo:SetActive(true)
  961. end
  962. --self:ShowBattleNormalUI()
  963. end
  964. function UIBattleView:OnForceBattleFailed(killboss,isPlayRecord)
  965. self:RestoreSpeed()
  966. -- self.battleFailGo:SetActive(true);
  967. self.BossBloodPart:Hide()
  968. self.HeadsBoxPart:Hide()
  969. self.StatisticsPart:Hide()
  970. self.rageBoxGo:SetActive(false)
  971. self:PlayChallengeBtnNormalAnim()
  972. self:PlayRewardNormalAnim()
  973. if killboss and (not isPlayRecord) then
  974. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIClimbingTowerBattleFailed,Enum.UIPageName.UIBattle)
  975. end
  976. self.battleFailGo:SetActive(false)
  977. end
  978. function UIBattleView:RestoreSpeed()
  979. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  980. end
  981. function UIBattleView:FuncOpen()
  982. self:PlayChallengeBtnNormalAnim()
  983. self:PlayRewardNormalAnim();
  984. self:OnRefreshEarnings();
  985. --if ManagerContainer.LuaUIMgr.CurrentPage.PageId == self.uiData.id then
  986. self:FuncOpen1()
  987. --end
  988. end
  989. function UIBattleView:FuncOpen1()
  990. local levelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  991. local newFuncs, nearFuncs, forceGuideList = ManagerContainer.UIFuncUnlockMgr:GetNewFuncAndNearFuncByLevelId(levelId)
  992. if newFuncs[1] == nil then
  993. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  994. return
  995. end
  996. local newFunc = newFuncs[1]
  997. self.newFuncs = newFuncs
  998. if #forceGuideList > 0 then
  999. self.controller:SetNewForceId(forceGuideList[1])
  1000. end
  1001. local newFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(newFunc)
  1002. CommonUtil.LoadIcon(self, newFuncData.FunIcon, function (sprite)
  1003. self.newOpen.image.image.sprite = sprite
  1004. self.newOpen.imageLt.image.sprite = sprite
  1005. end)
  1006. self.newOpen.nameTxt.text.text = I18N.T(newFuncData.FunName)
  1007. self.newOpen.dscTxt.text.text = I18N.T(newFuncData.FunDsc)
  1008. local item = self.newOpen.item
  1009. item:SetActive(nearFuncs[1] ~= nil)
  1010. if nearFuncs[1] ~= nil then
  1011. local nearData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(nearFuncs[1])
  1012. CommonUtil.LoadIcon(self, nearData.FunIcon, function (sprite)
  1013. item.image.image.sprite = sprite
  1014. end)
  1015. local result,val,content = ManagerContainer.UIFuncUnlockMgr:CheckConditionPassResult(nearData)
  1016. item.itemTxt.text.text = I18N.T(nearData.FunName).."("..content..")"
  1017. end
  1018. self.newOpen:SetActive(true)
  1019. end
  1020. function UIBattleView:OnTaskClick()
  1021. ManagerContainer.DataMgr.TaskDataNew:OpenTaskPanel();
  1022. end
  1023. function UIBattleView:OnCloseNewOpen()
  1024. self.newOpen:SetActive(false)
  1025. if self.newFuncs then
  1026. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_UNLOCK_NTF, self.newFuncs)
  1027. self.newFuncs = nil
  1028. end
  1029. local newForceId = self.controller:GetNewForceId()
  1030. if newForceId then
  1031. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_TRIGGER, Enum.ForceGuideTriggerEnum.FuncOpen, newForceId)
  1032. self.controller:SetNewForceId()
  1033. else
  1034. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  1035. end
  1036. end
  1037. function UIBattleView:OnBattleNewWave(levelName)
  1038. self.battleFailGo:SetActive(false);
  1039. self:OnRefreshEarnings();
  1040. end
  1041. function UIBattleView:OnHideLevelName()
  1042. end
  1043. function UIBattleView:OnShowBossRage()
  1044. self.rageBoxGo:SetActive(true)
  1045. end
  1046. function UIBattleView:OnShowBossRageLeftTime(leftTime)
  1047. self:RefreshRageTime(leftTime)
  1048. end
  1049. function UIBattleView:OnBossInRage()
  1050. self.rageBoxGo:SetActive(false)
  1051. end
  1052. function UIBattleView:PlayChallengeBtnNormalAnim()
  1053. if self.btnBossAnimator~= nil then
  1054. self.challengeAnimName = bossFightCDRemainTime <= 0 and "BtnBoss1" or "BtnBoss4"
  1055. if self.btnBossAnimator.activeInHierarchy then
  1056. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  1057. end
  1058. if bossFightCDRemainTime > 0 then
  1059. self.btnChallenge.remainCDTime.text.text = I18N.SetLanguageValue("FightCD", math.ceil(bossFightCDRemainTime))
  1060. end
  1061. end
  1062. --self.ReceiveGo:SetActive(true);
  1063. self.quickBattleBtn.button.interactable = true
  1064. end
  1065. function UIBattleView:PlayRewardNormalAnim()
  1066. self:OnRefreshRewardTime();
  1067. end
  1068. function UIBattleView:RefreshRageTime(leftTime)
  1069. if leftTime ~= nil then
  1070. local spriteName = nil
  1071. if leftTime == 10 then
  1072. spriteName = "Alert_number_0"
  1073. else
  1074. spriteName = "Alert_number_"..leftTime
  1075. end
  1076. self.rageNum1.image.sprite = self.rageNum1.switchSprite:GetSprite(spriteName)
  1077. self.rageNum2.image.sprite = self.rageNum2.switchSprite:GetSprite(spriteName)
  1078. if leftTime == 1 then
  1079. self.rageBoxGo.bg.animator:Play("BafengteAlertEnd")
  1080. end
  1081. end
  1082. end
  1083. function UIBattleView:OnShowBossWarning(vis)
  1084. self.bossWarning.animator.gameObject:SetActive(vis)
  1085. end
  1086. function UIBattleView:OnRefreshEarnings()
  1087. self.ExpLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelExp() .. "/" .. I18N.T("m") ;
  1088. self.ZenyLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelZeny() .. "/" .. I18N.T("m");
  1089. self.ParnterExpLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelParnterExp() .. "/" .. I18N.T("m");
  1090. self.CruiseLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelCruise() .. "/" .. I18N.T("m");
  1091. self.CurLevelName.text.text = ManagerContainer.LuaBattleMgr:CurLevelName();
  1092. ManagerContainer.LuaBattleMgr:SetRewardDropPos(self.RewardBoxBtnPos);
  1093. local lockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(35)
  1094. ManagerContainer.LuaUIMgr:SetBattleDropRootVisible(lockState)
  1095. end
  1096. function UIBattleView:OnRefreshRewardTime()
  1097. local passedTime = ManagerContainer.LuaBattleMgr:AccumIncomeTime();
  1098. local maxTime = ManagerContainer.LuaBattleMgr:MaxInComeTime() * 1000
  1099. if passedTime >= maxTime then
  1100. passedTime = maxTime
  1101. end
  1102. local leftTime,num = ManagerContainer.LuaBattleMgr:GetIncomeInfo()
  1103. if num == nil then
  1104. num = 0
  1105. end
  1106. self.rewardPoint:SetActive(num >= 1)
  1107. if num > 999 then
  1108. self.rewardPoint.num.text.text = "999+"
  1109. else
  1110. self.rewardPoint.num.text.text = tostring(num)
  1111. end
  1112. if passedTime >= maxTime then
  1113. self.RewardTimeLbl.text.text = "Max";
  1114. else
  1115. self.RewardTimeLbl.text.text = DateTimeUtil.convertSeconds2TimeStr(leftTime,true);
  1116. end
  1117. self:CheckRewardBoxStatus(passedTime)
  1118. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_HANG_TIME,passedTime);
  1119. end
  1120. function UIBattleView:CheckRewardBoxStatus(passedTime)
  1121. local animName = "Chest01New"
  1122. if bBoxState then
  1123. animName = "ChestClose"
  1124. else
  1125. if passedTime <= self.statTime1 then
  1126. animName = "Chest01New"
  1127. elseif passedTime <= self.statTime2 then
  1128. animName = "Chest02New"
  1129. elseif passedTime <= self.statTime3 then
  1130. animName = "Chest03New"
  1131. else
  1132. animName = "Chest04New"
  1133. end
  1134. end
  1135. if self.RewardBoxBtn.activeInHierarchy then
  1136. self.RewardBoxBtn.animator:Play(animName);
  1137. end
  1138. end
  1139. function UIBattleView:OnBattleIncomeAck(dropLoc)
  1140. local zeny = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.Coin)
  1141. local partnerExp = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.ParterExp)
  1142. local exp = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.RoleBaseExp)
  1143. local createZeny = false;
  1144. local createExp=false;
  1145. local createPartnerExp = false;
  1146. if UIMainCtr == nil then
  1147. UIMainCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIMain)
  1148. end
  1149. local zenyPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.Coin)
  1150. local expPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.RoleBaseExp)
  1151. local bagPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.ParterExp)
  1152. if zeny ~= nil and zeny > 0 then
  1153. createZeny = true
  1154. end
  1155. if partnerExp~= nil and partnerExp > 0 then
  1156. createPartnerExp = true
  1157. end
  1158. if exp ~= nil and exp > 0 then
  1159. createExp = true
  1160. end
  1161. local itemIcons = {};
  1162. for i =1, #ManagerContainer.LuaBattleMgr.rewardItemList do
  1163. local item = ManagerContainer.LuaBattleMgr.rewardItemList[i];
  1164. if item.key >= 100 then
  1165. local itemCfg = ManagerContainer.CfgMgr:GetItemById(item.key)
  1166. if itemCfg~= nil then
  1167. itemIcons[#itemIcons+1] = itemCfg.Icon
  1168. end
  1169. end
  1170. end
  1171. self.dropType = dropLoc;
  1172. if dropLoc == 0 then
  1173. LuaBattleBridge.GenerateDropItems(self.RewardBoxBtnPos,createZeny,zenyPos,createExp,expPos,createPartnerExp,bagPos,false,Vector3.zero,0.15,0.25,unpack(itemIcons));
  1174. else
  1175. LuaBattleBridge.GenerateDropItems(Vector3.New(0, 0, 0),createZeny,zenyPos,createExp,expPos,createPartnerExp,bagPos,false,Vector3.zero,0.30,0.25,unpack(itemIcons));
  1176. end
  1177. if self.openRewardTimer ~= nil then
  1178. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer)
  1179. self.openRewardTimer = nil
  1180. end
  1181. self.openRewardTimer = ManagerContainer.LuaTimerMgr:AddTimer(GlobalConfig.Instance:GetConfigFloatValue(78)*1000, 1, self, self.OnOpenRewardPage, nil)
  1182. end
  1183. function UIBattleView:OnOpenRewardPage()
  1184. self.openRewardTimer = nil
  1185. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleReward,self.dropType)
  1186. end
  1187. function UIBattleView:LoadMinimap()
  1188. local mapId = ManagerContainer.LuaBattleMgr:GetCurMapId()
  1189. local mapCfgData = ManagerContainer.CfgMgr:GetMapData(mapId)
  1190. local center = mapCfgData.Center
  1191. self.mapCenter = Vector3.New(center[1], center[2], center[3])
  1192. self.mapSizeX = mapCfgData.RealSizeX
  1193. self.mapSizeZ = mapCfgData.RealSizeZ
  1194. local scale = mapCfgData.MinimapScale *0.01
  1195. self.minimap.transform.localScale = Vector3.New(scale, scale, scale)
  1196. self.minimapSizeX = mapCfgData.MinimapSizeX * scale
  1197. self.minimapSizeZ = mapCfgData.MinimapSizeZ * scale
  1198. CommonUtil.LoadTexture(self, mapCfgData.MinimapIcon, function (texture)
  1199. self.minimap.rawImage.texture = texture
  1200. self:RefreshMinimapInfo()
  1201. end)
  1202. end
  1203. function UIBattleView:WorldPos2MinimapPos(pos)
  1204. local xRate = pos.x / self.mapSizeX
  1205. local zRate = pos.z / self.mapSizeZ
  1206. local x = self.minimapSizeX * xRate
  1207. local z = self.minimapSizeZ * zRate
  1208. return x,z
  1209. end
  1210. function UIBattleView:OnRefreshMinimap()
  1211. self:RefreshMinimapInfo()
  1212. end
  1213. function UIBattleView:RefreshMinimapInfo()
  1214. if self.miniMapGoes == nil then
  1215. return
  1216. end
  1217. if ManagerContainer.LuaBattleMgr.isBattleing then
  1218. return
  1219. end
  1220. LuaBattleBridge.RefreshMinimap(self.mapCenter, self.mapSizeX,self.mapSizeZ,self.minimapSizeX,self.minimapSizeZ, self.hero,unpack(self.miniMapGoes))
  1221. end
  1222. function UIBattleView:InitCruise()
  1223. end
  1224. function UIBattleView:RefreshCruise()
  1225. end
  1226. function UIBattleView:OnClickCruiseBtn()
  1227. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UITreasures)
  1228. end
  1229. function UIBattleView:OnClickMailBtn()
  1230. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIMailBox)
  1231. end
  1232. function UIBattleView:GeAnchoredPosition3DByType(type)
  1233. if type ~= Enum.ItemType.RoleJobExp and type ~= Enum.ItemType.RoleBaseExp then
  1234. return self.ReceiveGo.transform.position
  1235. end
  1236. return Vector3.zero
  1237. end
  1238. function UIBattleView:GetMiniMapPosition()
  1239. return self.minimap.transform.parent.position
  1240. end
  1241. function UIBattleView:RewardBoxRefresh()
  1242. bBoxState = false
  1243. self:PlayRewardNormalAnim();
  1244. end
  1245. function UIBattleView:GetBattleState()
  1246. return bBossStage
  1247. end
  1248. function UIBattleView:PopGotAnimEnd(type)
  1249. if type == Enum.ItemIEnterType.BattleWin then
  1250. self:PlayChallengeBtnNormalAnim()
  1251. end
  1252. end
  1253. function UIBattleView:NewLevelIncrease()
  1254. if levelIncreaseTimer ~= nil then
  1255. ManagerContainer.LuaTimerMgr:RemoveTimer(levelIncreaseTimer)
  1256. levelIncreaseTimer = nil
  1257. end
  1258. if bBossStage then return end
  1259. local count = 0
  1260. local list = {}
  1261. local lastLevelZeny = ManagerContainer.LuaBattleMgr.lastLevelZeny
  1262. local curLevelZeny = ManagerContainer.LuaBattleMgr:CurLevelZeny()
  1263. if lastLevelZeny < curLevelZeny then
  1264. count = count + 1
  1265. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelZeny, newNum = curLevelZeny}
  1266. list[#list + 1] = data
  1267. end
  1268. local lastLevelExp = ManagerContainer.LuaBattleMgr.lastLevelExp
  1269. local curLevelExp = ManagerContainer.LuaBattleMgr:CurLevelExp()
  1270. if lastLevelExp < curLevelExp then
  1271. count = count + 1
  1272. local data = {iconPath = Enum.LevelIncreaseType.BaseExp, lastNum = lastLevelExp, newNum = curLevelExp}
  1273. list[#list + 1] = data
  1274. end
  1275. local lastLevelPartnerExp = ManagerContainer.LuaBattleMgr.lastLevelPartnerExp
  1276. local curLevelPartnerExp = ManagerContainer.LuaBattleMgr:CurLevelParnterExp()
  1277. if lastLevelPartnerExp < curLevelPartnerExp then
  1278. count = count + 1
  1279. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelPartnerExp, newNum = curLevelPartnerExp}
  1280. list[#list + 1] = data
  1281. end
  1282. local lastLevelCruise = ManagerContainer.LuaBattleMgr.lastLevelCruise
  1283. local curLevelCruise = ManagerContainer.LuaBattleMgr:CurLevelCruise()
  1284. if lastLevelCruise < curLevelCruise then
  1285. count = count + 1
  1286. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelCruise, newNum = curLevelCruise}
  1287. list[#list + 1] = data
  1288. end
  1289. if #list > 0 then
  1290. increaseIdx = 0
  1291. self:ShowLevelIncrease(0, list)
  1292. if #list > 1 then
  1293. levelIncreaseTimer = ManagerContainer.LuaTimerMgr:AddTimer(500, #list - 1, self, self.ShowLevelIncrease, list)
  1294. end
  1295. end
  1296. end
  1297. function UIBattleView:ShowLevelIncrease(idx, list)
  1298. increaseIdx = increaseIdx + 1
  1299. local data = list[increaseIdx]
  1300. ManagerContainer.GoPoolMgr:SpawnGo(Enum.PrefabNames.LevelIncreaseItem, function(itemlua)
  1301. CommonUtil.BatchCreateItems(self, itemlua, self.centerNode.transform, data)
  1302. end)
  1303. end
  1304. function UIBattleView:DisposeNewLevelIncrease()
  1305. if levelIncreaseTimer ~= nil then
  1306. ManagerContainer.LuaTimerMgr:RemoveTimer(levelIncreaseTimer)
  1307. levelIncreaseTimer = nil
  1308. end
  1309. CommonUtil.RecycleFromBatchItemsByPrefabName(self, Enum.PrefabNames.LevelIncreaseItem)
  1310. end
  1311. function UIBattleView:IsSomeFrameCount(keyName)
  1312. local value = self[keyName]
  1313. if value and value >= Time.frameCount then
  1314. return true
  1315. end
  1316. self[keyName] = Time.frameCount
  1317. return false
  1318. end
  1319. function UIBattleView:OnClickBattleRecordBtn()
  1320. ManagerContainer.LuaBattleMgr:SendBattleRecordReq()
  1321. end
  1322. function UIBattleView:OnClickBattleStatisticsBtn()
  1323. if LuaBattleBridge.HasStatistics(BattleMode.Normal,BattleSubMode.None) then
  1324. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleStatistics,{BattleMode.Normal,BattleSubMode.None})
  1325. else
  1326. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("NullBattleInformation1")
  1327. end
  1328. end
  1329. function UIBattleView:OnClickAutoChallenge()
  1330. if not ManagerContainer.DataMgr.RuneShopDataMgr:GetRoPassAutoBattle() then
  1331. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("nomonthcard")
  1332. ManagerContainer.LuaBattleMgr:StopAutoChallenge()
  1333. return
  1334. end
  1335. if ManagerContainer.LuaBattleMgr:GetAutoChallengeState() then
  1336. self.autoAnim.animator:Play("AutoKeep")
  1337. ManagerContainer.LuaBattleMgr:StopAutoChallenge()
  1338. else
  1339. self.autoAnim.animator:Play("AutoIn")
  1340. ManagerContainer.LuaBattleMgr:SetAutoChallengeState(true)
  1341. end
  1342. end
  1343. function UIBattleView:FindTaskCompeleted1(id, owner, ownerCB)
  1344. local page = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIPOPGot)
  1345. if page then
  1346. local pop = page.MLuaTable
  1347. pop:UIClose()
  1348. end
  1349. local target = self.btnChallenge
  1350. if target == nil then
  1351. if owner and ownerCB then
  1352. ownerCB(owner)
  1353. end
  1354. return
  1355. end
  1356. if owner and ownerCB then
  1357. ownerCB(owner, target)
  1358. end
  1359. end
  1360. return UIBattleView