源战役客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

305 řádky
9.7 KiB

před 4 týdny
  1. --只显示装备信息的tips, 可与showiconitem搭配使用
  2. WingInfoTips = WingInfoTips or BaseClass(EquipToolTips)
  3. WingInfoTips.ONLY_SHOW = 0 --只展示信息
  4. WingInfoTips.COMPOSE_OFF = 1 --显示取出按钮,点击移除合成物品
  5. WingInfoTips.OFF_AND_REPLACE = 2 --显示取出和替换
  6. function WingInfoTips:__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.goods_vo = nil
  15. --self:AddPreLoadList("common_asset",{"star", "com_blackstar"},LuaResManager.RES_TYPE.SPRITE)
  16. self.load_callback = function ()
  17. self:LoadSuccess()
  18. end
  19. self.open_callback = function ()
  20. self:SetData(self.goods_vo)
  21. end
  22. self.close_callback = function ()
  23. end
  24. self.destroy_callback = function ()
  25. self:Remove()
  26. end
  27. end
  28. --[[
  29. dynamic: table
  30. type_or_goodsID:
  31. ]]
  32. function WingInfoTips:Open(type_id, x, y, type_or_goodsID, off_callback, replace_callback)
  33. do return end
  34. if not Config.Twing[type_id] then
  35. print("WingInfoTips:Open() 不存在的翅膀类型, type_id = "..type_id)
  36. self:Close()
  37. return
  38. end
  39. self.type_id = type_id
  40. self.type_or_goodsID = type_or_goodsID
  41. self.pos_x = x
  42. self.pos_y = y
  43. self.off_callback = off_callback
  44. self.replace_callback = replace_callback
  45. BaseView.Open(self)
  46. end
  47. function WingInfoTips:LoadSuccess()
  48. EquipToolTips.LoadSuccess(self)
  49. self.normal_tra = self:GetChild("layout/normal")
  50. self.replaceBtn = self.strengthBtn
  51. self.replace_btn_text, self.equip_text = self:GetChildTexts({"layout/normal/btn_conta/strengthBtn/Text", "layout/normal/Text2"})
  52. self.replace_btn_text.text = "替换"
  53. self.normal_tra.anchoredPosition = Vector2(0,0)
  54. SetSizeDelta(self.transform,ScreenWidth,ScreenHeight)
  55. self.skill_desc = self:GetChild("layout/normal/ScrollView/Viewport/Content/addStrengthProp"):GetComponent("Text")
  56. self:GetChild("layout/normal/ScrollView/Viewport/Content/line2/Text"):GetComponent("Text").text = "翅膀描述"
  57. self.ScrollView:GetComponent("ScrollRect").enabled = false
  58. end
  59. function WingInfoTips:Remove()
  60. if self.icon_item then
  61. self.icon_item:DeleteMe()
  62. self.icon_item = nil
  63. end
  64. if self.modelPreview then
  65. self.modelPreview:DeleteMe()
  66. self.modelPreview = nil
  67. end
  68. self:DeleteArrowTip()
  69. if self.addNumComponent then
  70. if self.change_count_id then
  71. self.addNumComponent:UnBind(self.change_count_id)
  72. self.change_count_id = nil
  73. end
  74. self.addNumComponent:DeleteMe()
  75. self.addNumComponent = nil
  76. end
  77. end
  78. function WingInfoTips:InitEvent()
  79. local function onBtnClickHandler(target)
  80. if target == self.takeBtn then
  81. if self.off_callback ~= nil then
  82. local fun = self.off_callback
  83. setTimeout(fun, 0)
  84. self:Close()
  85. end
  86. elseif target == self.replaceBtn then
  87. if self.replace_callback ~= nil then
  88. self:Close()
  89. self.replace_callback()
  90. end
  91. elseif target == self.wearBtn then
  92. WingModel:getInstance():OutsideRequireWearWing(self.type_or_goodsID)
  93. self:Close()
  94. elseif target == self.shelvesUpBtn then
  95. end
  96. end
  97. AddClickEvent(self.takeBtn, onBtnClickHandler)
  98. AddClickEvent(self.strengthBtn, onBtnClickHandler)
  99. AddClickEvent(self.wearBtn, onBtnClickHandler)
  100. AddClickEvent(self.shelvesUpBtn, onBtnClickHandler)
  101. end
  102. function WingInfoTips:SetData()
  103. self.goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
  104. local wing_vo = Config.Twing[self.type_id]
  105. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id)
  106. if wing_vo == nil or basic == nil then
  107. return print("WingInfoTips:SetData() 数据错误, wing_vo = "..tostring(wing_vo)..", basic = "..tostring(basic)..", type_id = "..self.type_id)
  108. end
  109. -- 名字
  110. self.nameText.text = "<color="..WordManager.GetGoodsColor(basic.color)..">"..basic.goods_name.."</color>"
  111. local mainVo = RoleManager.Instance.mainRoleInfo
  112. local color_str
  113. -- 职业
  114. if wing_vo.career_id == 0 or mainVo.career == wing_vo.career_id then
  115. color_str = ColorUtil.WHITE
  116. else
  117. color_str = ColorUtil.RED
  118. end
  119. local career_name = WordManager:GetCareerName(wing_vo.career) or ""
  120. self.career.text = "<color="..color_str..">" .. career_name .. "</color>"
  121. -- 等级
  122. color_str = ColorUtil.WHITE
  123. if basic.level > mainVo.level then
  124. color_str = ColorUtil.RED
  125. end
  126. self.level.text = "<color="..color_str..">" .. basic.level .. "</color>"
  127. -- 等阶
  128. local step_str = WordManager:GetWingStepNum(self.type_id)
  129. self.step_num.text = "<color="..WordManager.GetGoodsColor(basic.color)..">" .. step_str .. "</color>"
  130. self.icon_item:SetData(basic)
  131. lua_resM:setImageSprite(self, self.step_bg, "uiComponent_asset", "tsui_pj_"..basic.color)
  132. if basic then
  133. local base_pro = ErlangParser:GetInstance():Parse(wing_vo.attr)
  134. self:SetProperty(base_pro)
  135. --self.composite_score.text = GetFighting(base_pro)
  136. self.composite_score.text = wing_vo.power
  137. end
  138. self:SetBtns()
  139. self:AdjustLayoutPos()
  140. if Config.ConfigModelPreview[self.type_id] then
  141. self.modelPreview = ModelPreviewCon.New(self.normal_tra)
  142. self.modelPreview:SetData(self.type_id,self.bg.sizeDelta.y-29)
  143. if self.layout.anchoredPosition.x < 400 then
  144. self.layout.anchoredPosition = Vector2(400, self.layout.anchoredPosition.y)
  145. end
  146. end
  147. end
  148. --按钮显示
  149. function WingInfoTips:SetBtns()
  150. for i,v in ipairs(self.btn_list) do
  151. v:SetActive(false)
  152. end
  153. local btn_list = nil
  154. if self.type_or_goodsID == WingInfoTips.COMPOSE_OFF then
  155. btn_list = {self.takeBtn}
  156. elseif self.type_or_goodsID == WingInfoTips.OFF_AND_REPLACE then
  157. btn_list = {self.takeBtn,self.replaceBtn}
  158. elseif self.type_or_goodsID == WingInfoTips.ONLY_SHOW then
  159. btn_list = {}
  160. else
  161. btn_list = {self.wearBtn,self.shelvesUpBtn}
  162. end
  163. for i,v in ipairs(btn_list) do
  164. v:SetActive(true)
  165. end
  166. self.btn_conta.sizeDelta = Vector2(self.btn_conta.sizeDelta.x, #btn_list * 60 +10)
  167. end
  168. --设置基础属性
  169. function WingInfoTips:SetProperty(base_pro)
  170. self.equip_text.gameObject:SetActive(false)
  171. self.equip_score.gameObject:SetActive(false)
  172. self.line3.gameObject:SetActive(false)
  173. self.line4.gameObject:SetActive(false)
  174. self.line5.gameObject:SetActive(false)
  175. self.line6.gameObject:SetActive(false)
  176. self.line7.gameObject:SetActive(false)
  177. self.line8.gameObject:SetActive(false)
  178. self.line9.gameObject:SetActive(false)
  179. self.line10.gameObject:SetActive(false)
  180. self.strengthAdd.gameObject:SetActive(false)
  181. self.addName.gameObject:SetActive(false)
  182. self.addPro.gameObject:SetActive(false)
  183. self.washName.gameObject:SetActive(false)
  184. self.washPro.gameObject:SetActive(false)
  185. self.spiritName.gameObject:SetActive(false)
  186. self.spiritPro.gameObject:SetActive(false)
  187. self.stone_conta.gameObject:SetActive(false)
  188. self.suitNum.gameObject:SetActive(false)
  189. self.suitName.gameObject:SetActive(false)
  190. self.suitPro.gameObject:SetActive(false)
  191. self.suitNameList.gameObject:SetActive(false)
  192. self.wake_baseName.gameObject:SetActive(false)
  193. self.wake_basePro.gameObject:SetActive(false)
  194. self.wake_baseAdd.gameObject:SetActive(false)
  195. self.wake_strenName.gameObject:SetActive(false)
  196. self.wake_strenPro.gameObject:SetActive(false)
  197. self.wake_strenAdd.gameObject:SetActive(false)
  198. self.wake_suitNum.gameObject:SetActive(false)
  199. self.wake_suitName.gameObject:SetActive(false)
  200. self.wake_suitPro.gameObject:SetActive(false)
  201. self.wake_suitAdd.gameObject:SetActive(false)
  202. self.magic_skillName.gameObject:SetActive(false)
  203. self.magic_skillLevel.gameObject:SetActive(false)
  204. self.expired_label.gameObject:SetActive(false)
  205. self.descCon.gameObject:SetActive(false)
  206. local name_str = ""
  207. local pro_str = ""
  208. local size = #base_pro
  209. for i,v in ipairs(base_pro) do
  210. name_str = name_str .. WordManager:GetProperties(tonumber(v[1]))
  211. pro_str = pro_str.."+" .. WordManager:GetPropertyValue(tonumber(v[1]),tonumber(v[2]))
  212. if i < size then
  213. name_str = name_str.."\n"
  214. pro_str = pro_str.."\n"
  215. end
  216. end
  217. self.baseName.text = name_str
  218. self.basePro.text = pro_str
  219. SetSizeDelta(self.baseName.transform, self.baseName.transform.sizeDelta.x, 25 * size)
  220. SetSizeDelta(self.basePro.transform, self.basePro.transform.sizeDelta.x, 25 * size)
  221. local wing_vo = Config.Twing[self.type_id]
  222. self.skill_desc.text = "<color=#A4663CFF>"..Trim(wing_vo.description).."</color>"
  223. local skill_desc_h = 75
  224. SetAnchoredPosition(self.skill_desc.transform, 25, -25 * size - 100)
  225. SetSizeDelta(self.skill_desc.transform, 344, skill_desc_h)
  226. SetAnchoredPosition(self.line2, 0, -25 * size - 52)
  227. SetSizeDelta(self.bg, self.bg.sizeDelta.x, 315 + 25 * size + skill_desc_h)
  228. self.btn_conta.anchoredPosition = Vector2(self.btn_conta.anchoredPosition.x, -205 - 25 * size)
  229. setTimeout(function ()
  230. if not self._use_delete_method then
  231. local skill_desc_h = self.skill_desc.preferredHeight
  232. SetSizeDelta(self.skill_desc.transform, 344, skill_desc_h)
  233. SetSizeDelta(self.bg, self.bg.sizeDelta.x, 315 + 25 * size + skill_desc_h)
  234. self.btn_conta.anchoredPosition = Vector2(self.btn_conta.anchoredPosition.x, -205 - 25 * size - skill_desc_h)
  235. end
  236. end,0)
  237. end
  238. function WingInfoTips:AdjustLayoutPos()
  239. if self.pos_x and self.pos_y then
  240. local layout_width = self.bg.sizeDelta.x + self.btn_conta.sizeDelta.x
  241. local layout_height = self.bg.sizeDelta.y
  242. local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
  243. local iphone_x_offset = math.max(ClientConfig.iphone_x_offset_left,ClientConfig.iphone_x_offset_right)
  244. if x + layout_width + 50 + iphone_x_offset * 2 > SrcScreenWidth then
  245. x = SrcScreenWidth - layout_width - 90 - iphone_x_offset * 2
  246. end
  247. if y < layout_height + 50 then
  248. y = layout_height + 50
  249. end
  250. self.layout.anchoredPosition = Vector2(x,y - ScreenHeight)
  251. end
  252. end