You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 rivejä
1.4 KiB

  1. local Mahjong3DHuCardView = require("mj.luaScript.Common.3d.Mahjong3DHuCardView")
  2. local HuCardView_3d = class("HuCardView_3d", Mahjong3DHuCardView)
  3. function HuCardView_3d:ctor(...)
  4. HuCardView_3d.super.ctor(self, ...)
  5. end
  6. function HuCardView_3d:getHuCards(huCards, isClean)
  7. self._huCards = self._huCards or {};
  8. if isClean then
  9. self._huCards = {};
  10. end
  11. for k, v in ipairs(huCards or {}) do
  12. table.insert(self._huCards, v);
  13. end
  14. self:createHuCards(self._huCards)
  15. end
  16. function HuCardView_3d:refreshHuCardZOrder(huCardNodes)
  17. local viewId = self:getViewId()
  18. for k, mjCard in ipairs(huCardNodes or {}) do
  19. local col = k % 20 == 0 and 20 or k % 20 -- 列数,从右往左数
  20. local row = math.ceil(k / 20) -- 行数,从下往上
  21. local zorder = col
  22. if viewId == 1 then
  23. zorder = col
  24. elseif viewId == 2 then
  25. zorder = 10 - col
  26. zorder = zorder > 0 and -zorder or zorder
  27. if row >= 3 then
  28. row = row - 2
  29. end
  30. zorder = zorder + (row - 1) * 10
  31. elseif viewId == 4 then
  32. row = row % 2 == 0 and 2 or (row % 2)
  33. zorder = 10 - col
  34. zorder = zorder > 0 and -zorder or zorder
  35. zorder = zorder - (row - 1) * 10
  36. elseif viewId == 3 then
  37. zorder = 20 - col
  38. end
  39. mjCard:setLocalZOrder(zorder)
  40. end
  41. end
  42. return HuCardView_3d