敌方属性
This commit is contained in:
parent
73cf5ee6c2
commit
4a53da9d7e
@ -16,6 +16,7 @@ function DataManager:init()
|
|||||||
self:initManager("HeroDataOther", "app/userdata/hero/hero_data_other")
|
self:initManager("HeroDataOther", "app/userdata/hero/hero_data_other")
|
||||||
self:initManager("BagData", "app/userdata/bag/bag_data")
|
self:initManager("BagData", "app/userdata/bag/bag_data")
|
||||||
self:initManager("EquipData", "app/userdata/equip/equip_data")
|
self:initManager("EquipData", "app/userdata/equip/equip_data")
|
||||||
|
self:initManager("EquipDataOther", "app/userdata/equip/equip_data_other")
|
||||||
self:initManager("SkinData", "app/userdata/skin/skin_data")
|
self:initManager("SkinData", "app/userdata/skin/skin_data")
|
||||||
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
||||||
self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data")
|
self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data")
|
||||||
|
|||||||
@ -1812,6 +1812,8 @@ function GFunc.formatPlayerFormationInfo(info)
|
|||||||
if not info.heroes then
|
if not info.heroes then
|
||||||
return formation
|
return formation
|
||||||
end
|
end
|
||||||
|
DataManager.HeroDataOther:clear()
|
||||||
|
DataManager.EquipDataOther:clear()
|
||||||
-- 天赋
|
-- 天赋
|
||||||
if info.talent then
|
if info.talent then
|
||||||
local TalentCfg = ConfigManager:getConfig("talent")
|
local TalentCfg = ConfigManager:getConfig("talent")
|
||||||
@ -1835,6 +1837,24 @@ function GFunc.formatPlayerFormationInfo(info)
|
|||||||
DataManager.HeroDataOther:setTalentAttr(attr)
|
DataManager.HeroDataOther:setTalentAttr(attr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- info.equips = {
|
||||||
|
-- {
|
||||||
|
-- {
|
||||||
|
-- cfg_id = 111;
|
||||||
|
-- level = 0;
|
||||||
|
-- refine = 0;
|
||||||
|
-- extra_attrs = {};
|
||||||
|
-- },
|
||||||
|
-- {
|
||||||
|
-- cfg_id = 252;
|
||||||
|
-- level = 0;
|
||||||
|
-- refine = 0;
|
||||||
|
-- extra_attrs = {};
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
DataManager.EquipDataOther:init(info.equips or {})
|
||||||
|
|
||||||
for index, info in ipairs(info.heroes) do
|
for index, info in ipairs(info.heroes) do
|
||||||
-- 只是配置检测
|
-- 只是配置检测
|
||||||
if DataManager.HeroData:isExistHeroById(info.id) then
|
if DataManager.HeroData:isExistHeroById(info.id) then
|
||||||
@ -1843,7 +1863,6 @@ function GFunc.formatPlayerFormationInfo(info)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
info.equips = info.equips or {}
|
|
||||||
info.skins = info.skins or {}
|
info.skins = info.skins or {}
|
||||||
info.heroes_runes = info.heroes_runes or {}
|
info.heroes_runes = info.heroes_runes or {}
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,73 @@ function EquipManager:onEquipDecomposeRsp(result)
|
|||||||
|
|
||||||
-- ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.EQUIP_RESOLVE_NUM, #result.reqData.ids)
|
-- ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.EQUIP_RESOLVE_NUM, #result.reqData.ids)
|
||||||
|
|
||||||
-- BIReport:postEquipResolveOpt(BIReport.EQUIP_OP_TYPE.RESOLVE, result.reqData.ids, result.rewards)
|
BIReport:postEquipResolveOpt(BIReport.EQUIP_OP_TYPE.RESOLVE, result.reqData.ids, result.rewards)
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
|
||||||
|
--@region 上报
|
||||||
|
local EVENT_NAME_EQUIP_OPT = "client_equip_opt"
|
||||||
|
|
||||||
|
BIReport.EQUIP_OP_TYPE = {
|
||||||
|
GET = "Get",
|
||||||
|
WEAR = "Wear",
|
||||||
|
LEVEL_UP = "LevelUp",
|
||||||
|
REFINE_UP = "RefineUp",
|
||||||
|
RESOLVE = "Resolve",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- 装备
|
||||||
|
function BIReport:postEquipWearOpt(optType, seat, list)
|
||||||
|
local str_list = ""
|
||||||
|
for _, equipId in ipairs(list) do
|
||||||
|
str_list = str_list .. equipId .. ";"
|
||||||
|
end
|
||||||
|
local args = {
|
||||||
|
opt_type = optType,
|
||||||
|
seat = seat,
|
||||||
|
wear_equips = str_list,
|
||||||
|
seat_data = DataManager.EquipData:getSeatDataString(),
|
||||||
|
}
|
||||||
|
self:report(EVENT_NAME_EQUIP_OPT, args)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BIReport:postEquipLvUpOpt(optType, seat, parts)
|
||||||
|
local strData = ""
|
||||||
|
for _, part in ipairs(parts) do
|
||||||
|
strData = strData .. part .. ";"
|
||||||
|
end
|
||||||
|
local args = {
|
||||||
|
opt_type = optType,
|
||||||
|
seat = seat,
|
||||||
|
part = strData,
|
||||||
|
seat_data = DataManager.EquipData:getSeatDataString(),
|
||||||
|
}
|
||||||
|
self:report(EVENT_NAME_EQUIP_OPT, args)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BIReport:postEquipResolveOpt(optType, resolveIds, rewards)
|
||||||
|
local args = {
|
||||||
|
opt_type = optType,
|
||||||
|
resolve_ids = resolveIds,
|
||||||
|
reward_str = rewards and GFunc.getRewardsStr(rewards) or nil,
|
||||||
|
seat_data = DataManager.EquipData:getSeatDataString(),
|
||||||
|
}
|
||||||
|
self:report(EVENT_NAME_EQUIP_OPT, args)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BIReport:postEquipGet(equipId, cfgId, getType)
|
||||||
|
local equip = DataManager.EquipData:getEquipByUid(equipId)
|
||||||
|
local args = {
|
||||||
|
opt_type = BIReport.EQUIP_OP_TYPE.GET,
|
||||||
|
equip_id = equipId,
|
||||||
|
equip_cfg_id = cfgId,
|
||||||
|
type = getType,
|
||||||
|
}
|
||||||
|
if equip then
|
||||||
|
args.equip_part = equip:getPart()
|
||||||
|
args.equip_qlt = equip:getQlt()
|
||||||
|
end
|
||||||
|
self:report(EVENT_NAME_EQUIP_OPT, args)
|
||||||
end
|
end
|
||||||
--@endregion
|
--@endregion
|
||||||
return EquipManager
|
return EquipManager
|
||||||
@ -19,7 +19,7 @@ function LargeHeroCell:init()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.baseObject:setAnchoredPositionX(OUT_SCREEN_X)
|
self.baseObject:setAnchoredPositionX(OUT_SCREEN_X)
|
||||||
ModuleManager.HeroManager:showHeroDetailUI(self.heroId)
|
ModuleManager.HeroManager:showHeroDetailUI(self.heroId, nil, nil, self.battleType)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
uiMap["large_hero_cell.hero_bg.use_btn"]:addClickListener(function()
|
uiMap["large_hero_cell.hero_bg.use_btn"]:addClickListener(function()
|
||||||
@ -31,7 +31,8 @@ function LargeHeroCell:init()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function LargeHeroCell:refresh(heroEntity, isGray, useFunc)
|
function LargeHeroCell:refresh(heroEntity, isGray, useFunc, battleType)
|
||||||
|
self.battleType = battleType
|
||||||
self.heroId = heroEntity:getCfgId()
|
self.heroId = heroEntity:getCfgId()
|
||||||
self.matchType = heroEntity:getMatchType()
|
self.matchType = heroEntity:getMatchType()
|
||||||
local heroInfo = heroEntity:getConfig()
|
local heroInfo = heroEntity:getConfig()
|
||||||
|
|||||||
@ -86,7 +86,9 @@ function EquipInfoComp:setParentUI(ui)
|
|||||||
self.uiRoot = ui
|
self.uiRoot = ui
|
||||||
end
|
end
|
||||||
|
|
||||||
function EquipInfoComp:setHeroData(heroEntity)
|
function EquipInfoComp:setHeroData(heroEntity, onlyLook, formationType)
|
||||||
|
self.onlyLook = onlyLook
|
||||||
|
self.formationType = formationType
|
||||||
if not self.heroEntity or self.heroEntity ~= heroEntity then
|
if not self.heroEntity or self.heroEntity ~= heroEntity then
|
||||||
for part = 1, 6 do
|
for part = 1, 6 do
|
||||||
local eid = DataManager.EquipData:getPartEquipUid(heroEntity:getMatchType(), part)
|
local eid = DataManager.EquipData:getPartEquipUid(heroEntity:getMatchType(), part)
|
||||||
@ -104,7 +106,7 @@ end
|
|||||||
|
|
||||||
function EquipInfoComp:refreshEquip()
|
function EquipInfoComp:refreshEquip()
|
||||||
local slotId = self.heroEntity:getMatchType()
|
local slotId = self.heroEntity:getMatchType()
|
||||||
self.curFormation = DataManager.FormationData:getStageFormation()
|
self.curFormation = DataManager.FormationData:getFormation(self.formationType)
|
||||||
if self.curFormation[slotId] ~= self.heroEntity:getCfgId() then
|
if self.curFormation[slotId] ~= self.heroEntity:getCfgId() then
|
||||||
self.emptyTx:setActive(true)
|
self.emptyTx:setActive(true)
|
||||||
self.equipNode:setActive(false)
|
self.equipNode:setActive(false)
|
||||||
|
|||||||
@ -308,7 +308,7 @@ function HeroComp:onClickHero(cell, heroId)
|
|||||||
targetPos = CS.BF.Utils.RectTransformScreenPointToLocalPointInRectangle(self.content:getTransform(), sPoint.x, sPoint.y, UIManager:getUICameraComponent())
|
targetPos = CS.BF.Utils.RectTransformScreenPointToLocalPointInRectangle(self.content:getTransform(), sPoint.x, sPoint.y, UIManager:getUICameraComponent())
|
||||||
self.largeHeroCell:getBaseObject():setAnchoredPosition(targetPos.x, targetPos.y)
|
self.largeHeroCell:getBaseObject():setAnchoredPosition(targetPos.x, targetPos.y)
|
||||||
self.largeHeroCell:getBaseObject():getTransform():SetAsLastSibling()
|
self.largeHeroCell:getBaseObject():getTransform():SetAsLastSibling()
|
||||||
self.largeHeroCell:refresh(entity, not entity:isActived(), self.onClickUseFunc)
|
self.largeHeroCell:refresh(entity, not entity:isActived(), self.onClickUseFunc, self.battleType)
|
||||||
self.largeHeroCell:showCheck(self.curFormation[entity:getMatchType()] == heroId)
|
self.largeHeroCell:showCheck(self.curFormation[entity:getMatchType()] == heroId)
|
||||||
else
|
else
|
||||||
ModuleManager.HeroManager:showHeroDetailUI(heroId, nil, nil, self.battleType)
|
ModuleManager.HeroManager:showHeroDetailUI(heroId, nil, nil, self.battleType)
|
||||||
|
|||||||
@ -200,7 +200,7 @@ function HeroDetailUI:getIsOpen(page)
|
|||||||
elseif page == GConst.HeroConst.PANEL_TYPE.STAR then
|
elseif page == GConst.HeroConst.PANEL_TYPE.STAR then
|
||||||
return DataManager.HeroData:isStarOpen()
|
return DataManager.HeroData:isStarOpen()
|
||||||
elseif page == GConst.HeroConst.PANEL_TYPE.EQUIP then
|
elseif page == GConst.HeroConst.PANEL_TYPE.EQUIP then
|
||||||
return true
|
return DataManager.EquipData:isOpen()
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -407,7 +407,7 @@ function HeroDetailUI:showHeroInfo()
|
|||||||
self.compHero:setParentUI(self)
|
self.compHero:setParentUI(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.compHero:setHeroData(self.heroEntity, self.onlyLook)
|
self.compHero:setHeroData(self.heroEntity, self.onlyLook, self.formationType)
|
||||||
self.compHero:refresh(self.checkLvUpState)
|
self.compHero:refresh(self.checkLvUpState)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ function HeroDetailUI:showStarInfo()
|
|||||||
self.compStar:setParentUI(self)
|
self.compStar:setParentUI(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.compStar:setHeroData(self.heroEntity, self.onlyLook)
|
self.compStar:setHeroData(self.heroEntity, self.onlyLook, self.formationType)
|
||||||
self.compStar:refresh(self.checkLvUpState)
|
self.compStar:refresh(self.checkLvUpState)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ function HeroDetailUI:showEquipInfo()
|
|||||||
self.compEquip:setParentUI(self)
|
self.compEquip:setParentUI(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.compEquip:setHeroData(self.heroEntity)
|
self.compEquip:setHeroData(self.heroEntity, self.onlyLook, self.formationType)
|
||||||
self.compEquip:refresh(self.checkLvUpState)
|
self.compEquip:refresh(self.checkLvUpState)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -55,10 +55,11 @@ function HeroInfoComp:setParentUI(parentUI)
|
|||||||
self.parentUI = parentUI
|
self.parentUI = parentUI
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroInfoComp:setHeroData(heroEntity, onlyLook)
|
function HeroInfoComp:setHeroData(heroEntity, onlyLook, formationType)
|
||||||
self.curLevel = heroEntity:getLv()
|
self.curLevel = heroEntity:getLv()
|
||||||
self.heroEntity = heroEntity
|
self.heroEntity = heroEntity
|
||||||
self.onlyLook = onlyLook
|
self.onlyLook = onlyLook
|
||||||
|
self.formationType = formationType
|
||||||
-- self:bind(self.heroEntity, "isDirty", function()
|
-- self:bind(self.heroEntity, "isDirty", function()
|
||||||
-- self:refresh(true)
|
-- self:refresh(true)
|
||||||
-- end)
|
-- end)
|
||||||
|
|||||||
@ -51,9 +51,10 @@ function StarInfoComp:setParentUI(parentUI)
|
|||||||
self.parentUI = parentUI
|
self.parentUI = parentUI
|
||||||
end
|
end
|
||||||
|
|
||||||
function StarInfoComp:setHeroData(heroEntity, onlyLook)
|
function StarInfoComp:setHeroData(heroEntity, onlyLook, formationType)
|
||||||
self.heroEntity = heroEntity
|
self.heroEntity = heroEntity
|
||||||
self.onlyLook = onlyLook
|
self.onlyLook = onlyLook
|
||||||
|
self.formationType = formationType
|
||||||
-- self:bind(self.heroEntity, "isDirty", function()
|
-- self:bind(self.heroEntity, "isDirty", function()
|
||||||
-- self:refresh(true)
|
-- self:refresh(true)
|
||||||
-- end)
|
-- end)
|
||||||
|
|||||||
@ -964,10 +964,10 @@ function EquipData:getEquipAttrBySlotId(heroId, slotId)
|
|||||||
if not self.slots[slotId] or not self.slots[slotId].parts then
|
if not self.slots[slotId] or not self.slots[slotId].parts then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
local curFormation = DataManager.FormationData:getStageFormation()
|
-- local curFormation = DataManager.FormationData:getStageFormation()
|
||||||
if curFormation[slotId] ~= heroId then
|
-- if curFormation[slotId] ~= heroId then
|
||||||
return {}
|
-- return {}
|
||||||
end
|
-- end
|
||||||
|
|
||||||
local allAttr = {}
|
local allAttr = {}
|
||||||
for part, info in ipairs(self.slots[slotId].parts) do
|
for part, info in ipairs(self.slots[slotId].parts) do
|
||||||
|
|||||||
174
lua/app/userdata/equip/equip_data_other.lua
Normal file
174
lua/app/userdata/equip/equip_data_other.lua
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
local EquipDataOther = class("EquipDataOther", BaseData)
|
||||||
|
local EquipEntityOther = require "app/userdata/equip/equip_entity_other"
|
||||||
|
|
||||||
|
function EquipDataOther:ctor()
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipDataOther:clear()
|
||||||
|
self.allEquips = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipDataOther:init(data)
|
||||||
|
data = data or GConst.EMPTY_TABLE
|
||||||
|
if EDITOR_MODE then
|
||||||
|
Logger.logHighlight("装备数据")
|
||||||
|
Logger.printTable(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.allEquips = {}
|
||||||
|
self.equipLvs = {}
|
||||||
|
self.equipRefineLvs = {}
|
||||||
|
for slotId = 1, 5 do
|
||||||
|
for part = 1, 6 do
|
||||||
|
if data[slotId] and data[slotId][part] then
|
||||||
|
local uid = slotId * 100 + part
|
||||||
|
local equip = EquipEntityOther:create(data[slotId][part])
|
||||||
|
self.allEquips[uid] = equip
|
||||||
|
self.equipLvs[uid] = data[slotId][part].level
|
||||||
|
self.equipRefineLvs[uid] = data[slotId][part].refine
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--@region 属性
|
||||||
|
function EquipDataOther:getResonateLevelValue(type, value, value2)
|
||||||
|
local list = DataManager.EquipData:getResonateList(type)
|
||||||
|
local lv = 0
|
||||||
|
local nextLv = 0
|
||||||
|
local attrs = {}
|
||||||
|
local attrNexts = {}
|
||||||
|
for i,v in ipairs(list) do
|
||||||
|
if type == 1 or type == 3 then
|
||||||
|
if v.parameter[1] <= value then
|
||||||
|
lv = i
|
||||||
|
for _, vv in ipairs(v.attr) do
|
||||||
|
attrs[vv.type] = (attrs[vv.type] or 0) + vv.num
|
||||||
|
end
|
||||||
|
else
|
||||||
|
nextLv = v.parameter
|
||||||
|
for _, vv in ipairs(v.attr) do
|
||||||
|
attrNexts[vv.type] = (attrNexts[vv.type] or 0) + vv.num
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
elseif type == 2 then
|
||||||
|
local isTrue = false
|
||||||
|
if v.parameter[1] < value then
|
||||||
|
isTrue = true
|
||||||
|
elseif v.parameter[1] == value and v.parameter[2] <= value2 then
|
||||||
|
isTrue = true
|
||||||
|
end
|
||||||
|
if isTrue then
|
||||||
|
lv = i
|
||||||
|
for _, vv in ipairs(v.attr) do
|
||||||
|
attrs[vv.type] = (attrs[vv.type] or 0) + vv.num
|
||||||
|
end
|
||||||
|
else
|
||||||
|
nextLv = v.parameter
|
||||||
|
for _, vv in ipairs(v.attr) do
|
||||||
|
attrNexts[vv.type] = (attrNexts[vv.type] or 0) + vv.num
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return lv, nextLv, attrs, attrNexts, table.nums(list)
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipDataOther:getResonateLevel(type, slotId)
|
||||||
|
if type == 1 then
|
||||||
|
local minLv = 999
|
||||||
|
for i = 1, 6 do
|
||||||
|
local uid = slotId * 100 + i
|
||||||
|
local level = self.equipLvs[uid] or 0
|
||||||
|
if level < minLv then
|
||||||
|
minLv = level
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:getResonateLevelValue(type, minLv)
|
||||||
|
elseif type == 2 then
|
||||||
|
local qlt = 99
|
||||||
|
local star = 99
|
||||||
|
for i = 1, 6 do
|
||||||
|
local uid = slotId * 100 + i
|
||||||
|
local equip = self.allEquips[uid]
|
||||||
|
if equip == nil then
|
||||||
|
qlt = 0
|
||||||
|
star = 0
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local q = equip:getQlt()
|
||||||
|
local s = equip:getStar()
|
||||||
|
if qlt > q then
|
||||||
|
qlt = q
|
||||||
|
star = s
|
||||||
|
elseif qlt == q then
|
||||||
|
if star > s then
|
||||||
|
qlt = q
|
||||||
|
star = s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:getResonateLevelValue(type, qlt, star)
|
||||||
|
elseif type == 3 then
|
||||||
|
local minRefine = 999
|
||||||
|
for i = 1, 6 do
|
||||||
|
local uid = slotId * 100 + i
|
||||||
|
local refine = self.equipRefineLvs[uid] or 0
|
||||||
|
if refine < minRefine then
|
||||||
|
minRefine = refine
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:getResonateLevelValue(type, minRefine)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipDataOther:getEquipAttrBySlotId(slotId)
|
||||||
|
local allAttr = {}
|
||||||
|
for part = 1, 6 do
|
||||||
|
local uid = slotId * 100 + part
|
||||||
|
local equip = self.allEquips[uid]
|
||||||
|
if equip then
|
||||||
|
local attr = equip:getAllAttr()
|
||||||
|
for k, v in pairs(attr) do
|
||||||
|
allAttr[k] = (allAttr[k] or 0) + v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 升级属性
|
||||||
|
local level = self.equipLvs[uid] or 0
|
||||||
|
local baseType = equip:getBaseAttr().type
|
||||||
|
allAttr[baseType] = (attr[baseType] or 0) + DataManager.EquipData:getBaseAttrLvAdd(baseType, level)
|
||||||
|
|
||||||
|
-- 精炼属性
|
||||||
|
local equipAttrs = equip:getExtraMap()
|
||||||
|
local refine = self.equipRefineLvs[uid] or 0
|
||||||
|
if refine > 0 then
|
||||||
|
for _, extraAttr in pairs(equipAttrs) do
|
||||||
|
local attrName = GFunc.getAttrNameById(extraAttr.id)
|
||||||
|
local nowAttr = DataManager.EquipData:getRefineAttrAdd(refine, attrName)
|
||||||
|
allAttr[attrName] = (allAttr[attrName] or 0) + nowAttr.num
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 共鸣
|
||||||
|
for i = 1, 3 do
|
||||||
|
local lv = self:getResonateLevel(i, slotId)
|
||||||
|
local list = DataManager.EquipData:getResonateList(i)
|
||||||
|
for ii, vv in ipairs(list) do
|
||||||
|
if ii <= lv then
|
||||||
|
for _, vvv in ipairs(vv.attr or {}) do
|
||||||
|
allAttr[vvv.type] = (allAttr[vvv.type] or 0) + vvv.num
|
||||||
|
end
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return allAttr
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
return EquipDataOther
|
||||||
10
lua/app/userdata/equip/equip_data_other.lua.meta
Normal file
10
lua/app/userdata/equip/equip_data_other.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 115f9b491d4684b5ebe3f5abff60965f
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
139
lua/app/userdata/equip/equip_entity_other.lua
Normal file
139
lua/app/userdata/equip/equip_entity_other.lua
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
local EquipEntity = require "app/userdata/equip/equip_entity"
|
||||||
|
local EquipEntityOther = class("EquipEntityOther", EquipEntity)
|
||||||
|
|
||||||
|
local EquipCfg = ConfigManager:getConfig("equip")
|
||||||
|
|
||||||
|
function EquipEntityOther:ctor(equip)
|
||||||
|
self.baseAttrs = {}
|
||||||
|
self:init(equip)
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:init(equip)
|
||||||
|
self:setId(equip.cfg_id)
|
||||||
|
self:initBaseAttr()
|
||||||
|
self:setExtraAttr(equip.extra_attrs)
|
||||||
|
|
||||||
|
self.lastPower = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:setId(id)
|
||||||
|
self.id = id
|
||||||
|
self.config = EquipCfg[id]
|
||||||
|
end
|
||||||
|
|
||||||
|
--获取配置id
|
||||||
|
function EquipEntityOther:getId()
|
||||||
|
return self.id
|
||||||
|
end
|
||||||
|
|
||||||
|
--@region 属性
|
||||||
|
function EquipEntityOther:initBaseAttr()
|
||||||
|
for k,v in pairs(self.config.base_attr) do
|
||||||
|
self.baseAttrs[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:setExtraAttr(attr)
|
||||||
|
self.extraAttrs = {}
|
||||||
|
self.extraMap = attr
|
||||||
|
if attr and #attr > 0 then
|
||||||
|
for i, data in pairs(attr) do
|
||||||
|
local attrType = GFunc.getAttrNameById(data.id)
|
||||||
|
if attrType then
|
||||||
|
self.extraAttrs[attrType] = (self.extraAttrs[attrType] or 0) + data.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.allAttrs = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:getBaseAttr()
|
||||||
|
return self.baseAttrs
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:getExtraMap()
|
||||||
|
return self.extraMap
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:getExtraList()
|
||||||
|
local list = {}
|
||||||
|
for k,v in pairs(self.extraAttrs) do
|
||||||
|
table.insert(list, {type = k, num = v, id = GFunc.getAttrIdByName(k)})
|
||||||
|
end
|
||||||
|
table.sort(list, function (a, b)
|
||||||
|
return a.id < b.id
|
||||||
|
end)
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:getExtraAttrs()
|
||||||
|
return self.extraAttrs
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:getAllAttr()
|
||||||
|
if self.allAttrs == nil then
|
||||||
|
self.allAttrs = {}
|
||||||
|
-- 基础
|
||||||
|
-- for attrName, attrNum in pairs(self:getBaseAttr()) do
|
||||||
|
-- self.allAttrs[attrName] = (self.allAttrs[attrName] or 0) + attrNum
|
||||||
|
-- end
|
||||||
|
self.allAttrs[self.baseAttrs.type] = (self.allAttrs[self.baseAttrs.type] or 0) + self.baseAttrs.num
|
||||||
|
-- 额外属性
|
||||||
|
for attrName, attrNum in pairs(self:getExtraAttrs()) do
|
||||||
|
self.allAttrs[attrName] = (self.allAttrs[attrName] or 0) + attrNum
|
||||||
|
end
|
||||||
|
|
||||||
|
-- self:calcPower()
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.allAttrs
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
|
||||||
|
--@region 战力
|
||||||
|
function EquipEntityOther:setPowerDirty()
|
||||||
|
self.data.isPowerDirty = not self.data.isPowerDirty
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:getPower()
|
||||||
|
if not self.curPower then
|
||||||
|
self:getAllAttr()
|
||||||
|
end
|
||||||
|
return self.curPower
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 计算战斗力
|
||||||
|
function EquipEntityOther:calcPower()
|
||||||
|
if self.lastPower then
|
||||||
|
self.lastPower = self.curPower
|
||||||
|
end
|
||||||
|
self.curPower = math.floor(self:_getAttrPower())
|
||||||
|
if not self.lastPower then
|
||||||
|
self.lastPower = self.curPower
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.lastPower ~= self.curPower then
|
||||||
|
self:setPowerDirty()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function EquipEntityOther:_getAttrPower()
|
||||||
|
local power = 0
|
||||||
|
local attr = self:getAllAttr()
|
||||||
|
for attrName, attrNum in pairs(attr) do
|
||||||
|
local cfg = GFunc.getAttrNameCfg()[attrName]
|
||||||
|
if cfg then
|
||||||
|
local realValue = attrNum
|
||||||
|
-- 特殊处理,玩家基础暴击伤害不算
|
||||||
|
if attrName == GConst.BattleConst.ATTR_NAME.CRIT_TIME then
|
||||||
|
realValue = attrNum - 15000
|
||||||
|
end
|
||||||
|
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR + 0.0000001)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return power
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
|
||||||
|
return EquipEntityOther
|
||||||
10
lua/app/userdata/equip/equip_entity_other.lua.meta
Normal file
10
lua/app/userdata/equip/equip_entity_other.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4a93f5a0ffdca410c973334c22d0ac33
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -146,6 +146,7 @@ end
|
|||||||
-- end
|
-- end
|
||||||
|
|
||||||
function FormationData:getFormation(formationType)
|
function FormationData:getFormation(formationType)
|
||||||
|
formationType = formationType or GConst.BattleConst.FORMATION_TYPE.STAGE
|
||||||
local formation = self.formations[formationType]
|
local formation = self.formations[formationType]
|
||||||
if formation == nil then
|
if formation == nil then
|
||||||
formation = {}
|
formation = {}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
local HeroEntity = require "app/userdata/hero/hero_entity_other"
|
local HeroEntityOther = require "app/userdata/hero/hero_entity_other"
|
||||||
local HeroDataOther = class("HeroDataOther", BaseData)
|
local HeroDataOther = class("HeroDataOther", BaseData)
|
||||||
|
|
||||||
function HeroDataOther:ctor()
|
function HeroDataOther:ctor()
|
||||||
@ -14,7 +14,7 @@ function HeroDataOther:clear()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function HeroDataOther:getEntity(heroStruct)
|
function HeroDataOther:getEntity(heroStruct)
|
||||||
return HeroEntity:create(heroStruct.id, heroStruct.level, heroStruct.skin, heroStruct.star)
|
return HeroEntityOther:create(heroStruct.id, heroStruct.level, heroStruct.skin, heroStruct.star)
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroDataOther:getMatchType(heroId)
|
function HeroDataOther:getMatchType(heroId)
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
local HeroEntity = class("HeroEntity", BaseData)
|
local HeroEntity = require "app/userdata/hero/hero_entity"
|
||||||
|
local HeroEntityOther = class("HeroEntityOther", HeroEntity)
|
||||||
local ATTR_NAME = GConst.BattleConst.ATTR_NAME
|
local ATTR_NAME = GConst.BattleConst.ATTR_NAME
|
||||||
|
|
||||||
function HeroEntity:ctor(cfgId, lv, skin, star)
|
function HeroEntityOther:ctor(cfgId, lv, skin, star)
|
||||||
self.cfgId = cfgId
|
self.cfgId = cfgId
|
||||||
self.data.isDirty = false
|
self.data.isDirty = false
|
||||||
self.data.lv = lv
|
self.data.lv = lv
|
||||||
@ -20,60 +21,8 @@ function HeroEntity:ctor(cfgId, lv, skin, star)
|
|||||||
self.attrBaseDirty = true
|
self.attrBaseDirty = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- region 属性
|
|
||||||
function HeroEntity:initAttr()
|
|
||||||
self.allBaseAttr[ATTR_NAME.HP] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.ATK] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.ATK_RED] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.ATK_YELLOW] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.ATK_GREEN] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.ATK_BLUE] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.ATK_PURPLE] = 0
|
|
||||||
self.allBaseAttr[ATTR_NAME.DMGDEC] = 0
|
|
||||||
|
|
||||||
self:_updateAllBaseAttr()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:onBaseAttrChange()
|
|
||||||
self:_updateBaseAttr()
|
|
||||||
self:_updateTotalAttr()
|
|
||||||
self:setDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:onStarAttrChange()
|
|
||||||
self:_updateStarAttr()
|
|
||||||
self:_updateTotalAttr()
|
|
||||||
self:setDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:onSkinAttrChange()
|
|
||||||
self:_updateSkinAttr()
|
|
||||||
self:_updateTotalAttr()
|
|
||||||
self:setDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:setDirty()
|
|
||||||
self.data.isDirty = not self.data.isDirty
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:setAttrDirty()
|
|
||||||
self.attrDirty = true
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:setBaseAttrDirty()
|
|
||||||
self.attrBaseDirty = true
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getAllAttr()
|
|
||||||
if self.attrDirty == true then
|
|
||||||
self.attrDirty = false
|
|
||||||
self:_updateAllAttr()
|
|
||||||
end
|
|
||||||
return self.allAttr
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新所有属性(包括其他英雄的加成)
|
-- 更新所有属性(包括其他英雄的加成)
|
||||||
function HeroEntity:_updateAllAttr()
|
function HeroEntityOther:_updateAllAttr()
|
||||||
self.allAttr = {}
|
self.allAttr = {}
|
||||||
self.allBaseAttr = self:_getAllBaseAttr()
|
self.allBaseAttr = self:_getAllBaseAttr()
|
||||||
for k, v in pairs(self.allBaseAttr) do
|
for k, v in pairs(self.allBaseAttr) do
|
||||||
@ -81,7 +30,7 @@ function HeroEntity:_updateAllAttr()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 装备
|
-- 装备
|
||||||
local equipAttr = DataManager.EquipData:getEquipAttrBySlotId(self.cfgId, self:getMatchType())
|
local equipAttr = DataManager.EquipDataOther:getEquipAttrBySlotId(self:getMatchType())
|
||||||
for k, v in pairs(equipAttr) do
|
for k, v in pairs(equipAttr) do
|
||||||
self.allAttr[k] = (self.allAttr[k] or 0) + v
|
self.allAttr[k] = (self.allAttr[k] or 0) + v
|
||||||
end
|
end
|
||||||
@ -131,776 +80,8 @@ function HeroEntity:_updateAllAttr()
|
|||||||
self:calcPower()
|
self:calcPower()
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:getGlobalAttrByType(attrType)
|
function HeroEntityOther:getGlobalAttrByType(attrType)
|
||||||
return DataManager.HeroDataOther:getAttrByMatchType(self:getMatchType(), attrType) or 0
|
return DataManager.HeroDataOther:getAttrByMatchType(self:getMatchType(), attrType) or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:_getAllBaseAttr()
|
return HeroEntityOther
|
||||||
if self.attrBaseDirty == true then
|
|
||||||
self.attrBaseDirty = false
|
|
||||||
self:_updateAllBaseAttr()
|
|
||||||
end
|
|
||||||
return self.allBaseAttr
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新所有属性(自己)
|
|
||||||
function HeroEntity:_updateAllBaseAttr()
|
|
||||||
self:_updateBaseAttr()
|
|
||||||
self:_updateLvAttr()
|
|
||||||
self:_updateStarAttr()
|
|
||||||
-- self:_updateSkinAttr()
|
|
||||||
self:_updateTotalAttr()
|
|
||||||
|
|
||||||
-- 处理全局属性
|
|
||||||
local attr = {}
|
|
||||||
if self.allBaseAttr[GConst.MATCH_ALL_ATKP_NAME[self:getMatchType()]] ~= nil then
|
|
||||||
attr[GConst.MATCH_ALL_ATKP_NAME[self:getMatchType()]] = self.allBaseAttr[GConst.MATCH_ALL_ATKP_NAME[self:getMatchType()]]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_ATK_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_ATK_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_HP_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_HP_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_DMGDEC_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_DMGDEC_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_CRIT_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_CRIT_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_CRIT_TIME_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_CRIT_TIME_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_NORMAL_HURTP_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_NORMAL_HURTP_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_SKILL_HURTP_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_SKILL_HURTP_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_ATKP_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_ATKP_ALL]
|
|
||||||
-- attr[GConst.ATTR_ALL.ATTR_HPP_ALL] = self.allBaseAttr[GConst.ATTR_ALL.ATTR_HPP_ALL]
|
|
||||||
for _, v in pairs(GConst.ATTR_ALL) do
|
|
||||||
attr[v] = self.allBaseAttr[v]
|
|
||||||
end
|
|
||||||
|
|
||||||
DataManager.HeroDataOther:setHeroAttr(self:getCfgId(), attr)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新英雄基础属性
|
|
||||||
function HeroEntity:_updateBaseAttr()
|
|
||||||
self.baseAttrOriginal[ATTR_NAME.HP] = self:getCfgHp()
|
|
||||||
self.baseAttrOriginal[ATTR_NAME.ATK_RED] = 0
|
|
||||||
self.baseAttrOriginal[ATTR_NAME.ATK_YELLOW] = 0
|
|
||||||
self.baseAttrOriginal[ATTR_NAME.ATK_GREEN] = 0
|
|
||||||
self.baseAttrOriginal[ATTR_NAME.ATK_BLUE] = 0
|
|
||||||
self.baseAttrOriginal[ATTR_NAME.ATK_PURPLE] = 0
|
|
||||||
self.baseAttrOriginal[GConst.MATCH_ATTACK_NAME[self.config.position]] = self:getCfgAtk()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新升级属性
|
|
||||||
function HeroEntity:_updateLvAttr()
|
|
||||||
self.lvAttr = {}
|
|
||||||
local lvPoint = self:getLvAttrPointList()
|
|
||||||
for i = 1, #lvPoint do
|
|
||||||
if self.data.lv >= lvPoint[i] then
|
|
||||||
local attr = self:getLvAttrCfg(i)
|
|
||||||
self.lvAttr[attr.type] = (self.lvAttr[attr.type] or 0) + attr.num
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新升星属性
|
|
||||||
function HeroEntity:_updateStarAttr()
|
|
||||||
self.starAttr = {}
|
|
||||||
for i = 1, self.data.star do
|
|
||||||
local attrs = self:getStarAttrCfg(i)
|
|
||||||
for _, attr in ipairs(attrs) do
|
|
||||||
self.starAttr[attr.type] = (self.starAttr[attr.type] or 0) + attr.num
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarAttr()
|
|
||||||
self:getAllAttr()
|
|
||||||
return self.starAttr
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新皮肤属性
|
|
||||||
function HeroEntity:_updateSkinAttr()
|
|
||||||
self.skinAttr = {}
|
|
||||||
|
|
||||||
-- local hp = DataManager.SkinData:getHp(self)
|
|
||||||
-- local atk = DataManager.SkinData:getAttack(self)
|
|
||||||
-- local normalHurt = DataManager.SkinData:getNormalHurt(self)
|
|
||||||
-- local skillHurt = DataManager.SkinData:getSkillHurt(self)
|
|
||||||
-- local critPer = DataManager.SkinData:getCritPercent(self)
|
|
||||||
-- local critHurtPer = DataManager.SkinData:getCritHurtPercent(self)
|
|
||||||
-- local normalHurtPer = DataManager.SkinData:getNormalHurtPercent(self)
|
|
||||||
-- local skillHurtPer = DataManager.SkinData:getSkillHurtPercent(self)
|
|
||||||
-- local healPer = DataManager.SkinData:getHealPercent(self)
|
|
||||||
|
|
||||||
-- self.skinAttr[GConst.MATCH_HP_NAME[self:getMatchType()]] = hp
|
|
||||||
-- self.skinAttr[GConst.MATCH_ATTACK_NAME[self:getMatchType()]] = atk
|
|
||||||
-- self.skinAttr[GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()]] = normalHurt
|
|
||||||
-- self.skinAttr[GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()]] = skillHurt
|
|
||||||
-- self.skinAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] = critPer
|
|
||||||
-- self.skinAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] = critHurtPer
|
|
||||||
-- self.skinAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] = normalHurtPer
|
|
||||||
-- self.skinAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] = skillHurtPer
|
|
||||||
-- self.skinAttr[GConst.MATCH_CURED_NAME[self:getMatchType()]] = healPer
|
|
||||||
|
|
||||||
-- if EDITOR_MODE then
|
|
||||||
-- local printStr = ""
|
|
||||||
-- printStr = printStr .. "更新皮肤数值:"..self:getCfgId() .. "\n"
|
|
||||||
-- printStr = printStr .. "生命:".. hp .. "\n"
|
|
||||||
-- printStr = printStr .. "攻击力:".. atk .. "\n"
|
|
||||||
-- printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
|
|
||||||
-- printStr = printStr .. "技能增伤:".. skillHurt .. "\n"
|
|
||||||
-- printStr = printStr .. "暴击率:".. critPer .. "\n"
|
|
||||||
-- printStr = printStr .. "暴击伤害百分比:".. critHurtPer .. "\n"
|
|
||||||
-- printStr = printStr .. "普攻增伤百分比:".. normalHurtPer .. "\n"
|
|
||||||
-- printStr = printStr .. "技能增伤百分比:".. skillHurtPer .. "\n"
|
|
||||||
-- printStr = printStr .. "治疗加成百分比:".. healPer .. "\n"
|
|
||||||
-- Logger.logHighlight(printStr)
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 更新总属性
|
|
||||||
function HeroEntity:_updateTotalAttr()
|
|
||||||
self.allBaseAttr = {}
|
|
||||||
for k, v in pairs(self.baseAttrOriginal) do
|
|
||||||
self.allBaseAttr[k] = (self.allBaseAttr[k] or 0) + v
|
|
||||||
end
|
|
||||||
for k, v in pairs(self.lvAttr) do
|
|
||||||
self.allBaseAttr[k] = (self.allBaseAttr[k] or 0) + v
|
|
||||||
end
|
|
||||||
for k, v in pairs(self.starAttr) do
|
|
||||||
self.allBaseAttr[k] = (self.allBaseAttr[k] or 0) + v
|
|
||||||
end
|
|
||||||
-- for k, v in pairs(self.skinAttr) do
|
|
||||||
-- self.allBaseAttr[k] = (self.allBaseAttr[k] or 0) + v
|
|
||||||
-- end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getTotalAttrValue(name)
|
|
||||||
local attr = self:getAllAttr()
|
|
||||||
return attr[name] or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getAtk()
|
|
||||||
local attr = self:getAllAttr()
|
|
||||||
return attr[GConst.MATCH_ATTACK_NAME[self:getMatchType()]]
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getHp()
|
|
||||||
local attr = self:getAllAttr()
|
|
||||||
return attr[GConst.MATCH_HP_NAME[self:getMatchType()]]
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getCfgHp(lv)
|
|
||||||
lv = lv or self.data.lv
|
|
||||||
if lv > self:getMaxLv() then
|
|
||||||
lv = self:getMaxLv()
|
|
||||||
end
|
|
||||||
if self.config and self.config.hp then
|
|
||||||
return self.config.hp[lv] or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getCfgAtk(lv)
|
|
||||||
lv = lv or self.data.lv
|
|
||||||
if lv > self:getMaxLv() then
|
|
||||||
lv = self:getMaxLv()
|
|
||||||
end
|
|
||||||
if self.config and self.config.atk then
|
|
||||||
return self.config.atk[lv] or 0
|
|
||||||
end
|
|
||||||
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
-- region 基础
|
|
||||||
function HeroEntity:setLv(lv, onlyChangeLv)
|
|
||||||
if not lv then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.data.lv == lv then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.isNew = lv == 1
|
|
||||||
self.data.lv = lv
|
|
||||||
self:_updateAllBaseAttr()
|
|
||||||
self:setDirty()
|
|
||||||
self:setAttrDirty()
|
|
||||||
|
|
||||||
if not onlyChangeLv then
|
|
||||||
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
|
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.HERO_UPGRADE_SUCCESS, self:getCfgId())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getIsNew()
|
|
||||||
local isNew = self.isNew
|
|
||||||
self.isNew = false
|
|
||||||
return isNew
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getLv()
|
|
||||||
return self.data.lv
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getBeginLv()
|
|
||||||
return self.beginLv
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:isMaxLv()
|
|
||||||
return self.data.lv >= self:getMaxLv()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getMaxLv()
|
|
||||||
if not self.maxLv then
|
|
||||||
self.maxLv = ConfigManager:getConfigNum("hero_level")
|
|
||||||
end
|
|
||||||
return self.maxLv
|
|
||||||
end
|
|
||||||
|
|
||||||
-- function HeroEntity:getCurrMaxLv()
|
|
||||||
-- local cfg = ConfigManager:getConfig("hero_level")
|
|
||||||
-- local lv = self.data.lv
|
|
||||||
-- if lv <= 0 then
|
|
||||||
-- return 1
|
|
||||||
-- end
|
|
||||||
-- for i = self.data.lv, #cfg do
|
|
||||||
-- if cfg[i].star > self.data.star then
|
|
||||||
-- break
|
|
||||||
-- else
|
|
||||||
-- lv = i
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- return lv
|
|
||||||
-- end
|
|
||||||
|
|
||||||
function HeroEntity:getNextMaxLv()
|
|
||||||
local cfg = ConfigManager:getConfig("hero_level")
|
|
||||||
local lv = self.data.lv
|
|
||||||
for i = self.data.lv + 1, #cfg do
|
|
||||||
if self.data.star + 1 >= cfg[i].star then
|
|
||||||
lv = i
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return lv
|
|
||||||
end
|
|
||||||
|
|
||||||
-- function HeroEntity:getNextLv()
|
|
||||||
-- local cfg = ConfigManager:getConfig("hero_level")
|
|
||||||
-- local lv = self.data.lv
|
|
||||||
-- for i = self.data.lv + 1, #cfg do
|
|
||||||
-- if self.data.star >= cfg[i].star then
|
|
||||||
-- lv = i
|
|
||||||
-- else
|
|
||||||
-- break
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- return lv
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function HeroEntity:getIsCurLvMax()
|
|
||||||
-- if self:isMaxLv() then
|
|
||||||
-- return true
|
|
||||||
-- end
|
|
||||||
-- local cfg = ConfigManager:getConfig("hero_level")[self.data.lv + 1]
|
|
||||||
-- if not cfg then
|
|
||||||
-- return true
|
|
||||||
-- end
|
|
||||||
-- return self.data.star < cfg.star
|
|
||||||
-- end
|
|
||||||
|
|
||||||
function HeroEntity:canLvUp(showToast)
|
|
||||||
if self:isMaxLv() then
|
|
||||||
return false, GConst.HeroConst.CHECK_LV_UP_STATE.MAX_LV
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if self:getIsCurLvMax() then
|
|
||||||
-- return false, GConst.HeroConst.CHECK_LV_UP_STATE.NEED_STAR
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local costNum = self:getLvUpMaterialNum()
|
|
||||||
if not costNum then
|
|
||||||
return false, GConst.HeroConst.CHECK_LV_UP_STATE.NO_COST
|
|
||||||
end
|
|
||||||
|
|
||||||
if not GFunc.checkCost(self:getLvUpCostId(), costNum, showToast) then
|
|
||||||
return false, GConst.HeroConst.CHECK_LV_UP_STATE.FRAGMENT_NOT_ENOUGH
|
|
||||||
end
|
|
||||||
|
|
||||||
return true, GConst.HeroConst.CHECK_LV_UP_STATE.SUCCESS
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:isUnlock()
|
|
||||||
if self:isActived() then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
if self:canLvUp() then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:isActived()
|
|
||||||
return self.data.lv >= self:getBeginLv()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getLvUpLv()
|
|
||||||
local count = 0
|
|
||||||
local costId1 = self.config.level_id[1]
|
|
||||||
local totalCost1 = 0
|
|
||||||
local totalCost2 = 0
|
|
||||||
-- local nextLv = self:getNextLv()
|
|
||||||
for i = 1, 5 do
|
|
||||||
-- if self.data.lv + i > nextLv then
|
|
||||||
-- break
|
|
||||||
-- end
|
|
||||||
local lv = self.data.lv + i
|
|
||||||
local nextLvInfo = ConfigManager:getConfig("hero_level")[lv]
|
|
||||||
if not nextLvInfo then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
local needCostId = self:getLvUpCostId()
|
|
||||||
if needCostId == costId1 then
|
|
||||||
totalCost1 = totalCost1 + self:getLvUpMaterialNum()
|
|
||||||
if not GFunc.checkCost(needCostId, totalCost1, false) then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
else
|
|
||||||
totalCost2 = totalCost2 + self:getLvUpMaterialNum()
|
|
||||||
if not GFunc.checkCost(needCostId, totalCost2, false) then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
return count + self.data.lv, count ~= 0
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
-- region 配置
|
|
||||||
function HeroEntity:getConfig()
|
|
||||||
return self.config
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getModelId()
|
|
||||||
-- local skinModel = DataManager.SkinData:getModelId(self:getSkinId())
|
|
||||||
-- return skinModel or self.config.model_id
|
|
||||||
return self.config.model_id
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getBaseSkill()
|
|
||||||
return self.config.base_skill
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getHurtSkill()
|
|
||||||
return self.config.hurt_skill
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getFragmentId()
|
|
||||||
return self.config.item_id
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getIcon()
|
|
||||||
return self.config.icon
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getHurtNum()
|
|
||||||
return self.config.hurt_num
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getLvUpCostId()
|
|
||||||
local list = self:getLvAttrPointList()
|
|
||||||
if table.containValue(list, self.data.lv + 1) then
|
|
||||||
return self.config.level_id[2]
|
|
||||||
else
|
|
||||||
return self.config.level_id[1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getLvUpMaterialNum()
|
|
||||||
if self.data.lv <= 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local lv = self.data.lv + 1
|
|
||||||
if lv < self:getBeginLv() then
|
|
||||||
lv = self:getBeginLv()
|
|
||||||
end
|
|
||||||
local nextLvInfo = ConfigManager:getConfig("hero_level")[lv]
|
|
||||||
if not nextLvInfo then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local fieldName = "cost_" .. self:getQlt()
|
|
||||||
return nextLvInfo[fieldName][2]
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function HeroEntity:getCfgId()
|
|
||||||
return self.cfgId
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getName()
|
|
||||||
return ModuleManager.HeroManager:getHeroName(self:getCfgId())
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getDesc()
|
|
||||||
return ModuleManager.HeroManager:getHeroDesc(self:getCfgId())
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getQlt()
|
|
||||||
return self.config.qlt
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getMatchType()
|
|
||||||
return self.config.position
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarUpCostId()
|
|
||||||
return self.config.star_id
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarAttrCfg(star)
|
|
||||||
local cfg = ConfigManager:getConfig("hero_star")
|
|
||||||
return cfg[star]["attr_" .. self:getQlt()]
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarAttrTxt()
|
|
||||||
return self.config.star_txt
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getLvAttrCfg(lvPoint)
|
|
||||||
if lvPoint then
|
|
||||||
return self.config.level_attr[lvPoint]
|
|
||||||
end
|
|
||||||
return self.config.level_attr
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getLvAttrPointList()
|
|
||||||
return self.config.level_point
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
-- function HeroEntity:getActiveRogueCount()
|
|
||||||
-- local lvInfo = ConfigManager:getConfig("hero_level")[self.data.lv]
|
|
||||||
-- if not lvInfo then
|
|
||||||
-- return 0
|
|
||||||
-- end
|
|
||||||
-- --@TODO 123123
|
|
||||||
-- -- return lvInfo.unlock_skill
|
|
||||||
-- return 0
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- region 技能
|
|
||||||
function HeroEntity:getUnlockRogueId()
|
|
||||||
return self.config.rouge_skill
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:checkSkillUnlock()
|
|
||||||
if not self.oldStar then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
local needPop = false
|
|
||||||
local isUnlock = false
|
|
||||||
local skillIdx = 1
|
|
||||||
for i = 1, 4 do
|
|
||||||
local ids = self.config["rouge_skill_" .. i]
|
|
||||||
if ids then
|
|
||||||
for ii = #ids, 1, -1 do
|
|
||||||
if self.data.star >= ids[ii][1] and self.oldStar < ids[ii][1] then
|
|
||||||
skillIdx = i
|
|
||||||
needPop = true
|
|
||||||
isUnlock = ii == 1
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
if needPop then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
self.oldStar = nil
|
|
||||||
return needPop, isUnlock, skillIdx
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getRogueSkillList()
|
|
||||||
if not self.rogueSkillList then
|
|
||||||
self.rogueSkillList = {}
|
|
||||||
local count = 1
|
|
||||||
while true do
|
|
||||||
local ids = self.config["rouge_skill_" .. count]
|
|
||||||
if ids then
|
|
||||||
for i = #ids, 1, -1 do
|
|
||||||
if self.data.star >= ids[i][1] or i == 1 then
|
|
||||||
table.insert(self.rogueSkillList, ids[i])
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return self.rogueSkillList
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getUnlockSkillIdx(checkUp)
|
|
||||||
if not checkUp then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local count = 1
|
|
||||||
while true do
|
|
||||||
local ids = self.config["rouge_skill_" .. count]
|
|
||||||
if ids then
|
|
||||||
for i = #ids, 1, -1 do
|
|
||||||
if self.data.star == ids[i][1] then
|
|
||||||
return count
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getRogueSkillListBattle()
|
|
||||||
if not self.rogueSkillListBattle then
|
|
||||||
self.rogueSkillListBattle = {}
|
|
||||||
local count = 1
|
|
||||||
while true do
|
|
||||||
local ids = self.config["rouge_skill_" .. count]
|
|
||||||
if ids then
|
|
||||||
for i = #ids, 1, -1 do
|
|
||||||
if self.data.star >= ids[i][1] then
|
|
||||||
table.insert(self.rogueSkillListBattle, ids[i][2])
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return self.rogueSkillListBattle
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getRogueSkillListByIdx(idx)
|
|
||||||
local ids = self.config["rouge_skill_" .. idx]
|
|
||||||
local lv = 0
|
|
||||||
if ids then
|
|
||||||
for i = #ids, 1, -1 do
|
|
||||||
if self.data.star >= ids[i][1]then
|
|
||||||
lv = i
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return ids, lv
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getNextRougeLvUp(idx)
|
|
||||||
local ids = self.config["rouge_skill_" .. idx]
|
|
||||||
if ids then
|
|
||||||
for i,v in ipairs(ids) do
|
|
||||||
if self.data.star < ids[i][1] then
|
|
||||||
return ids[i][1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getActiveRogueSkills()
|
|
||||||
local list = {}
|
|
||||||
local count = 1
|
|
||||||
while true do
|
|
||||||
local ids = self.config["rouge_skill_" .. count]
|
|
||||||
if ids then
|
|
||||||
for i = #ids, 1, -1 do
|
|
||||||
if self.data.star >= ids[i][1] then
|
|
||||||
table.insert(list, ids[i][2])
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
return list
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
-- region 升星相关
|
|
||||||
function HeroEntity:getStar()
|
|
||||||
return self.data.star
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getIsStarMax()
|
|
||||||
local nextLvInfo = ConfigManager:getConfig("hero_star")[self.data.star + 1]
|
|
||||||
if not nextLvInfo then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarUpMaterialNum()
|
|
||||||
local nextLvInfo = ConfigManager:getConfig("hero_star")[self.data.star + 1]
|
|
||||||
if not nextLvInfo then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local fieldName = "cost_" .. self:getQlt()
|
|
||||||
return nextLvInfo[fieldName]
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:canStarUp(showToast)
|
|
||||||
if self:getIsStarMax() then
|
|
||||||
return false, GConst.HeroConst.CHECK_LV_UP_STATE.MAX_LV
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if not self:getIsCurLvMax() then
|
|
||||||
-- return false, GConst.HeroConst.CHECK_LV_UP_STATE.NEED_LV
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local costNum = self:getStarUpMaterialNum()
|
|
||||||
if not costNum then
|
|
||||||
return false, GConst.HeroConst.CHECK_LV_UP_STATE.NO_COST
|
|
||||||
end
|
|
||||||
|
|
||||||
if not GFunc.checkCost(self:getStarUpCostId(), costNum, showToast) then
|
|
||||||
return false, GConst.HeroConst.CHECK_LV_UP_STATE.FRAGMENT_NOT_ENOUGH
|
|
||||||
end
|
|
||||||
-- local itemCost = cost[2] or 0
|
|
||||||
-- if not GFunc.checkCost(self:getStarUpCostId(), itemCost, showToast) then
|
|
||||||
-- return false, GConst.HeroConst.CHECK_LV_UP_STATE.COIN_NOT_ENOUGH
|
|
||||||
-- end
|
|
||||||
|
|
||||||
return true, GConst.HeroConst.CHECK_LV_UP_STATE.SUCCESS
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:onHeroStarUp()
|
|
||||||
self.oldStar = self.data.star
|
|
||||||
self.data.star = self.data.star + 1
|
|
||||||
self:setBaseAttrDirty()
|
|
||||||
self:setDirty()
|
|
||||||
self:setAttrDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getMaxStar()
|
|
||||||
return #self:getStarCfg()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarCfg()
|
|
||||||
return ConfigManager:getConfig("hero_star")
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getStarUnlockSkillId(star)
|
|
||||||
local count = 1
|
|
||||||
while true do
|
|
||||||
local ids = self.config["rouge_skill_" .. count]
|
|
||||||
if ids then
|
|
||||||
for i = #ids, 1, -1 do
|
|
||||||
if star == ids[i][1] then
|
|
||||||
return ids[i][2]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
break
|
|
||||||
end
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
-- region 皮肤相关
|
|
||||||
|
|
||||||
-- 获取当前穿戴皮肤
|
|
||||||
function HeroEntity:getSkinId()
|
|
||||||
if self.data.skin == nil or self.data.skin == 0 then
|
|
||||||
return DataManager.SkinData:getOriginSkinId(self:getCfgId())
|
|
||||||
end
|
|
||||||
return self.data.skin
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 穿戴皮肤
|
|
||||||
function HeroEntity:onChangeSkin(skinId)
|
|
||||||
self.data.skin = skinId
|
|
||||||
self:setDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getSkins()
|
|
||||||
return self.unlockSkins
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:setSkins(skinIds)
|
|
||||||
self.unlockSkins = skinIds
|
|
||||||
self:getTotalAttrValue() -- 防止报错
|
|
||||||
self:onSkinAttrChange()
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
--@region 战力
|
|
||||||
function HeroEntity:setPowerDirty()
|
|
||||||
self.data.isPowerDirty = not self.data.isPowerDirty
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:getPower()
|
|
||||||
if not self.curPower or self.attrDirty then
|
|
||||||
self:getAllAttr()
|
|
||||||
end
|
|
||||||
return self.curPower
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 计算战斗力
|
|
||||||
function HeroEntity:calcPower()
|
|
||||||
if self.lastPower then
|
|
||||||
self.lastPower = self.curPower
|
|
||||||
end
|
|
||||||
self.curPower = math.floor(self:_getAttrPower())
|
|
||||||
if not self.lastPower then
|
|
||||||
self.lastPower = self.curPower
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.lastPower ~= self.curPower then
|
|
||||||
self:setPowerDirty()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:_getAttrPower()
|
|
||||||
local power = 0
|
|
||||||
for attrName, attrNum in pairs(self:getAllAttr()) do
|
|
||||||
local cfg = GFunc.getAttrNameCfg()[attrName]
|
|
||||||
if cfg then
|
|
||||||
local realValue = attrNum
|
|
||||||
-- 特殊处理,玩家基础暴击伤害不算
|
|
||||||
if attrName == GConst.BattleConst.ATTR_NAME.CRIT_TIME then
|
|
||||||
realValue = attrNum - 15000
|
|
||||||
end
|
|
||||||
|
|
||||||
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR + 0.0000001)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return power
|
|
||||||
end
|
|
||||||
--@endregion
|
|
||||||
|
|
||||||
--@region 红点
|
|
||||||
function HeroEntity:showRedPointEntrance()
|
|
||||||
return self:canLvUp() or self:canStarUp()
|
|
||||||
end
|
|
||||||
|
|
||||||
function HeroEntity:showRedPoint(page)
|
|
||||||
if page == GConst.HeroConst.PANEL_TYPE.HERO then
|
|
||||||
return self:canLvUp()
|
|
||||||
elseif page == GConst.HeroConst.PANEL_TYPE.STAR then
|
|
||||||
return self:canStarUp()
|
|
||||||
elseif page == GConst.HeroConst.PANEL_TYPE.EQUIP then
|
|
||||||
return DataManager.EquipData:hasEquipRedPoint(self:getMatchType())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--@endregion
|
|
||||||
return HeroEntity
|
|
||||||
Loading…
x
Reference in New Issue
Block a user