buff tips

This commit is contained in:
chenxi 2023-04-20 12:06:33 +08:00
parent 79852d0c6e
commit bd57840816
5 changed files with 236 additions and 30 deletions

View File

@ -2,37 +2,43 @@ local buff = {
[1]={ [1]={
["name"]="hurt", ["name"]="hurt",
["buff_type"]=3, ["buff_type"]=3,
["formula"]=1 ["formula"]=1,
["icon"]="dec_dmg_red_add"
}, },
[2]={ [2]={
["name"]="hurt_red", ["name"]="hurt_red",
["buff_type"]=3, ["buff_type"]=3,
["position"]=1, ["position"]=1,
["formula"]=1 ["formula"]=1,
["icon"]="dec_dmg_red_add"
}, },
[3]={ [3]={
["name"]="hurt_yellow", ["name"]="hurt_yellow",
["buff_type"]=3, ["buff_type"]=3,
["position"]=2, ["position"]=2,
["formula"]=1 ["formula"]=1,
["icon"]="dec_dmg_red_add"
}, },
[4]={ [4]={
["name"]="hurt_green", ["name"]="hurt_green",
["buff_type"]=3, ["buff_type"]=3,
["position"]=3, ["position"]=3,
["formula"]=1 ["formula"]=1,
["icon"]="dec_dmg_red_add"
}, },
[5]={ [5]={
["name"]="hurt_blue", ["name"]="hurt_blue",
["buff_type"]=3, ["buff_type"]=3,
["position"]=4, ["position"]=4,
["formula"]=1 ["formula"]=1,
["icon"]="dec_dmg_red_add"
}, },
[6]={ [6]={
["name"]="hurt_purple", ["name"]="hurt_purple",
["buff_type"]=3, ["buff_type"]=3,
["position"]=5, ["position"]=5,
["formula"]=1 ["formula"]=1,
["icon"]="dec_dmg_red_add"
}, },
[7]={ [7]={
["name"]="dec_dmg_red_add", ["name"]="dec_dmg_red_add",
@ -107,70 +113,84 @@ local buff = {
[19]={ [19]={
["name"]="dmg_addition_red_add", ["name"]="dmg_addition_red_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=1 ["position"]=1,
["icon"]="dec_dmg_red_add"
}, },
[20]={ [20]={
["name"]="dmg_addition_yellow_add", ["name"]="dmg_addition_yellow_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=2 ["position"]=2,
["icon"]="dec_dmg_red_add"
}, },
[21]={ [21]={
["name"]="dmg_addition_green_add", ["name"]="dmg_addition_green_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=3 ["position"]=3,
["icon"]="dec_dmg_red_add"
}, },
[22]={ [22]={
["name"]="dmg_addition_blue_add", ["name"]="dmg_addition_blue_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=4 ["position"]=4,
["icon"]="dec_dmg_red_add"
}, },
[23]={ [23]={
["name"]="dmg_addition_purple_add", ["name"]="dmg_addition_purple_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=5 ["position"]=5,
["icon"]="dec_dmg_red_add"
}, },
[24]={ [24]={
["name"]="dmg_addition_all_add", ["name"]="dmg_addition_all_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[25]={ [25]={
["name"]="atkp_color_add", ["name"]="atkp_color_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[26]={ [26]={
["name"]="atkp_red_add", ["name"]="atkp_red_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=1 ["position"]=1,
["icon"]="dec_dmg_red_add"
}, },
[27]={ [27]={
["name"]="atkp_yellow_add", ["name"]="atkp_yellow_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=2 ["position"]=2,
["icon"]="dec_dmg_red_add"
}, },
[28]={ [28]={
["name"]="atkp_green_add", ["name"]="atkp_green_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=3 ["position"]=3,
["icon"]="dec_dmg_red_add"
}, },
[29]={ [29]={
["name"]="atkp_blue_add", ["name"]="atkp_blue_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=4 ["position"]=4,
["icon"]="dec_dmg_red_add"
}, },
[30]={ [30]={
["name"]="atkp_purple_add", ["name"]="atkp_purple_add",
["buff_type"]=1, ["buff_type"]=1,
["position"]=5 ["position"]=5,
["icon"]="dec_dmg_red_add"
}, },
[31]={ [31]={
["name"]="wavehealp", ["name"]="wavehealp",
["buff_type"]=5, ["buff_type"]=5,
["formula"]=2 ["formula"]=2,
["icon"]="dec_dmg_red_add"
}, },
[32]={ [32]={
["name"]="heal", ["name"]="heal",
["buff_type"]=5, ["buff_type"]=5,
["formula"]=3, ["formula"]=3,
["icon"]="dec_dmg_red_add",
["fx_take"]={ ["fx_take"]={
4001 4001
} }
@ -193,7 +213,8 @@ local buff = {
}, },
[35]={ [35]={
["name"]="atkp_add", ["name"]="atkp_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[36]={ [36]={
["name"]="normal_attack_dec", ["name"]="normal_attack_dec",
@ -206,41 +227,50 @@ local buff = {
[37]={ [37]={
["name"]="normal_attack_add", ["name"]="normal_attack_add",
["buff_type"]=1, ["buff_type"]=1,
["icon"]="dec_dmg_red_add",
["fx_continued"]={ ["fx_continued"]={
4001 4001
} }
}, },
[38]={ [38]={
["name"]="block", ["name"]="block",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[39]={ [39]={
["name"]="hpp_add", ["name"]="hpp_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[40]={ [40]={
["name"]="crit_add", ["name"]="crit_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[41]={ [41]={
["name"]="crit_time_add", ["name"]="crit_time_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[42]={ [42]={
["name"]="exp_time_add", ["name"]="exp_time_add",
["buff_type"]=7 ["buff_type"]=7,
["icon"]="dec_dmg_red_add"
}, },
[43]={ [43]={
["name"]="cured_add", ["name"]="cured_add",
["buff_type"]=1 ["buff_type"]=1,
["icon"]="dec_dmg_red_add"
}, },
[44]={ [44]={
["name"]="add_skill", ["name"]="add_skill",
["buff_type"]=7 ["buff_type"]=7,
["icon"]="dec_dmg_red_add"
}, },
[45]={ [45]={
["name"]="skill_fire_times", ["name"]="skill_fire_times",
["buff_type"]=7 ["buff_type"]=7,
["icon"]="dec_dmg_red_add"
} }
} }
local keys = { local keys = {

View File

@ -0,0 +1,87 @@
local buff = {
[7]={
["desc"]="受到红色元素伤害降低",
["name"]="dec_dmg_red_add"
},
[8]={
["desc"]="受到黄色元素伤害降低",
["name"]="dec_dmg_yellow_add"
},
[9]={
["desc"]="受到绿色元素伤害降低",
["name"]="dec_dmg_green_add"
},
[10]={
["desc"]="受到蓝色元素伤害降低",
["name"]="dec_dmg_blue_add"
},
[11]={
["desc"]="受到紫色元素伤害降低",
["name"]="dec_dmg_purple_add"
},
[12]={
["desc"]="受到所有伤害降低",
["name"]="dec_dmg_all_add"
},
[13]={
["desc"]="受到红色元素伤害增加",
["name"]="weakness_red_add"
},
[14]={
["desc"]="受到黄色元素伤害增加",
["name"]="weakness_yellow_add"
},
[15]={
["desc"]="受到绿色元素伤害增加",
["name"]="weakness_green_add"
},
[16]={
["desc"]="受到蓝色元素伤害增加",
["name"]="weakness_blue_add"
},
[17]={
["desc"]="受到紫色元素伤害增加",
["name"]="weakness_purple_add"
},
[18]={
["desc"]="受到所有伤害伤害增加",
["name"]="weakness_all_add"
},
[33]={
["desc"]="眩晕效果,无法进行攻击",
["name"]="stun"
},
[34]={
["desc"]="护盾可抵挡一定的伤害",
["name"]="shield"
},
[36]={
["desc"]="普攻攻击次数减少",
["name"]="normal_attack_dec"
}
}
local keys = {
name = {
["dec_dmg_red_add"]=buff[7],
["dec_dmg_yellow_add"]=buff[8],
["dec_dmg_green_add"]=buff[9],
["dec_dmg_blue_add"]=buff[10],
["dec_dmg_purple_add"]=buff[11],
["dec_dmg_all_add"]=buff[12],
["weakness_red_add"]=buff[13],
["weakness_yellow_add"]=buff[14],
["weakness_green_add"]=buff[15],
["weakness_blue_add"]=buff[16],
["weakness_purple_add"]=buff[17],
["weakness_all_add"]=buff[18],
["stun"]=buff[33],
["shield"]=buff[34],
["normal_attack_dec"]=buff[36]
}
}
local config = {
data=buff,
keys=keys,
count=15
}
return config

View File

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

View File

@ -1,3 +1,5 @@
local UIPrefabObject = require "app/bf/unity/uiprefab_object"
local BattleUI = class("BattleUI", BaseUI) local BattleUI = class("BattleUI", BaseUI)
local GRID_CELL = "app/ui/battle/cell/grid_cell" local GRID_CELL = "app/ui/battle/cell/grid_cell"
local GRID_CELL_PATH = "assets/prefabs/ui/battle/cell/grid_cell.prefab" local GRID_CELL_PATH = "assets/prefabs/ui/battle/cell/grid_cell.prefab"
@ -134,7 +136,7 @@ function BattleUI:initBuff()
self.uiMap["battle_ui.top_node.buff_r.buff_4"], self.uiMap["battle_ui.top_node.buff_r.buff_4"],
self.uiMap["battle_ui.top_node.buff_r.buff_5"], self.uiMap["battle_ui.top_node.buff_r.buff_5"],
} }
for k, v in ipairs(self.atkBuffIconList) do for k, v in ipairs(self.defBuffIconList) do
v:addClickListener(function() v:addClickListener(function()
self.battleController:showBuffTips(2) self.battleController:showBuffTips(2)
end) end)
@ -159,6 +161,13 @@ function BattleUI:initBuff()
end) end)
self.battleBuffTipsBg = self.uiMap["battle_ui.battle_buff_tips.bg"] self.battleBuffTipsBg = self.uiMap["battle_ui.battle_buff_tips.bg"]
self.battleBuffTipsBuff = self.uiMap["battle_ui.battle_buff_tips.bg.buff"] self.battleBuffTipsBuff = self.uiMap["battle_ui.battle_buff_tips.bg.buff"]
self.battleBuffTipsBuffList = {}
local children = self.battleBuffTipsBg:getChildList()
if children then
for k, v in ipairs(children) do
table.insert(self.battleBuffTipsBuffList, v)
end
end
end end
function BattleUI:refreshBuff(side, buffList) function BattleUI:refreshBuff(side, buffList)
@ -240,15 +249,73 @@ function BattleUI:clearBuff(side)
end end
function BattleUI:showLeftBuffTips(buffList) function BattleUI:showLeftBuffTips(buffList)
local x = self.battleBuffTipsBg:fastGetAnchoredPosition()
if x > 0 then
self.battleBuffTipsBg:setAnchoredPositionX(-x)
end
self:showBuffTips(buffList) self:showBuffTips(buffList)
end end
function BattleUI:showLeftBuffTips(buffList) function BattleUI:showRightBuffTips(buffList)
local x = self.battleBuffTipsBg:fastGetAnchoredPosition()
if x < 0 then
self.battleBuffTipsBg:setAnchoredPositionX(-x)
end
self:showBuffTips(buffList) self:showBuffTips(buffList)
end end
function BattleUI:showBuffTips(buffList) function BattleUI:showBuffTips(buffList)
if #buffList <= 0 then
return
end
self.battleBuffTipsRoot:setLocalScale(1, 1, 1)
local buffObj = nil
local count = #buffList
local index = 1
local addY = 0
for i = 1, count do
buffObj = buffList[i]
if buffObj and buffObj.buff:getIcon() then
local buffTipsObj = self:getBattleBuffTipsObj(index)
buffTipsObj:setLocalScale(1, 1, 1)
buffTipsObj:setAnchoredPositionY(-addY)
local buffTipsObjMap = buffTipsObj:genAllChildren()
buffTipsObjMap["buff.icon"]:setSprite(GConst.ATLAS_PATH.ICON_BUFF, buffObj.buff:getIcon())
local round = buffObj.round
if round <= 1 or round > 9 then
buffTipsObjMap["buff.round"]:setText(GConst.EMPTY_STRING)
else
buffTipsObjMap["buff.round"]:setText(tostring(round))
end
local descTx = buffTipsObjMap["buff.desc"]
descTx:setText(buffObj.buff:getDesc())
descTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO):ForceMeshUpdate()
local height = descTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).renderedHeight
if height > 30 then
addY = addY + 46 + height - 30
else
addY = addY + 46
end
index = index + 1
end
end
for i = index, #self.battleBuffTipsBuffList do
self.battleBuffTipsBuffList[i]:setLocalScale(0, 0, 0)
end
self.battleBuffTipsBg:setSizeDeltaY(addY + 20)
end
function BattleUI:getBattleBuffTipsObj(index)
if self.battleBuffTipsBuffList[index] then
return self.battleBuffTipsBuffList[index]
end
local prefab = CS.UnityEngine.Object.Instantiate(self.battleBuffTipsBuff:getGameObject())
local prefabObject = UIPrefabObject:create()
prefabObject:initWithPrefab(self.battleBuffTipsBuff:getAssetPath(), prefab)
prefabObject:initPrefabHelper()
prefabObject:setParent(self.battleBuffTipsBg, false)
table.insert(self.battleBuffTipsBuffList, prefabObject)
return prefabObject
end end
function BattleUI:initBattlefield() function BattleUI:initBattlefield()

View File

@ -22,6 +22,18 @@ function BattleBuffEntity:getName()
return self.name return self.name
end end
function BattleBuffEntity:getDesc()
if self.desc == nil then
local buff18NInfo = I18N:getConfigWithOtherKey("buff", "name")[self.name]
if buff18NInfo then
self.desc = buff18NInfo.desc or GConst.EMPTY_STRING
else
self.desc = GConst.EMPTY_STRING
end
end
return self.desc
end
function BattleBuffEntity:getBuffType() function BattleBuffEntity:getBuffType()
return self.buffType return self.buffType
end end