KLBigSecretCopyTaskPanel.lua 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. ---@class KLBigSecretCopyTaskPanel:UIKmlLuaPanelBase
  2. ---@field view KLBigSecretCopyTaskPanelView
  3. local KLBigSecretCopyTaskPanel = class(UIKmlLuaPanelBase)
  4. local this = KLBigSecretCopyTaskPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. self.is_open = false
  8. --GUI:UIPanel_Open("dev/outui/BigSecretCopy/Panel/KLBigSecretCopyTask/KLBigSecretCopyTaskPanel")
  9. self.updateID = SL:Schedule(self.updateID,1,1,-1,function()
  10. self:Update()
  11. end)
  12. end
  13. function this:InitBegin(data)
  14. --SL:LogTable(data,true)
  15. GUI:setVisible(self.view.task_root,false)
  16. GUI:setVisible(self.view.begin_root,true)
  17. this.configId = tonumber(data)
  18. local name_str = SL:GetConfig("cfg_rep",this.configId).name[1]
  19. GUI:Text_setString(self.view.ActivityName,name_str)
  20. self.prepareTime = SL:GetConfig("cfg_rep",this.configId).prepareTime
  21. local str = self.prepareTime .. "秒后开启副本"
  22. GUI:Text_setString(self.view.openDesTxt,str)
  23. self.is_begin_time = true
  24. end
  25. function this:InitData(data)
  26. GUI:setVisible(self.view.task_root,true)
  27. GUI:setVisible(self.view.begin_root,false)
  28. --SL:LogTable(data,true)
  29. this.configId = data.configId
  30. local monster = SL:GetConfig("cfg_repMonster",tonumber(data.taskId)).monster[1]
  31. self.monster_data = monster
  32. local monster_cfgId = monster[1]
  33. local monster_name = SL:GetConfig('cfg_monster', monster_cfgId).name
  34. GUI:Text_setString(self.view.name,"击杀" .. monster_name)
  35. local num_sre = data.nowCount .. "/" .. data.totalCount
  36. GUI:Text_setString(self.view.num,num_sre)
  37. local nextStateStartTime = tonumber(data.nextStateStartTime)
  38. local server_time = SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME)
  39. local e_time = nextStateStartTime - server_time
  40. if e_time < 0 then
  41. e_time = 0
  42. end
  43. self.endTime = math.floor(e_time/1000)
  44. --GUI:SetControl_time(self.view.end_time,e_time)
  45. GUI:setVisible(self.view.end_time,true)
  46. local continuous = SL:GetConfig("cfg_rep",this.configId).continuous
  47. local st_time = continuous *1000 - e_time
  48. if st_time < 0 then
  49. st_time = 0
  50. end
  51. self.startTime = math.floor(st_time/1000)
  52. --GUI:SetControl_time(self.view.start_time,st_time)
  53. GUI:setVisible(self.view.start_time,true)
  54. local name_str = SL:GetConfig("cfg_rep",this.configId).name[1]
  55. GUI:Text_setString(self.view.ActivityName,name_str)
  56. local taskId = tonumber(data.taskId)
  57. local task_name_str = SL:GetConfig("cfg_repTask",taskId).name
  58. GUI:Text_setString(self.view.info,task_name_str)
  59. -- SL:LogError("startTime---")
  60. -- SL:LogError(self.startTime)
  61. -- SL:LogError("endTime---")
  62. -- SL:LogError(self.endTime)
  63. self.score_data = SL:GetConfig("cfg_bigUncharted",this.configId)
  64. self.is_open = true
  65. end
  66. function this:Update()
  67. if self.is_open then
  68. local start_str = self:GetTime(self.startTime)
  69. GUI:Text_setString(self.view.start_time, start_str)
  70. local end_str = self:GetTime(self.endTime)
  71. GUI:Text_setString(self.view.end_time, end_str)
  72. self.startTime = self.startTime + 1
  73. self.endTime = self.endTime - 1
  74. if self.endTime < 0 then
  75. self.endTime = 0
  76. end
  77. -- SL:LogError(start_str)
  78. -- SL:LogError(end_str)
  79. local cur_score = ""
  80. if self.score_data and self.score_data.time then
  81. for i, minute in ipairs(self.score_data.time) do
  82. if self.startTime <= minute *60 then
  83. cur_score = self.score_data.score[i]
  84. break
  85. end
  86. end
  87. end
  88. GUI:Text_setString(self.view.pingfen, cur_score)
  89. end
  90. if self.is_begin_time then
  91. if self.prepareTime < 0 then
  92. self.prepareTime = 0
  93. end
  94. local str = self.prepareTime .. "秒后开启副本"
  95. GUI:Text_setString(self.view.openDesTxt,str)
  96. self.prepareTime = self.prepareTime - 1
  97. end
  98. end
  99. ---创建或者刷新界面数据时调用
  100. function this:Refresh()
  101. end
  102. function this:SetVisible(isVisible)
  103. GUI:setVisible(self.view.root,isVisible)
  104. end
  105. ---注册UI事件和服务器消息
  106. function this:RegistEvents()
  107. -- GUI:SetToggleOnValueChange(self.view.boss_1_toggle, self, self.Boss1Click)
  108. -- GUI:SetToggleOnValueChange(self.view.boss_2_toggle, self, self.Boss2Click)
  109. -- GUI:SetToggleOnValueChange(self.view.boss_3_toggle, self, self.Boss3Click)
  110. GUI:AddOnClickEvent(self.view.exitBtn,self,self.Exit)
  111. SL:RegisterLUAEvent(LUA_EVENT_MONSTER_DIE, self.MonsterDie, self) --怪物死亡
  112. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_QUIT_DUPLICATE,self.RES_QUIT_SUCCESS,self)
  113. GUI:AddOnClickEvent(self.view.walkBtn,self,self.walkOnClick)
  114. GUI:AddOnClickEvent(self.view.HelpButton, self, self.OnClickHelpButton)
  115. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_BIG_SECRET_REALM_CLEARANCE_PANEL_INFO,self.RES_BIG_SECRET_REALM_CLEARANCE_PANEL_INFO,self)
  116. SL:RegisterLUAEvent(LUA_EVENT_LOGIN_MAP, self.LUA_EVENT_LOGIN_MAP, self) --登录进入地图
  117. end
  118. function this:UnRegistEvents()
  119. SL:UnRegisterLuaNetMsg(LuaMessageIdToClient.RES_BIG_SECRET_REALM_CLEARANCE_PANEL_INFO,self.RES_BIG_SECRET_REALM_CLEARANCE_PANEL_INFO,self)
  120. SL:UnRegisterLUAEvent(LUA_EVENT_LOGIN_MAP, self.LUA_EVENT_LOGIN_MAP, self)
  121. end
  122. function this:Exit()
  123. SL:CommonTipsMessage({ stringTblID=211, ui = self, sureBtnText = "确定", cancelBtnText = "取消",
  124. callback = self.ExitSure})
  125. end
  126. function this:ExitSure()
  127. InfoManager.copActivityInfo.hideTask = false
  128. SL:onLUAEvent(LUA_EVENT_SHOW_TASK)
  129. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_QUIT_DUPLICATE,this.configId)
  130. GUI:UIPanel_Close("dev/outui/BigSecretCopy/Panel/KLBigSecretCopyTask/KLBigSecretCopyTaskPanel")
  131. end
  132. function this:DelayExitSure()
  133. self.timer = SL:ScheduleOnce(3, function()
  134. self:ExitSure()
  135. end)
  136. end
  137. function this:StopTime1()
  138. if self.timer then
  139. SL:UnSchedule(self.timer)
  140. self.timer = nil
  141. end
  142. end
  143. function this:CloseOnclick()
  144. GUI:UIPanel_Close("dev/outui/ChallengeBoss/Panel/KLBigSecretCopyTask/KLBigSecretCopyTaskPanel")
  145. SL.ShowMainPanel()
  146. end
  147. function this:MonsterDie(_id,message)
  148. end
  149. function this:DieEnd(isDie,time)
  150. end
  151. function this:Close()
  152. self:StopTime1()
  153. self:UnRegistEvents()
  154. self.is_close = true
  155. if self.updateID then
  156. SL:UnSchedule(self.updateID)
  157. self.updateID = nil
  158. end
  159. self.is_open = false
  160. end
  161. function this:RES_QUIT_SUCCESS(id,message)
  162. ---@type cfg_rep_column
  163. local tbl = SL:GetConfig("cfg_rep",message,"id")
  164. if tbl.type == EActivityType.PrivilegeBoss then
  165. self.is_close = true
  166. InfoManager.copActivityInfo.hideTask = false
  167. self:CloseOnclick()
  168. end
  169. end
  170. function this:walkOnClick()
  171. if not self.monster_data then
  172. return
  173. end
  174. this.pos_monster_id = self.monster_data[1]
  175. local x = self.monster_data[3]
  176. local y = self.monster_data[4]
  177. this.map_id = SL:GetMetaValue(EMetaVarGetKey.MAP_ID)
  178. this.map_line = SL:GetMetaValue(EMetaVarGetKey.MAP_LINE)
  179. SL:Pathfinding(this.map_id, this.map_line, x, y,this.MonserPosEnd,this.pos_monster_id)
  180. end
  181. function this:MonserPosEnd(pos)
  182. --SL:StartOnHook(true,true)
  183. if pos and pos.x and pos.z then
  184. this.scheduleId = SL:ScheduleOnce(0.1, function()
  185. SL:Pathfinding( this.map_id, this.map_line, pos.x, pos.z,this.BossPointOnHook)
  186. end)
  187. else
  188. SL:StartOnHook(true,true,this.pos_monster_id)
  189. end
  190. end
  191. function this:BossPointOnHook()
  192. SL:StartOnHook(true,true,this.pos_monster_id)
  193. end
  194. function this:RES_BIG_SECRET_REALM_CLEARANCE_PANEL_INFO(_id,message)
  195. --SL:LogTable(message,true)
  196. GUI:UIPanel_Open("dev/outui/BigSecretCopy/Panel/KLBigSecretCopyReward/KLBigSecretCopyRewardPanel",nil,nil,message)
  197. end
  198. function this:GetTime(tims_n)
  199. local time_tab = SL:SecondToHMS(tims_n)
  200. local time_str = ""
  201. if time_tab.d and time_tab.d >0 then
  202. time_str = time_str ..time_tab.d .. "天 "
  203. end
  204. if time_tab.h and time_tab.h >0 then
  205. local hour = ""
  206. if time_tab.h < 10 then
  207. hour = "0"..time_tab.h
  208. else
  209. hour = tostring(time_tab.h)
  210. end
  211. time_str = time_str ..hour .. ":"
  212. end
  213. if time_tab.m and time_tab.m >0 then
  214. local hour = ""
  215. if time_tab.m < 10 then
  216. hour = "0"..time_tab.m
  217. else
  218. hour = tostring(time_tab.m)
  219. end
  220. time_str = time_str..hour .. ":"
  221. else
  222. time_str = time_str.."00:"
  223. end
  224. local s = ""
  225. if time_tab.s <10 then
  226. s= "0" .. time_tab.s
  227. else
  228. s= tostring(time_tab.s)
  229. end
  230. time_str = time_str ..s
  231. return time_str
  232. end
  233. --帮助页面
  234. function this:OnClickHelpButton()
  235. local helpCfg=SL:GetConfig("cfg_rule_text",19002)
  236. if helpCfg then
  237. SL:CommonStrTipsMessage({title =helpCfg.menutxt,str=helpCfg.location})
  238. end
  239. end
  240. function this:LUA_EVENT_LOGIN_MAP()
  241. local map_id = SL:GetMetaValue(EMetaVarGetKey.MAP_ID)
  242. local is_has = SL:HasConfigTwoKeys("cfg_rep",19001,map_id,"type","mapId")
  243. if not is_has then
  244. self:ExitSure()
  245. end
  246. end
  247. return this