UIBattleView.lua 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704
  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. local dif_s_lid = ManagerContainer.LuaBattleMgr:GetCurDiff_S_LvID()
  706. local IsDiff_s_Limit = ManagerContainer.LuaBattleMgr:GetBattleMode() == 2 and dif_s_lid >= GlobalConfig.Instance:GetConfigIntValue(366)
  707. if(ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId() >= Levelmaxlvid) or IsDiff_s_Limit then
  708. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("289")
  709. return
  710. end
  711. if bBossStage then
  712. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("Fighting1")
  713. return;
  714. end
  715. if bossFightCDRemainTime > 0 then
  716. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam("FightCD", math.ceil(bossFightCDRemainTime))
  717. return;
  718. end
  719. --======删除 等级限制==============================================
  720. local roleLv = ManagerContainer.DataMgr.UserData:GetRoleLv()
  721. local challengeLv = LuaBattleBridge.GetCurLevelChallengeLv()
  722. if roleLv < challengeLv then
  723. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.SetLanguageValue("LevelLimit", challengeLv))
  724. return
  725. end
  726. local jobLv = ManagerContainer.DataMgr.UserData:GetJobLv()
  727. local maxJobLv = ManagerContainer.DataMgr.UserData:GetJobMaxLevel()
  728. local jobStage = ManagerContainer.DataMgr.UserData:GetJobStage()
  729. if jobStage<3 and jobLv>= maxJobLv then
  730. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.T("JobLimit"))
  731. return
  732. end
  733. --======删除 等级限制==============================================
  734. --self.challengeAnimName = "BtnBoss2"
  735. --
  736. --if self.btnBossAnimator.activeInHierarchy then
  737. -- self.btnBossAnimator.animator:Play(self.challengeAnimName);
  738. --end
  739. local battleLoadingState,text = ManagerContainer.LuaBattleMgr:GetBattleLoadingState()
  740. if battleLoadingState then
  741. self.battleLoadingState = battleLoadingState
  742. self.btnChallenge.battleState.text.text = I18N.T(text)
  743. return
  744. end
  745. self:StartBattleBoss()
  746. end
  747. function UIBattleView:StartBattleBoss()
  748. local levelCfgId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  749. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(levelCfgId)
  750. if levelCfgData and levelCfgData.BossKey ~= "" then
  751. ManagerContainer.DataMgr.ChatData:AddLocalNewSystemData(levelCfgData.BossKey)
  752. end
  753. ManagerContainer.LuaBattleMgr:SendChallengeBossReq()
  754. end
  755. function UIBattleView:OnChallengeBossAck(factorList)
  756. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  757. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  758. bossFightCDRemainTime = levelCfgData.FightCD
  759. ManagerContainer.LuaUIMgr:OpenInputMask(9500)
  760. bBossStage = true
  761. bBoxState = true
  762. local battleFactors = System.Array.CreateInstance(Enum.TypeInfo.ValType, #factorList)
  763. for i = 1, #factorList do
  764. local factor = ValType.New(factorList[i].key,factorList[i].value)
  765. battleFactors[i-1] = factor
  766. end
  767. local teams = ManagerContainer.DataMgr.UserData:GetTeamData(true)
  768. for i = 1 , #teams do
  769. local actor = ManagerContainer.LuaActorDataMgr:GetActorsById(teams[i].uid,teams[i].id)
  770. --增加对应压制mark
  771. ManagerContainer.DataMgr.UserData:SetActorPveMark(teams[i].uid,actor)
  772. end
  773. LuaBattleBridge.ClickChallegeBoss(battleFactors);
  774. self.btnAuto:SetActive(Constant.OpenPay or false)
  775. local autoCState = ManagerContainer.LuaBattleMgr:GetAutoChallengeState()
  776. if autoCState then
  777. self.autoAnim.animator:Play("AutoIn")
  778. else
  779. self.autoAnim.animator:Play("AutoKeep")
  780. end
  781. end
  782. function UIBattleView:OnRefreshBossChallengeTime(time)
  783. bossFightCDRemainTime = time
  784. end
  785. function UIBattleView:BattleLoadingCompeleted()
  786. self.btnChallenge.battleState.text.text = I18N.T("BtnChallengeBOSS")
  787. if self.battleLoadingState then
  788. self.battleLoadingState = nil
  789. --self:StartBattleBoss()
  790. end
  791. end
  792. function UIBattleView:OnClickMiniMap()
  793. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBigMap, {id = ManagerContainer.LuaBattleMgr:GetCurMapId()})
  794. end
  795. function UIBattleView:OnBossDead()
  796. self.rageBoxGo:SetActive(false)
  797. end
  798. function UIBattleView:OnBossSpawned(bossActor,bossName,life,maxLife,skillParam,isPlayRecord)
  799. if bossMaskTimer ~= nil then
  800. ManagerContainer.LuaTimerMgr:RemoveTimer(bossMaskTimer)
  801. bossMaskTimer = nil
  802. end
  803. bossMaskTimer = ManagerContainer.LuaTimerMgr:AddTimer(1500, 1, self, self.CloseInputMask, nil)
  804. self.exploringTrans:SetActive(false);
  805. if self.btnBossAnimator ~= nil then
  806. self.challengeAnimName = "BtnBoss3"
  807. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  808. end
  809. self.quickBattleBtn.button.interactable = false
  810. if self.openRewardTimer~=nil then
  811. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer)
  812. self.openRewardTimer = nil;
  813. end
  814. self:OnHideLevelName()
  815. self:SetBossBattleInfo()
  816. self.StatisticsPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  817. self.BossBloodPart:Show(bossActor,bossName,life,maxLife,skillParam)
  818. self.HeadsBoxPart:Show()
  819. self.StatisticsPart:Show(BattleMode.Normal,BattleSubMode.None)
  820. if isPlayRecord then
  821. self.battleReplayPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  822. local name = ManagerContainer.CfgMgr:GetCurLevelName()--ManagerContainer.LuaBattleMgr:GetCurrentLevelData().Name--GetLeveNameById
  823. self.battleReplayPart:Show(name)
  824. self.battleRootNew:SetActive(false)
  825. end
  826. self.dragBg:SetActive(false)
  827. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIBattleReward)
  828. self:DisposeNewLevelIncrease()
  829. ManagerContainer.LuaGameMgr:SetGameSpeed(ManagerContainer.LuaGameMgr.GameSpeed)
  830. end
  831. function UIBattleView:CloseInputMask()
  832. ManagerContainer.LuaUIMgr:CloseInputMask()
  833. end
  834. function UIBattleView:BossBattleEnd(isPlayRecord)
  835. self.dragBg:SetActive(true)
  836. bBossStage = false
  837. bBoxState = false
  838. self:RefreshRedEnvelope()
  839. self:PlayChallengeBtnNormalAnim()
  840. if isPlayRecord then
  841. self.battleReplayPart:Hide()
  842. self.battleRootNew:SetActive(true)
  843. end
  844. self.btnAuto:SetActive(false)
  845. end
  846. function UIBattleView:SetBossBattleInfo()
  847. self.centerNode:SetActive(false)
  848. self.MapRootGo:SetActive(false)
  849. self.btnwarlog:SetActive(false)
  850. self.btnStatistics:SetActive(false)
  851. self:RefreshRedEnvelope()
  852. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BOSS_BATTLE_STATUS,true)
  853. end
  854. local remainTime = 2
  855. function UIBattleView:RefreshRedEnvelope()
  856. if not Constant.OpenPay then
  857. self.btnRedEnvelope:SetActive(false)
  858. self.windowEnvelope:SetActive(false)
  859. return
  860. end
  861. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  862. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  863. local reActItem = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(Enum.ActivityType.ACTIVITY_TYPE_CASH_SHOP)
  864. local state = reActItem and reActItem:IsUnlocked() and reActItem:IsOpened() and not reActItem:IsOutofDate()
  865. self.btnRedEnvelope:SetActive(state)
  866. self.windowEnvelope:SetActive(false)
  867. if state then
  868. if bBossStage then
  869. self:OnShowWindowsEnvelope()
  870. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnBattleREClick)
  871. else
  872. self:OnHideWindowsEnvelope()
  873. self:OnRedEnvelopeRemainTimeRefresh()
  874. self.uiBase:AddButtonUniqueEventListener(self.btnRedEnvelope.button, self, self.OnNormalREClick)
  875. end
  876. else
  877. if self.btnRedEnvelope.activeSelf then
  878. self.btnRedEnvelope:SetActive(false)
  879. end
  880. if self.windowEnvelope.activeSelf then
  881. self.windowEnvelope:SetActive(false)
  882. end
  883. end
  884. end
  885. function UIBattleView:OnHideWindowsEnvelope()
  886. self.windowEnvelope.transform:DOMove(self.btnRedEnvelope.transform.position, 0.3):SetEase(DG.Tweening.Ease.InQuint)
  887. self.windowEnvelope.transform:DOScale(0, 0.3):SetEase(DG.Tweening.Ease.InQuint):OnComplete(function()
  888. self.windowEnvelope:SetActive(false)
  889. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  890. self.btnRedEnvelope:SetActive(true)
  891. end)
  892. end
  893. function UIBattleView:OnShowWindowsEnvelope()
  894. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  895. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  896. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  897. if levelCfgData.Cash == 0 then
  898. self.btnRedEnvelope:SetActive(false)
  899. self.windowEnvelope:SetActive(false)
  900. return
  901. end
  902. self.windowEnvelope.transform.localScale = Vector3.zero
  903. self.windowEnvelope.cashNumber.text.text = levelCfgData.Cash
  904. self.windowEnvelope.textRank.uILocalizeScript:SetContentAndValues("CashReward01", {levelCfgData.PassNum})
  905. self.btnRedEnvelope:SetActive(false)
  906. self.windowEnvelope:SetActive(true)
  907. self.windowEnvelope.transform.position = self.btnRedEnvelope.transform.position
  908. self.windowEnvelope.transform:DOMove(windowREPos, 0.3):SetEase(DG.Tweening.Ease.OutQuint)
  909. self.windowEnvelope.transform:DOScale(1, 0.3):SetEase(DG.Tweening.Ease.OutBounce):OnComplete(function()
  910. remainTime = 2
  911. self.windowEnvelope.text.text.text = string.formatbykey("CashReward03", remainTime)
  912. self.windowEnvelope.transform:DOScale(1, 1):SetLoops(2):OnStepComplete(function ()
  913. remainTime = remainTime - 1
  914. self.windowEnvelope.text.text.text = string.formatbykey("CashReward03", remainTime)
  915. if remainTime == 0 then
  916. self.windowEnvelope.transform:DOMove(self.btnRedEnvelope.transform.position, 0.3):SetEase(DG.Tweening.Ease.InQuint)
  917. self.windowEnvelope.transform:DOScale(0, 0.3):SetEase(DG.Tweening.Ease.InQuint):OnComplete(function()
  918. self.windowEnvelope:SetActive(false)
  919. DG.Tweening.DOTween.Kill(self.windowEnvelope.transform)
  920. self.btnRedEnvelope:SetActive(true)
  921. end)
  922. end
  923. end)
  924. end)
  925. end
  926. function UIBattleView:OnRedEnvelopeRemainTimeRefresh()
  927. if not Constant.OpenPay then
  928. self.btnRedEnvelope:SetActive(false)
  929. self.windowEnvelope:SetActive(false)
  930. return
  931. end
  932. local reActItem = ManagerContainer.DataMgr.ActsDataMgr:GetActivityItemById(Enum.ActivityType.ACTIVITY_TYPE_CASH_SHOP)
  933. local state = reActItem and reActItem:IsUnlocked() and reActItem:IsOpened() and not reActItem:IsOutofDate()
  934. self.btnRedEnvelope:SetActive(state)
  935. if not state then
  936. self.windowEnvelope:SetActive(false)
  937. return
  938. end
  939. local curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  940. local levelCfgData = ManagerContainer.CfgMgr:GetLevelDataById(curLevelId)
  941. if levelCfgData.Cash == 0 and bBossStage then
  942. if self.btnRedEnvelope.activeSelf then
  943. self.btnRedEnvelope:SetActive(false)
  944. end
  945. if self.windowEnvelope.activeSelf then
  946. self.windowEnvelope:SetActive(false)
  947. end
  948. return
  949. end
  950. local leftSeconds = reActItem:LeftTime()
  951. if leftSeconds > 0 then
  952. if leftSeconds <= 60 then
  953. self.btnRedEnvelope.text.text.text = I18N.T("LessOneMinu")
  954. else
  955. local time = DateTimeUtil.convertSeconds2TimeStr1(leftSeconds, true, false)
  956. self.btnRedEnvelope.text.text.text = time
  957. end
  958. else
  959. if self.btnRedEnvelope.activeSelf then
  960. self.btnRedEnvelope:SetActive(false)
  961. end
  962. if self.windowEnvelope.activeSelf then
  963. self.windowEnvelope:SetActive(false)
  964. end
  965. end
  966. end
  967. function UIBattleView:OnBattleREClick()
  968. self:OnShowWindowsEnvelope()
  969. end
  970. function UIBattleView:OnNormalREClick()
  971. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIREShop, nil, self.uiData.id)
  972. end
  973. function UIBattleView:ShowBattleNormalUI()
  974. if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIBattle) then
  975. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.BOSS_BATTLE_STATUS,false)
  976. end
  977. self.transform:DOScale(1, 0.8):OnComplete(function ()
  978. self:ShowBattleNormalUI1()
  979. end)
  980. end
  981. function UIBattleView:ShowBattleNormalUI1()
  982. --self.bottomNode:SetActive(true)
  983. self.centerNode:SetActive(true)
  984. --self.ProfitBoxGo:SetActive(true)
  985. if not ManagerContainer.LuaBattleMgr:GetBossFightState() then
  986. self.MapRootGo:SetActive(true)
  987. end
  988. self.btnwarlog:SetActive(true)
  989. self.btnStatistics:SetActive(true)
  990. -- self:OnValueChangedToggle(nil,1, true)
  991. end
  992. function UIBattleView:OnContinueBattle()
  993. bBoxState = false
  994. self.battleFailGo:SetActive(false);
  995. self:PlayRewardNormalAnim();
  996. end
  997. function UIBattleView:OnBattleWin()
  998. self:RestoreSpeed()
  999. self.BossBloodPart:Hide()
  1000. self.HeadsBoxPart:Hide()
  1001. self.StatisticsPart:Hide()
  1002. self.rageBoxGo:SetActive(false)
  1003. end
  1004. function UIBattleView:OnBattleFailed(killboss,isPlayRecord)
  1005. self:RestoreSpeed()
  1006. -- self.battleFailGo:SetActive(true);
  1007. self.BossBloodPart:Hide()
  1008. self.HeadsBoxPart:Hide()
  1009. self.StatisticsPart:Hide()
  1010. self.rageBoxGo:SetActive(false)
  1011. self:PlayChallengeBtnNormalAnim()
  1012. self:PlayRewardNormalAnim()
  1013. if killboss and (not isPlayRecord) then
  1014. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIClimbingTowerBattleFailed,Enum.UIPageName.UIBattle)
  1015. else
  1016. self.battleFailGo:SetActive(true)
  1017. end
  1018. --self:ShowBattleNormalUI()
  1019. end
  1020. function UIBattleView:OnForceBattleFailed(killboss,isPlayRecord)
  1021. self:RestoreSpeed()
  1022. -- self.battleFailGo:SetActive(true);
  1023. self.BossBloodPart:Hide()
  1024. self.HeadsBoxPart:Hide()
  1025. self.StatisticsPart:Hide()
  1026. self.rageBoxGo:SetActive(false)
  1027. self:PlayChallengeBtnNormalAnim()
  1028. self:PlayRewardNormalAnim()
  1029. if killboss and (not isPlayRecord) then
  1030. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIClimbingTowerBattleFailed,Enum.UIPageName.UIBattle)
  1031. end
  1032. self.battleFailGo:SetActive(false)
  1033. end
  1034. function UIBattleView:RestoreSpeed()
  1035. ManagerContainer.LuaGameMgr:SetGameSpeed(1)
  1036. end
  1037. function UIBattleView:FuncOpen()
  1038. self:PlayChallengeBtnNormalAnim()
  1039. self:PlayRewardNormalAnim();
  1040. self:OnRefreshEarnings();
  1041. --if ManagerContainer.LuaUIMgr.CurrentPage.PageId == self.uiData.id then
  1042. self:FuncOpen1()
  1043. --end
  1044. end
  1045. function UIBattleView:FuncOpen1()
  1046. if ManagerContainer.LuaBattleMgr:IsShowDifficultyTxt() then
  1047. return
  1048. end
  1049. local levelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  1050. local newFuncs, nearFuncs, forceGuideList = ManagerContainer.UIFuncUnlockMgr:GetNewFuncAndNearFuncByLevelId(levelId)
  1051. if newFuncs[1] == nil then
  1052. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  1053. return
  1054. end
  1055. local newFunc = newFuncs[1]
  1056. self.newFuncs = newFuncs
  1057. if #forceGuideList > 0 then
  1058. self.controller:SetNewForceId(forceGuideList[1])
  1059. end
  1060. local newFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(newFunc)
  1061. CommonUtil.LoadIcon(self, newFuncData.FunIcon, function (sprite)
  1062. self.newOpen.image.image.sprite = sprite
  1063. self.newOpen.imageLt.image.sprite = sprite
  1064. end)
  1065. self.newOpen.nameTxt.text.text = I18N.T(newFuncData.FunName)
  1066. self.newOpen.dscTxt.text.text = I18N.T(newFuncData.FunDsc)
  1067. local item = self.newOpen.item
  1068. item:SetActive(nearFuncs[1] ~= nil)
  1069. if nearFuncs[1] ~= nil then
  1070. local nearData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(nearFuncs[1])
  1071. CommonUtil.LoadIcon(self, nearData.FunIcon, function (sprite)
  1072. item.image.image.sprite = sprite
  1073. end)
  1074. local result,val,content = ManagerContainer.UIFuncUnlockMgr:CheckConditionPassResult(nearData)
  1075. --content = content and content or ""
  1076. item.itemTxt.text.text = I18N.T(nearData.FunName).."("..content..")"
  1077. end
  1078. self.newOpen:SetActive(true)
  1079. end
  1080. function UIBattleView:OnTaskClick()
  1081. ManagerContainer.DataMgr.TaskDataNew:OpenTaskPanel();
  1082. end
  1083. function UIBattleView:OnCloseNewOpen()
  1084. self.newOpen:SetActive(false)
  1085. if self.newFuncs then
  1086. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_UNLOCK_NTF, self.newFuncs)
  1087. self.newFuncs = nil
  1088. end
  1089. local newForceId = self.controller:GetNewForceId()
  1090. if newForceId then
  1091. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_TRIGGER, Enum.ForceGuideTriggerEnum.FuncOpen, newForceId)
  1092. self.controller:SetNewForceId()
  1093. else
  1094. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  1095. end
  1096. end
  1097. function UIBattleView:OnBattleNewWave(levelName)
  1098. self.battleFailGo:SetActive(false);
  1099. self:OnRefreshEarnings();
  1100. end
  1101. function UIBattleView:OnHideLevelName()
  1102. end
  1103. function UIBattleView:OnShowBossRage()
  1104. self.rageBoxGo:SetActive(true)
  1105. end
  1106. function UIBattleView:OnShowBossRageLeftTime(leftTime)
  1107. self:RefreshRageTime(leftTime)
  1108. end
  1109. function UIBattleView:OnBossInRage()
  1110. self.rageBoxGo:SetActive(false)
  1111. end
  1112. function UIBattleView:PlayChallengeBtnNormalAnim()
  1113. if self.btnBossAnimator~= nil then
  1114. self.challengeAnimName = bossFightCDRemainTime <= 0 and "BtnBoss1" or "BtnBoss4"
  1115. if self.btnBossAnimator.activeInHierarchy then
  1116. self.btnBossAnimator.animator:Play(self.challengeAnimName);
  1117. end
  1118. if bossFightCDRemainTime > 0 then
  1119. self.btnChallenge.remainCDTime.text.text = I18N.SetLanguageValue("FightCD", math.ceil(bossFightCDRemainTime))
  1120. end
  1121. end
  1122. --self.ReceiveGo:SetActive(true);
  1123. self.quickBattleBtn.button.interactable = true
  1124. end
  1125. function UIBattleView:PlayRewardNormalAnim()
  1126. self:OnRefreshRewardTime();
  1127. end
  1128. function UIBattleView:RefreshRageTime(leftTime)
  1129. if leftTime ~= nil then
  1130. local spriteName = nil
  1131. if leftTime == 10 then
  1132. spriteName = "Alert_number_0"
  1133. else
  1134. spriteName = "Alert_number_"..leftTime
  1135. end
  1136. self.rageNum1.image.sprite = self.rageNum1.switchSprite:GetSprite(spriteName)
  1137. self.rageNum2.image.sprite = self.rageNum2.switchSprite:GetSprite(spriteName)
  1138. if leftTime == 1 then
  1139. self.rageBoxGo.bg.animator:Play("BafengteAlertEnd")
  1140. end
  1141. end
  1142. end
  1143. function UIBattleView:OnShowBossWarning(vis)
  1144. self.bossWarning.animator.gameObject:SetActive(vis)
  1145. end
  1146. function UIBattleView:OnRefreshEarnings()
  1147. self.ExpLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelExp() .. "/" .. I18N.T("m") ;
  1148. self.ZenyLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelZeny() .. "/" .. I18N.T("m");
  1149. self.ParnterExpLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelParnterExp() .. "/" .. I18N.T("m");
  1150. self.CruiseLbl.text.text = ManagerContainer.LuaBattleMgr:CurLevelCruise() .. "/" .. I18N.T("m");
  1151. self.CurLevelName.text.text = ManagerContainer.LuaBattleMgr:CurLevelName();
  1152. ManagerContainer.LuaBattleMgr:SetRewardDropPos(self.RewardBoxBtnPos);
  1153. local lockState = ManagerContainer.UIFuncUnlockMgr:GetFuncLockStatusById(35)
  1154. ManagerContainer.LuaUIMgr:SetBattleDropRootVisible(lockState)
  1155. end
  1156. function UIBattleView:OnRefreshRewardTime()
  1157. local passedTime = ManagerContainer.LuaBattleMgr:AccumIncomeTime();
  1158. local maxTime = ManagerContainer.LuaBattleMgr:MaxInComeTime() * 1000
  1159. if passedTime >= maxTime then
  1160. passedTime = maxTime
  1161. end
  1162. local leftTime,num = ManagerContainer.LuaBattleMgr:GetIncomeInfo()
  1163. if num == nil then
  1164. num = 0
  1165. end
  1166. self.rewardPoint:SetActive(num >= 1)
  1167. if num > 999 then
  1168. self.rewardPoint.num.text.text = "999+"
  1169. else
  1170. self.rewardPoint.num.text.text = tostring(num)
  1171. end
  1172. if passedTime >= maxTime then
  1173. self.RewardTimeLbl.text.text = "Max";
  1174. else
  1175. self.RewardTimeLbl.text.text = DateTimeUtil.convertSeconds2TimeStr(leftTime,true);
  1176. end
  1177. self:CheckRewardBoxStatus(passedTime)
  1178. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_HANG_TIME,passedTime);
  1179. end
  1180. function UIBattleView:CheckRewardBoxStatus(passedTime)
  1181. local animName = "Chest01New"
  1182. if bBoxState then
  1183. animName = "ChestClose"
  1184. else
  1185. if passedTime <= self.statTime1 then
  1186. animName = "Chest01New"
  1187. elseif passedTime <= self.statTime2 then
  1188. animName = "Chest02New"
  1189. elseif passedTime <= self.statTime3 then
  1190. animName = "Chest03New"
  1191. else
  1192. animName = "Chest04New"
  1193. end
  1194. end
  1195. if self.RewardBoxBtn.activeInHierarchy then
  1196. self.RewardBoxBtn.animator:Play(animName);
  1197. end
  1198. end
  1199. function UIBattleView:OnBattleIncomeAck(dropLoc)
  1200. local zeny = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.Coin)
  1201. local partnerExp = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.ParterExp)
  1202. local exp = ManagerContainer.LuaBattleMgr:GetRewardCnt(Enum.ItemType.RoleBaseExp)
  1203. local createZeny = false;
  1204. local createExp=false;
  1205. local createPartnerExp = false;
  1206. if UIMainCtr == nil then
  1207. UIMainCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIMain)
  1208. end
  1209. local zenyPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.Coin)
  1210. local expPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.RoleBaseExp)
  1211. local bagPos = UIMainCtr:GeAnchoredPosition3DByType(Enum.ItemType.ParterExp)
  1212. if zeny ~= nil and zeny > 0 then
  1213. createZeny = true
  1214. end
  1215. if partnerExp~= nil and partnerExp > 0 then
  1216. createPartnerExp = true
  1217. end
  1218. if exp ~= nil and exp > 0 then
  1219. createExp = true
  1220. end
  1221. local itemIcons = {};
  1222. for i =1, #ManagerContainer.LuaBattleMgr.rewardItemList do
  1223. local item = ManagerContainer.LuaBattleMgr.rewardItemList[i];
  1224. if item.key >= 100 then
  1225. local itemCfg = ManagerContainer.CfgMgr:GetItemById(item.key)
  1226. if itemCfg~= nil then
  1227. itemIcons[#itemIcons+1] = itemCfg.Icon
  1228. end
  1229. end
  1230. end
  1231. self.dropType = dropLoc;
  1232. if dropLoc == 0 then
  1233. LuaBattleBridge.GenerateDropItems(self.RewardBoxBtnPos,createZeny,zenyPos,createExp,expPos,createPartnerExp,bagPos,false,Vector3.zero,0.15,0.25,unpack(itemIcons));
  1234. else
  1235. LuaBattleBridge.GenerateDropItems(Vector3.New(0, 0, 0),createZeny,zenyPos,createExp,expPos,createPartnerExp,bagPos,false,Vector3.zero,0.30,0.25,unpack(itemIcons));
  1236. end
  1237. if self.openRewardTimer ~= nil then
  1238. ManagerContainer.LuaTimerMgr:RemoveTimer(self.openRewardTimer)
  1239. self.openRewardTimer = nil
  1240. end
  1241. self.openRewardTimer = ManagerContainer.LuaTimerMgr:AddTimer(GlobalConfig.Instance:GetConfigFloatValue(78)*1000, 1, self, self.OnOpenRewardPage, nil)
  1242. end
  1243. function UIBattleView:OnOpenRewardPage()
  1244. self.openRewardTimer = nil
  1245. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleReward,self.dropType)
  1246. end
  1247. function UIBattleView:LoadMinimap()
  1248. local mapId = ManagerContainer.LuaBattleMgr:GetCurMapId()
  1249. local mapCfgData = ManagerContainer.CfgMgr:GetMapData(mapId)
  1250. local center = mapCfgData.Center
  1251. self.mapCenter = Vector3.New(center[1], center[2], center[3])
  1252. self.mapSizeX = mapCfgData.RealSizeX
  1253. self.mapSizeZ = mapCfgData.RealSizeZ
  1254. local scale = mapCfgData.MinimapScale *0.01
  1255. self.minimap.transform.localScale = Vector3.New(scale, scale, scale)
  1256. self.minimapSizeX = mapCfgData.MinimapSizeX * scale
  1257. self.minimapSizeZ = mapCfgData.MinimapSizeZ * scale
  1258. CommonUtil.LoadTexture(self, mapCfgData.MinimapIcon, function (texture)
  1259. self.minimap.rawImage.texture = texture
  1260. self:RefreshMinimapInfo()
  1261. end)
  1262. end
  1263. function UIBattleView:WorldPos2MinimapPos(pos)
  1264. local xRate = pos.x / self.mapSizeX
  1265. local zRate = pos.z / self.mapSizeZ
  1266. local x = self.minimapSizeX * xRate
  1267. local z = self.minimapSizeZ * zRate
  1268. return x,z
  1269. end
  1270. function UIBattleView:OnRefreshMinimap()
  1271. self:RefreshMinimapInfo()
  1272. end
  1273. function UIBattleView:RefreshMinimapInfo()
  1274. if self.miniMapGoes == nil then
  1275. return
  1276. end
  1277. if ManagerContainer.LuaBattleMgr.isBattleing then
  1278. return
  1279. end
  1280. LuaBattleBridge.RefreshMinimap(self.mapCenter, self.mapSizeX,self.mapSizeZ,self.minimapSizeX,self.minimapSizeZ, self.hero,unpack(self.miniMapGoes))
  1281. end
  1282. function UIBattleView:InitCruise()
  1283. end
  1284. function UIBattleView:RefreshCruise()
  1285. end
  1286. function UIBattleView:OnClickCruiseBtn()
  1287. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UITreasures)
  1288. end
  1289. function UIBattleView:OnClickMailBtn()
  1290. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIMailBox)
  1291. end
  1292. function UIBattleView:GeAnchoredPosition3DByType(type)
  1293. if type ~= Enum.ItemType.RoleJobExp and type ~= Enum.ItemType.RoleBaseExp then
  1294. return self.ReceiveGo.transform.position
  1295. end
  1296. return Vector3.zero
  1297. end
  1298. function UIBattleView:GetMiniMapPosition()
  1299. return self.minimap.transform.parent.position
  1300. end
  1301. function UIBattleView:RewardBoxRefresh()
  1302. bBoxState = false
  1303. self:PlayRewardNormalAnim();
  1304. end
  1305. function UIBattleView:GetBattleState()
  1306. return bBossStage
  1307. end
  1308. function UIBattleView:PopGotAnimEnd(type)
  1309. if type == Enum.ItemIEnterType.BattleWin then
  1310. self:PlayChallengeBtnNormalAnim()
  1311. end
  1312. end
  1313. function UIBattleView:NewLevelIncrease()
  1314. if levelIncreaseTimer ~= nil then
  1315. ManagerContainer.LuaTimerMgr:RemoveTimer(levelIncreaseTimer)
  1316. levelIncreaseTimer = nil
  1317. end
  1318. if bBossStage then return end
  1319. local count = 0
  1320. local list = {}
  1321. local lastLevelZeny = ManagerContainer.LuaBattleMgr.lastLevelZeny
  1322. local curLevelZeny = ManagerContainer.LuaBattleMgr:CurLevelZeny()
  1323. if lastLevelZeny < curLevelZeny then
  1324. count = count + 1
  1325. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelZeny, newNum = curLevelZeny}
  1326. list[#list + 1] = data
  1327. end
  1328. local lastLevelExp = ManagerContainer.LuaBattleMgr.lastLevelExp
  1329. local curLevelExp = ManagerContainer.LuaBattleMgr:CurLevelExp()
  1330. if lastLevelExp < curLevelExp then
  1331. count = count + 1
  1332. local data = {iconPath = Enum.LevelIncreaseType.BaseExp, lastNum = lastLevelExp, newNum = curLevelExp}
  1333. list[#list + 1] = data
  1334. end
  1335. local lastLevelPartnerExp = ManagerContainer.LuaBattleMgr.lastLevelPartnerExp
  1336. local curLevelPartnerExp = ManagerContainer.LuaBattleMgr:CurLevelParnterExp()
  1337. if lastLevelPartnerExp < curLevelPartnerExp then
  1338. count = count + 1
  1339. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelPartnerExp, newNum = curLevelPartnerExp}
  1340. list[#list + 1] = data
  1341. end
  1342. local lastLevelCruise = ManagerContainer.LuaBattleMgr.lastLevelCruise
  1343. local curLevelCruise = ManagerContainer.LuaBattleMgr:CurLevelCruise()
  1344. if lastLevelCruise < curLevelCruise then
  1345. count = count + 1
  1346. local data = {iconPath = Enum.LevelIncreaseType.Zeny, lastNum = lastLevelCruise, newNum = curLevelCruise}
  1347. list[#list + 1] = data
  1348. end
  1349. if #list > 0 then
  1350. increaseIdx = 0
  1351. self:ShowLevelIncrease(0, list)
  1352. if #list > 1 then
  1353. levelIncreaseTimer = ManagerContainer.LuaTimerMgr:AddTimer(500, #list - 1, self, self.ShowLevelIncrease, list)
  1354. end
  1355. end
  1356. end
  1357. function UIBattleView:ShowLevelIncrease(idx, list)
  1358. increaseIdx = increaseIdx + 1
  1359. local data = list[increaseIdx]
  1360. ManagerContainer.GoPoolMgr:SpawnGo(Enum.PrefabNames.LevelIncreaseItem, function(itemlua)
  1361. CommonUtil.BatchCreateItems(self, itemlua, self.centerNode.transform, data)
  1362. end)
  1363. end
  1364. function UIBattleView:DisposeNewLevelIncrease()
  1365. if levelIncreaseTimer ~= nil then
  1366. ManagerContainer.LuaTimerMgr:RemoveTimer(levelIncreaseTimer)
  1367. levelIncreaseTimer = nil
  1368. end
  1369. CommonUtil.RecycleFromBatchItemsByPrefabName(self, Enum.PrefabNames.LevelIncreaseItem)
  1370. end
  1371. function UIBattleView:IsSomeFrameCount(keyName)
  1372. local value = self[keyName]
  1373. if value and value >= Time.frameCount then
  1374. return true
  1375. end
  1376. self[keyName] = Time.frameCount
  1377. return false
  1378. end
  1379. function UIBattleView:OnClickBattleRecordBtn()
  1380. ManagerContainer.LuaBattleMgr:SendBattleRecordReq()
  1381. end
  1382. function UIBattleView:OnClickBattleStatisticsBtn()
  1383. if LuaBattleBridge.HasStatistics(BattleMode.Normal,BattleSubMode.None) then
  1384. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleStatistics,{BattleMode.Normal,BattleSubMode.None})
  1385. else
  1386. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("NullBattleInformation1")
  1387. end
  1388. end
  1389. function UIBattleView:OnClickAutoChallenge()
  1390. if not ManagerContainer.DataMgr.RuneShopDataMgr:GetRoPassAutoBattle() then
  1391. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("nomonthcard")
  1392. ManagerContainer.LuaBattleMgr:StopAutoChallenge()
  1393. return
  1394. end
  1395. if ManagerContainer.LuaBattleMgr:GetAutoChallengeState() then
  1396. self.autoAnim.animator:Play("AutoKeep")
  1397. ManagerContainer.LuaBattleMgr:StopAutoChallenge()
  1398. else
  1399. self.autoAnim.animator:Play("AutoIn")
  1400. ManagerContainer.LuaBattleMgr:SetAutoChallengeState(true)
  1401. end
  1402. end
  1403. function UIBattleView:FindTaskCompeleted1(id, owner, ownerCB)
  1404. local page = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIPOPGot)
  1405. if page then
  1406. local pop = page.MLuaTable
  1407. pop:UIClose()
  1408. end
  1409. local target = self.btnChallenge
  1410. if target == nil then
  1411. if owner and ownerCB then
  1412. ownerCB(owner)
  1413. end
  1414. return
  1415. end
  1416. if owner and ownerCB then
  1417. ownerCB(owner, target)
  1418. end
  1419. end
  1420. return UIBattleView