NatureAttrItemCtr.lua 951 B

12345678910111213141516171819202122232425
  1. local NatureAttrItemCtr = {}
  2. function NatureAttrItemCtr:SetData(wnd, item, logicData)
  3. local attrId = logicData[1]
  4. local val1 = SDataUtil.InvConvert(logicData[2])
  5. local val2 = SDataUtil.InvConvert(logicData[3])
  6. local attrValue = attrId > 21 and CommonUtil.GetPreciseDecimalFloor(val1,3) or math.floor(val1)
  7. local addVal = attrId > 21 and CommonUtil.GetPreciseDecimalFloor(val2,3) or math.floor(val2)
  8. if attrValue <= 0.001 then
  9. attrValue = 0.001
  10. end
  11. item.numberGreen:SetActive(addVal > 0)
  12. item.text.uILocalizeScript:SetContent("Attr_" .. attrId)
  13. item.number.text.text = CommonUtil.HeroAttrFormatValue(attrId, attrValue, true)
  14. if addVal > 0 then
  15. item.numberGreen.text.text = CommonUtil.HeroAttrFormatValue(attrId, addVal, true)
  16. CommonUtil.SetTextColor(item.numberGreen.text, Constant.GreenColorText)
  17. end
  18. item.gameObject:SetActive(true)
  19. end
  20. return NatureAttrItemCtr