DemonGuildRankItemCtr.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. local DemonGuildRankItemCtr = {}
  2. function DemonGuildRankItemCtr:SetData(wnd, item, logicData, enterType)
  3. local harmValue = logicData.damage or 0
  4. local rank = logicData.rank or 0
  5. item.rankTxt:SetActive(rank == 0 or rank > 3)
  6. item.rank1:SetActive(rank == 1)
  7. item.rank2:SetActive(rank == 2)
  8. item.rank3:SetActive(rank == 3)
  9. local PlayerInfoMaxLimit = GlobalConfig.Instance:GetConfigIntValue(338) or 50
  10. if rank <= 0 or rank > PlayerInfoMaxLimit then
  11. item.rankTxt.text.text = I18N.SetLanguageValue('NoRank')
  12. else
  13. item.rankTxt.text.text = tostring(rank)
  14. end
  15. item.number.text.text = CommonUtil.FormatNumber(harmValue)
  16. local demonId = ManagerContainer.DataMgr.GuildDemonData:GetdemonId()
  17. local demonData = ManagerContainer.CfgMgr:GetGuildDemonCfgCfgById(demonId)
  18. if not demonData then
  19. return
  20. end
  21. local totalHarm = harmValue
  22. local currScore = 1
  23. local HarmSection = CommonUtil.DeserializeGlobalStrToNumberTable(demonData.DamageSegment)
  24. if HarmSection and #HarmSection > 0 then
  25. if totalHarm > HarmSection[#HarmSection][2] then
  26. currScore = HarmSection[#HarmSection][1]
  27. else
  28. for i = 1, #HarmSection - 1 do
  29. local lastvalue = HarmSection[i][2]
  30. local nextvalue = HarmSection[i][3]
  31. if totalHarm >= lastvalue and totalHarm <= nextvalue then
  32. currScore = HarmSection[i][1]
  33. break
  34. end
  35. end
  36. end
  37. end
  38. local scoreList = CommonUtil.DeserializeGlobalStrToTable(demonData.ScorePic)
  39. if currScore > 0 and currScore <= #scoreList then
  40. local scoreIcon = scoreList and scoreList[currScore] or ""
  41. item.iconScore:SetActive(true)
  42. CommonUtil.LoadIcon(wnd, scoreIcon , function (sprite)
  43. item.iconScore.image.sprite = sprite
  44. end)
  45. else
  46. item.iconScore:SetActive(false)
  47. end
  48. local brief = logicData.brief
  49. if brief then
  50. local badgeCfgData = ManagerContainer.CfgMgr:GetGuildBadgeCfgById(brief.guild_badge)
  51. local badgeResPath = nil
  52. if badgeCfgData then
  53. badgeResPath = badgeCfgData.Pic
  54. end
  55. CommonUtil.LoadIcon(wnd, badgeResPath, function(sprite)
  56. item.flag.image.sprite = sprite
  57. end, item, 'BadgeIcon')
  58. item.lvTxt.text.text = "LV."..brief.guild_level
  59. item.guildName.text.text = brief.guild_name
  60. end
  61. end
  62. return DemonGuildRankItemCtr