UIGuildWarMatchMapView.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. local UIGuildWarMatchMapView = require("UIGuildWar/UIGuildWarMatchMapView_Generate")
  2. local MatchMapState = Enum.GuildWarMatchMapState
  3. local SlotPoss =
  4. {
  5. Vector2(0, 200),
  6. Vector2(0, -160),
  7. Vector2(-266, 380),
  8. Vector2(266, 380),
  9. Vector2(-266, -355),
  10. Vector2(266, -355),
  11. Vector2(-402, 650),
  12. Vector2(-131, 650),
  13. Vector2(-402, -615),
  14. Vector2(-131, -615),
  15. Vector2(131, -615),
  16. Vector2(402, -615),
  17. Vector2(131, 650),
  18. Vector2(402, 650),
  19. }
  20. local HandleSlotPoss =
  21. {
  22. Vector2(0, 65),
  23. Vector2(0, 435),
  24. Vector2(0, -300),
  25. Vector2(-265, 705),
  26. Vector2(-265, -560),
  27. Vector2(265, -560),
  28. Vector2(265, 705),
  29. }
  30. local LoseNameBgColor = Color(0.47, 0.486, 0.596)
  31. local DefaultHandleBgColor = Color(0.333, 0.369, 0.455)
  32. local BattleHandleBgColor = Color(0.8, 0.259, 0.259)
  33. function UIGuildWarMatchMapView:OnAwake(data)
  34. self.controller = require("UIGuildWar/UIGuildWarMatchMapCtr"):new()
  35. self.controller:Init(self)
  36. self.controller:SetData(data)
  37. end
  38. function UIGuildWarMatchMapView:AddEventListener()
  39. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_WAR_MATCH_MAP_CHANGED, self, self.OnMatchMapChanged)
  40. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_WAR_OPEN_STATE_CHANGED, self, self.OnOpenStateChanged)
  41. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_ENTER_SUCCESS, self, self.OnGuildEnterSuccess)
  42. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_CREATE_SUCCESS, self, self.OnGuildCreateSuccess)
  43. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_DISBAND_SUCCESS, self, self.OnGuildDisBandSuccess)
  44. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_QUIT_SUCCESS, self, self.OnGuildQuitSuccess)
  45. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_KICKOUT_SUCCESS, self, self.OnGuildKickoutSuccess)
  46. end
  47. function UIGuildWarMatchMapView:FillContent(data, uiBase)
  48. self.uiBase = uiBase
  49. local gameObject = self.uiBase:GetRoot()
  50. if gameObject ~= nil then
  51. self.gameObject = gameObject
  52. self.transform = gameObject.transform
  53. end
  54. self:InitGenerate(self.transform, data)
  55. self:Init()
  56. end
  57. function UIGuildWarMatchMapView:Init()
  58. self:InitBaseSlots()
  59. self:InitSlots()
  60. self:InitCheckHandles()
  61. self:InitBattleHandles()
  62. self:RefreshMatchMap(true)
  63. end
  64. function UIGuildWarMatchMapView:RemoveEventListener()
  65. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  66. end
  67. function UIGuildWarMatchMapView:AddUIEventListener()
  68. self.uiBase:AddButtonUniqueEventListener(self.btnBack.button, self, self.OnClickBackBtn)
  69. self.uiBase:AddButtonUniqueEventListener(self.btnHelp.button, self, self.OnClickHelpBtn)
  70. self.uiBase:AddButtonUniqueEventListener(self.btnMatchShop.button, self, self.OnClickMatchShopBtn)
  71. end
  72. function UIGuildWarMatchMapView:OnHide()
  73. if self.refreshTimer then
  74. if self.refreshTimer.running then
  75. self.refreshTimer:Stop()
  76. end
  77. end
  78. end
  79. function UIGuildWarMatchMapView:OnShow(data)
  80. self.controller:SetData(data)
  81. self:RefreshMatchMap(true)
  82. end
  83. function UIGuildWarMatchMapView:OnClose()
  84. end
  85. function UIGuildWarMatchMapView:OnDispose()
  86. if self.refreshTimer then
  87. if self.refreshTimer.running then
  88. self.refreshTimer:Stop()
  89. end
  90. self.refreshTimer = nil
  91. end
  92. self:DisposeBaseSlots()
  93. self:DisposeSlots()
  94. self:DisposeCheckHandles()
  95. self:DisposeBattleHandles()
  96. self.controller:OnDispose()
  97. end
  98. function UIGuildWarMatchMapView:OnMatchMapChanged()
  99. self:RefreshMatchMap()
  100. end
  101. function UIGuildWarMatchMapView:OnOpenStateChanged(isOpen)
  102. if isOpen then return end
  103. self:UIClose()
  104. if self.uiBase.MSourceUIID > 0 then
  105. ManagerContainer.LuaUIMgr:Open(self.uiBase.MSourceUIID, nil, nil, false)
  106. end
  107. end
  108. function UIGuildWarMatchMapView:OnGuildEnterSuccess()
  109. self:RefreshMatchMap()
  110. end
  111. function UIGuildWarMatchMapView:OnGuildCreateSuccess()
  112. self:RefreshMatchMap()
  113. end
  114. function UIGuildWarMatchMapView:OnGuildDisBandSuccess()
  115. self:RefreshMatchMap()
  116. end
  117. function UIGuildWarMatchMapView:OnGuildQuitSuccess()
  118. self:RefreshMatchMap()
  119. end
  120. function UIGuildWarMatchMapView:OnGuildKickoutSuccess()
  121. self:RefreshMatchMap()
  122. end
  123. function UIGuildWarMatchMapView:OnClickBackBtn()
  124. self:UIClose()
  125. if self.uiBase.MSourceUIID > 0 then
  126. ManagerContainer.LuaUIMgr:Open(self.uiBase.MSourceUIID, nil, nil, false)
  127. end
  128. end
  129. function UIGuildWarMatchMapView:OnClickHelpBtn()
  130. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', 'GuildWarDiagramText'})
  131. end
  132. function UIGuildWarMatchMapView:OnClickMatchShopBtn()
  133. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildWarActivityShop)
  134. end
  135. function UIGuildWarMatchMapView:OnClickSlotItem(_, params)
  136. local id = params[0]
  137. if not id then return end
  138. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildInfo, id)
  139. end
  140. function UIGuildWarMatchMapView:OnClickBattleHandle(_, params)
  141. local idx = params[0]
  142. if idx then
  143. local matchMapData = self.controller:GetMatchMapData()
  144. if matchMapData and matchMapData:HasValid() then
  145. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildWar, idx)
  146. return
  147. end
  148. end
  149. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('GuildWarDiagram14')
  150. end
  151. function UIGuildWarMatchMapView:OnClickCheckHandle(_, params)
  152. local idx = params[0]
  153. if idx then
  154. local matchMapData = self.controller:GetMatchMapData()
  155. if matchMapData and matchMapData:HasValid() then
  156. local battleData = matchMapData:GetBattleDataById(idx)
  157. if battleData then
  158. if not battleData.id1 or battleData.id1 <= 0 then
  159. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam('GuildWarDiagram32', tostring(battleData.name2))
  160. return
  161. end
  162. if not battleData.id2 or battleData.id2 <= 0 then
  163. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam('GuildWarDiagram32', tostring(battleData.name1))
  164. return
  165. end
  166. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildWarRank, idx)
  167. return
  168. end
  169. end
  170. end
  171. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('GuildWarDiagram14')
  172. end
  173. function UIGuildWarMatchMapView:RefreshMatchMap(isFirst)
  174. local matchMapData = self.controller:GetMatchMapData()
  175. if matchMapData then
  176. local valid = matchMapData:HasValid()
  177. if valid then
  178. self.matchMap:SetActive(true)
  179. self.bottom:SetActive(true)
  180. self.btnMatchShop:SetActive(Constant.OpenPay or false)
  181. self:RefreshTimeList(matchMapData)
  182. self:RefreshBattles(matchMapData)
  183. else
  184. if isFirst then
  185. self.matchMap:SetActive(false)
  186. self.bottom:SetActive(false)
  187. self.btnMatchShop:SetActive(false)
  188. else
  189. self.matchMap:SetActive(true)
  190. self.bottom:SetActive(true)
  191. self.btnMatchShop:SetActive(Constant.OpenPay or false)
  192. self:RefreshTimeList(matchMapData)
  193. self:RefreshBattles(matchMapData)
  194. end
  195. end
  196. if not isFirst then
  197. local remainTime = matchMapData:GetNextRefreshRemainTime()
  198. if remainTime and remainTime > 0 then
  199. if self.refreshTimer then
  200. self.refreshTimer.time = remainTime
  201. self.refreshTimer.duration = remainTime
  202. self.refreshTimer.loop = 1
  203. else
  204. self.refreshTimer = Timer.New(slot(self.RefreshTimer, self), remainTime, 1)
  205. end
  206. if not self.refreshTimer.running then
  207. self.refreshTimer:Start()
  208. end
  209. else
  210. if self.refreshTimer and self.refreshTimer.running then
  211. self.refreshTimer:Stop()
  212. end
  213. end
  214. end
  215. else
  216. self.matchMap:SetActive(false)
  217. self.bottom:SetActive(false)
  218. self.btnMatchShop:SetActive(false)
  219. if self.refreshTimer and self.refreshTimer.running then
  220. self.refreshTimer:Stop()
  221. end
  222. end
  223. if isFirst then
  224. self.controller:SendGetGuildWarMatchMapReq()
  225. end
  226. end
  227. function UIGuildWarMatchMapView:RefreshTimer()
  228. if self.refreshTimer and self.refreshTimer.running then
  229. self.refreshTimer:Stop()
  230. end
  231. self.controller:SendGetGuildWarMatchMapReq()
  232. end
  233. function UIGuildWarMatchMapView:RefreshTimeList(matchMapData)
  234. local curMatchMapState = matchMapData.curMatchMapState
  235. self:RefreshTimeItem(self.matchTime1, curMatchMapState, MatchMapState.One, 'GuildWarDiagram7', 'GuildWarDiagram10')
  236. self:RefreshTimeItem(self.matchTime2, curMatchMapState, MatchMapState.Two, 'GuildWarDiagram8', 'GuildWarDiagram11')
  237. self:RefreshTimeItem(self.matchTime3, curMatchMapState, MatchMapState.Three, 'GuildWarDiagram9', 'GuildWarDiagram12')
  238. end
  239. function UIGuildWarMatchMapView:RefreshTimeItem(matchTime, curState, validState, nameLangKey, timeLangKey)
  240. matchTime.nameTxt.text.text = string.formatbykey(nameLangKey)
  241. if curState == validState then
  242. matchTime.bar.uIImageSwitchSprite:ChangeSprite(1)
  243. matchTime.title.uIImageSwitchSprite:ChangeSprite(1)
  244. matchTime.timeTxt.text.text = string.formatbykey(timeLangKey)
  245. elseif curState > validState then
  246. matchTime.bar.uIImageSwitchSprite:ChangeSprite(1)
  247. matchTime.title.uIImageSwitchSprite:ChangeSprite(0)
  248. matchTime.timeTxt.text.text = string.formatbykey('GuildWarDiagram13')
  249. else
  250. matchTime.bar.uIImageSwitchSprite:ChangeSprite(0)
  251. matchTime.title.uIImageSwitchSprite:ChangeSprite(0)
  252. matchTime.timeTxt.text.text = string.formatbykey(timeLangKey)
  253. end
  254. end
  255. function UIGuildWarMatchMapView:RefreshBattles(matchMapData)
  256. local battleData = nil
  257. local baseSlotOffset = 1
  258. local slotOffset = 1
  259. local checkHandleOffset = 1
  260. local battleHandleOffset = 1
  261. for i = 1, 7 do
  262. battleData = matchMapData:GetBattleDataById(i)
  263. self:RefreshLineItem(i, battleData)
  264. baseSlotOffset, slotOffset, checkHandleOffset, battleHandleOffset = self:RefreshBattle(i, battleData, baseSlotOffset, slotOffset, checkHandleOffset, battleHandleOffset)
  265. if i == 1 then
  266. if not battleData or battleData.state ~= 3 then
  267. self:RefreshSlotItem(self.championItem, nil, nil, nil, false, true)
  268. else
  269. if battleData.isWin then
  270. self:RefreshSlotItem(self.championItem, battleData.id1, battleData.name1, battleData.badge1, false, true)
  271. else
  272. self:RefreshSlotItem(self.championItem, battleData.id2, battleData.name2, battleData.badge2, false, true)
  273. end
  274. end
  275. end
  276. end
  277. if self.baseSlots and self.baseSlotNum then
  278. for i = baseSlotOffset, self.baseSlotNum do
  279. local baseSlot = self.baseSlots[i]
  280. if baseSlot then
  281. baseSlot:SetActive(false)
  282. end
  283. end
  284. end
  285. if self.slots and self.slotNum then
  286. for i = slotOffset, self.slotNum do
  287. local slot = self.slots[i]
  288. if slot then
  289. slot:SetActive(false)
  290. end
  291. end
  292. end
  293. if self.checkHandles and self.checkHandleNum then
  294. for i = checkHandleOffset, self.checkHandleNum do
  295. local checkHandle = self.checkHandles[i]
  296. if checkHandle and checkHandle.go then
  297. checkHandle.go:SetActive(false)
  298. end
  299. end
  300. end
  301. if self.battleHandles and self.battleHandleNum then
  302. for i = battleHandleOffset, self.battleHandleNum do
  303. local battleHandle = self.battleHandles[i]
  304. if battleHandle and battleHandle.go then
  305. battleHandle.go:SetActive(false)
  306. end
  307. end
  308. end
  309. end
  310. function UIGuildWarMatchMapView:RefreshLineItem(idx, battleData)
  311. local line = self['line' .. idx]
  312. if not line then return end
  313. if battleData then
  314. if battleData.state == 3 then
  315. if battleData.isWin then
  316. line.lineL:SetActive(true)
  317. line.lineR:SetActive(false)
  318. return
  319. else
  320. line.lineL:SetActive(false)
  321. line.lineR:SetActive(true)
  322. return
  323. end
  324. end
  325. end
  326. line.lineL:SetActive(false)
  327. line.lineR:SetActive(false)
  328. end
  329. function UIGuildWarMatchMapView:RefreshBattle(idx, battleData, baseSlotOffset, slotOffset, checkHandleOffset, battleHandleOffset)
  330. local posIdx = (idx - 1) * 2
  331. if not battleData or battleData.id1 <= 0 then
  332. local base = self:GetBaseSlot(baseSlotOffset)
  333. baseSlotOffset = baseSlotOffset + 1
  334. if base then
  335. base.transform.anchoredPosition = SlotPoss[posIdx + 1]
  336. base:SetActive(true)
  337. end
  338. else
  339. local slot = self:GetSlot(slotOffset)
  340. slotOffset = slotOffset + 1
  341. if slot then
  342. slot.transform.anchoredPosition = SlotPoss[posIdx + 1]
  343. slot:SetActive(true)
  344. self:RefreshSlotItem(slot, battleData.id1, battleData.name1, battleData.badge1, (battleData.state == 3 and not battleData.isWin or false))
  345. end
  346. end
  347. if not battleData or battleData.id2 <= 0 then
  348. local base = self:GetBaseSlot(baseSlotOffset)
  349. baseSlotOffset = baseSlotOffset + 1
  350. if base then
  351. base.transform.anchoredPosition = SlotPoss[posIdx + 2]
  352. base:SetActive(true)
  353. end
  354. else
  355. local slot = self:GetSlot(slotOffset)
  356. slotOffset = slotOffset + 1
  357. if slot then
  358. slot.transform.anchoredPosition = SlotPoss[posIdx + 2]
  359. slot:SetActive(true)
  360. self:RefreshSlotItem(slot, battleData.id2, battleData.name2, battleData.badge2, (battleData.state == 3 and battleData.isWin or false))
  361. end
  362. end
  363. if battleData then
  364. if battleData.state == 2 then
  365. local battleHandle = self:GetBattleHandle(battleHandleOffset)
  366. battleHandleOffset = battleHandleOffset + 1
  367. if battleHandle then
  368. local hasSelfGuild = (self.controller:IsSameGuild(battleData.id1) or self.controller:IsSameGuild(battleData.id2))
  369. if battleHandle.desBgImg then
  370. battleHandle.desBgImg.color = hasSelfGuild and BattleHandleBgColor or DefaultHandleBgColor
  371. end
  372. if battleHandle.desTxt then
  373. battleHandle.desTxt.text = string.formatbykey( hasSelfGuild and 'GuildWarDiagram3' or 'GuildWarDiagram2')
  374. end
  375. if battleHandle.trans then
  376. battleHandle.trans.anchoredPosition = HandleSlotPoss[idx]
  377. end
  378. if battleHandle.go then
  379. battleHandle.go:SetActive(true)
  380. end
  381. if battleHandle.button then
  382. self.uiBase:AddButtonUniqueEventListener(battleHandle.button, self, self.OnClickBattleHandle, idx)
  383. end
  384. end
  385. elseif battleData.state == 3 then
  386. local checkHandle = self:GetCheckHandle(checkHandleOffset)
  387. checkHandleOffset = checkHandleOffset + 1
  388. if checkHandle then
  389. if checkHandle.desTxt then
  390. checkHandle.desTxt.text = string.formatbykey('GuildWarDiagram4')
  391. end
  392. if checkHandle.trans then
  393. checkHandle.trans.anchoredPosition = HandleSlotPoss[idx]
  394. end
  395. if checkHandle.go then
  396. checkHandle.go:SetActive(true)
  397. end
  398. if checkHandle.button then
  399. self.uiBase:AddButtonUniqueEventListener(checkHandle.button, self, self.OnClickCheckHandle, idx)
  400. end
  401. end
  402. end
  403. end
  404. return baseSlotOffset, slotOffset, checkHandleOffset, battleHandleOffset
  405. end
  406. function UIGuildWarMatchMapView:RefreshSlotItem(itemLua, id, name, badge, isLose, isFirst)
  407. itemLua.badge.image.enabled = false
  408. itemLua.badge.image.sprite = nil
  409. if not id or id <= 0 then
  410. itemLua.guildFlag:SetActive(false)
  411. itemLua.nameTxt.text.text = string.formatbykey('GuildWarDiagram5')
  412. itemLua.tagMy:SetActive(false)
  413. itemLua.tagChamp:SetActive(true)
  414. itemLua.button.onClick:RemoveAllListeners()
  415. return
  416. end
  417. itemLua.guildFlag:SetActive(true)
  418. itemLua.nameTxt.text.text = tostring(name)
  419. if badge then
  420. local badgeCfgData = ManagerContainer.CfgMgr:GetGuildBadgeCfgById(badge)
  421. if badgeCfgData then
  422. CommonUtil.LoadIcon(self, badgeCfgData.Pic, function (sprite)
  423. if sprite then
  424. itemLua.badge.image.sprite = sprite
  425. itemLua.badge.image.enabled = true
  426. end
  427. end, itemLua, 'BadgeIconAsyncIdx')
  428. end
  429. end
  430. itemLua.loseTag:SetActive(isLose)
  431. if isFirst then
  432. itemLua.tagMy:SetActive(false)
  433. itemLua.tagChamp:SetActive(true)
  434. elseif self.controller:IsSameGuild(id) then
  435. itemLua.tagMy:SetActive(true)
  436. itemLua.tagChamp:SetActive(false)
  437. itemLua.nameBg.image.color = isLose and LoseNameBgColor or Color.white
  438. else
  439. itemLua.tagMy:SetActive(false)
  440. itemLua.tagChamp:SetActive(false)
  441. itemLua.nameBg.image.color = isLose and LoseNameBgColor or Color.white
  442. end
  443. self.uiBase:AddButtonUniqueEventListener(itemLua.button, self, self.OnClickSlotItem, id)
  444. end
  445. function UIGuildWarMatchMapView:GetBaseSlot(idx)
  446. local baseSlot = self.baseSlots[idx]
  447. if not baseSlot then
  448. if self.baseSlot then
  449. baseSlot = UnityEngine.GameObject.Instantiate(self.baseSlot)
  450. local baseSlotTrans = baseSlot.transform
  451. baseSlotTrans:SetParent(self.baseSlotParent.transform)
  452. baseSlotTrans.localPosition = Vector3.zero
  453. baseSlotTrans.localRotation = Quaternion.identity
  454. baseSlotTrans.localScale = Vector3(0.8, 0.8, 1)
  455. self.baseSlots[idx] = baseSlot
  456. if not self.baseSlotNum or self.baseSlotNum < idx then
  457. self.baseSlotNum = idx
  458. end
  459. end
  460. end
  461. return baseSlot
  462. end
  463. function UIGuildWarMatchMapView:InitBaseSlots()
  464. if not self.baseSlots then
  465. if not self.baseSlot then
  466. self.baseSlot = self.baseSlotParent.transform:Find('BaseSlot').gameObject
  467. self.baseSlot:SetActive(false)
  468. end
  469. self.baseSlotNum = 1
  470. self.baseSlots = {self.baseSlot}
  471. end
  472. end
  473. function UIGuildWarMatchMapView:DisposeBaseSlots()
  474. if self.baseSlots then
  475. for _, baseSlot in pairs(self.baseSlots) do
  476. if baseSlot and baseSlot ~= self.baseSlot then
  477. CommonUtil.DestroyGO(baseSlot)
  478. end
  479. end
  480. end
  481. self.baseSlot = nil
  482. self.baseSlotNum = nil
  483. end
  484. function UIGuildWarMatchMapView:GetSlot(idx)
  485. local slot = self.slots[idx]
  486. if not slot then
  487. if self.slots then
  488. local slotGo = UnityEngine.GameObject.Instantiate(self.guildWarMatchMapSlotItem.gameObject)
  489. local slotTrans = slotGo.transform
  490. slotTrans:SetParent(self.guildSlotParent.transform)
  491. slotTrans.localPosition = Vector3.zero
  492. slotTrans.localRotation = Quaternion.identity
  493. slotTrans.localScale = Vector3.one
  494. slot = CommonUtil.BindGridViewItem2Lua(self, 'GuildWarMatchMapSlotItem', slotGo)
  495. self.slots[idx] = slot
  496. if not self.slotNum or self.slotNum < idx then
  497. self.slotNum = idx
  498. end
  499. end
  500. end
  501. return slot
  502. end
  503. function UIGuildWarMatchMapView:InitSlots()
  504. if not self.slots then
  505. self.guildWarMatchMapSlotItem:SetActive(false)
  506. self.slotNum = 1
  507. self.slots = {self.guildWarMatchMapSlotItem}
  508. end
  509. end
  510. function UIGuildWarMatchMapView:DisposeSlots()
  511. if self.slots then
  512. for _, slot in pairs(self.slots) do
  513. if slot and slot ~= self.guildWarMatchMapSlotItem then
  514. local slotGo = slot.gameObject
  515. CommonUtil.ClearBindGridViewItem2Lua(self, 'GuildWarMatchMapSlotItem', slot.gameObject)
  516. CommonUtil.DestroyGO(slotGo)
  517. end
  518. end
  519. end
  520. self.slot = nil
  521. self.slotNum = nil
  522. end
  523. function UIGuildWarMatchMapView:GetCheckHandle(idx)
  524. local checkHandle = self.checkHandles[idx]
  525. if not checkHandle then
  526. if self.checkHandles then
  527. local go = UnityEngine.GameObject.Instantiate(self.checkHandle.go)
  528. local checkHandleTrans = go.transform
  529. checkHandle =
  530. {
  531. trans = checkHandleTrans,
  532. go = go,
  533. button = go:GetComponent(Enum.TypeInfo.Button),
  534. desTxt = checkHandleTrans:Find('Text'):GetComponent(Enum.TypeInfo.Text),
  535. }
  536. checkHandleTrans:SetParent(self.handleSlotParent.transform)
  537. checkHandleTrans.localPosition = Vector3.zero
  538. checkHandleTrans.localRotation = Quaternion.identity
  539. checkHandleTrans.localScale = Vector3.one
  540. self.checkHandles[idx] = checkHandle
  541. if not self.checkHandleNum or self.checkHandleNum < idx then
  542. self.checkHandleNum = idx
  543. end
  544. end
  545. end
  546. return checkHandle
  547. end
  548. function UIGuildWarMatchMapView:InitCheckHandles()
  549. if not self.checkHandles then
  550. if not self.checkHandle then
  551. local trans = self.handleSlotParent.transform:Find('BtnCheck')
  552. local go = trans.gameObject
  553. go:SetActive(false)
  554. self.checkHandle =
  555. {
  556. trans = trans,
  557. go = go,
  558. button = trans:GetComponent(Enum.TypeInfo.Button),
  559. desTxt = trans:Find('Text'):GetComponent(Enum.TypeInfo.Text),
  560. }
  561. end
  562. self.checkHandleNum = 1
  563. self.checkHandles = {self.checkHandle}
  564. end
  565. end
  566. function UIGuildWarMatchMapView:DisposeCheckHandles()
  567. if self.checkHandles then
  568. for _, checkHandle in pairs(self.checkHandles) do
  569. if checkHandle and checkHandle ~= self.checkHandle then
  570. local go = checkHandle.go
  571. checkHandle.trans = nil
  572. checkHandle.go = nil
  573. checkHandle.button = nil
  574. CommonUtil.DestroyGO(go)
  575. end
  576. end
  577. end
  578. self.checkHandle = nil
  579. self.checkHandleNum = nil
  580. end
  581. function UIGuildWarMatchMapView:GetBattleHandle(idx)
  582. local battleHandle = self.battleHandles[idx]
  583. if not battleHandle then
  584. if self.battleHandles then
  585. local go = UnityEngine.GameObject.Instantiate(self.battleHandle.go)
  586. local battleHandleTrans = go.transform
  587. battleHandle =
  588. {
  589. trans = battleHandleTrans,
  590. go = go,
  591. button = go:GetComponent(Enum.TypeInfo.Button),
  592. desBgImg = battleHandleTrans:Find('Button'):GetComponent(Enum.TypeInfo.Image),
  593. desTxt = battleHandleTrans:Find('Text'):GetComponent(Enum.TypeInfo.Text),
  594. }
  595. battleHandleTrans:SetParent(self.handleSlotParent.transform)
  596. battleHandleTrans.localPosition = Vector3.zero
  597. battleHandleTrans.localRotation = Quaternion.identity
  598. battleHandleTrans.localScale = Vector3.one
  599. self.battleHandles[idx] = battleHandle
  600. if not self.battleHandleNum or self.battleHandleNum < idx then
  601. self.battleHandleNum = idx
  602. end
  603. end
  604. end
  605. return battleHandle
  606. end
  607. function UIGuildWarMatchMapView:InitBattleHandles()
  608. if not self.battleHandles then
  609. if not self.battleHandle then
  610. local trans = self.handleSlotParent.transform:Find('BtnBattle')
  611. local go = trans.gameObject
  612. go:SetActive(false)
  613. self.battleHandle =
  614. {
  615. trans = trans,
  616. go = go,
  617. button = trans:GetComponent(Enum.TypeInfo.Button),
  618. desBgImg = trans:Find('Button'):GetComponent(Enum.TypeInfo.Image),
  619. desTxt = trans:Find('Text'):GetComponent(Enum.TypeInfo.Text),
  620. }
  621. end
  622. self.battleHandleNum = 1
  623. self.battleHandles = {self.battleHandle}
  624. end
  625. end
  626. function UIGuildWarMatchMapView:DisposeBattleHandles()
  627. if self.battleHandles then
  628. for _, battleHandle in pairs(self.battleHandles) do
  629. if battleHandle and battleHandle ~= self.battleHandle then
  630. local go = battleHandle.go
  631. battleHandle.trans = nil
  632. battleHandle.go = nil
  633. battleHandle.button = nil
  634. CommonUtil.DestroyGO(go)
  635. end
  636. end
  637. end
  638. self.battleHandle = nil
  639. self.battleHandleNum = nil
  640. end
  641. return UIGuildWarMatchMapView