装备
This commit is contained in:
parent
d0362beb78
commit
00f30b9ab3
@ -683,6 +683,8 @@ local LocalizationGlobalConst =
|
||||
BAG_DESC_1 = "BAG_DESC_1",
|
||||
EQUIP_DESC_29 = "EQUIP_DESC_29",
|
||||
EQUIP_DESC_30 = "EQUIP_DESC_30",
|
||||
EQUIP_DESC_31 = "EQUIP_DESC_31",
|
||||
EQUIP_DESC_32 = "EQUIP_DESC_32",
|
||||
}
|
||||
|
||||
return LocalizationGlobalConst
|
||||
@ -683,6 +683,8 @@ local localization_global =
|
||||
["BAG_DESC_1"] = "背包",
|
||||
["EQUIP_DESC_29"] = "只有上阵的英雄才能穿戴装备",
|
||||
["EQUIP_DESC_30"] = "穿戴",
|
||||
["EQUIP_DESC_31"] = "一键穿戴",
|
||||
["EQUIP_DESC_32"] = "装备培养",
|
||||
}
|
||||
|
||||
return localization_global
|
||||
@ -7,7 +7,7 @@ EquipConst.PART_TYPE = {
|
||||
EQUIP_3 = 3,
|
||||
EQUIP_4 = 4,
|
||||
EQUIP_5 = 5,
|
||||
EQUIP_6 = 5,
|
||||
EQUIP_6 = 6,
|
||||
}
|
||||
|
||||
return EquipConst
|
||||
@ -89,8 +89,9 @@ end
|
||||
|
||||
function EquipManager:onEquipWearRsp(result)
|
||||
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:calcPower()
|
||||
|
||||
AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP)
|
||||
end
|
||||
|
||||
@ -10,17 +10,19 @@ function EquipListCell:init()
|
||||
self.wearBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_30))
|
||||
|
||||
self.wearBtn:addClickListener(function()
|
||||
-- if DataManager.DailyTaskData:canClaimTask(self.taskId) then
|
||||
-- ModuleManager.TaskManager:claimDailyTask(self.taskId)
|
||||
-- else
|
||||
-- ModuleManager.TaskManager:taskGoto(self.taskType)
|
||||
-- local ids = {}
|
||||
-- for i = 1, GConst.EquipConst.PART_TYPE.EQUIP_6 do
|
||||
-- ids[i] = DataManager.EquipData:getPartEquipUid(self.slotId, i)
|
||||
-- end
|
||||
-- ids[self.equipPart] = self.entity:getUid()
|
||||
ModuleManager.EquipManager:onEquipWearReq(self.slotId, {self.entity:getUid()})
|
||||
end)
|
||||
end
|
||||
|
||||
function EquipListCell:refresh(entity, slotId)
|
||||
function EquipListCell:refresh(entity, slotId, equipPart)
|
||||
self.entity = entity
|
||||
self.slotId = slotId
|
||||
self.equipPart = equipPart
|
||||
self.nameTx:setText(entity:getName())
|
||||
self.powerTx:setText(entity:getPower())
|
||||
self.equipCell:refresh(entity, slotId)
|
||||
|
||||
@ -36,9 +36,13 @@ function EquipListUI:onLoadRootComplete()
|
||||
return EQUIP_LIST_CELL
|
||||
end)
|
||||
self.scrollRectComp:addRefreshCallback(function(index, cell)
|
||||
cell:refresh(self.equipList[index], self.slotId)
|
||||
cell:refresh(self.equipList[index], self.slotId, self.equipPart)
|
||||
end)
|
||||
self.scrollRectComp:clearCells()
|
||||
|
||||
self:bind(DataManager.HeroData, "isDirty", function()
|
||||
self:closeUI()
|
||||
end)
|
||||
end
|
||||
|
||||
function EquipListUI:onRefresh()
|
||||
@ -50,10 +54,10 @@ function EquipListUI:onRefresh()
|
||||
end
|
||||
|
||||
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
|
||||
local equipEntity = DataManager.EquipData:getEquipByUid(eid)
|
||||
self.equipCell:refresh(equipEntity, false, true)
|
||||
self.equipCell:refresh(equipEntity, self.equipPart)
|
||||
else
|
||||
self.equipCell:refreshEmpty(self.equipPart)
|
||||
end
|
||||
|
||||
@ -21,6 +21,8 @@ function EquipInfoComp:init()
|
||||
self.hpNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
|
||||
self.atkNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3))
|
||||
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.suitTxs = {}
|
||||
@ -32,9 +34,21 @@ function EquipInfoComp:init()
|
||||
end)
|
||||
end
|
||||
|
||||
-- self.txAttr:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_6))
|
||||
-- self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
|
||||
-- self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
|
||||
self.autoWaerBtn:addClickListener(function()
|
||||
local soltId = self.heroEntity:getMatchType()
|
||||
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()
|
||||
UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity})
|
||||
end)
|
||||
@ -97,7 +111,7 @@ function EquipInfoComp:refreshEquip()
|
||||
local eid = DataManager.EquipData:getPartEquipUid(self.heroEntity:getMatchType(), part)
|
||||
if eid and eid > 0 then
|
||||
local equipEntity = DataManager.EquipData:getEquipByUid(eid)
|
||||
self.equipCells[part]:refresh(equipEntity, false, true)
|
||||
self.equipCells[part]:refresh(equipEntity, part)
|
||||
else
|
||||
-- self.equipCells[part]:refreshByCustom(nil, part)
|
||||
self.equipCells[part]:refreshEmpty(part)
|
||||
|
||||
@ -96,6 +96,9 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
self:bind(DataManager.BagData.ItemData, "dirty", function()
|
||||
self:refreshPageBtn()
|
||||
end)
|
||||
self:bind(DataManager.HeroData, "isDirty", function()
|
||||
self:onRefresh()
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.HERO_UPGRADE_SUCCESS, function(id)
|
||||
self:refreshPageBtn()
|
||||
end)
|
||||
|
||||
@ -103,12 +103,12 @@ end
|
||||
|
||||
-- 基础属性
|
||||
function EquipData:getBaseAttr(id)
|
||||
return self:getConfig(id).base_attr
|
||||
return self:getConfig(id).base_attr
|
||||
end
|
||||
|
||||
-- 装备名字
|
||||
function EquipData:getName(id)
|
||||
return I18N:getText("equip", id, "name")
|
||||
return I18N:getText("equip", id, "name")
|
||||
end
|
||||
|
||||
--@endregion
|
||||
@ -156,23 +156,51 @@ end
|
||||
--@region 穿戴
|
||||
--装备穿戴
|
||||
function EquipData:onWearSuccess(soltId, uids)
|
||||
for i,uid in ipairs(uids) do
|
||||
local equip = self:getEquipByUid(uid)
|
||||
local part = equip:getPart()
|
||||
if part then
|
||||
local oldUid = self.slots[soltId].parts[part].equip_uid
|
||||
for i,info in ipairs(self.slots) do
|
||||
if i ~= soltId then
|
||||
if info.parts[part].equip_uid == uid then
|
||||
info.parts[part].equip_uid = oldUid
|
||||
end
|
||||
for _, uid in ipairs(uids) do
|
||||
local equip = self:getEquipByUid(uid)
|
||||
local part = equip:getPart()
|
||||
if part then
|
||||
local oldUid = self.slots[soltId].parts[part].equip_uid
|
||||
for i,info in ipairs(self.slots) do
|
||||
if i ~= soltId then
|
||||
if info.parts[part].equip_uid == uid then
|
||||
info.parts[part].equip_uid = oldUid
|
||||
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
|
||||
self.slots[soltId].parts[part].equip_uid = uid
|
||||
end
|
||||
end
|
||||
self:setDirty()
|
||||
-- DataManager.ForceData:updateTeamPower()
|
||||
return equip
|
||||
end
|
||||
--@endregion
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user