UIBattleView.lua 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  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. self.uiBase:AddButtonUniqueEventListener(self.bgBtn.button,self,self.CloseMapModeSelectPanel)
  352. end
  353. function UIBattleView:OnClickDifficultBtn()
  354. -- if bBossStage then
  355. -- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting1")
  356. -- return;
  357. -- end
  358. -- local mapMode = ManagerContainer.LuaBattleMgr:GetBattleMode() == Enum.MapModeType.Difficulty and Enum.MapModeType.Simple or Enum.MapModeType.Difficulty
  359. -- ManagerContainer.LuaBattleMgr:SendChangeMapLevelTypeReq(mapMode)
  360. self.mapLevelModes:SetActive(true)
  361. self:RefMapModeBtn()
  362. end
  363. function UIBattleView:OnMapModeChange(mode)
  364. --self.difficultBtn.DifTxt
  365. local Btntxt = I18N.T("SelectMapModeTxt")
  366. -- if mode == 0 then
  367. -- Btntxt = I18N.T("DifficultMode")
  368. -- else
  369. -- Btntxt = I18N.T("SimpleMode")
  370. -- end
  371. --LogError("--------------------"..Btntxt)
  372. self.difficultBtn.DifTxt.text.text = Btntxt
  373. end
  374. function UIBattleView:RefMapModeBtn()
  375. local curMode = ManagerContainer.LuaBattleMgr:GetBattleMode()
  376. local AllMode = {0,1}
  377. local emUnlockLevel = GlobalConfig.Instance:GetConfigIntValue(365)
  378. local curLevel = ManagerContainer.LuaBattleMgr:GetCurDiffLvID()
  379. if(curLevel >= emUnlockLevel)then
  380. table.insert(AllMode,2)
  381. end
  382. local needShowModeBtn = {}
  383. for _, v in ipairs(AllMode) do
  384. if v ~= curMode then
  385. table.insert(needShowModeBtn,v)
  386. end
  387. end
  388. self.modeNode.loopVerticalScrollRect:ClearCells()
  389. CommonUtil.LoopGridViewEleCreateNew(self,
  390. self.modeNode.loopVerticalScrollRect,
  391. self.content.verticalLayoutGroup,
  392. needShowModeBtn,
  393. 0,
  394. self,
  395. self.UpdateModeNode,
  396. nil, nil, 0);
  397. end
  398. function UIBattleView:UpdateModeNode(_itemLua, _idx,_data)
  399. if not _itemLua or not _data then return end
  400. CommonUtil.UpdateItemPrefab(self, _itemLua, _data, nil,self,self.OnClickMapMode)
  401. end
  402. function UIBattleView:OnClickMapMode(btn,data)
  403. --LogError("点击 data = " ..Inspect(data))
  404. self:CloseMapModeSelectPanel()
  405. if bBossStage then
  406. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting1")
  407. return;
  408. end
  409. ManagerContainer.LuaBattleMgr:SendChangeMapLevelTypeReq(data[0])
  410. end
  411. function UIBattleView:CloseMapModeSelectPanel()
  412. self.mapLevelModes:SetActive(false)
  413. end
  414. function UIBattleView:OnHide()
  415. self.newFunc = nil
  416. self:DisposeNewLevelIncrease()
  417. self.recordSpeed = ManagerContainer.LuaGameMgr:GetGameSpeed();
  418. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  419. needRefreshMinimap = false
  420. if self.inited then
  421. self.chatView:SetActive(false)
  422. end
  423. if chatHideTimer then
  424. ManagerContainer.LuaTimerMgr:RemoveTimer(chatHideTimer)
  425. chatHideTimer = nil
  426. end
  427. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  428. end
  429. function UIBattleView:OnShow()
  430. ManagerContainer.LuaGameMgr:SetGameSpeed(self.recordSpeed)
  431. self:InitComs();
  432. self:OnRefreshEarnings();
  433. self:LoadMinimap()
  434. self:InitCruise()
  435. --self:RefreshChatBg()
  436. if self.btnBossAnimator.activeInHierarchy then
  437. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  438. end
  439. self:OnRefreshRewardTime();
  440. --self:RefreshStageGoalUI()
  441. local result = ManagerContainer.UIFuncUnlockMgr:GetNeedDisplayNewFuncStatus()
  442. if result then
  443. self:FuncOpen1()
  444. else
  445. self.newOpen:SetActive(false)
  446. end
  447. self.btnAuto:SetActive(false)
  448. needRefreshMinimap = true
  449. --self.chatView:SetActive(true)
  450. --self.battleLogView:SetActive(false)
  451. self.battleRootNew:SetActive(true)
  452. --self:HandleChatToggleBtns(1)
  453. if not ManagerContainer.LuaBattleMgr:GetBossFightState() then
  454. self.MapRootGo:SetActive(true)
  455. end
  456. self:RefreshOnlineRecordBtn()
  457. self:OnMapModeChange(ManagerContainer.LuaBattleMgr:GetBattleMode())
  458. end
  459. function UIBattleView:OnClose()
  460. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  461. if updateHandle ~= nil then
  462. UpdateBeat:RemoveListener(updateHandle)
  463. updateHandle = nil
  464. end
  465. self.logList = nil
  466. if chatHideTimer then
  467. ManagerContainer.LuaTimerMgr:RemoveTimer(chatHideTimer)
  468. chatHideTimer = nil
  469. end
  470. if self.inited then
  471. self.battleLogView.loopVerticalScrollRect:SetUpdateCellCallback(nil,nil)
  472. -- self:ClearBattleSkillTimer()
  473. if self.openRewardTimer ~= nil then
  474. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer);
  475. self.openRewardTimer = nil
  476. end
  477. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  478. self.controller:SetChatChannelType(nil)
  479. end
  480. if self.BossBloodPart ~= nil then
  481. self.BossBloodPart:Dispose()
  482. self.BossBloodPart = nil
  483. end
  484. if self.HeadsBoxPart ~= nil then
  485. self.HeadsBoxPart:Dispose()
  486. self.HeadsBoxPart = nil
  487. end
  488. if self.StatisticsPart ~= nil then
  489. self.StatisticsPart:Dispose()
  490. self.StatisticsPart = nil
  491. end
  492. if self.battleReplayPart ~= nil then
  493. self.battleReplayPart:Dispose()
  494. self.battleReplayPart = nil
  495. end
  496. if self.NewBattleChatPart ~= nil then
  497. self.NewBattleChatPart:Dispose()
  498. self.NewBattleChatPart = nil
  499. end
  500. pageToggleData = nil
  501. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  502. self.uIEventHandler:RemoveListener()
  503. end
  504. function UIBattleView:RefreshStageGoalUI(newProgress)
  505. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  506. self.btnStageGoal:SetActive(curGoal ~= nil and curGoal.taskId <= ManagerContainer.CfgMgr:LastTargetTaskId() and curGoal.state <= 1)
  507. if curGoal ~= nil then
  508. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  509. if goalCfgData == nil then
  510. return
  511. end
  512. local max = 0
  513. for _,v in pairs(CommonUtil.DeserializeCfgItemList(goalCfgData.TargetTaskCondition)) do
  514. max = max + v[#v]
  515. end
  516. local progress = ManagerContainer.DataMgr.StageGoalData:GetCurGoalDataProgress()
  517. local isCompleted = progress == max
  518. local func
  519. if not isCompleted then
  520. self.btnStageGoal.state:SetActive(false)
  521. func = self.ShowItemTips
  522. else
  523. if not newProgress then
  524. self.btnStageGoal.state:SetActive(true)
  525. func = self.AwardGoal
  526. else
  527. self.btnStageGoal.state:SetActive(false)
  528. func = self.ShowItemTips
  529. end
  530. end
  531. local data = {cfgId = goalCfgData.TargetReward[1][1], num = goalCfgData.TargetReward[1][2]}
  532. CommonUtil.UpdateItemPrefab(self, self.btnStageGoal.iconItem, data, Enum.ItemIEnterType.Bag, self, func)
  533. if max < 4 then
  534. self.btnStageGoal.points.gridLayoutGroup.spacing = stageGoalGridSpacing[1]
  535. elseif max == 4 then
  536. self.btnStageGoal.points.gridLayoutGroup.spacing = stageGoalGridSpacing[2]
  537. elseif max == 5 then
  538. self.btnStageGoal.points.gridLayoutGroup.spacing = stageGoalGridSpacing[3]
  539. end
  540. for i = 1, Constant.StageGoalMaxPoints do
  541. self["point"..i]:SetActive(i <= max)
  542. if i <= max then
  543. self["point"..i].light.animator:Play(i < progress and "CupKeep" or "CupEmpty")
  544. if newProgress then
  545. newStageCompeleted = newProgress
  546. else
  547. if i == progress then
  548. self["point"..i].light.animator:Play("CupKeep")
  549. end
  550. end
  551. end
  552. end
  553. end
  554. end
  555. function UIBattleView:NewStageCompletedNtf()
  556. if newStageCompeleted then
  557. newStageCompeleted = false
  558. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  559. if curGoal ~= nil then
  560. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  561. if goalCfgData == nil then
  562. return
  563. end
  564. local max = 0
  565. for _,v in pairs(CommonUtil.DeserializeCfgItemList(goalCfgData.TargetTaskCondition)) do
  566. max = max + v[#v]
  567. end
  568. if curGoal.state == Enum.TaskStateType.CompletedAndNoReceive then
  569. self.btnStageGoal.state:SetActive(true)
  570. local func = self.AwardGoal
  571. local data = {cfgId = goalCfgData.TargetReward[1][1], num = goalCfgData.TargetReward[1][2]}
  572. CommonUtil.UpdateItemPrefab(self, self.btnStageGoal.iconItem, data, Enum.ItemIEnterType.Bag, self, func)
  573. end
  574. local progress = ManagerContainer.DataMgr.StageGoalData:GetCurGoalDataProgress()
  575. for i = 1, Constant.StageGoalMaxPoints do
  576. if i == progress then
  577. self["point"..i].light.animator:Play("CupShow")
  578. end
  579. end
  580. end
  581. end
  582. end
  583. function UIBattleView:StageGoalAwarded(list)
  584. if #list == 0 then
  585. -- LogError("no item")
  586. return
  587. end
  588. local data = {cfgId = list[1].key, num = list[1].value}
  589. local data1 = {list = {data}, startPoses = {self.btnStageGoal.iconItem.transform.position}, enterType = Enum.ItemIEnterType.StageGoal}
  590. ManagerContainer.LuaUIMgr:POPGotAnimNotice(data1)
  591. self:RefreshStageGoalUI()
  592. end
  593. function UIBattleView:AwardOrJumpStageGoal(button, params)
  594. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  595. if curGoal ~= nil then
  596. if curGoal.state ~= 1 then
  597. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  598. local data = ManagerContainer.CfgMgr:GetUIJumpData(goalCfgData.SkipInterface)
  599. if data == nil then return end
  600. ManagerContainer.UIJumpMgr:CreateJumpTask(data)
  601. else
  602. self:AwardGoal()
  603. end
  604. end
  605. end
  606. function UIBattleView:AwardGoal()
  607. local curGoal = ManagerContainer.DataMgr.StageGoalData:GetCurGoalData()
  608. if curGoal ~= nil then
  609. if curGoal.state ~= 1 then
  610. local goalCfgData = ManagerContainer.CfgMgr:GetTargetTaskDataById(curGoal.taskId)
  611. local data = {cfgId = goalCfgData.TargetReward[1][1], num = goalCfgData.TargetReward[1][2]}
  612. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIItemTips, data)
  613. ManagerContainer.LuaUIMgr:OpenTips(data)
  614. else
  615. self.stageGoalNtf:SetActive(false)
  616. self.controller:SendGetMainTaskRewardReq()
  617. end
  618. end
  619. end
  620. function UIBattleView:ShowItemTips(button, params)
  621. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIItemTips, params[0])
  622. local data = params[0]
  623. ManagerContainer.LuaUIMgr:OpenTips(data)
  624. end
  625. function UIBattleView:OnDispose()
  626. self.battleLoadingState = nil
  627. self.chatView.loopListView:Dispose()
  628. self:DisposeNewLevelIncrease()
  629. if bossMaskTimer ~= nil then
  630. ManagerContainer.LuaTimerMgr:RemoveTimer(bossMaskTimer)
  631. bossMaskTimer = nil
  632. end
  633. needRefreshMinimap = false
  634. self.miniMapGoes = nil
  635. if updateHandle ~= nil then
  636. UpdateBeat:RemoveListener(updateHandle)
  637. updateHandle = nil
  638. end
  639. DG.Tweening.DOTween.Kill(self.transform)
  640. self.battleLogView.uIEventTriggerListener.onPointerUp = nil
  641. self.battleLogView.uIEventTriggerListener.onClick = nil
  642. UIMainCtr = nil
  643. end
  644. function UIBattleView:OnClickQuickBtn()
  645. if self.controller:IsUnlockQuickBattle() then
  646. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIQuickBattle)
  647. else
  648. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(self.controller:UnlockQuickBattleCondition())
  649. end
  650. end
  651. function UIBattleView:OnClickRewardBtn()
  652. if bBossStage then
  653. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting2")
  654. return
  655. else
  656. ManagerContainer.LuaBattleMgr:SendBattleIncomeReq()
  657. end
  658. self.RewardBoxBtn.animator:Play("ChestPressedNew");
  659. end
  660. function UIBattleView:OnAutoChallengeClickEvent()
  661. if ManagerContainer.LuaBattleMgr:GetAutoChallengeState() and not bBossStage then
  662. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  663. end
  664. end
  665. function UIBattleView:OnStartAutoChallenge()
  666. if not ManagerContainer.LuaBattleMgr:GetAutoChallengeState() then
  667. return
  668. end
  669. self:DisposeNewLevelIncrease()
  670. if bBossStage then
  671. return;
  672. end
  673. if bossFightCDRemainTime > 0 then
  674. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  675. return;
  676. end
  677. local roleLv = ManagerContainer.DataMgr.UserData:GetRoleLv()
  678. local challengeLv = LuaBattleBridge.GetCurLevelChallengeLv()
  679. if roleLv < challengeLv then
  680. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  681. return
  682. end
  683. local jobLv = ManagerContainer.DataMgr.UserData:GetJobLv()
  684. local maxJobLv = ManagerContainer.DataMgr.UserData:GetJobMaxLevel()
  685. local jobStage = ManagerContainer.DataMgr.UserData:GetJobStage()
  686. if jobStage<3 and jobLv>= maxJobLv then
  687. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  688. return
  689. end
  690. --self.challengeAnimName = "BtnBoss2"
  691. --
  692. --if self.btnBossAnimator.activeInHierarchy then
  693. -- self.btnBossAnimator.animator:Play(self.challengeAnimName);
  694. --end
  695. local battleLoadingState,text = ManagerContainer.LuaBattleMgr:GetBattleLoadingState()
  696. if battleLoadingState then
  697. ManagerContainer.LuaBattleMgr:StopAutoChallenge(true)
  698. return
  699. end
  700. self:StartBattleBoss()
  701. end
  702. function UIBattleView:OnClickChallengeBtn(btn)
  703. self:DisposeNewLevelIncrease()
  704. local Levelmaxlvid = GlobalConfig.Instance:GetConfigIntValue(363)
  705. if(ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId() >= Levelmaxlvid) then
  706. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("289")
  707. return
  708. end
  709. if bBossStage then
  710. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting1")
  711. return;
  712. end
  713. if bossFightCDRemainTime > 0 then
  714. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam("FightCD", math.ceil(bossFightCDRemainTime))
  715. return;
  716. end
  717. --======删除 等级限制==============================================
  718. local roleLv = ManagerContainer.DataMgr.UserData:GetRoleLv()
  719. local challengeLv = LuaBattleBridge.GetCurLevelChallengeLv()
  720. if roleLv < challengeLv then
  721. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.SetLanguageValue("LevelLimit", challengeLv))
  722. return
  723. end
  724. local jobLv = ManagerContainer.DataMgr.UserData:GetJobLv()
  725. local maxJobLv = ManagerContainer.DataMgr.UserData:GetJobMaxLevel()
  726. local jobStage = ManagerContainer.DataMgr.UserData:GetJobStage()
  727. if jobStage<3 and jobLv>= maxJobLv then
  728. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.T("JobLimit"))
  729. return
  730. end
  731. --======删除 等级限制==============================================
  732. --self.challengeAnimName = "BtnBoss2"
  733. --
  734. --if self.btnBossAnimator.activeInHierarchy then
  735. -- self.btnBossAnimator.animator:Play(self.challengeAnimName);
  736. --end
  737. local battleLoadingState,text = ManagerContainer.LuaBattleMgr:GetBattleLoadingState()
  738. if battleLoadingState then
  739. self.battleLoadingState = battleLoadingState
  740. self.btnChallenge.battleState.text.text = I18N.T(text)
  741. return
  742. end
  743. self:StartBattleBoss()
  744. end
  745. function UIBattleView:StartBattleBoss()
  746. local levelCfgId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  747. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(levelCfgId)
  748. if levelCfgData and levelCfgData.BossKey ~= "" then
  749. ManagerContainer.DataMgr.ChatData:AddLocalNewSystemData(levelCfgData.BossKey)
  750. end
  751. ManagerContainer.LuaBattleMgr:SendChallengeBossReq()
  752. end
  753. function UIBattleView:OnChallengeBossAck(factorList)
  754. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  755. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  756. bossFightCDRemainTime = levelCfgData.FightCD
  757. ManagerContainer.LuaUIMgr:OpenInputMask(9500)
  758. bBossStage = true
  759. bBoxState = true
  760. local battleFactors = System.Array.CreateInstance(Enum.TypeInfo.ValType, #factorList)
  761. for i = 1, #factorList do
  762. local factor = ValType.New(factorList[i].key,factorList[i].value)
  763. battleFactors[i-1] = factor
  764. end
  765. local teams = ManagerContainer.DataMgr.UserData:GetTeamData(true)
  766. for i = 1 , #teams do
  767. local actor = ManagerContainer.LuaActorDataMgr:GetActorsById(teams[i].uid,teams[i].id)
  768. --增加对应压制mark
  769. ManagerContainer.DataMgr.UserData:SetActorPveMark(teams[i].uid,actor)
  770. end
  771. LuaBattleBridge.ClickChallegeBoss(battleFactors);
  772. self.btnAuto:SetActive(Constant.OpenPay or false)
  773. local autoCState = ManagerContainer.LuaBattleMgr:GetAutoChallengeState()
  774. if autoCState then
  775. self.autoAnim.animator:Play("AutoIn")
  776. else
  777. self.autoAnim.animator:Play("AutoKeep")
  778. end
  779. end
  780. function UIBattleView:OnRefreshBossChallengeTime(time)
  781. bossFightCDRemainTime = time
  782. end
  783. function UIBattleView:BattleLoadingCompeleted()
  784. self.btnChallenge.battleState.text.text = I18N.T("BtnChallengeBOSS")
  785. if self.battleLoadingState then
  786. self.battleLoadingState = nil
  787. --self:StartBattleBoss()
  788. end
  789. end
  790. function UIBattleView:OnClickMiniMap()
  791. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBigMap, {id = ManagerContainer.LuaBattleMgr:GetCurMapId()})
  792. end
  793. function UIBattleView:OnBossDead()
  794. self.rageBoxGo:SetActive(false)
  795. end
  796. function UIBattleView:OnBossSpawned(bossActor,bossName,life,maxLife,skillParam,isPlayRecord)
  797. if bossMaskTimer ~= nil then
  798. ManagerContainer.LuaTimerMgr:RemoveTimer(bossMaskTimer)
  799. bossMaskTimer = nil
  800. end
  801. bossMaskTimer = ManagerContainer.LuaTimerMgr:AddTimer(1500, 1, self, self.CloseInputMask, nil)
  802. self.exploringTrans:SetActive(false);
  803. if self.btnBossAnimator ~= nil then
  804. self.challengeAnimName = "BtnBoss3"
  805. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  806. end
  807. self.quickBattleBtn.button.interactable = false
  808. if self.openRewardTimer~=nil then
  809. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer)
  810. self.openRewardTimer = nil;
  811. end
  812. self:OnHideLevelName()
  813. self:SetBossBattleInfo()
  814. self.StatisticsPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  815. self.BossBloodPart:Show(bossActor,bossName,life,maxLife,skillParam)
  816. self.HeadsBoxPart:Show()
  817. self.StatisticsPart:Show(BattleMode.Normal,BattleSubMode.None)
  818. if isPlayRecord then
  819. self.battleReplayPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  820. self.battleReplayPart:Show(ManagerContainer.LuaBattleMgr:GetCurrentLevelData().Name)
  821. self.battleRootNew:SetActive(false)
  822. end
  823. self.dragBg:SetActive(false)
  824. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIBattleReward)
  825. self:DisposeNewLevelIncrease()
  826. ManagerContainer.LuaGameMgr:SetGameSpeed(ManagerContainer.LuaGameMgr.GameSpeed)
  827. end
  828. function UIBattleView:CloseInputMask()
  829. ManagerContainer.LuaUIMgr:CloseInputMask()
  830. end
  831. function UIBattleView:BossBattleEnd(isPlayRecord)
  832. self.dragBg:SetActive(true)
  833. bBossStage = false
  834. bBoxState = false
  835. self:RefreshRedEnvelope()
  836. self:PlayChallengeBtnNormalAnim()
  837. if isPlayRecord then
  838. self.battleReplayPart:Hide()
  839. self.battleRootNew:SetActive(true)
  840. end
  841. self.btnAuto:SetActive(false)
  842. end
  843. function UIBattleView:SetBossBattleInfo()
  844. self.centerNode:SetActive(false)
  845. self.MapRootGo:SetActive(false)
  846. self.btnwarlog:SetActive(false)
  847. self.btnStatistics:SetActive(false)
  848. self:RefreshRedEnvelope()
  849. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BOSS_BATTLE_STATUS,true)
  850. end
  851. local remainTime = 2
  852. function UIBattleView:RefreshRedEnvelope()
  853. if not Constant.OpenPay then
  854. self.btnRedEnvelope:SetActive(false)
  855. self.windowEnvelope:SetActive(false)
  856. return
  857. end
  858. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  859. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  860. local reActItem = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(Enum.ActivityType.ACTIVITY_TYPE_CASH_SHOP)
  861. local state = reActItem and reActItem:IsUnlocked() and reActItem:IsOpened() and not reActItem:IsOutofDate()
  862. self.btnRedEnvelope:SetActive(state)
  863. self.windowEnvelope:SetActive(false)
  864. if state then
  865. if bBossStage then
  866. self:OnShowWindowsEnvelope()
  867. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnBattleREClick)
  868. else
  869. self:OnHideWindowsEnvelope()
  870. self:OnRedEnvelopeRemainTimeRefresh()
  871. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnNormalREClick)
  872. end
  873. else
  874. if self.btnRedEnvelope.activeSelf then
  875. self.btnRedEnvelope:SetActive(false)
  876. end
  877. if self.windowEnvelope.activeSelf then
  878. self.windowEnvelope:SetActive(false)
  879. end
  880. end
  881. end
  882. function UIBattleView:OnHideWindowsEnvelope()
  883. self.windowEnvelope.transform:DOMove(self.btnRedEnvelope.transform.position, 0.3):SetEase(DG.Tweening.Ease.InQuint)
  884. self.windowEnvelope.transform:DOScale(0, 0.3):SetEase(DG.Tweening.Ease.InQuint):OnComplete(function()
  885. self.windowEnvelope:SetActive(false)
  886. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  887. self.btnRedEnvelope:SetActive(true)
  888. end)
  889. end
  890. function UIBattleView:OnShowWindowsEnvelope()
  891. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  892. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  893. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  894. if levelCfgData.Cash == 0 then
  895. self.btnRedEnvelope:SetActive(false)
  896. self.windowEnvelope:SetActive(false)
  897. return
  898. end
  899. self.windowEnvelope.transform.localScale = Vector3.zero
  900. self.windowEnvelope.cashNumber.text.text = levelCfgData.Cash
  901. self.windowEnvelope.textRank.uILocalizeScript:SetContentAndValues("CashReward01", {levelCfgData.PassNum})
  902. self.btnRedEnvelope:SetActive(false)
  903. self.windowEnvelope:SetActive(true)
  904. self.windowEnvelope.transform.position = self.btnRedEnvelope.transform.position
  905. self.windowEnvelope.transform:DOMove(windowREPos, 0.3):SetEase(DG.Tweening.Ease.OutQuint)
  906. self.windowEnvelope.transform:DOScale(1, 0.3):SetEase(DG.Tweening.Ease.OutBounce):OnComplete(function()
  907. remainTime = 2
  908. self.windowEnvelope.text.text.text = string.formatbykey("CashReward03", remainTime)
  909. self.windowEnvelope.transform:DOScale(1, 1):SetLoops(2):OnStepComplete(function ()
  910. remainTime = remainTime - 1
  911. self.windowEnvelope.text.text.text = string.formatbykey("CashReward03", remainTime)
  912. if remainTime == 0 then
  913. self.windowEnvelope.transform:DOMove(self.btnRedEnvelope.transform.position, 0.3):SetEase(DG.Tweening.Ease.InQuint)
  914. self.windowEnvelope.transform:DOScale(0, 0.3):SetEase(DG.Tweening.Ease.InQuint):OnComplete(function()
  915. self.windowEnvelope:SetActive(false)
  916. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  917. self.btnRedEnvelope:SetActive(true)
  918. end)
  919. end
  920. end)
  921. end)
  922. end
  923. function UIBattleView:OnRedEnvelopeRemainTimeRefresh()
  924. if not Constant.OpenPay then
  925. self.btnRedEnvelope:SetActive(false)
  926. self.windowEnvelope:SetActive(false)
  927. return
  928. end
  929. local reActItem = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(Enum.ActivityType.ACTIVITY_TYPE_CASH_SHOP)
  930. local state = reActItem and reActItem:IsUnlocked() and reActItem:IsOpened() and not reActItem:IsOutofDate()
  931. self.btnRedEnvelope:SetActive(state)
  932. if not state then
  933. self.windowEnvelope:SetActive(false)
  934. return
  935. end
  936. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  937. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  938. if levelCfgData.Cash == 0 and bBossStage then
  939. if self.btnRedEnvelope.activeSelf then
  940. self.btnRedEnvelope:SetActive(false)
  941. end
  942. if self.windowEnvelope.activeSelf then
  943. self.windowEnvelope:SetActive(false)
  944. end
  945. return
  946. end
  947. local leftSeconds = reActItem:LeftTime()
  948. if leftSeconds > 0 then
  949. if leftSeconds <= 60 then
  950. self.btnRedEnvelope.text.text.text = I18N.T("LessOneMinu")
  951. else
  952. local time = DateTimeUtil.convertSeconds2TimeStr1(leftSeconds, true, false)
  953. self.btnRedEnvelope.text.text.text = time
  954. end
  955. else
  956. if self.btnRedEnvelope.activeSelf then
  957. self.btnRedEnvelope:SetActive(false)
  958. end
  959. if self.windowEnvelope.activeSelf then
  960. self.windowEnvelope:SetActive(false)
  961. end
  962. end
  963. end
  964. function UIBattleView:OnBattleREClick()
  965. self:OnShowWindowsEnvelope()
  966. end
  967. function UIBattleView:OnNormalREClick()
  968. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIREShop, nil, self.uiData.id)
  969. end
  970. function UIBattleView:ShowBattleNormalUI()
  971. if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIBattle) then
  972. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BOSS_BATTLE_STATUS,false)
  973. end
  974. self.transform:DOScale(1, 0.8):OnComplete(function ()
  975. self:ShowBattleNormalUI1()
  976. end)
  977. end
  978. function UIBattleView:ShowBattleNormalUI1()
  979. --self.bottomNode:SetActive(true)
  980. self.centerNode:SetActive(true)
  981. --self.ProfitBoxGo:SetActive(true)
  982. if not ManagerContainer.LuaBattleMgr:GetBossFightState() then
  983. self.MapRootGo:SetActive(true)
  984. end
  985. self.btnwarlog:SetActive(true)
  986. self.btnStatistics:SetActive(true)
  987. -- self:OnValueChangedToggle(nil,1, true)
  988. end
  989. function UIBattleView:OnContinueBattle()
  990. bBoxState = false
  991. self.battleFailGo:SetActive(false);
  992. self:PlayRewardNormalAnim();
  993. end
  994. function UIBattleView:OnBattleWin()
  995. self:RestoreSpeed()
  996. self.BossBloodPart:Hide()
  997. self.HeadsBoxPart:Hide()
  998. self.StatisticsPart:Hide()
  999. self.rageBoxGo:SetActive(false)
  1000. end
  1001. function UIBattleView:OnBattleFailed(killboss,isPlayRecord)
  1002. self:RestoreSpeed()
  1003. -- self.battleFailGo:SetActive(true);
  1004. self.BossBloodPart:Hide()
  1005. self.HeadsBoxPart:Hide()
  1006. self.StatisticsPart:Hide()
  1007. self.rageBoxGo:SetActive(false)
  1008. self:PlayChallengeBtnNormalAnim()
  1009. self:PlayRewardNormalAnim()
  1010. if killboss and (not isPlayRecord) then
  1011. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIClimbingTowerBattleFailed,Enum.UIPageName.UIBattle)
  1012. else
  1013. self.battleFailGo:SetActive(true)
  1014. end
  1015. --self:ShowBattleNormalUI()
  1016. end
  1017. function UIBattleView:OnForceBattleFailed(killboss,isPlayRecord)
  1018. self:RestoreSpeed()
  1019. -- self.battleFailGo:SetActive(true);
  1020. self.BossBloodPart:Hide()
  1021. self.HeadsBoxPart:Hide()
  1022. self.StatisticsPart:Hide()
  1023. self.rageBoxGo:SetActive(false)
  1024. self:PlayChallengeBtnNormalAnim()
  1025. self:PlayRewardNormalAnim()
  1026. if killboss and (not isPlayRecord) then
  1027. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIClimbingTowerBattleFailed,Enum.UIPageName.UIBattle)
  1028. end
  1029. self.battleFailGo:SetActive(false)
  1030. end
  1031. function UIBattleView:RestoreSpeed()
  1032. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  1033. end
  1034. function UIBattleView:FuncOpen()
  1035. self:PlayChallengeBtnNormalAnim()
  1036. self:PlayRewardNormalAnim();
  1037. self:OnRefreshEarnings();
  1038. --if ManagerContainer.LuaUIMgr.CurrentPage.PageId == self.uiData.id then
  1039. self:FuncOpen1()
  1040. --end
  1041. end
  1042. function UIBattleView:FuncOpen1()
  1043. if ManagerContainer.LuaBattleMgr:IsShowDifficultyTxt() then
  1044. return
  1045. end
  1046. local levelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  1047. local newFuncs, nearFuncs, forceGuideList = ManagerContainer.UIFuncUnlockMgr:GetNewFuncAndNearFuncByLevelId(levelId)
  1048. if newFuncs[1] == nil then
  1049. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  1050. return
  1051. end
  1052. local newFunc = newFuncs[1]
  1053. self.newFuncs = newFuncs
  1054. if #forceGuideList > 0 then
  1055. self.controller:SetNewForceId(forceGuideList[1])
  1056. end
  1057. local newFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(newFunc)
  1058. CommonUtil.LoadIcon(self, newFuncData.FunIcon, function (sprite)
  1059. self.newOpen.image.image.sprite = sprite
  1060. self.newOpen.imageLt.image.sprite = sprite
  1061. end)
  1062. self.newOpen.nameTxt.text.text = I18N.T(newFuncData.FunName)
  1063. self.newOpen.dscTxt.text.text = I18N.T(newFuncData.FunDsc)
  1064. local item = self.newOpen.item
  1065. item:SetActive(nearFuncs[1] ~= nil)
  1066. if nearFuncs[1] ~= nil then
  1067. local nearData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(nearFuncs[1])
  1068. CommonUtil.LoadIcon(self, nearData.FunIcon, function (sprite)
  1069. item.image.image.sprite = sprite
  1070. end)
  1071. local result,val,content = ManagerContainer.UIFuncUnlockMgr:CheckConditionPassResult(nearData)
  1072. --content = content and content or ""
  1073. item.itemTxt.text.text = I18N.T(nearData.FunName).."("..content..")"
  1074. end
  1075. self.newOpen:SetActive(true)
  1076. end
  1077. function UIBattleView:OnTaskClick()
  1078. ManagerContainer.DataMgr.TaskDataNew:OpenTaskPanel();
  1079. end
  1080. function UIBattleView:OnCloseNewOpen()
  1081. self.newOpen:SetActive(false)
  1082. if self.newFuncs then
  1083. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_UNLOCK_NTF, self.newFuncs)
  1084. self.newFuncs = nil
  1085. end
  1086. local newForceId = self.controller:GetNewForceId()
  1087. if newForceId then
  1088. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_TRIGGER, Enum.ForceGuideTriggerEnum.FuncOpen, newForceId)
  1089. self.controller:SetNewForceId()
  1090. else
  1091. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  1092. end
  1093. end
  1094. function UIBattleView:OnBattleNewWave(levelName)
  1095. self.battleFailGo:SetActive(false);
  1096. self:OnRefreshEarnings();
  1097. end
  1098. function UIBattleView:OnHideLevelName()
  1099. end
  1100. function UIBattleView:OnShowBossRage()
  1101. self.rageBoxGo:SetActive(true)
  1102. end
  1103. function UIBattleView:OnShowBossRageLeftTime(leftTime)
  1104. self:RefreshRageTime(leftTime)
  1105. end
  1106. function UIBattleView:OnBossInRage()
  1107. self.rageBoxGo:SetActive(false)
  1108. end
  1109. function UIBattleView:PlayChallengeBtnNormalAnim()
  1110. if self.btnBossAnimator~= nil then
  1111. self.challengeAnimName = bossFightCDRemainTime <= 0 and "BtnBoss1" or "BtnBoss4"
  1112. if self.btnBossAnimator.activeInHierarchy then
  1113. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  1114. end
  1115. if bossFightCDRemainTime > 0 then
  1116. self.btnChallenge.remainCDTime.text.text = I18N.SetLanguageValue("FightCD", math.ceil(bossFightCDRemainTime))
  1117. end
  1118. end
  1119. --self.ReceiveGo:SetActive(true);
  1120. self.quickBattleBtn.button.interactable = true
  1121. end
  1122. function UIBattleView:PlayRewardNormalAnim()
  1123. self:OnRefreshRewardTime();
  1124. end
  1125. function UIBattleView:RefreshRageTime(leftTime)
  1126. if leftTime ~= nil then
  1127. local spriteName = nil
  1128. if leftTime == 10 then
  1129. spriteName = "Alert_number_0"
  1130. else
  1131. spriteName = "Alert_number_"..leftTime
  1132. end
  1133. self.rageNum1.image.sprite = self.rageNum1.switchSprite:GetSprite(spriteName)
  1134. self.rageNum2.image.sprite = self.rageNum2.switchSprite:GetSprite(spriteName)
  1135. if leftTime == 1 then
  1136. self.rageBoxGo.bg.animator:Play("BafengteAlertEnd")
  1137. end
  1138. end
  1139. end
  1140. function UIBattleView:OnShowBossWarning(vis)
  1141. self.bossWarning.animator.gameObject:SetActive(vis)
  1142. end
  1143. function UIBattleView:OnRefreshEarnings()
  1144. self.ExpLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelExp() .. "/" .. I18N.T("m") ;
  1145. self.ZenyLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelZeny() .. "/" .. I18N.T("m");
  1146. self.ParnterExpLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelParnterExp() .. "/" .. I18N.T("m");
  1147. self.CruiseLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelCruise() .. "/" .. I18N.T("m");
  1148. self.CurLevelName.text.text = ManagerContainer.LuaBattleMgr:CurLevelName();
  1149. ManagerContainer.LuaBattleMgr:SetRewardDropPos(self.RewardBoxBtnPos);
  1150. local lockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(35)
  1151. ManagerContainer.LuaUIMgr:SetBattleDropRootVisible(lockState)
  1152. end
  1153. function UIBattleView:OnRefreshRewardTime()
  1154. local passedTime = ManagerContainer.LuaBattleMgr:AccumIncomeTime();
  1155. local maxTime = ManagerContainer.LuaBattleMgr:MaxInComeTime() * 1000
  1156. if passedTime >= maxTime then
  1157. passedTime = maxTime
  1158. end
  1159. local leftTime,num = ManagerContainer.LuaBattleMgr:GetIncomeInfo()
  1160. if num == nil then
  1161. num = 0
  1162. end
  1163. self.rewardPoint:SetActive(num >= 1)
  1164. if num > 999 then
  1165. self.rewardPoint.num.text.text = "999+"
  1166. else
  1167. self.rewardPoint.num.text.text = tostring(num)
  1168. end
  1169. if passedTime >= maxTime then
  1170. self.RewardTimeLbl.text.text = "Max";
  1171. else
  1172. self.RewardTimeLbl.text.text = DateTimeUtil.convertSeconds2TimeStr(leftTime,true);
  1173. end
  1174. self:CheckRewardBoxStatus(passedTime)
  1175. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_HANG_TIME,passedTime);
  1176. end
  1177. function UIBattleView:CheckRewardBoxStatus(passedTime)
  1178. local animName = "Chest01New"
  1179. if bBoxState then
  1180. animName = "ChestClose"
  1181. else
  1182. if passedTime <= self.statTime1 then
  1183. animName = "Chest01New"
  1184. elseif passedTime <= self.statTime2 then
  1185. animName = "Chest02New"
  1186. elseif passedTime <= self.statTime3 then
  1187. animName = "Chest03New"
  1188. else
  1189. animName = "Chest04New"
  1190. end
  1191. end
  1192. if self.RewardBoxBtn.activeInHierarchy then
  1193. self.RewardBoxBtn.animator:Play(animName);
  1194. end
  1195. end
  1196. function UIBattleView:OnBattleIncomeAck(dropLoc)
  1197. local zeny = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.Coin)
  1198. local partnerExp = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.ParterExp)
  1199. local exp = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.RoleBaseExp)
  1200. local createZeny = false;
  1201. local createExp=false;
  1202. local createPartnerExp = false;
  1203. if UIMainCtr == nil then
  1204. UIMainCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIMain)
  1205. end
  1206. local zenyPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.Coin)
  1207. local expPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.RoleBaseExp)
  1208. local bagPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.ParterExp)
  1209. if zeny ~= nil and zeny > 0 then
  1210. createZeny = true
  1211. end
  1212. if partnerExp~= nil and partnerExp > 0 then
  1213. createPartnerExp = true
  1214. end
  1215. if exp ~= nil and exp > 0 then
  1216. createExp = true
  1217. end
  1218. local itemIcons = {};
  1219. for i =1, #ManagerContainer.LuaBattleMgr.rewardItemList do
  1220. local item = ManagerContainer.LuaBattleMgr.rewardItemList[i];
  1221. if item.key >= 100 then
  1222. local itemCfg = ManagerContainer.CfgMgr:GetItemById(item.key)
  1223. if itemCfg~= nil then
  1224. itemIcons[#itemIcons+1] = itemCfg.Icon
  1225. end
  1226. end
  1227. end
  1228. self.dropType = dropLoc;
  1229. if dropLoc == 0 then
  1230. LuaBattleBridge.GenerateDropItems(self.RewardBoxBtnPos,createZeny,zenyPos,createExp,expPos,createPartnerExp,bagPos,false,Vector3.zero,0.15,0.25,unpack(itemIcons));
  1231. else
  1232. LuaBattleBridge.GenerateDropItems(Vector3.New(0, 0, 0),createZeny,zenyPos,createExp,expPos,createPartnerExp,bagPos,false,Vector3.zero,0.30,0.25,unpack(itemIcons));
  1233. end
  1234. if self.openRewardTimer ~= nil then
  1235. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer)
  1236. self.openRewardTimer = nil
  1237. end
  1238. self.openRewardTimer = ManagerContainer.LuaTimerMgr:AddTimer(GlobalConfig.Instance:GetConfigFloatValue(78)*1000, 1, self, self.OnOpenRewardPage, nil)
  1239. end
  1240. function UIBattleView:OnOpenRewardPage()
  1241. self.openRewardTimer = nil
  1242. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleReward,self.dropType)
  1243. end
  1244. function UIBattleView:LoadMinimap()
  1245. local mapId = ManagerContainer.LuaBattleMgr:GetCurMapId()
  1246. local mapCfgData = ManagerContainer.CfgMgr:GetMapData(mapId)
  1247. local center = mapCfgData.Center
  1248. self.mapCenter = Vector3.New(center[1], center[2], center[3])
  1249. self.mapSizeX = mapCfgData.RealSizeX
  1250. self.mapSizeZ = mapCfgData.RealSizeZ
  1251. local scale = mapCfgData.MinimapScale *0.01
  1252. self.minimap.transform.localScale = Vector3.New(scale, scale, scale)
  1253. self.minimapSizeX = mapCfgData.MinimapSizeX * scale
  1254. self.minimapSizeZ = mapCfgData.MinimapSizeZ * scale
  1255. CommonUtil.LoadTexture(self, mapCfgData.MinimapIcon, function (texture)
  1256. self.minimap.rawImage.texture = texture
  1257. self:RefreshMinimapInfo()
  1258. end)
  1259. end
  1260. function UIBattleView:WorldPos2MinimapPos(pos)
  1261. local xRate = pos.x / self.mapSizeX
  1262. local zRate = pos.z / self.mapSizeZ
  1263. local x = self.minimapSizeX * xRate
  1264. local z = self.minimapSizeZ * zRate
  1265. return x,z
  1266. end
  1267. function UIBattleView:OnRefreshMinimap()
  1268. self:RefreshMinimapInfo()
  1269. end
  1270. function UIBattleView:RefreshMinimapInfo()
  1271. if self.miniMapGoes == nil then
  1272. return
  1273. end
  1274. if ManagerContainer.LuaBattleMgr.isBattleing then
  1275. return
  1276. end
  1277. LuaBattleBridge.RefreshMinimap(self.mapCenter, self.mapSizeX,self.mapSizeZ,self.minimapSizeX,self.minimapSizeZ, self.hero,unpack(self.miniMapGoes))
  1278. end
  1279. function UIBattleView:InitCruise()
  1280. end
  1281. function UIBattleView:RefreshCruise()
  1282. end
  1283. function UIBattleView:OnClickCruiseBtn()
  1284. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UITreasures)
  1285. end
  1286. function UIBattleView:OnClickMailBtn()
  1287. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIMailBox)
  1288. end
  1289. function UIBattleView:GeAnchoredPosition3DByType(type)
  1290. if type ~= Enum.ItemType.RoleJobExp and type ~= Enum.ItemType.RoleBaseExp then
  1291. return self.ReceiveGo.transform.position
  1292. end
  1293. return Vector3.zero
  1294. end
  1295. function UIBattleView:GetMiniMapPosition()
  1296. return self.minimap.transform.parent.position
  1297. end
  1298. function UIBattleView:RewardBoxRefresh()
  1299. bBoxState = false
  1300. self:PlayRewardNormalAnim();
  1301. end
  1302. function UIBattleView:GetBattleState()
  1303. return bBossStage
  1304. end
  1305. function UIBattleView:PopGotAnimEnd(type)
  1306. if type == Enum.ItemIEnterType.BattleWin then
  1307. self:PlayChallengeBtnNormalAnim()
  1308. end
  1309. end
  1310. function UIBattleView:NewLevelIncrease()
  1311. if levelIncreaseTimer ~= nil then
  1312. ManagerContainer.LuaTimerMgr:RemoveTimer(levelIncreaseTimer)
  1313. levelIncreaseTimer = nil
  1314. end
  1315. if bBossStage then return end
  1316. local count = 0
  1317. local list = {}
  1318. local lastLevelZeny = ManagerContainer.LuaBattleMgr.lastLevelZeny
  1319. local curLevelZeny = ManagerContainer.LuaBattleMgr:CurLevelZeny()
  1320. if lastLevelZeny < curLevelZeny then
  1321. count = count + 1
  1322. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelZeny, newNum = curLevelZeny}
  1323. list[#list + 1] = data
  1324. end
  1325. local lastLevelExp = ManagerContainer.LuaBattleMgr.lastLevelExp
  1326. local curLevelExp = ManagerContainer.LuaBattleMgr:CurLevelExp()
  1327. if lastLevelExp < curLevelExp then
  1328. count = count + 1
  1329. local data = {iconPath = Enum.LevelIncreaseType.BaseExp, lastNum = lastLevelExp, newNum = curLevelExp}
  1330. list[#list + 1] = data
  1331. end
  1332. local lastLevelPartnerExp = ManagerContainer.LuaBattleMgr.lastLevelPartnerExp
  1333. local curLevelPartnerExp = ManagerContainer.LuaBattleMgr:CurLevelParnterExp()
  1334. if lastLevelPartnerExp < curLevelPartnerExp then
  1335. count = count + 1
  1336. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelPartnerExp, newNum = curLevelPartnerExp}
  1337. list[#list + 1] = data
  1338. end
  1339. local lastLevelCruise = ManagerContainer.LuaBattleMgr.lastLevelCruise
  1340. local curLevelCruise = ManagerContainer.LuaBattleMgr:CurLevelCruise()
  1341. if lastLevelCruise < curLevelCruise then
  1342. count = count + 1
  1343. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelCruise, newNum = curLevelCruise}
  1344. list[#list + 1] = data
  1345. end
  1346. if #list > 0 then
  1347. increaseIdx = 0
  1348. self:ShowLevelIncrease(0, list)
  1349. if #list > 1 then
  1350. levelIncreaseTimer = ManagerContainer.LuaTimerMgr:AddTimer(500, #list - 1, self, self.ShowLevelIncrease, list)
  1351. end
  1352. end
  1353. end
  1354. function UIBattleView:ShowLevelIncrease(idx, list)
  1355. increaseIdx = increaseIdx + 1
  1356. local data = list[increaseIdx]
  1357. ManagerContainer.GoPoolMgr:SpawnGo(Enum.PrefabNames.LevelIncreaseItem, function(itemlua)
  1358. CommonUtil.BatchCreateItems(self, itemlua, self.centerNode.transform, data)
  1359. end)
  1360. end
  1361. function UIBattleView:DisposeNewLevelIncrease()
  1362. if levelIncreaseTimer ~= nil then
  1363. ManagerContainer.LuaTimerMgr:RemoveTimer(levelIncreaseTimer)
  1364. levelIncreaseTimer = nil
  1365. end
  1366. CommonUtil.RecycleFromBatchItemsByPrefabName(self, Enum.PrefabNames.LevelIncreaseItem)
  1367. end
  1368. function UIBattleView:IsSomeFrameCount(keyName)
  1369. local value = self[keyName]
  1370. if value and value >= Time.frameCount then
  1371. return true
  1372. end
  1373. self[keyName] = Time.frameCount
  1374. return false
  1375. end
  1376. function UIBattleView:OnClickBattleRecordBtn()
  1377. ManagerContainer.LuaBattleMgr:SendBattleRecordReq()
  1378. end
  1379. function UIBattleView:OnClickBattleStatisticsBtn()
  1380. if LuaBattleBridge.HasStatistics(BattleMode.Normal,BattleSubMode.None) then
  1381. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleStatistics,{BattleMode.Normal,BattleSubMode.None})
  1382. else
  1383. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("NullBattleInformation1")
  1384. end
  1385. end
  1386. function UIBattleView:OnClickAutoChallenge()
  1387. if not ManagerContainer.DataMgr.RuneShopDataMgr:GetRoPassAutoBattle() then
  1388. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("nomonthcard")
  1389. ManagerContainer.LuaBattleMgr:StopAutoChallenge()
  1390. return
  1391. end
  1392. if ManagerContainer.LuaBattleMgr:GetAutoChallengeState() then
  1393. self.autoAnim.animator:Play("AutoKeep")
  1394. ManagerContainer.LuaBattleMgr:StopAutoChallenge()
  1395. else
  1396. self.autoAnim.animator:Play("AutoIn")
  1397. ManagerContainer.LuaBattleMgr:SetAutoChallengeState(true)
  1398. end
  1399. end
  1400. function UIBattleView:FindTaskCompeleted1(id, owner, ownerCB)
  1401. local page = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIPOPGot)
  1402. if page then
  1403. local pop = page.MLuaTable
  1404. pop:UIClose()
  1405. end
  1406. local target = self.btnChallenge
  1407. if target == nil then
  1408. if owner and ownerCB then
  1409. ownerCB(owner)
  1410. end
  1411. return
  1412. end
  1413. if owner and ownerCB then
  1414. ownerCB(owner, target)
  1415. end
  1416. end
  1417. return UIBattleView