This commit is contained in:
puxuan 2025-09-09 21:10:35 +08:00
parent d0362beb78
commit 00f30b9ab3
9 changed files with 85 additions and 29 deletions

View File

@ -683,6 +683,8 @@ local LocalizationGlobalConst =
BAG_DESC_1 = "BAG_DESC_1", BAG_DESC_1 = "BAG_DESC_1",
EQUIP_DESC_29 = "EQUIP_DESC_29", EQUIP_DESC_29 = "EQUIP_DESC_29",
EQUIP_DESC_30 = "EQUIP_DESC_30", EQUIP_DESC_30 = "EQUIP_DESC_30",
EQUIP_DESC_31 = "EQUIP_DESC_31",
EQUIP_DESC_32 = "EQUIP_DESC_32",
} }
return LocalizationGlobalConst return LocalizationGlobalConst

View File

@ -683,6 +683,8 @@ local localization_global =
["BAG_DESC_1"] = "背包", ["BAG_DESC_1"] = "背包",
["EQUIP_DESC_29"] = "只有上阵的英雄才能穿戴装备", ["EQUIP_DESC_29"] = "只有上阵的英雄才能穿戴装备",
["EQUIP_DESC_30"] = "穿戴", ["EQUIP_DESC_30"] = "穿戴",
["EQUIP_DESC_31"] = "一键穿戴",
["EQUIP_DESC_32"] = "装备培养",
} }
return localization_global return localization_global

View File

@ -7,7 +7,7 @@ EquipConst.PART_TYPE = {
EQUIP_3 = 3, EQUIP_3 = 3,
EQUIP_4 = 4, EQUIP_4 = 4,
EQUIP_5 = 5, EQUIP_5 = 5,
EQUIP_6 = 5, EQUIP_6 = 6,
} }
return EquipConst return EquipConst

View File

@ -89,8 +89,9 @@ end
function EquipManager:onEquipWearRsp(result) function EquipManager:onEquipWearRsp(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.HeroData:setHeroLv(result.hero.id, result.hero.level) DataManager.EquipData:onWearSuccess(result.reqData.slot, result.reqData.ids)
DataManager.HeroData:setDirty() DataManager.HeroData:setDirty()
DataManager.HeroData:calcPower()
AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP) AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP)
end end

View File

@ -10,17 +10,19 @@ function EquipListCell:init()
self.wearBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_30)) self.wearBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_30))
self.wearBtn:addClickListener(function() self.wearBtn:addClickListener(function()
-- if DataManager.DailyTaskData:canClaimTask(self.taskId) then -- local ids = {}
-- ModuleManager.TaskManager:claimDailyTask(self.taskId) -- for i = 1, GConst.EquipConst.PART_TYPE.EQUIP_6 do
-- else -- ids[i] = DataManager.EquipData:getPartEquipUid(self.slotId, i)
-- ModuleManager.TaskManager:taskGoto(self.taskType)
-- end -- end
-- ids[self.equipPart] = self.entity:getUid()
ModuleManager.EquipManager:onEquipWearReq(self.slotId, {self.entity:getUid()})
end) end)
end end
function EquipListCell:refresh(entity, slotId) function EquipListCell:refresh(entity, slotId, equipPart)
self.entity = entity self.entity = entity
self.slotId = slotId self.slotId = slotId
self.equipPart = equipPart
self.nameTx:setText(entity:getName()) self.nameTx:setText(entity:getName())
self.powerTx:setText(entity:getPower()) self.powerTx:setText(entity:getPower())
self.equipCell:refresh(entity, slotId) self.equipCell:refresh(entity, slotId)

View File

@ -36,9 +36,13 @@ function EquipListUI:onLoadRootComplete()
return EQUIP_LIST_CELL return EQUIP_LIST_CELL
end) end)
self.scrollRectComp:addRefreshCallback(function(index, cell) self.scrollRectComp:addRefreshCallback(function(index, cell)
cell:refresh(self.equipList[index], self.slotId) cell:refresh(self.equipList[index], self.slotId, self.equipPart)
end) end)
self.scrollRectComp:clearCells() self.scrollRectComp:clearCells()
self:bind(DataManager.HeroData, "isDirty", function()
self:closeUI()
end)
end end
function EquipListUI:onRefresh() function EquipListUI:onRefresh()
@ -50,10 +54,10 @@ function EquipListUI:onRefresh()
end end
function EquipListUI:refreshEquipCell() function EquipListUI:refreshEquipCell()
local eid = DataManager.EquipData:getPartEquipUid(self.heroEntity:getMatchType(), self.equipPart) local eid = DataManager.EquipData:getPartEquipUid(self.slotId, self.equipPart)
if eid and eid > 0 then if eid and eid > 0 then
local equipEntity = DataManager.EquipData:getEquipByUid(eid) local equipEntity = DataManager.EquipData:getEquipByUid(eid)
self.equipCell:refresh(equipEntity, false, true) self.equipCell:refresh(equipEntity, self.equipPart)
else else
self.equipCell:refreshEmpty(self.equipPart) self.equipCell:refreshEmpty(self.equipPart)
end end

View File

@ -21,6 +21,8 @@ function EquipInfoComp:init()
self.hpNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2)) self.hpNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
self.atkNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3)) self.atkNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3))
self.emptyTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_29)) self.emptyTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_29))
self.upBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_32))
self.autoWaerBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_31))
self.equipCells = {} self.equipCells = {}
self.suitTxs = {} self.suitTxs = {}
@ -32,9 +34,21 @@ function EquipInfoComp:init()
end) end)
end end
-- self.txAttr:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_6)) self.autoWaerBtn:addClickListener(function()
-- self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16)) local soltId = self.heroEntity:getMatchType()
-- self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3)) local listUids = {}
for i = 1, 6 do
local equip = DataManager.EquipData:getEquipMaxScore(soltId, i)
if equip ~= nil then
table.insert(listUids, equip:getUid())
end
end
ModuleManager.EquipManager:onEquipWearReq(soltId, listUids)
end)
self.upBtn:addClickListener(function()
-- UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity})
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_32))
end)
self.attrBtn:addClickListener(function() self.attrBtn:addClickListener(function()
UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity}) UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity})
end) end)
@ -97,7 +111,7 @@ function EquipInfoComp:refreshEquip()
local eid = DataManager.EquipData:getPartEquipUid(self.heroEntity:getMatchType(), part) local eid = DataManager.EquipData:getPartEquipUid(self.heroEntity:getMatchType(), part)
if eid and eid > 0 then if eid and eid > 0 then
local equipEntity = DataManager.EquipData:getEquipByUid(eid) local equipEntity = DataManager.EquipData:getEquipByUid(eid)
self.equipCells[part]:refresh(equipEntity, false, true) self.equipCells[part]:refresh(equipEntity, part)
else else
-- self.equipCells[part]:refreshByCustom(nil, part) -- self.equipCells[part]:refreshByCustom(nil, part)
self.equipCells[part]:refreshEmpty(part) self.equipCells[part]:refreshEmpty(part)

View File

@ -96,6 +96,9 @@ function HeroDetailUI:onLoadRootComplete()
self:bind(DataManager.BagData.ItemData, "dirty", function() self:bind(DataManager.BagData.ItemData, "dirty", function()
self:refreshPageBtn() self:refreshPageBtn()
end) end)
self:bind(DataManager.HeroData, "isDirty", function()
self:onRefresh()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.HERO_UPGRADE_SUCCESS, function(id) self:addEventListener(EventManager.CUSTOM_EVENT.HERO_UPGRADE_SUCCESS, function(id)
self:refreshPageBtn() self:refreshPageBtn()
end) end)

View File

@ -103,12 +103,12 @@ end
-- 基础属性 -- 基础属性
function EquipData:getBaseAttr(id) function EquipData:getBaseAttr(id)
return self:getConfig(id).base_attr return self:getConfig(id).base_attr
end end
-- 装备名字 -- 装备名字
function EquipData:getName(id) function EquipData:getName(id)
return I18N:getText("equip", id, "name") return I18N:getText("equip", id, "name")
end end
--@endregion --@endregion
@ -156,23 +156,51 @@ end
--@region 穿戴 --@region 穿戴
--装备穿戴 --装备穿戴
function EquipData:onWearSuccess(soltId, uids) function EquipData:onWearSuccess(soltId, uids)
for i,uid in ipairs(uids) do for _, uid in ipairs(uids) do
local equip = self:getEquipByUid(uid) local equip = self:getEquipByUid(uid)
local part = equip:getPart() local part = equip:getPart()
if part then if part then
local oldUid = self.slots[soltId].parts[part].equip_uid local oldUid = self.slots[soltId].parts[part].equip_uid
for i,info in ipairs(self.slots) do for i,info in ipairs(self.slots) do
if i ~= soltId then if i ~= soltId then
if info.parts[part].equip_uid == uid then if info.parts[part].equip_uid == uid then
info.parts[part].equip_uid = oldUid info.parts[part].equip_uid = oldUid
end end
end
end
self.slots[soltId].parts[part].equip_uid = uid
end
end
self:setDirty()
end
function EquipData:getEquipMaxScore(soltId, part)
local equip = nil
local maxScore = 0
local useUid = self:getPartEquipUid(soltId, part)
if useUid ~= 0 then
local useEquip = self:getEquipByUid(useUid)
maxScore = useEquip:getPower()
end
for i, v in pairs(self.allEquips) do
if v:getPart() == part then
local isEquip = false
for k2, info in ipairs(self.slots) do
if info.parts[part] and info.parts[part].equip_uid == v:getUid() then
isEquip = true
break
end
end
if not isEquip then
local score = v:getPower()
if score > maxScore then
equip = v
maxScore = score
end end
end end
self.slots[soltId].parts[part].equip_uid = uid
end end
end end
self:setDirty() return equip
-- DataManager.ForceData:updateTeamPower()
end end
--@endregion --@endregion