UIQuickBattleView.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. local UIQuickBattleView = require("UIBattle/UIQuickBattleView_Generate")
  2. function UIQuickBattleView:OnAwake(data)
  3. self.controller = require("UIBattle/UIQuickBattleCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIQuickBattleView:AddEventListener()
  8. end
  9. function UIQuickBattleView:FillContent(data, uiBase)
  10. self.uiBase = uiBase
  11. local gameObject = self.uiBase:GetRoot()
  12. if gameObject ~= nil then
  13. self.gameObject = gameObject
  14. self.transform = gameObject.transform
  15. end
  16. self:InitGenerate(self.transform, data)
  17. self:Init()
  18. end
  19. function UIQuickBattleView:Init()
  20. self.LeftTimesLbl.text.text = tostring(self.controller:LeftCnt())
  21. local costText, enough = self.controller:GetUseCondition()
  22. self.StartBtnLbl.text.text = costText
  23. if enough == false then
  24. self.StartBtnLbl.text.color = Color.red
  25. else
  26. self.StartBtnLbl.text.color = Color.white
  27. end
  28. end
  29. function UIQuickBattleView:RemoveEventListener()
  30. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  31. end
  32. function UIQuickBattleView:AddUIEventListener()
  33. self.uiBase:AddButtonEventListener(self.StartBtn.button,self, self.OnClickStart)
  34. self.uiBase:AddButtonEventListener(self.CloseBtn.button,self, self.OnClickClose)
  35. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickClose)
  36. end
  37. function UIQuickBattleView:OnHide()
  38. end
  39. function UIQuickBattleView:OnShow(data)
  40. self.controller:SetData(data)
  41. self:Init()
  42. end
  43. function UIQuickBattleView:OnClose()
  44. end
  45. function UIQuickBattleView:OnDispose()
  46. end
  47. function UIQuickBattleView:OnClickStart()
  48. if self.controller:LeftCnt() > 0 then
  49. ManagerContainer.LuaBattleMgr:SendQuickBattleReq()
  50. self:OnClickClose();
  51. else
  52. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.T("BtnQuickFinish")) --今日次数已用完
  53. end
  54. end
  55. function UIQuickBattleView:OnClickClose()
  56. ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIQuickBattle)
  57. end
  58. return UIQuickBattleView