源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

166 righe
4.6 KiB

  1. --自动挂机时间,经验状态tips
  2. AutoFightTips = AutoFightTips or BaseClass(BaseView)
  3. function AutoFightTips:__init()
  4. self.base_file = "autoFight"
  5. self.layout_file = "AutoFightTips"
  6. self.layer_name = "Activity"
  7. self.open_wnd_anim = 0
  8. -- self.use_local_view = true
  9. self.change_scene_close = true
  10. self.close_mode = CloseMode.CloseDestroy
  11. self.destroy_imm = true
  12. self.hide_maincancas = false
  13. self.background_alpha = 0
  14. self.use_background = true --任务栏特效遮罩影响了这里,加上透明背景
  15. self.click_bg_toClose = true
  16. self.model = AutoFightManager:getInstance()
  17. self.item_list = {}
  18. self.load_callback = function()
  19. self:LoadSuccess()
  20. self:InitEvent()
  21. end
  22. self.open_callback = function()
  23. GoodsModel:getInstance():Fire(GoodsModel.GET_GOODS_BUFF_LIST) --发15055更新物品buff
  24. self:SetData()
  25. end
  26. self.destroy_callback = function()
  27. self:Remove()
  28. end
  29. end
  30. function AutoFightTips:Remove()
  31. if self.orientation_change_id then
  32. GlobalEventSystem:UnBind(self.orientation_change_id)
  33. self.orientation_change_id = nil
  34. end
  35. if self.event_id then
  36. AutoFightManager:getInstance():UnBind(self.event_id)
  37. self.event_id = nil
  38. end
  39. if self.event_id2 then
  40. GoodsModel:getInstance():UnBind(self.event_id2)
  41. self.event_id2 = nil
  42. end
  43. if self.event_id3 then
  44. AutoFightManager:getInstance():UnBind(self.event_id3)
  45. self.event_id3 = nil
  46. end
  47. if self.event_id4 then
  48. GlobalEventSystem:UnBind(self.event_id4)
  49. self.event_id4 = nil
  50. end
  51. if self.event_id5 then
  52. GlobalEventSystem:UnBind(self.event_id5)
  53. self.event_id5 = nil
  54. end
  55. for i,v in ipairs(self.item_list) do
  56. v:DeleteMe()
  57. v = nil
  58. end
  59. self.item_list = {}
  60. end
  61. function AutoFightTips:Open()
  62. BaseView.Open(self)
  63. end
  64. function AutoFightTips:LoadSuccess()
  65. self.raycast = self:GetChild("raycast")
  66. self.raycast.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight)
  67. self.raycast.localPosition = Vector3(-ScreenWidth/2+ClientConfig.iphone_x_offset_left, ScreenHeight/2, 0)
  68. self.layout = self:GetChild("layout")
  69. self.layout.localPosition = Vector3(-ScreenWidth/2 + 172 + ClientConfig.iphone_x_offset_left, ScreenHeight / 2 - 90, 0)
  70. self.ScrollView = self:GetChild("layout/ScrollView")
  71. self.ScrollViewViewport = self:GetChild("layout/ScrollView/Viewport")
  72. self.ScrollViewCon = self:GetChild("layout/ScrollView/Viewport/Content")
  73. self.bg = self:GetChild("layout/bg")
  74. self.scroll_comp = self.ScrollView:GetComponent("ScrollRect")
  75. end
  76. function AutoFightTips:InitEvent()
  77. local function onOrientationChange()
  78. self.layout.localPosition = Vector2(ClientConfig.iphone_x_offset_left, 0)
  79. end
  80. self.orientation_change_id = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  81. AddClickEvent(self.raycast.gameObject,function ()
  82. self:Close()
  83. end)
  84. local update_fun = function ()
  85. -- local function on_delay( )
  86. self:SetData()
  87. -- end
  88. -- setTimeout(on_delay, 0.1)
  89. end
  90. -- self.event_id = AutoFightManager:getInstance():Bind(AutoFightManager.UPDATE_EXPERIENCE_DATA, update_fun)
  91. -- self.event_id2 = GoodsModel:getInstance():Bind(GoodsModel.UPDATE_GOODS_BUFF_DATA, update_fun)
  92. self.event_id4 = GlobalEventSystem:Bind(EventName.UPDATE_BUFF_VIEW, update_fun)
  93. local close_fun = function ()
  94. self:Close()
  95. end
  96. self.event_id3 = AutoFightManager:getInstance():Bind(AutoFightManager.CLOSE_AUTO_FIGHT_TIP, close_fun)
  97. local function onSceneChangeHandler()
  98. self:Close()
  99. end
  100. self.event_id5 = GlobalEventSystem:Bind(SceneEventType.SCENE_CHANGED, onSceneChangeHandler)
  101. self:SetData()
  102. end
  103. function AutoFightTips:SetData()
  104. if IsNull(self.gameObject) then
  105. return
  106. end
  107. for k,v in pairs(self.item_list) do
  108. v:SetVisible(false)
  109. end
  110. local mvo = RoleManager.Instance.mainRoleInfo
  111. local scroll_height = 0
  112. local count = 0
  113. local height = 0
  114. local buff_list = MainUIModel:getInstance():GetAllBuff()
  115. if buff_list then
  116. for i,v in ipairs(buff_list) do
  117. if Config.ConfigBuffIcon[v.id] then
  118. local item = self.item_list[count + 1]
  119. if item == nil then
  120. item = BufferTipsItem.New(self.ScrollViewCon)
  121. self.item_list[count + 1] = item
  122. end
  123. local is_end = i == #buff_list
  124. item:SetData(v, is_end)
  125. item:SetVisible(true)
  126. local x = 6
  127. item:SetAnchoredPosition(x, -height)
  128. count = count + 1
  129. height = item:GetAllHeight() + height
  130. end
  131. end
  132. end
  133. scroll_height = height
  134. self.scroll_comp.enabled = false
  135. if count >= 4 then
  136. height = 418
  137. self.scroll_comp.enabled = true
  138. elseif count > 0 then
  139. height = height + 31
  140. else
  141. height = 0
  142. end
  143. self.gameObject:SetActive(height > 0)
  144. self.bg.sizeDelta = Vector2(311, height)
  145. self.ScrollView.sizeDelta = Vector2(311, height-31)
  146. self.ScrollViewCon.sizeDelta = Vector2(311, scroll_height)
  147. end