This commit is contained in:
puxuan 2025-06-12 22:47:10 +08:00
parent ec9b3a4815
commit b0f9cedce0
5 changed files with 182 additions and 3 deletions

View File

@ -42,7 +42,7 @@ local chapter = {
101,
101,
101,
105
501
},
["mystery_box"]={
0

View File

@ -173,6 +173,16 @@ function TipsManager:showSkillTips(targetObj, buffIds, skillId)
UIManager:showUI("app/ui/tips/skill_tips", params)
end
function TipsManager:showBattleSkillTips(targetObj, buffIds, skillId)
local tarCornerScreenPos = self:getCornerScreenPosition(targetObj, TipsManager.ALIGN_TYPE.TOP_CENTER)
local params = {
tarCornerScreenPos = tarCornerScreenPos,
buffNames = buffIds,
skillId = skillId,
}
UIManager:showUI("app/ui/tips/battle_skill_tips", params)
end
function TipsManager:showBattleBoardSkillTips(heroEntity, battleController, side, tarPrefabObj, alignType)
local params = {
heroEntity = heroEntity,

View File

@ -4,7 +4,7 @@ function BossSkillCell:init()
self.baseObject:addClickListener(function()
-- self.battleController:showBuffTips(SIDE_DEF)
-- ModuleManager.TipsManager:showBattleBoardSkillTips(self.battleData:getHeroEntity(elementType, side), self.battleController, side)
ModuleManager.TipsManager:showSkillTips(self.baseObject, nil, self.skillId)
ModuleManager.TipsManager:showBattleSkillTips(self.baseObject, nil, self.skillId)
end)
local uiMap = self:getUIMap()
self.icon = uiMap["boss_skill_cell.icon"]
@ -16,7 +16,8 @@ function BossSkillCell:refresh(skillId)
print("=============================== skillId = %s", skillId)
self.skillId = skillId
-- self.icon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, self.lastSkillIcon)
self.icon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, "14_3")
local icon = ModuleManager.HeroManager:getSkillIcon(skillId)
self.icon:setSprite(GConst.ATLAS_PATH.ICON_SKILL, icon)
end
function BossSkillCell:setActive(active)

View File

@ -0,0 +1,158 @@
local BaseTips = require "app/ui/tips/base_tips"
local SkillTips = class("SkillTips", BaseTips)
local LINE_SIZE = 4
-- 技能描述+buff描述
local WIDTH_SKILL = 260
local PADDING_SKILL = 17
local SPACING_SKILL = 10
local ICON_SIZE_SKILL = 31
local BUFF_TX_WIDTH_SKILL = 185
-- buff描述
local WIDTH_BUFF = 450
local PADDING_BUFF = 22
local SPACING_BUFF = 13
local ICON_SIZE_BUFF = 36
local BUFF_TX_WIDTH_BUFF = 370
function SkillTips:ctor(params)
self.tarCornerScreenPos = params.tarCornerScreenPos
self.buffNames = params.buffNames
self.skillId = params.skillId
self.location = self.skillId ~= nil and ModuleManager.TipsManager.ALIGN_TYPE.TOP_CENTER or ModuleManager.TipsManager.ALIGN_TYPE.BOTTOM_CENTER
end
function SkillTips:getPrefabPath()
return "assets/prefabs/ui/tips/skill_tips.prefab"
end
function SkillTips:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.content = uiMap["skill_tips.content"]
self.bg = uiMap["skill_tips.content.bg"]
self.imgArrow = uiMap["skill_tips.content.bg.img_arrow"]
self.txDesc = uiMap["skill_tips.content.bg.tx_desc"]
self.skillList = {}
for i = 1, 3 do
table.insert(self.skillList, uiMap["skill_tips.content.bg.item_desc_" .. i])
end
self.lineList = {}
for i = 1, 3 do
table.insert(self.lineList, uiMap["skill_tips.content.bg.line_" .. i])
end
local tipsBgTransform = self.bg:getTransform()
self.originSizeDelta = tipsBgTransform.sizeDelta
self.originPivot = tipsBgTransform.pivot
self.originAnchoredPosition = tipsBgTransform.anchoredPosition
self.originLocalPosition = tipsBgTransform.localPosition
end
function SkillTips:onRefresh()
self.root:addClickListener(function ()
self:closeUI()
end)
self:refreshSkillDesc()
if self.tarCornerScreenPos then
self:locate(self.location, self.originSizeDelta, self.bg, self.tarCornerScreenPos)
end
end
function SkillTips:onClose()
if self.originSizeDelta then
local tipsBgTransform = self.bg:getTransform()
tipsBgTransform.sizeDelta = self.originSizeDelta
tipsBgTransform.pivot = self.originPivot
tipsBgTransform.anchoredPosition = self.originAnchoredPosition
tipsBgTransform.localPosition = self.originLocalPosition
end
end
-- 刷新技能描述
function SkillTips:refreshSkillDesc()
local width = self.skillId ~= nil and WIDTH_SKILL or WIDTH_BUFF
local padding = self.skillId ~= nil and PADDING_SKILL or PADDING_BUFF
local spacing = self.skillId ~= nil and SPACING_SKILL or SPACING_BUFF
local iconSize = self.skillId ~= nil and ICON_SIZE_SKILL or ICON_SIZE_BUFF
local buffWidth = self.skillId ~= nil and BUFF_TX_WIDTH_SKILL or BUFF_TX_WIDTH_BUFF
self.bg:setSizeDeltaX(width)
self.imgArrow:setActive(self.skillId ~= nil)
-- Logger.logHighlight("显示buff")
-- Logger.printTable(self.buffNames)
local heightObjList = {}
local txHeroList = {}
-- 技能描述
if self.skillId then
self.txDesc:setActive(true)
self.txDesc:setSizeDeltaX(width - 20)
self.txDesc:setText(ModuleManager.HeroManager:getSkillDesc(self.skillId))
local txMeshPro = self.txDesc:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
txMeshPro:ForceMeshUpdate()
table.insert(heightObjList, self.txDesc)
table.insert(txHeroList, txMeshPro.renderedHeight)
else
self.txDesc:setActive(false)
end
-- buff描述
for index, obj in ipairs(self.skillList) do
if self.buffNames and self.buffNames[index] then
-- 显示buff描述
local ui = obj:genAllChildren()
local icon = ui["img_icon"]
local desc = ui["tx_desc"]
local buffInfo = ConfigManager:getConfigWithOtherKey("buff", "name")[self.buffNames[index]]
obj:setActive(true)
obj:setSizeDeltaX(width)
desc:setSizeDeltaX(buffWidth)
desc:setText(I18N:getTextWithOtherKey("buff", "name", buffInfo.name, "tips_desc"))
icon:setSizeDelta(iconSize, iconSize)
icon:setSprite(GConst.ATLAS_PATH.ICON_BUFF, buffInfo.icon)
local txMeshPro = desc:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
txMeshPro:ForceMeshUpdate()
table.insert(heightObjList, obj)
table.insert(txHeroList, txMeshPro.renderedHeight > iconSize and txMeshPro.renderedHeight or iconSize)
else
obj:setActive(false)
end
end
local h = padding
local str = "tips高度" .. padding
for index, obj in ipairs(heightObjList) do
obj:setAnchoredPositionY(-h)
h = h + txHeroList[index]
str = str .. " + " .. txHeroList[index]
if index < #heightObjList then
h = h + spacing
str = str .. " + " .. spacing
self.lineList[1]:setAnchoredPositionY(-h)
self.lineList[1]:setActive(true)
self.lineList[1]:setSizeDelta(width - 10, LINE_SIZE)
h = h + LINE_SIZE + spacing
str = str .. " + " .. LINE_SIZE
str = str .. " + " .. spacing
table.remove(self.lineList, 1)
end
end
for index, obj in ipairs(self.lineList) do
obj:setActive(false)
end
h = h + padding
str = str .. " + " .. padding
-- Logger.logHighlight(str.. " = " ..h)
-- h = math.max(h, 136)
self.bg:setSizeDeltaY(h)
end
return SkillTips

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3de9f7879369e4a6eb11521029bba071
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}