UIFuncUnlockMgr.lua 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. local UIFuncUnlockMgr = class("UIFuncUnlockMgr")
  2. local ConditionJudge = require("Common/ConditionJudge")
  3. local lockLevels = {}
  4. local funcBtns = {}
  5. local curOpened = {}
  6. local loggedinLevelId = 10001
  7. local dir = Vector3.zero
  8. function UIFuncUnlockMgr:ctor()
  9. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.UI_FILLCONTENT_COMPELETED, self, self.FillContentCompeleted)
  10. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.UI_CLOSE_COMPELETED, self, self.UICloseCompeleted)
  11. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.UI_FUNCLOCK_OPEN_NTF, self, self.UINewLevelFuncOpen)
  12. ManagerContainer.LuaEventMgr:RegisterEvent(UIEventNames.UI_VIP_FUNCLOCK_OPEN_NTF, self, self.UIFuncOpen)
  13. self:InitLockLevels()
  14. end
  15. function UIFuncUnlockMgr:InitLockLevels()
  16. local cfgs = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgAllDatas()
  17. for _,v in pairs(cfgs) do
  18. if v.PrePose == 0 then
  19. local conds = v.UnlockCond
  20. if conds then
  21. for i = 1, #conds do
  22. local cond = conds[i]
  23. if cond then
  24. if cond[1] == Enum.TaskType.Level_Battle_Count then
  25. if not CommonUtil.EleInTable(cond[2], lockLevels) then
  26. lockLevels[#lockLevels + 1]= cond[2]
  27. end
  28. end
  29. end
  30. end
  31. end
  32. --for _,v1 in pairs(conds) do
  33. -- local conditionData = ManagerContainer.CfgMgr:GetCondDataById(v1)
  34. --
  35. -- local condition = conditionData.Condition
  36. -- if condition[1] == Enum.TaskType.Base_Level then
  37. --
  38. -- elseif condition[1] == Enum.TaskType.Level_Battle_Count then
  39. -- if not CommonUtil.EleInTable(condition[2], lockLevels) then
  40. -- lockLevels[#lockLevels + 1]= condition[2]
  41. -- end
  42. -- end
  43. --end
  44. end
  45. end
  46. end
  47. function UIFuncUnlockMgr:SaveNeedDisplayNewFuncStatus(status)
  48. local uid = ManagerContainer.DataMgr.UserData:GetUserId()
  49. UnityEngine.PlayerPrefs.SetInt(tostring(uid).."NewFunc", status and 1 or 0)
  50. end
  51. function UIFuncUnlockMgr:GetNeedDisplayNewFuncStatus()
  52. local uid = ManagerContainer.DataMgr.UserData:GetUserId()
  53. local result = UnityEngine.PlayerPrefs.GetInt(tostring(uid).."NewFunc", 0)
  54. return result == 1
  55. end
  56. function UIFuncUnlockMgr:SaveLockBubbleStatus(id, status)
  57. local uid = ManagerContainer.DataMgr.UserData:GetUserId()
  58. UnityEngine.PlayerPrefs.SetInt(tostring(uid).."LockBubble"..id, status and 1 or 0)
  59. end
  60. function UIFuncUnlockMgr:GetLockBubbleStatus(id)
  61. local uid = ManagerContainer.DataMgr.UserData:GetUserId()
  62. local result = UnityEngine.PlayerPrefs.GetInt(tostring(uid).."LockBubble"..id, 0)
  63. return result == 1
  64. end
  65. function UIFuncUnlockMgr:NeedOpenFuncCurLevelStart(levelId)
  66. return CommonUtil.EleInTable(levelId, lockLevels) and levelId >= loggedinLevelId
  67. end
  68. function UIFuncUnlockMgr:SetLoggedinLevelId(levelId)
  69. loggedinLevelId = levelId
  70. end
  71. function UIFuncUnlockMgr:FillContentCompeleted(wnd)
  72. local list = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataByUIId(wnd.uiData.id)
  73. for _,v in pairs(list) do
  74. self:InsertFuncController(wnd, v)
  75. end
  76. end
  77. function UIFuncUnlockMgr:InsertFuncController(wnd, data)
  78. if data.PrePose > 0 and (not CommonUtil.EleInTable(data.PrePose, curOpened) or CommonUtil.EleInTable(data.Id, curOpened)) then
  79. return
  80. end
  81. local target = CommonUtil.ParseUITargetPath(wnd, data.FuncEnterPath)
  82. if target == nil then return end
  83. if type(target) == "table" then
  84. target = target.gameObject
  85. end
  86. local conds = data.UnlockCond
  87. if not conds then return end
  88. local result = self:CheckConditionPassResult(data)
  89. local isLoggedinLevelId = false
  90. for _,cond in pairs(conds) do
  91. if cond[1] == Enum.TaskType.Level_Battle_Count then
  92. if result and loggedinLevelId == cond[2] and tonumber(cond[2]) ~= 10001 then
  93. isLoggedinLevelId = true
  94. end
  95. if not isLoggedinLevelId and tonumber(cond[2]) <= loggedinLevelId and tonumber(loggedinLevelId) ~= 10001 then
  96. curOpened[#curOpened + 1] = data.Id
  97. end
  98. end
  99. end
  100. --for _,v in pairs(conds) do
  101. -- local result1, condDsc, type = ConditionJudge:ConditionPassResult(v)
  102. -- cond = condDsc
  103. -- if result1 and type == Enum.TaskType.Level_Battle_Count and loggedinLevelId == condDsc then
  104. -- isLoggedinLevelId = true
  105. -- end
  106. -- if not result1 then
  107. -- result = false
  108. -- end
  109. --end
  110. local key ="self."..data.FuncEnterPath
  111. if funcBtns[wnd.uiData.id] == nil then
  112. funcBtns[wnd.uiData.id] = {}
  113. end
  114. local guideState = self:GetLockBubbleStatus(data.Id)
  115. if result == true then
  116. if funcBtns[wnd.uiData.id][key] == nil then
  117. if not guideState then
  118. target:SetActive(true)
  119. return
  120. elseif isLoggedinLevelId and not guideState then
  121. target:SetActive(true)
  122. return
  123. elseif not isLoggedinLevelId and CommonUtil.EleInTable(data.Id, curOpened) and not guideState then
  124. target:SetActive(true)
  125. return
  126. end
  127. else
  128. --if not guideState then
  129. -- target:SetActive(true)
  130. -- local parent = target.transform.parent
  131. -- local lock = target.transform:Find(target.name.."_lock")
  132. -- if lock == nil then
  133. -- lock = parent:Find(target.name.."_lock")
  134. -- end
  135. -- if lock then
  136. -- lock.gameObject:SetActive(false)
  137. -- end
  138. -- return
  139. --end
  140. end
  141. end
  142. if not data.Special then
  143. self:NormalLock(wnd, data, target, result, key, guideState, conds)
  144. else
  145. self:SpecialLock(wnd, data, target, result, key, guideState, conds)
  146. end
  147. end
  148. function UIFuncUnlockMgr:NormalLock(wnd, data, target, result, key, guideState, conds)
  149. local parent = target.transform.parent
  150. local lock = target.transform:Find(target.name.."_lock")
  151. target:SetActive(result or (not result and data.NeedDisplay))
  152. if result and not guideState then
  153. local parent = target.transform.parent
  154. local lock = target.transform:Find(target.name.."_lock")
  155. if lock == nil then
  156. lock = parent:Find(target.name.."_lock")
  157. end
  158. if lock then
  159. lock.gameObject:SetActive(false)
  160. end
  161. return
  162. end
  163. local go
  164. if lock == nil then
  165. lock = parent:Find(target.name.."_lock")
  166. end
  167. if lock == nil then
  168. local targetSize = target:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta
  169. go = UnityEngine.GameObject.New(target.name.."_lock")
  170. go.transform:SetParent(target.transform)
  171. go.transform.localPosition = Vector3.zero
  172. go.transform.localScale = Vector3.one
  173. local rectTrans = go:GetOrAddComponent(Enum.TypeInfo.RectTransform)
  174. rectTrans.sizeDelta = targetSize
  175. end
  176. if lock == nil and go ~= nil then
  177. lock = go.transform
  178. end
  179. if funcBtns[wnd.uiData.id][key] == nil then
  180. funcBtns[wnd.uiData.id][key] = {}
  181. end
  182. funcBtns[wnd.uiData.id][key]["target"] = target
  183. funcBtns[wnd.uiData.id][key]["data"] = data
  184. funcBtns[wnd.uiData.id][key]["lock"] = lock
  185. funcBtns[wnd.uiData.id][key]["needGuide"] = data.NeedGuide
  186. if not result and not guideState then
  187. self:SaveLockBubbleStatus(data.Id, data.NeedGuide)
  188. end
  189. if lock == nil or tolua.isnull(lock) then
  190. --LogError(data.Id.." has no lock target")
  191. return
  192. end
  193. local lockBtn = lock:Find("btn")
  194. local lockBubble = lock:Find("bubble")
  195. if lockBtn == nil then
  196. go = nil
  197. local targetSize = target:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta
  198. go = UnityEngine.GameObject.New("btn")
  199. go.transform:SetParent(lock.transform)
  200. go.transform.localPosition = Vector3.zero
  201. go.transform.localScale = Vector3.one
  202. local rectTrans = go:GetOrAddComponent(Enum.TypeInfo.RectTransform)
  203. rectTrans.sizeDelta = targetSize
  204. go:GetOrAddComponent(Enum.TypeInfo.CanvasRenderer)
  205. go:GetOrAddComponent(Enum.TypeInfo.UIRaycastNoDraw)
  206. go:GetOrAddComponent(Enum.TypeInfo.Button)
  207. end
  208. if lockBtn == nil and go ~= nil then
  209. lockBtn = go.transform
  210. end
  211. lockBtn.gameObject:SetActive(not result and data.NeedMask)
  212. if lockBubble == nil then
  213. go = nil
  214. local targetSize = target:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta
  215. go = UnityEngine.GameObject.New("bubble")
  216. go.transform:SetParent(lock.transform)
  217. go.transform.localPosition = Vector3.zero
  218. go.transform.localScale = Vector3.one
  219. local rectTrans = go:GetOrAddComponent(Enum.TypeInfo.RectTransform)
  220. rectTrans.sizeDelta = targetSize
  221. go:GetOrAddComponent(Enum.TypeInfo.UIRaycastNoDraw)
  222. go:GetOrAddComponent(Enum.TypeInfo.Button)
  223. end
  224. if lockBubble == nil and go ~= nil then
  225. lockBubble = go.transform
  226. end
  227. lockBubble.gameObject:SetActive(result and funcBtns[wnd.uiData.id][key]["needGuide"])
  228. local dscText = lockBubble:Find("Talk/bg/Text")
  229. if dscText ~= nil then
  230. local text = dscText:GetComponent(Enum.TypeInfo.Text)
  231. text.text = I18N.T(data.LockDsc)
  232. end
  233. lock.gameObject:SetActive((not result or (result and funcBtns[wnd.uiData.id][key]["needGuide"])) and data.NeedLock)
  234. if not result then
  235. local button1 = target:GetComponent(Enum.TypeInfo.Button)
  236. if button1 then
  237. local image = target:GetComponent(Enum.TypeInfo.Image)
  238. if image then
  239. image.raycastTarget = false
  240. end
  241. else
  242. button1 = target:GetComponent(Enum.TypeInfo.Toggle)
  243. if button1 then
  244. button1.graphic.raycastTarget = false
  245. end
  246. end
  247. if lockBtn then
  248. local button = lockBtn:GetComponent(Enum.TypeInfo.Button)
  249. if button == nil then
  250. button = lockBtn.gameObject:GetOrAddComponent(Enum.TypeInfo.Button)
  251. end
  252. wnd.uiBase:AddButtonUniqueEventListener(button, wnd, function (button, params)
  253. local result, val, content = self:CheckConditionPassResult(data)
  254. if not result then
  255. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(content..I18N.T(data.FunName)..I18N.T("Fun"))
  256. end
  257. end)
  258. end
  259. if lockBubble and funcBtns[wnd.uiData.id][key]["needGuide"] then
  260. local button = lockBubble:GetComponent(Enum.TypeInfo.Button)
  261. if button == nil then
  262. button = lockBubble.gameObject:GetOrAddComponent(Enum.TypeInfo.Button)
  263. end
  264. wnd.uiBase:AddButtonUniqueEventListener(button, wnd, function (button, params)
  265. if target then
  266. self:SaveLockBubbleStatus(data.Id, false)
  267. funcBtns[wnd.uiData.id][key] = nil
  268. target:SetActive(true)
  269. lock.gameObject:SetActive(false)
  270. curOpened[#curOpened + 1] = data.Id
  271. local button1 = target:GetComponent(Enum.TypeInfo.Button)
  272. if button1 then
  273. button1.onClick:Invoke()
  274. else
  275. button1 = target:GetComponent(Enum.TypeInfo.Toggle)
  276. button1.onValueChanged:Invoke(true)
  277. end
  278. local nextFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(data.PostPose)
  279. if nextFuncData and wnd.uiData.id == nextFuncData.UIId then
  280. self:InsertFuncController(wnd, nextFuncData)
  281. end
  282. end
  283. end)
  284. end
  285. else
  286. if lockBubble and funcBtns[wnd.uiData.id][key]["needGuide"] then
  287. local button = lockBubble:GetComponent(Enum.TypeInfo.Button)
  288. if button == nil then
  289. button = lockBubble.gameObject:GetOrAddComponent(Enum.TypeInfo.Button)
  290. end
  291. wnd.uiBase:AddButtonUniqueEventListener(button, wnd, function (button, params)
  292. if target then
  293. self:SaveLockBubbleStatus(data.Id, false)
  294. funcBtns[wnd.uiData.id][key] = nil
  295. local button1 = target:GetComponent(Enum.TypeInfo.Button)
  296. target:SetActive(true)
  297. lock.gameObject:SetActive(false)
  298. curOpened[#curOpened + 1] = data.Id
  299. if button1 then
  300. if button1.onClick then
  301. button1.onClick:Invoke()
  302. elseif button1.onValueChanged then
  303. button1.onValueChanged:Invoke(true)
  304. end
  305. end
  306. local nextFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(data.PostPose)
  307. if nextFuncData and wnd.uiData.id == nextFuncData.UIId then
  308. self:InsertFuncController(wnd, nextFuncData)
  309. end
  310. end
  311. end)
  312. end
  313. end
  314. end
  315. --只用于主城的建筑
  316. function UIFuncUnlockMgr:SpecialLock(wnd, data, target, result, key, guideState, conds)
  317. local function InitTitle(lock, targetButtonField, targetTitle, textContent)
  318. local title = lock.transform:Find("Title")
  319. title.transform.position = targetTitle.transform.position
  320. local titleText = title:Find("Text")
  321. titleText:GetComponent(Enum.TypeInfo.TextMeshProUGUI).text = textContent
  322. local rectSize = targetButtonField:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta
  323. local lockButtonField = lock.transform:Find("TargetBox")
  324. lockButtonField.transform.position = targetButtonField.transform.position
  325. lockButtonField:GetComponent(Enum.TypeInfo.RectTransform).sizeDelta = rectSize
  326. end
  327. local targetButtonField = target.transform:Find("TargetBox")
  328. local targetTitle = target.transform:Find("Title")
  329. local textContent = targetTitle:Find("Text"):GetComponent(Enum.TypeInfo.TextMeshProUGUI).text
  330. targetTitle.gameObject:SetActive(result or (not result and data.NeedDisplay))
  331. if result and not guideState then
  332. local lockBtn = target.transform:Find("LockbtnItem")
  333. if lockBtn then
  334. lockBtn.gameObject:SetActive(false)
  335. end
  336. local lockBubble = target.transform:Find("LockBubbleItem")
  337. if lockBubble then
  338. lockBubble.gameObject:SetActive(false)
  339. end
  340. return
  341. end
  342. local lockBtn = target.transform:Find("LockbtnItem")
  343. if not result and data.NeedMask then
  344. if lockBtn == nil then
  345. lockBtn = ManagerContainer.ResMgr:GetGoFromPool(Constants.UICommonPath, "LockbtnItem")
  346. lockBtn.name = "LockbtnItem"
  347. lockBtn.transform:SetParent(target.transform)
  348. lockBtn.transform.localPosition = Vector3.zero
  349. lockBtn.transform.localScale = Vector3.one
  350. InitTitle(lockBtn, targetButtonField, targetTitle, I18N.T(data.FunName))
  351. end
  352. local lockButton = lockBtn.gameObject:GetOrAddComponent(Enum.TypeInfo.Button)
  353. if lockButton then
  354. wnd.uiBase:AddButtonUniqueEventListener(lockButton, wnd, function (button, params)
  355. local result, val, content = self:CheckConditionPassResult(data)
  356. if not result then
  357. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(content..I18N.T(data.FunName)..I18N.T("Fun"))
  358. end
  359. end)
  360. end
  361. lockBtn.gameObject:SetActive(true)
  362. else
  363. if lockBtn then
  364. lockBtn.gameObject:SetActive(false)
  365. end
  366. end
  367. if funcBtns[wnd.uiData.id][key] == nil then
  368. funcBtns[wnd.uiData.id][key] = {}
  369. end
  370. funcBtns[wnd.uiData.id][key]["target"] = target
  371. funcBtns[wnd.uiData.id][key]["data"] = data
  372. funcBtns[wnd.uiData.id][key]["lockBtn"] = lockBtn
  373. funcBtns[wnd.uiData.id][key]["needGuide"] = data.NeedGuide
  374. if not result and not guideState then
  375. self:SaveLockBubbleStatus(data.Id, data.NeedGuide)
  376. end
  377. local lockBubble = target.transform:Find("LockBubbleItem")
  378. if result and funcBtns[wnd.uiData.id][key]["needGuide"] then
  379. if lockBubble == nil then
  380. lockBubble = ManagerContainer.ResMgr:GetGoFromPool(Constants.UICommonPath, "LockBubbleItem")
  381. lockBubble.name = "LockBubbleItem"
  382. lockBubble.transform:SetParent(target.transform)
  383. lockBubble.transform.localPosition = Vector3.zero
  384. lockBubble.transform.localScale = Vector3.one
  385. local canvas = lockBubble:GetComponent(Enum.TypeInfo.Canvas)
  386. if canvas then
  387. canvas.overrideSorting = true
  388. canvas.sortingOrder = Enum.UISibling[Enum.UIType.MAIN + 1] - 1
  389. end
  390. InitTitle(lockBubble, targetButtonField, targetTitle, I18N.T(data.FunName))
  391. local light = lockBubble.transform:Find("BtnLightItem")
  392. light.transform.position = targetTitle.transform.position
  393. local talk = lockBubble.transform:Find("Talk")
  394. local vec2 = data.DscPos and Vector2(data.DscPos[1], data.DscPos[2]) or Vector2.zero
  395. talk:GetComponent(Enum.TypeInfo.RectTransform).anchoredPosition = vec2
  396. local arrowUp = talk.transform:Find("bg/upArrow")
  397. local arrowDown = talk.transform:Find("bg/downArrow")
  398. local arrowLeft = talk.transform:Find("bg/leftArrow")
  399. local arrowRight = talk.transform:Find("bg/rightArrow")
  400. arrowUp.gameObject:SetActive(data.ArrowDir == 1)
  401. arrowDown.gameObject:SetActive(data.ArrowDir == 2)
  402. arrowLeft.gameObject:SetActive(data.ArrowDir == 3)
  403. arrowRight.gameObject:SetActive(data.ArrowDir == 4)
  404. local talkContent = talk.transform:Find("bg/Text")
  405. talkContent:GetComponent(Enum.TypeInfo.Text).text = I18N.T(data.LockDsc)
  406. end
  407. local lockButton = lockBubble.gameObject:GetOrAddComponent(Enum.TypeInfo.Button)
  408. if lockButton then
  409. wnd.uiBase:AddButtonUniqueEventListener(lockButton, wnd, function (button, params)
  410. if target then
  411. self:SaveLockBubbleStatus(data.Id, false)
  412. target:SetActive(true)
  413. local lockBtn = funcBtns[wnd.uiData.id][key]["lockBtn"]
  414. if lockBtn then
  415. lockBtn.gameObject:SetActive(false)
  416. end
  417. local lockBubble = funcBtns[wnd.uiData.id][key]["lockBubble"]
  418. if lockBubble then
  419. lockBubble.gameObject:SetActive(false)
  420. end
  421. targetTitle.gameObject:SetActive(true)
  422. curOpened[#curOpened + 1] = data.Id
  423. local button1 = target:GetComponent(Enum.TypeInfo.Button)
  424. if button1 then
  425. button1.onClick:Invoke()
  426. end
  427. local nextFuncData = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(data.PostPose)
  428. if nextFuncData and wnd.uiData.id == nextFuncData.UIId then
  429. self:InsertFuncController(wnd, nextFuncData)
  430. end
  431. funcBtns[wnd.uiData.id][key] = nil
  432. end
  433. end)
  434. end
  435. lockBubble.gameObject:SetActive(true)
  436. else
  437. if lockBubble then
  438. lockBubble.gameObject:SetActive(false)
  439. end
  440. end
  441. funcBtns[wnd.uiData.id][key]["lockBubble"] = lockBubble
  442. end
  443. function UIFuncUnlockMgr:UICloseCompeleted(wnd)
  444. if funcBtns[wnd.uiData.id] == nil then return end
  445. for k, v in pairs(funcBtns[wnd.uiData.id]) do
  446. v["target"] = nil
  447. --v["data"] = nil
  448. v["lock"] = nil
  449. v["lockBtn"] = nil
  450. v["lockBubble"] = nil
  451. end
  452. end
  453. ---通关关卡后的解锁通知
  454. function UIFuncUnlockMgr:UINewLevelFuncOpen(type)
  455. self:SaveNeedDisplayNewFuncStatus(true)
  456. self:UIFuncOpen(type)
  457. end
  458. function UIFuncUnlockMgr:UIFuncOpen(type)
  459. for k, v in pairs(funcBtns) do
  460. for k1,v1 in pairs(v) do
  461. if v1.target and not v1.data.IsOperations then
  462. local result = self:CheckConditionPassResult(v1.data)
  463. if result then
  464. v1.target:SetActive(true)
  465. local button1 = v1.target:GetComponent(Enum.TypeInfo.Button)
  466. if button1 then
  467. local image = v1.target:GetComponent(Enum.TypeInfo.Image)
  468. if image then
  469. image.raycastTarget = true
  470. end
  471. else
  472. button1 = v1.target:GetComponent(Enum.TypeInfo.Toggle)
  473. if button1 then
  474. button1.graphic.raycastTarget = true
  475. end
  476. end
  477. if not v1.data.Special then
  478. if v1.lock then
  479. local lockBtn = v1.lock:Find("btn")
  480. local lockBubble = v1.lock:Find("bubble")
  481. if lockBtn then
  482. lockBtn.gameObject:SetActive(false)
  483. end
  484. if lockBubble then
  485. lockBubble.gameObject:SetActive(v1["needGuide"])
  486. end
  487. v1.lock.gameObject:SetActive(v1["needGuide"] and v1.data.NeedLock)
  488. end
  489. else
  490. if v1.lock then
  491. local lockBtn = v1.lockBtn
  492. local lockBubble = v1.lockBubble
  493. if lockBtn then
  494. lockBtn.gameObject:SetActive(false)
  495. end
  496. if lockBubble then
  497. lockBubble.gameObject:SetActive(v1["needGuide"])
  498. end
  499. local targetTitle = v1.target.transform:Find("Title")
  500. targetTitle.gameObject:SetActive(not v1["needGuide"])
  501. end
  502. end
  503. if not v1["needGuide"] then
  504. curOpened[#curOpened + 1] = v1["data"].Id
  505. end
  506. v1["target"] = nil
  507. --v1["data"] = nil
  508. v1["lock"] = nil
  509. v1["lockBtn"] = nil
  510. v1["lockBubble"] = nil
  511. end
  512. end
  513. end
  514. end
  515. end
  516. function UIFuncUnlockMgr:GetTargetFuncLockStatus(wnd, target)
  517. if funcBtns[wnd.uiData.id] == nil then return false end
  518. for k, v in pairs(funcBtns[wnd.uiData.id]) do
  519. if v["target"] == target then
  520. return true
  521. end
  522. end
  523. return false
  524. end
  525. --获得是否已经解锁
  526. function UIFuncUnlockMgr:GetFuncLockStatusById(id, keepSrcContent)
  527. local data = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgDataById(id)
  528. if data == nil then
  529. return true
  530. end
  531. if data.PrePose > 0 and CommonUtil.EleInTable(data.PrePose, curOpened) and CommonUtil.EleInTable(data.Id, curOpened) then
  532. return false
  533. end
  534. local result, val, content = self:CheckConditionPassResult(data)
  535. if not result and content and not keepSrcContent then
  536. content = content..I18N.T(data.FunName)..I18N.T("Fun")
  537. end
  538. return result, val, content
  539. end
  540. function UIFuncUnlockMgr:GetNewFuncAndNearFuncByLevelId(levelId)
  541. self:SaveNeedDisplayNewFuncStatus(false)
  542. local newFuncs, nearFuncs, forceGuideList = ManagerContainer.CfgMgr:GetUIFuncUnLockCfgNewAndNearLevelId(levelId)
  543. return newFuncs, nearFuncs, forceGuideList
  544. end
  545. function UIFuncUnlockMgr:CheckConditionPassResult(data)
  546. local conds = data.UnlockCond
  547. if not conds then
  548. return true, 0, ''
  549. end
  550. local result, val, content
  551. if data.LuaCondition and data.LuaCondition ~= "" then
  552. result = false
  553. local luaCondition = require("FuncUnlockCondition/"..data.LuaCondition)
  554. if luaCondition.CheckCondition then
  555. result, val, content = luaCondition:CheckCondition(data)
  556. end
  557. else
  558. result = true
  559. local result1, val1, content1
  560. for i = 1, #conds do
  561. local cond = conds[i]
  562. if cond then
  563. result1, val1, content1 = ConditionJudge:ConditionPassResult1(cond)
  564. if not result1 then
  565. result = false
  566. if content1 and content1 ~= '' then
  567. val = val1
  568. content = content1
  569. break
  570. end
  571. end
  572. end
  573. end
  574. end
  575. return result, val, content
  576. end
  577. function UIFuncUnlockMgr:Clear()
  578. --self:AutoSaveBubbleLockState()
  579. funcBtns = nil
  580. lockLevels = nil
  581. curOpened = nil
  582. end
  583. function UIFuncUnlockMgr:AutoSaveBubbleLockState()
  584. for _,v in pairs(funcBtns) do
  585. for _,v1 in pairs(v) do
  586. self:SaveLockBubbleStatus(v1.data.Id, false)
  587. end
  588. end
  589. end
  590. function UIFuncUnlockMgr:Destroy()
  591. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.UI_FILLCONTENT_COMPELETED, self, self.FillContentCompeleted)
  592. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.UI_CLOSE_COMPELETED, self, self.UICloseCompeleted)
  593. ManagerContainer.LuaEventMgr:UnregisterEvent(UIEventNames.UI_FUNCLOCK_OPEN_NTF, self, self.UIFuncOpen)
  594. self:Clear()
  595. if tolua.getpeer(self) ~= nil then
  596. tolua.setpeer(self, nil)
  597. end
  598. end
  599. return UIFuncUnlockMgr