UIBattleView.lua 54 KB

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