|
SkillToolTips = SkillToolTips or BaseClass(BaseView)
|
|
function SkillToolTips:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "SkillToolTips"
|
|
self.layer_name = "Top"
|
|
self.use_background = true
|
|
self.click_bg_toClose = true
|
|
self.is_set_zdepth = true
|
|
self.pos_x = 0
|
|
self.pos_y = 0
|
|
self.skill_cfg = nil
|
|
self.is_delay_callback = false
|
|
|
|
self.model = GoodsModel:getInstance()
|
|
self.mainVo = RoleManager.Instance.mainRoleInfo
|
|
|
|
self.curr_height = 0
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
end
|
|
self.open_callback = function ()
|
|
self:SetData()
|
|
end
|
|
self.close_callback = function ()
|
|
end
|
|
self.destroy_callback = function ()
|
|
|
|
end
|
|
end
|
|
|
|
function SkillToolTips:LoadSuccess()
|
|
self.layout = self:GetChild("layout")
|
|
self.bg = self:GetChild("layout/bg")
|
|
self.icon = self:GetChild("layout/icon_con")
|
|
self.icon_con = self:GetChild("layout/icon_con"):GetComponent("Image")
|
|
self.nameText = self:GetChild("layout/nameText"):GetComponent("Text")
|
|
self.typeTextObj = self:GetChild("layout/typeText").gameObject
|
|
self.typeText = self:GetChild("layout/typeText"):GetComponent("Text")
|
|
self.levelText = self:GetChild("layout/levelText"):GetComponent("Text")
|
|
self.line1 = self:GetChild("layout/line1")
|
|
self.contentText = self:GetChild("layout/contentText")
|
|
self.conditionText = self:GetChild("layout/conditionText")
|
|
self.active_text = self:GetChild("layout/active"):GetComponent("Text")
|
|
self.layout_x = self.layout.sizeDelta.x
|
|
SetSizeDelta(self.transform, ScreenWidth, ScreenHeight)
|
|
self:InitEvent()
|
|
end
|
|
|
|
function SkillToolTips:InitEvent()
|
|
|
|
end
|
|
--is_rasto 如果是印记 则 skill_id 就是印记id
|
|
--is_mount 坐骑装备技能特殊显示
|
|
--activeStr 激活标志内容
|
|
function SkillToolTips:Open(skill_id, skill_lv, x, y, conditionStr,is_rasto, is_mount,activeStr)
|
|
self.skill_id = skill_id
|
|
self.skill_lv = skill_lv or 1
|
|
self.conditionStr = conditionStr
|
|
self.pos_x = x
|
|
self.pos_y = y
|
|
self.is_rasto = is_rasto
|
|
self.is_mount = is_mount
|
|
self.activeStr = activeStr or ""
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function SkillToolTips:SetData()
|
|
if self.is_rasto then
|
|
local key = self.skill_id .. "@" .. self.skill_lv
|
|
local config = Config.Godseal[key]
|
|
if config then
|
|
self.nameText.text = Trim(config.name)
|
|
self.contentText:GetComponent("Text").text = ChuanWenManager:getInstance():FormatColorTag(config.description)
|
|
lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetSkillIcon(config.icon))
|
|
end
|
|
elseif self.is_mount then
|
|
local cfg = Config.Mountequipskillnew
|
|
if cfg then
|
|
for k,v in pairs(cfg) do
|
|
if self.skill_id and self.skill_id == v.icon then
|
|
self.nameText.text = Trim(v.skill_name)
|
|
local str = ""
|
|
local arr = Trim(v.tips)
|
|
arr = Split(arr, [[\n]])
|
|
if arr then
|
|
for k,v in pairs(arr) do
|
|
str = str..v
|
|
if arr[k+1] then
|
|
str = str.."\n"
|
|
end
|
|
end
|
|
end
|
|
self.contentText:GetComponent("Text").text = str
|
|
lua_resM:setOutsideImageSprite(self, self.icon_con, GameResPath.GetSkillIcon(v.icon))
|
|
break
|
|
end
|
|
end
|
|
end
|
|
else
|
|
self.skill_cfg = SkillManager:getInstance():getSkillFromConfig(self.skill_id)
|
|
if self.skill_cfg == nil then return end
|
|
|
|
local is_main = false
|
|
for k,v in pairs(Config.ConfigSkillUI.InitiativeSkill) do
|
|
if TableContains(v,self.skill_id) then
|
|
is_main = true
|
|
break
|
|
end
|
|
end
|
|
|
|
if is_main then
|
|
lua_resM:setImageSprite(self,self.icon_con,"mainUI_asset",self.skill_id)
|
|
else
|
|
-- lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetSkillIcon(self.skill_id),false,false,true)
|
|
lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetSkillIcon(self.skill_id),false)
|
|
end
|
|
|
|
local skill_desc,skill_name = SkillManager:getInstance():GetSkillFromConfigByIdAndLevel(self.skill_id, self.skill_lv)
|
|
self.nameText.text = Trim(skill_name)
|
|
|
|
local typeStr = "被动效果"
|
|
self.typeText.text = "<color=#fac090>技能类型:</color><color=#ffffff>".. typeStr .."</color>"
|
|
self.levelText.text = ""
|
|
|
|
local contentStr = Trim(skill_desc)
|
|
self.contentText:GetComponent("Text").text = ChuanWenManager:getInstance():FormatColorTag(contentStr)
|
|
end
|
|
|
|
|
|
self.curr_height = 152
|
|
-- self.contentText.localPosition = Vector3(32,-self.curr_height,0)
|
|
|
|
|
|
self.curr_height = self.curr_height + self.contentText:GetComponent("Text").preferredHeight
|
|
|
|
self.curr_height = self.curr_height + 36
|
|
|
|
if self.conditionStr and self.conditionStr ~= "" then
|
|
-- self.conditionText.localPosition = Vector3(32,-self.curr_height,0)
|
|
self.conditionText:GetComponent("Text").text = self.conditionStr
|
|
self.curr_height = self.curr_height + self.conditionText:GetComponent("Text").preferredHeight
|
|
else
|
|
self.conditionText:GetComponent("Text").text = ""
|
|
end
|
|
|
|
self.curr_height = self.curr_height + 20
|
|
|
|
|
|
self.bg.sizeDelta = Vector2(407,self.curr_height)
|
|
self.layout.sizeDelta = Vector2(407,self.curr_height)
|
|
|
|
local curr_height = 147
|
|
self.contentText.localPosition = Vector3(37,-curr_height,0)
|
|
curr_height = curr_height + self.contentText:GetComponent("Text").preferredHeight
|
|
curr_height = curr_height + 36
|
|
|
|
if self.conditionStr ~= "" then
|
|
self.conditionText.localPosition = Vector3(32,-curr_height,0)
|
|
end
|
|
if self.pos_x and self.pos_y then
|
|
local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
|
|
if x+self.layout_x > SrcScreenWidth then
|
|
x = SrcScreenWidth-self.layout_x-20
|
|
elseif x<20 then
|
|
x = 20
|
|
end
|
|
if y < 20 then
|
|
y = 20
|
|
elseif y+self.bg.sizeDelta.y > ScreenHeight then
|
|
y = ScreenHeight-self.bg.sizeDelta.y -20
|
|
end
|
|
self.layout.anchoredPosition = Vector3(x,y +self.bg.sizeDelta.y)
|
|
end
|
|
|
|
self.active_text.text = self.activeStr
|
|
end
|
|
|
|
function SkillToolTips:packageNumber(str)
|
|
local function FormatText(n)
|
|
return Language.substitute("<color=#4eae1a>{0}</color>",n)
|
|
end
|
|
str = string.gsub(str, "(%d+%%?)",FormatText)
|
|
return str
|
|
end
|