源战役客户端
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.

219 line
7.1 KiB

  1. EquipToolTipsAttr = EquipToolTipsAttr or BaseClass(BaseItem)
  2. EquipToolTipsAttr.Height = 27
  3. local EquipToolTipsAttr = EquipToolTipsAttr
  4. function EquipToolTipsAttr:__init()
  5. self.base_file = "common"
  6. self.layout_file = "EquipToolTipsAttr"
  7. self.is_delay_callback = true
  8. self.attrType = EquipToolTips.AttrType.BaseAttr
  9. self.model = EquipModel:getInstance()
  10. self.height = 27
  11. self.item_height = 0
  12. self.attr_list = {}
  13. self.pos_data = {}
  14. self:Load()
  15. end
  16. function EquipToolTipsAttr:Load_callback()
  17. self.nodes = {
  18. "suit_con:obj","zhuoyue_con:obj","suit_con/suitText:tmp"
  19. ,"base_con:obj","attr_con:obj","title:tmp",
  20. }
  21. self:GetChildren(self.nodes)
  22. if self.need_refreshData then
  23. self:SetData(self.data)
  24. end
  25. self:InitEvent()
  26. end
  27. function EquipToolTipsAttr:InitEvent()
  28. -- local function clickHandler(target)
  29. -- if target == self.touch_obj then
  30. -- end
  31. -- end
  32. -- AddClickEvent(self.touch_obj, clickHandler,2)
  33. end
  34. function EquipToolTipsAttr:__delete()
  35. for k,v in pairs(self.attr_list) do
  36. v:DeleteMe()
  37. v = nil
  38. end
  39. self.attr_list = {}
  40. end
  41. function EquipToolTipsAttr:SetData(vo,attrType,value,equip_cfg,is_last,empower_lv)
  42. self.data = vo
  43. self.attrType = attrType or self.attrType
  44. self.value = value or self.value
  45. self.equip_cfg = equip_cfg or self.equip_cfg
  46. self.is_last = is_last or self.is_last
  47. self.empower_lv = empower_lv or self.empower_lv
  48. if self.is_loaded then
  49. self.need_refreshData = false
  50. else
  51. self.need_refreshData = true
  52. return
  53. end
  54. -- print("huangcong:EquipToolTipsAttr [start:56] self.data:", self.data)
  55. -- PrintTable(self.data)
  56. -- print("huangcong:EquipToolTipsAttr [end]")
  57. --基础属性
  58. if self.attrType == EquipToolTips.AttrType.BaseAttr then
  59. self.base_con_obj:SetActive(true)
  60. -- if self.value and self.value[1] and self.value[1] > 0 then
  61. -- self.base_strangthen_txt.text = string.format("<color=%s>(精炼+%s)</color>",ColorUtil.GREEN_DARK,self.value[1])
  62. -- else
  63. -- self.base_strangthen_txt.text = ""
  64. -- end
  65. self.title_tmp.text = "基础属性(基础+精炼)"
  66. self.item_class = EquipToolTipsBaseAttr
  67. --升星属性
  68. elseif self.attrType == EquipToolTips.AttrType.EvolutionAttr then
  69. self.base_con_obj:SetActive(true)
  70. self.item_class = EquipToolTipsBaseAttr
  71. self.title_tmp.text = "升星属性"
  72. -- self.base_strangthen_txt.text = string.format("<color=%s>(升星+%s)</color>",ColorUtil.GREEN_DARK,self.value)
  73. --高级属性
  74. elseif self.attrType == EquipToolTips.AttrType.ZhuoyueAttr then
  75. self.zhuoyue_con_obj:SetActive(true)
  76. self.item_class = EquipToolTipsZhuoYueAttr
  77. local level = 0
  78. for k,v in pairs(self.data) do
  79. if v and v[1] and v[1][1] then
  80. level = level + 1
  81. end
  82. end
  83. if self.value - level > 0 then--还有可升星的
  84. self.title_tmp.text = string.format("高级属性(剩余%s条可升星解锁)",self.value - level)
  85. else
  86. self.title_tmp.text ="高级属性"
  87. end
  88. --宝石属性
  89. elseif self.attrType == EquipToolTips.AttrType.GemstoneAttr then
  90. self.item_class = EquipToolTipsGemstoneAttr
  91. local new_gems_info = {}
  92. for i=1,3 do
  93. new_gems_info[i] = self.data[i] or {}
  94. end
  95. self.data = new_gems_info
  96. self.title_tmp.text = "宝石属性"
  97. --刻印属性
  98. elseif self.attrType == EquipToolTips.AttrType.DraconicAttr then
  99. self.item_class = EquipToolTipsDraconicAttr
  100. self.title_tmp.text = "刻印属性"
  101. --技能
  102. elseif self.attrType == EquipToolTips.AttrType.Skill then
  103. self.item_class = EquipToolTipsSkillAttr
  104. self.title_tmp.text = "技能"
  105. --套装属性
  106. elseif self.attrType == EquipToolTips.AttrType.SuitAttr then
  107. self.suit_con_obj:SetActive(true)
  108. self.item_class = EquipToolTipsSuitAttr
  109. local is_color_ok = self.value.is_color_ok or false
  110. if self.data[1] then
  111. local cur_suit_id_num,suit_equip_pos_list = self.value.cur_suit_id_num,self.value.suit_equip_pos_list
  112. -- suit_equip_pos_list = is_color_ok and suit_equip_pos_list or {}
  113. -- cur_suit_id_num = is_color_ok and cur_suit_id_num or 0
  114. local suit_str = nil
  115. for i,v in ipairs(self.data[1].suit_equip) do
  116. if i ~= EquipModel.EquipType.Guard then
  117. local equip_name = Config.ConfigEquipShow[v].name
  118. if not suit_str then
  119. suit_str = HtmlColorTxt(equip_name, not suit_equip_pos_list[v] and ColorUtil.GRAY_DARK or "#ffffff")
  120. else
  121. suit_str = suit_str.." "..HtmlColorTxt(equip_name, not suit_equip_pos_list[v] and ColorUtil.GRAY_DARK or "#ffffff")
  122. end
  123. end
  124. end
  125. self.suitText_tmp.text = suit_str
  126. --当前穿了几件套装相关
  127. local suit_num_str = ""
  128. local name = Trim(self.data[#self.data].name)
  129. if cur_suit_id_num then
  130. suit_num_str = string.format("%s/%s",cur_suit_id_num <= self.data[1].suit_num_max and cur_suit_id_num or self.data[1].suit_num_max,self.data[1].suit_num_max)
  131. -- suit_num_str = cur_suit_id_num > 0 and HtmlColorTxt(suit_num_str, ColorUtil.GREEN_DARK) or suit_num_str
  132. self.value = cur_suit_id_num
  133. for i,v in ipairs(self.data) do
  134. if cur_suit_id_num <= v.suit_num then
  135. name = Trim(v.name)
  136. end
  137. end
  138. else
  139. suit_num_str = "0/"..self.data[1].suit_num_max
  140. end
  141. self.title_tmp.text = string.format("%s(%s)%s", Trim(name),suit_num_str,not is_color_ok and HtmlColorTxt("橙品装备可激活", ColorUtil.RED_DARK) or "")
  142. local sort_func = function ( a, b )
  143. return a.suit_num < b.suit_num
  144. end
  145. table.sort(self.data, sort_func)
  146. end
  147. self.pos_data = {}
  148. local pos_value = 0
  149. for i,vo in ipairs(self.data) do
  150. if vo.stage_attr then
  151. pos_value = #vo.stage_attr + pos_value
  152. self.pos_data[i] = {#self.data,pos_value}
  153. end
  154. end
  155. elseif self.attrType == EquipToolTips.AttrType.EmpowerAttr then
  156. self.base_con_obj:SetActive(true)
  157. self.title_tmp.text = "升品属性"
  158. -- if self.empower_lv and self.empower_lv > 0 then
  159. -- self.base_strangthen_txt.text = string.format("<color=%s>(精炼+%s)</color>",ColorUtil.GREEN_DARK,self.empower_lv)
  160. -- else
  161. -- self.base_strangthen_txt.text = ""
  162. -- end
  163. self.item_class = EquipToolTipsBaseAttr
  164. end
  165. self:UpdateAttrList()
  166. end
  167. function EquipToolTipsAttr:UpdateAttrList( )
  168. if not self.item_class or not self.data then return end
  169. local data = self.data
  170. for k,v in pairs(self.attr_list) do
  171. v:SetVisible(true)
  172. end
  173. local y = 0
  174. local real_len = 0
  175. for i,v in ipairs(data) do
  176. local item = self.attr_list[i]
  177. if not item then
  178. item = self.item_class.New(self.attr_con)
  179. self.attr_list[i] = item
  180. if self.attrType == EquipToolTips.AttrType.SuitAttr then--装备套装要计算排版位置
  181. if i == 1 then
  182. y = 0
  183. else
  184. real_len = #v.attr+real_len
  185. y = -self.item_class.Height*real_len + 12*(i-1)
  186. end
  187. else
  188. y = -self.item_class.Height*(i - 1)
  189. end
  190. item:SetPosition(0, y)
  191. end
  192. if self.attrType == EquipToolTips.AttrType.EmpowerAttr then
  193. item:SetData(v, i, self.value, ColorUtil.RED_DARK)
  194. else
  195. item:SetData(v, i, self.value, self.pos_data[i])
  196. end
  197. item:SetVisible(true)
  198. end
  199. if self.attrType == EquipToolTips.AttrType.SuitAttr then--装备套装要计算排版位置
  200. else
  201. self.item_height = #data*self.item_class.Height
  202. end
  203. SetSizeDeltaY(self.transform,self.item_height + EquipToolTipsAttr.Height)
  204. if self.call_back and self.is_last then
  205. self.call_back()
  206. end
  207. end
  208. function EquipToolTipsAttr:SetCallBack( call_back )
  209. self.call_back = call_back
  210. end