UIBattleView.lua 53 KB

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