源战役客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

417 lignes
13 KiB

  1. --只显示装备信息的tips, 可与showiconitem搭配使用
  2. EquipShowTips = EquipShowTips or BaseClass(EquipToolTips)
  3. EquipShowTips.ONLY_SHOW = 0 --只展示信息
  4. EquipShowTips.COMPOSE_OFF = 1 --显示卸下按钮,点击移除合成物品
  5. EquipShowTips.EQUIP_RECOMMAND_TARGET = 2 --显示合成装备的推荐属性
  6. function EquipShowTips:__init()
  7. self.base_file = "common"
  8. self.layout_file = "EquipToolTips"
  9. self.layer_name = "Top"
  10. self.use_background = true
  11. self.click_bg_toClose = true
  12. self.close_mode = CloseMode.CloseDestroy
  13. self.destroy_imm = true
  14. self.dynamic = nil
  15. self.is_show_btn = false
  16. --self:AddPreLoadList("common_asset",{"star", "com_blackstar"},LuaResManager.RES_TYPE.SPRITE)
  17. self.star_list = {}
  18. self.item_list = {}
  19. self.fumo_item_list = {}
  20. self.stone_item_list = {}
  21. self.load_callback = function ()
  22. self:LoadSuccess()
  23. end
  24. self.open_callback = function ()
  25. self:SetData(self.dynamic)
  26. end
  27. self.close_callback = function ()
  28. end
  29. self.destroy_callback = function ()
  30. self:Remove()
  31. end
  32. end
  33. --[[
  34. dynamic: table
  35. type:
  36. ych#callback:
  37. ]]
  38. function EquipShowTips:Open(dynamic, x, y, type, callback)
  39. self.dynamic = dynamic
  40. self.type = type
  41. self.pos_x = x
  42. self.pos_y = y
  43. self.off_callback = callback
  44. BaseView.Open(self)
  45. end
  46. function EquipShowTips:Remove()
  47. if self.icon_item then
  48. self.icon_item:DeleteMe()
  49. self.icon_item = nil
  50. end
  51. for i,v in ipairs(self.item_list) do
  52. v:DeleteMe()
  53. v = nil
  54. end
  55. self.item_list = {}
  56. if self.compareTips then
  57. self.compareTips:DeleteMe()
  58. end
  59. for i,v in ipairs(self.stone_item_list) do
  60. v:DeleteMe()
  61. v = nil
  62. end
  63. self.stone_item_list = {}
  64. for i,v in ipairs(self.fumo_item_list) do
  65. v:DeleteMe()
  66. v = nil
  67. end
  68. self.fumo_item_list = {}
  69. self:DeleteArrowTip()
  70. if self.addNumComponent then
  71. if self.change_count_id then
  72. self.addNumComponent:UnBind(self.change_count_id)
  73. self.change_count_id = nil
  74. end
  75. self.addNumComponent:DeleteMe()
  76. self.addNumComponent = nil
  77. end
  78. end
  79. function EquipShowTips:InitEvent()
  80. local function onBtnClickHandler(target)
  81. if target == self.takeBtn then
  82. if self.off_callback ~= nil then
  83. self.off_callback()
  84. else
  85. if self.type == EquipShowTips.COMPOSE_OFF then
  86. ComposeModel:getInstance():Fire(ComposeEvent.COMPOSE_GOODS_OFF, self.dynamic.goods_id)
  87. --为了兼容神装打造,取出装备
  88. EquipModel:getInstance():Fire(ComposeEvent.COMPOSE_GOODS_OFF, self.dynamic.goods_id)
  89. end
  90. end
  91. end
  92. self:Close()
  93. end
  94. AddClickEvent(self.takeBtn, onBtnClickHandler)
  95. end
  96. function EquipShowTips:SetData(dynamic)
  97. self.dynamic = dynamic
  98. self.goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.dynamic.type_id)
  99. if self.dynamic == nil or self.goods_vo == nil then
  100. return print("EquipShowTips里面没有物品数据")
  101. end
  102. self.show_compare_tips, self.have_equip_data = EquipModel:getInstance():ShowCompareTips(self.goods_vo.goods_id, self.goods_vo.equip_type)
  103. if self.show_compare_tips then
  104. self.compare_conta.gameObject:SetActive(true)
  105. self.compareTips = self.compareTips or EquipCompareTips.New(self.compare_conta, nil, self.layer_name)
  106. self.compareTips:SetData(self.have_equip_data)
  107. else
  108. self.compare_conta.gameObject:SetActive(false)
  109. end
  110. local mainVo = RoleManager.Instance.mainRoleInfo
  111. local color_str = ColorUtil.WHITE
  112. if self.goods_vo.level > mainVo.level then
  113. color_str = ColorUtil.RED
  114. end
  115. self.level.text = "<color='#ffc12c'>" .. self.goods_vo.level .. "</color>"
  116. -- local index = Config.ConfigEquipShow[self.goods_vo.equip_type].index
  117. self.equip_pos.text = WordManager:GetEquipStyleStr(self.goods_vo.equip_type)
  118. self.fight.text = self.goods_vo.combat_power or 0
  119. if (self.goods_vo.career_id == 0 or mainVo.career == self.goods_vo.career_id) and (self.goods_vo.sex == 0 or self.goods_vo.sex == mainVo.sex) and self.goods_vo.turn <= mainVo.turn then
  120. color_str = "#ffc12c"
  121. else
  122. color_str = ColorUtil.RED
  123. end
  124. local career_name = WordManager:GetRoleCareerName(self.goods_vo.career_id,self.goods_vo.turn)
  125. self.career.text = "<color="..color_str..">" .. career_name .. "</color>"
  126. -- self:CreateStar(8)
  127. self.depot_conta.gameObject:SetActive(false)
  128. local stren = ""
  129. self.dynamic.stren = self.dynamic.stren or 0
  130. if self.dynamic.stren > 0 then
  131. stren = "+" .. self.dynamic.stren
  132. end
  133. self.nameText.text = "<color="..WordManager.GetGoodsColor(self.goods_vo.color)..">" .. WordManager:GetEquipPrefix(self.dynamic.prefix,"·") .. self.goods_vo.goods_name .. stren .. "</color>"
  134. local step_str = WordManager:GetEquipStepNum(self.dynamic.type_id)
  135. self.step_num.text = "<color="..WordManager.GetGoodsColor(self.goods_vo.color)..">" .. step_str .. "</color>"
  136. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id)
  137. if self.dynamic.color then
  138. lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..self.dynamic.color)
  139. elseif basic then
  140. lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..basic.color)
  141. end
  142. self.icon_item:SetData(self.goods_vo)
  143. self.equip_score.text = self:GetEquipScore(self.goods_vo.type_id) --self.dynamic.rating
  144. self.composite_score.text = self:GetFightList(self.dynamic,basic) --self.dynamic.overall_rating or self.dynamic.rating
  145. if basic then
  146. local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
  147. self:SetProperty(base_pro, self.dynamic.stren, basic.equip_type)
  148. self.fight.text = self.dynamic.combat_power or 0
  149. end
  150. self:SetAddProperty(self.dynamic)
  151. self:SetWashProperty(self.dynamic)
  152. self:SetSpiritProperty(self.dynamic)
  153. if self.dynamic.suit_lv and self.dynamic.suit_lv > 0 then
  154. self:SetSuitProperty(self.dynamic, self.goods_vo.equip_type)
  155. end
  156. if self.dynamic.awakening_lv and self.dynamic.awakening_lv > 0 then
  157. self:SetWakeProperty(self.dynamic)
  158. end
  159. if self.dynamic.equip_skill_lv and self.dynamic.equip_skill_lv > 0 then
  160. self:SetMagicSKill(self.dynamic)
  161. end
  162. self:SetSellState(self.dynamic.sell, self.dynamic.price_type, self.dynamic.type_id)
  163. self:Refresh()
  164. end
  165. --按钮显示
  166. function EquipShowTips:SetBtns()
  167. for i,v in ipairs(self.btn_list) do
  168. v:SetActive(false)
  169. end
  170. local btn_list = {}
  171. if self.type == EquipShowTips.COMPOSE_OFF then
  172. table.insert(btn_list, self.takeBtn)
  173. end
  174. for i,v in ipairs(btn_list) do
  175. v:SetActive(true)
  176. end
  177. self.btn_conta.sizeDelta = Vector2(self.btn_conta.sizeDelta.x, #btn_list * 53)
  178. --[[local pos_y = self.layout.sizeDelta.y - self.btn_conta.sizeDelta.y + 20
  179. --prefab做了自适应处理,固定在底部就行了
  180. if self.goods_vo.type==10 and self.goods_vo.subtype==11 then
  181. self.btn_conta.transform.anchoredPosition = Vector3(self.btn_conta.transform.anchoredPosition.x, -401, 0)
  182. else
  183. self.btn_conta.anchoredPosition = Vector2(self.btn_conta.transform.anchoredPosition.x, -600 + self.stren_y + 20)
  184. end--]]
  185. end
  186. --刷新相关控件的位置
  187. function EquipShowTips:Refresh()
  188. if self.dynamic then
  189. self:RefreshPosAndSize(self.dynamic)
  190. self:SetRootPos()
  191. self:SetBtns()
  192. end
  193. end
  194. function EquipShowTips:GetFightList( dynamic,basic)
  195. local list = {}
  196. if basic then
  197. --基础属性
  198. local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
  199. for i,v in ipairs(base_pro) do
  200. table.insert(list,{attr_id = v[1],attr_val = v[2]})
  201. end
  202. local equip_cfg = Config.Equipattr[basic.type_id]
  203. if equip_cfg then
  204. local parse_list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
  205. if parse_list and #parse_list > 0 then
  206. for i,v in ipairs(parse_list) do
  207. table.insert(list,{attr_id = tonumber(v[2]),attr_val = tonumber(v[3])})
  208. end
  209. end
  210. end
  211. end
  212. if dynamic.equip_extra_attr then
  213. --极品属性
  214. for i,v in ipairs(dynamic.equip_extra_attr) do
  215. table.insert(list,{attr_id = v.attr_id,attr_val = v.attr_val})
  216. end
  217. end
  218. local stren_config = EquipModel:getInstance():GetStrengthConfig(basic.equip_type, dynamic.stren)
  219. if stren_config and Trim(stren_config.attr_list) ~= "[]" then
  220. pro_list = ErlangParser:GetInstance():Parse(stren_config.attr_list)
  221. for i,v in ipairs(pro_list) do
  222. table.insert(list,{attr_id = v[1],attr_val = v[2]})
  223. end
  224. end
  225. local temp_attr_id,temp_attr_val
  226. --说明之前有装备
  227. local base_attr_list = {
  228. [1] = 0,
  229. [2] = 0,
  230. [3] = 0,
  231. [4] = 0,
  232. [5] = 0,
  233. [6] = 0,
  234. [7] = 0,
  235. [8] = 0,
  236. }
  237. local wear_equip = GoodsModel:getInstance().wear_equip_dic[dynamic.goods_id]
  238. if wear_equip == nil then
  239. --要先减去当前穿的,然后加上要替换的基础属性跟魂火属性
  240. if self.show_compare_tips then
  241. --print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.穿戴id ",self.have_equip_data.type_id)
  242. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.have_equip_data.type_id)
  243. if basic then
  244. local list = ErlangParser:GetInstance():Parse(basic.base_attrlist)
  245. if list and #list > 0 then
  246. for index,data in ipairs(list) do
  247. temp_attr_id = tonumber(data[1])
  248. if base_attr_list[temp_attr_id] then
  249. base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] - tonumber(data[2])
  250. -- print("当前减去穿戴基础属性 ",temp_attr_id,tonumber(data[2]))
  251. end
  252. end
  253. end
  254. end
  255. local equip_cfg = Config.Equipattr[self.have_equip_data.type_id]
  256. if equip_cfg then
  257. local list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
  258. if list and #list > 0 then
  259. for index,data in ipairs(list) do
  260. temp_attr_id = tonumber(data[2])
  261. if base_attr_list[temp_attr_id] then
  262. base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] - tonumber(data[3])
  263. -- print("当前减去魂火基础属性 ",temp_attr_id,tonumber(data[3]))
  264. end
  265. end
  266. end
  267. end
  268. end
  269. --加上要替换的基础属性跟魂火属性
  270. if basic then
  271. --print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.替换id ",basic.type_id)
  272. local list = ErlangParser:GetInstance():Parse(basic.base_attrlist)
  273. if list and #list > 0 then
  274. for index,data in ipairs(list) do
  275. temp_attr_id = tonumber(data[1])
  276. if base_attr_list[temp_attr_id] then
  277. base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] + tonumber(data[2])
  278. --print("当前加上替换基础属性 ",temp_attr_id,tonumber(data[2]))
  279. end
  280. end
  281. end
  282. local equip_cfg = Config.Equipattr[basic.type_id]
  283. if equip_cfg then
  284. local list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
  285. if list and #list > 0 then
  286. for index,data in ipairs(list) do
  287. temp_attr_id = tonumber(data[2])
  288. if base_attr_list[temp_attr_id] then
  289. base_attr_list[temp_attr_id] = base_attr_list[temp_attr_id] + tonumber(data[3])
  290. -- print("当前加上替换魂火属性 ",temp_attr_id,tonumber(data[3]))
  291. end
  292. end
  293. end
  294. end
  295. end
  296. end
  297. local AllProList = {}
  298. local tempList = {}
  299. local mainVo = RoleManager.Instance.mainRoleInfo
  300. for i,v in ipairs(list) do
  301. local cfg = Config.ConfigAttributeAddition[v.attr_id]
  302. if cfg then
  303. --print("人物当前最基础属性 ",v.attr_id,mainVo[cfg.baseAttrVo] )
  304. local val = v.attr_val * (mainVo[cfg.baseAttrVo] + (base_attr_list[cfg.baseAttr] or 0)) / 10000
  305. table.insert(tempList,{attr_id = cfg.baseAttr,attr_val = val})
  306. else
  307. table.insert(AllProList,v)
  308. end
  309. end
  310. for i,v in ipairs(tempList) do
  311. table.insert(AllProList,v)
  312. end
  313. local endList = {}
  314. for i,v in ipairs(AllProList) do
  315. table.insert(endList,{[1] = v.attr_id,[2] = v.attr_val})
  316. end
  317. return GetFighting(endList)
  318. end
  319. function EquipShowTips:GetEquipScore(type_id)
  320. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
  321. local score = 0
  322. local dict = {}
  323. if basic then
  324. --基础属性
  325. local attr_id
  326. local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist)
  327. for i,v in ipairs(base_pro) do
  328. attr_id = tonumber(v[1])
  329. if dict[attr_id] then
  330. dict[attr_id] = dict[attr_id] + tonumber(v[2])
  331. else
  332. dict[attr_id] = tonumber(v[2])
  333. end
  334. end
  335. end
  336. local equip_cfg = Config.Equipattr[type_id]
  337. if equip_cfg then
  338. local parse_list = ErlangParser:GetInstance():Parse(equip_cfg.extra_attr)
  339. if parse_list and #parse_list > 0 then
  340. for i,v in ipairs(parse_list) do
  341. attr_id = tonumber(v[2])
  342. if dict[attr_id] then
  343. dict[attr_id] = dict[attr_id] + tonumber(v[3])
  344. else
  345. dict[attr_id] = tonumber(v[3])
  346. end
  347. end
  348. end
  349. parse_list = ErlangParser:GetInstance():Parse(equip_cfg.recommend_attr)
  350. if parse_list and #parse_list > 0 then
  351. for i,v in ipairs(parse_list) do
  352. attr_id = tonumber(v[2][2])
  353. if dict[attr_id] then
  354. dict[attr_id] = dict[attr_id] + tonumber(v[2][3])
  355. else
  356. dict[attr_id] = tonumber(v[2][3])
  357. end
  358. end
  359. end
  360. local config
  361. for key,value in pairs(dict) do
  362. config = Config.Equipattrrating[key .. "@" .. equip_cfg.stage]
  363. if config then
  364. score = score + value * config.rating
  365. end
  366. end
  367. end
  368. return score
  369. end