CardItemCtr.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. local CardItemCtr = {}
  2. local ConditionJudge = require("Common/ConditionJudge")
  3. function CardItemCtr:SetData(wnd, item, logicData, enterType)
  4. local cfgId = logicData.cfgId
  5. local condition = logicData.condition
  6. local result, val, content = ConditionJudge:ConditionPassResult1(condition)
  7. item.attrBg:SetActive(result and cfgId > 0)
  8. item.owned:SetActive(result and cfgId > 0)
  9. item.unowned:SetActive(result and cfgId == 0)
  10. item.locked:SetActive(not result)
  11. item.noCard:SetActive(result and cfgId == 0)
  12. item.lvLocked:SetActive(not result)
  13. item.nameTextNormal:SetActive(false)
  14. item.nameTextMini:SetActive(false)
  15. item.nameTextMVP:SetActive(false)
  16. item.grid:SetActive(cfgId > 0)
  17. item.notice:SetActive(enterType ~= Enum.ItemIEnterType.HeroEquip)
  18. if cfgId == 0 then
  19. if not result then
  20. item.lvLocked.text.text = content
  21. end
  22. else
  23. local cardData = ManagerContainer.CfgMgr:GetCardDataById(cfgId)
  24. item.nameTextNormal:SetActive(cardData.CardType == Enum.CardType.NORMAL)
  25. item.nameTextMini:SetActive(cardData.CardType == Enum.CardType.MINIBOSS)
  26. item.nameTextMVP:SetActive(cardData.CardType == Enum.CardType.MVP)
  27. if cardData.CardType == Enum.CardType.NORMAL then
  28. item.nameTextNormal.uILocalizeScript:SetContent(cardData.CardName)
  29. elseif cardData.CardType == Enum.CardType.MINIBOSS then
  30. item.nameTextMini.uILocalizeScript:SetContent(cardData.CardName)
  31. elseif cardData.CardType == Enum.CardType.MVP then
  32. item.nameTextMVP.uILocalizeScript:SetContent(cardData.CardName)
  33. end
  34. local idx = 0
  35. for _,v in pairs(CommonUtil.DeserializeCfgItemList(cardData.Attribute1)) do
  36. idx = idx + 1
  37. CommonUtil.BatchCreateItemsLoopSpawnPrefab(wnd, Enum.PrefabNames.CardAttrItem, item.grid.transform, v, idx)
  38. end
  39. end
  40. end
  41. return CardItemCtr