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

183 lines
5.7 KiB

  1. SkillToolTips = SkillToolTips or BaseClass(BaseView)
  2. function SkillToolTips:__init()
  3. self.base_file = "common"
  4. self.layout_file = "SkillToolTips"
  5. self.layer_name = "Top"
  6. self.use_background = true
  7. self.click_bg_toClose = true
  8. self.is_set_zdepth = true
  9. self.pos_x = 0
  10. self.pos_y = 0
  11. self.skill_cfg = nil
  12. self.is_delay_callback = false
  13. self.model = GoodsModel:getInstance()
  14. self.mainVo = RoleManager.Instance.mainRoleInfo
  15. self.curr_height = 0
  16. self.load_callback = function ()
  17. self:LoadSuccess()
  18. end
  19. self.open_callback = function ()
  20. self:SetData()
  21. end
  22. self.close_callback = function ()
  23. end
  24. self.destroy_callback = function ()
  25. end
  26. end
  27. function SkillToolTips:LoadSuccess()
  28. self.layout = self:GetChild("layout")
  29. self.bg = self:GetChild("layout/bg")
  30. self.icon = self:GetChild("layout/icon_con")
  31. self.icon_con = self:GetChild("layout/icon_con"):GetComponent("Image")
  32. self.nameText = self:GetChild("layout/nameText"):GetComponent("Text")
  33. self.typeTextObj = self:GetChild("layout/typeText").gameObject
  34. self.typeText = self:GetChild("layout/typeText"):GetComponent("Text")
  35. self.levelText = self:GetChild("layout/levelText"):GetComponent("Text")
  36. self.line1 = self:GetChild("layout/line1")
  37. self.contentText = self:GetChild("layout/contentText")
  38. self.conditionText = self:GetChild("layout/conditionText")
  39. self.active_text = self:GetChild("layout/active"):GetComponent("Text")
  40. self.layout_x = self.layout.sizeDelta.x
  41. SetSizeDelta(self.transform, ScreenWidth, ScreenHeight)
  42. self:InitEvent()
  43. end
  44. function SkillToolTips:InitEvent()
  45. end
  46. --is_rasto 如果是印记 则 skill_id 就是印记id
  47. --is_mount 坐骑装备技能特殊显示
  48. --activeStr 激活标志内容
  49. function SkillToolTips:Open(skill_id, skill_lv, x, y, conditionStr,is_rasto, is_mount,activeStr)
  50. self.skill_id = skill_id
  51. self.skill_lv = skill_lv or 1
  52. self.conditionStr = conditionStr
  53. self.pos_x = x
  54. self.pos_y = y
  55. self.is_rasto = is_rasto
  56. self.is_mount = is_mount
  57. self.activeStr = activeStr or ""
  58. BaseView.Open(self)
  59. end
  60. function SkillToolTips:SetData()
  61. if self.is_rasto then
  62. local key = self.skill_id .. "@" .. self.skill_lv
  63. local config = Config.Godseal[key]
  64. if config then
  65. self.nameText.text = Trim(config.name)
  66. self.contentText:GetComponent("Text").text = ChuanWenManager:getInstance():FormatColorTag(config.description)
  67. lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetSkillIcon(config.icon))
  68. end
  69. elseif self.is_mount then
  70. local cfg = Config.Mountequipskillnew
  71. if cfg then
  72. for k,v in pairs(cfg) do
  73. if self.skill_id and self.skill_id == v.icon then
  74. self.nameText.text = Trim(v.skill_name)
  75. local str = ""
  76. local arr = Trim(v.tips)
  77. arr = Split(arr, [[\n]])
  78. if arr then
  79. for k,v in pairs(arr) do
  80. str = str..v
  81. if arr[k+1] then
  82. str = str.."\n"
  83. end
  84. end
  85. end
  86. self.contentText:GetComponent("Text").text = str
  87. lua_resM:setOutsideImageSprite(self, self.icon_con, GameResPath.GetSkillIcon(v.icon))
  88. break
  89. end
  90. end
  91. end
  92. else
  93. self.skill_cfg = SkillManager:getInstance():getSkillFromConfig(self.skill_id)
  94. if self.skill_cfg == nil then return end
  95. local is_main = false
  96. for k,v in pairs(Config.ConfigSkillUI.InitiativeSkill) do
  97. if TableContains(v,self.skill_id) then
  98. is_main = true
  99. break
  100. end
  101. end
  102. if is_main then
  103. lua_resM:setImageSprite(self,self.icon_con,"mainUI_asset",self.skill_id)
  104. else
  105. -- lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetSkillIcon(self.skill_id),false,false,true)
  106. lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetSkillIcon(self.skill_id),false)
  107. end
  108. local skill_desc,skill_name = SkillManager:getInstance():GetSkillFromConfigByIdAndLevel(self.skill_id, self.skill_lv)
  109. self.nameText.text = Trim(skill_name)
  110. local typeStr = "被动效果"
  111. self.typeText.text = "<color=#fac090>技能类型:</color><color=#ffffff>".. typeStr .."</color>"
  112. self.levelText.text = ""
  113. local contentStr = Trim(skill_desc)
  114. self.contentText:GetComponent("Text").text = ChuanWenManager:getInstance():FormatColorTag(contentStr)
  115. end
  116. self.curr_height = 152
  117. -- self.contentText.localPosition = Vector3(32,-self.curr_height,0)
  118. self.curr_height = self.curr_height + self.contentText:GetComponent("Text").preferredHeight
  119. self.curr_height = self.curr_height + 36
  120. if self.conditionStr and self.conditionStr ~= "" then
  121. -- self.conditionText.localPosition = Vector3(32,-self.curr_height,0)
  122. self.conditionText:GetComponent("Text").text = self.conditionStr
  123. self.curr_height = self.curr_height + self.conditionText:GetComponent("Text").preferredHeight
  124. else
  125. self.conditionText:GetComponent("Text").text = ""
  126. end
  127. self.curr_height = self.curr_height + 20
  128. self.bg.sizeDelta = Vector2(407,self.curr_height)
  129. self.layout.sizeDelta = Vector2(407,self.curr_height)
  130. local curr_height = 147
  131. self.contentText.localPosition = Vector3(37,-curr_height,0)
  132. curr_height = curr_height + self.contentText:GetComponent("Text").preferredHeight
  133. curr_height = curr_height + 36
  134. if self.conditionStr ~= "" then
  135. self.conditionText.localPosition = Vector3(32,-curr_height,0)
  136. end
  137. if self.pos_x and self.pos_y then
  138. local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
  139. if x+self.layout_x > SrcScreenWidth then
  140. x = SrcScreenWidth-self.layout_x-20
  141. elseif x<20 then
  142. x = 20
  143. end
  144. if y < 20 then
  145. y = 20
  146. elseif y+self.bg.sizeDelta.y > ScreenHeight then
  147. y = ScreenHeight-self.bg.sizeDelta.y -20
  148. end
  149. self.layout.anchoredPosition = Vector3(x,y +self.bg.sizeDelta.y)
  150. end
  151. self.active_text.text = self.activeStr
  152. end
  153. function SkillToolTips:packageNumber(str)
  154. local function FormatText(n)
  155. return Language.substitute("<color=#4eae1a>{0}</color>",n)
  156. end
  157. str = string.gsub(str, "(%d+%%?)",FormatText)
  158. return str
  159. end