UIVoyageReformingView.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. local UIVoyageReformingView = require("UIVoyage/UIVoyageReformingView_Generate")
  2. function UIVoyageReformingView:OnAwake(data)
  3. self.controller = require("UIVoyage/UIVoyageReformingCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIVoyageReformingView:AddEventListener()
  8. end
  9. function UIVoyageReformingView: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 UIVoyageReformingView:Init()
  20. self.animator:Play('ShipReforming')
  21. self.checkoutNum = 0
  22. if self.forceShowTimer then
  23. self.forceShowTimer.time = 0.5
  24. else
  25. self.forceShowTimer = Timer.New(slot(self.CheckResult, self), 0.5, -1)
  26. end
  27. if not self.forceShowTimer.running then
  28. self.forceShowTimer:Start()
  29. end
  30. end
  31. function UIVoyageReformingView:RemoveEventListener()
  32. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  33. end
  34. function UIVoyageReformingView:AddUIEventListener()
  35. self.uiBase:AddButtonUniqueEventListener(self.AnyBtn.button, self, self.OnClickCloseBtn)
  36. end
  37. function UIVoyageReformingView:OnHide()
  38. end
  39. function UIVoyageReformingView:OnShow(data)
  40. self.controller:SetData(data)
  41. end
  42. function UIVoyageReformingView:OnClose()
  43. end
  44. function UIVoyageReformingView:OnDispose()
  45. self.checkoutNum = nil
  46. if self.forceShowTimer then
  47. self.forceShowTimer:Stop()
  48. self.forceShowTimer = nil
  49. end
  50. self.controller:OnDispose()
  51. end
  52. function UIVoyageReformingView:OnClickCloseBtn()
  53. if self.forceShowTimer and self.forceShowTimer.running then
  54. return
  55. end
  56. self:UIClose()
  57. end
  58. function UIVoyageReformingView:CheckResult()
  59. self.checkoutNum = self.checkoutNum + 1
  60. if self.checkoutNum > 5 then
  61. self:ShowResult(false)
  62. return
  63. end
  64. local result = ManagerContainer.DataMgr.VoyageDataMgr:GetRefreshAirShipResult()
  65. if result then
  66. self:ShowResult(true)
  67. elseif result == false then
  68. self:ShowResult(false)
  69. end
  70. end
  71. function UIVoyageReformingView:ShowResult(success)
  72. if self.forceShowTimer then
  73. self.forceShowTimer:Stop()
  74. end
  75. self.fail:SetActive(not success)
  76. self.success:SetActive(success)
  77. self.animator:Play('ShipReformingResult')
  78. end
  79. return UIVoyageReformingView