UIBattleView.lua 53 KB

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