diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index 0d484f0c..69cce666 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -13,6 +13,7 @@ function DataManager:init() self:initManager("ArenaData", "app/userdata/arena/arena_data") self:initManager("CollectionData", "app/userdata/collection/collection_data") self:initManager("HeroData", "app/userdata/hero/hero_data") + self:initManager("HeroDataOther", "app/userdata/hero/hero_data_other") self:initManager("BagData", "app/userdata/bag/bag_data") self:initManager("EquipData", "app/userdata/equip/equip_data") self:initManager("SkinData", "app/userdata/skin/skin_data") @@ -156,9 +157,9 @@ function DataManager:initWithServerData(data) self.PlayerData:init(data) self.ChapterData:init(data.chapter) self.DailyChallengeData:init(data.chapter_daily_challenge) - self.DungeonData:initDungeonGold(data.chapter_gold_challenge) - self.DungeonData:initDungeonShards(data.chapter_shards_challenge) - self.FormationData:init(data.fight_info) + -- self.DungeonData:initDungeonGold(data.chapter_gold_challenge) + -- self.DungeonData:initDungeonShards(data.chapter_shards_challenge) + self.FormationData:init(data.formations) self.EquipData:init(data.equip) self.SkinData:init(data.bag.skins) self.TalentData:init(data.talent) diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index 451b9975..29532e4c 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -1770,18 +1770,46 @@ end -- info = {array_heroes, heroes_equips, skins, heroes_runes} -- 服务器返回的数据 function GFunc.formatPlayerFormationInfo(info) local formation = {} - if not info.array_heroes then + if not info.heroes then return formation end - for index, info in ipairs(info.array_heroes) do + -- 天赋 + if info.talent then + local TalentCfg = ConfigManager:getConfig("talent") + local allAttr = {} + for id = 1, #TalentCfg do + local cfg = TalentCfg[id] + local lv = info.talent[id] or 0 + if lv and lv > 0 and cfg.attr then + for _, v in ipairs(cfg.attr) do + allAttr[v.type] = (allAttr[v.type] or 0) + v.num + end + end + end + + -- 处理全局属性 + local attr = {} + attr[GConst.ALL_ATTR.ATTR_ATK_ALL] = allAttr[GConst.ALL_ATTR.ATTR_ATK_ALL] + attr[GConst.ALL_ATTR.ATTR_HP_ALL] = allAttr[GConst.ALL_ATTR.ATTR_HP_ALL] + attr[GConst.ALL_ATTR.ATTR_DMGDEC_ALL] = allAttr[GConst.ALL_ATTR.ATTR_DMGDEC_ALL] + attr[GConst.ALL_ATTR.ATTR_CRIT_ALL] = allAttr[GConst.ALL_ATTR.ATTR_CRIT_ALL] + attr[GConst.ALL_ATTR.ATTR_CRIT_TIME_ALL] = allAttr[GConst.ALL_ATTR.ATTR_CRIT_TIME_ALL] + attr[GConst.ALL_ATTR.ATTR_NORMAL_HURTP_ALL] = allAttr[GConst.ALL_ATTR.ATTR_NORMAL_HURTP_ALL] + attr[GConst.ALL_ATTR.ATTR_SKILL_HURTP_ALL] = allAttr[GConst.ALL_ATTR.ATTR_SKILL_HURTP_ALL] + attr[GConst.ALL_ATTR.ATTR_ATKP_ALL] = allAttr[GConst.ALL_ATTR.ATTR_ATKP_ALL] + + DataManager.HeroDataOther:setTalentAttr(attr) + end + + for index, info in ipairs(info.heroes) do if DataManager.HeroData:isExistHeroById(info.id) then - local heroEntity = DataManager.HeroData:getEntity(info) + local heroEntity = DataManager.HeroDataOther:getEntity(info) formation[heroEntity:getMatchType()] = heroEntity end end - if not info.heroes_equips then - info.heroes_equips = {} + if not info.equips then + info.equips = {} end if not info.skins then info.skins = {} @@ -1790,6 +1818,11 @@ function GFunc.formatPlayerFormationInfo(info) info.heroes_runes = {} end + -- 有全局的属性 需要在最后重新计算 + for _, entity in pairs(formation) do + entity:setAttrDirty() + end + -- for matchType, heroEntity in pairs(formation) do -- local heroId = heroEntity:getCfgId() diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index d126755f..f5af2b9a 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -100,15 +100,18 @@ BattleConst.IS_PVP_BATTLE = { [BattleConst.BATTLE_TYPE.ACT_PVP] = true, } +-- // 1 主线 2 每日挑战 3 日常副本 4 竞技场进攻 5 竞技场防守 -- 编队 BattleConst.FORMATION_TYPE = { STAGE = "1",-- 主线章节 - ARENA_ATTACK = "2",-- 竞技场进攻 - ARENA_DEFEND = "3",-- 竞技场防守 - DUNGEON_WEAPON = "4", -- 武器副本 - DUNGEON_ARMOR = "5", -- 支线副本 - BOSS_RUSH = "6", -- boss rush - DUNGEON_RUNE = "7", -- 符文副本 + DAILY_CHALLENGE = "2",-- 每日挑战 + DUNGEON = "3",-- 日常副本 + ARENA_ATTACK = "4",-- 竞技场进攻 + ARENA_DEFEND = "5",-- 竞技场防守 + DUNGEON_WEAPON = "41", -- 武器副本 + DUNGEON_ARMOR = "51", -- 支线副本 + BOSS_RUSH = "61", -- boss rush + DUNGEON_RUNE = "71", -- 符文副本 } BattleConst.TYPEOF_LUA_COMP = { diff --git a/lua/app/module/formation/formation_manager.lua b/lua/app/module/formation/formation_manager.lua index 0916eb3c..5913278d 100644 --- a/lua/app/module/formation/formation_manager.lua +++ b/lua/app/module/formation/formation_manager.lua @@ -14,7 +14,7 @@ end function FormationManager:upHeroToStageFormationFinish(result) if result.err_code == GConst.ERROR_STR.SUCCESS then - DataManager.FormationData:init(result) + DataManager.FormationData:initStage(result) DataManager.HeroData:setDirty() local data = {} diff --git a/lua/app/ui/arena/arena_formation_ui.lua b/lua/app/ui/arena/arena_formation_ui.lua index 4678d9c0..2ffa95f4 100644 --- a/lua/app/ui/arena/arena_formation_ui.lua +++ b/lua/app/ui/arena/arena_formation_ui.lua @@ -61,12 +61,14 @@ function ArenaFormationUI:onLoadRootComplete() uiMap["arena_formation_ui.banner.btn_attack"]:addClickListener(function() self.formationType = GConst.BattleConst.FORMATION_TYPE.ARENA_ATTACK self:onRefresh() + self.heroComp:hideLargeHeroCell() end) self.selectDefend = uiMap["arena_formation_ui.banner.btn_defend.img_select"] uiMap["arena_formation_ui.banner.btn_defend.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_9)) uiMap["arena_formation_ui.banner.btn_defend"]:addClickListener(function() self.formationType = GConst.BattleConst.FORMATION_TYPE.ARENA_DEFEND self:onRefresh() + self.heroComp:hideLargeHeroCell() end) local heroUI = uiMap["arena_formation_ui.hero_ui"] diff --git a/lua/app/ui/hero/hero_comp.lua b/lua/app/ui/hero/hero_comp.lua index 1f13d739..1ea6e490 100644 --- a/lua/app/ui/hero/hero_comp.lua +++ b/lua/app/ui/hero/hero_comp.lua @@ -288,6 +288,10 @@ function HeroComp:refreshScrollRect() end end +function HeroComp:hideLargeHeroCell() + self.largeHeroCell:getBaseObject():setAnchoredPositionX(OUT_SCREEN_X) +end + function HeroComp:onClickHero(cell, heroId) if not cell or not heroId then self.largeHeroCell:getBaseObject():setAnchoredPositionX(OUT_SCREEN_X) diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 9ae4314a..1e99960a 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -1171,11 +1171,11 @@ function MainCityUI:checkTutorial(onlyCheck) end end - if DataManager.DungeonData:isOpenAnyone() then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_DUNGEON, onlyCheck) then - return true - end - end + -- if DataManager.DungeonData:isOpenAnyone() then + -- if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_DUNGEON, onlyCheck) then + -- return true + -- end + -- end if DataManager.ArenaData:isOpen() then if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.UNLOCK_ARENA, onlyCheck) then @@ -1183,23 +1183,23 @@ function MainCityUI:checkTutorial(onlyCheck) end end - if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_WEAPON) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.WEAPON_DUNGEON, onlyCheck) then - return true - end - end + -- if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_WEAPON) then + -- if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.WEAPON_DUNGEON, onlyCheck) then + -- return true + -- end + -- end - if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_ARMOR) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.ARMOR_DUNGEON, onlyCheck) then - return true - end - end + -- if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.EQUIP_ARMOR) then + -- if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.ARMOR_DUNGEON, onlyCheck) then + -- return true + -- end + -- end - if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.RUNES_OPEN) then - if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.RUNE_DUNGEON, onlyCheck) then - return true - end - end + -- if DataManager.DungeonData:isOpen(ModuleManager.MODULE_KEY.RUNES_OPEN) then + -- if ModuleManager.TutorialManager:checkFuncTutorial(GConst.TutorialConst.RUNE_DUNGEON, onlyCheck) then + -- return true + -- end + -- end end -- 检查礼包(首充(作废)/入门/章节/新手/助力/成长/金币顺序) diff --git a/lua/app/userdata/formation/formation_data.lua b/lua/app/userdata/formation/formation_data.lua index 37cb1a49..31d0d867 100644 --- a/lua/app/userdata/formation/formation_data.lua +++ b/lua/app/userdata/formation/formation_data.lua @@ -5,27 +5,46 @@ function FormationData:ctor() self.formations = {} end --- 初始化主线阵容 +-- 初始化阵容 function FormationData:init(data) - if self.formations == nil then - self.formations = {} - end + data = data or {} + self.formations = self.formations or {} - if data and data.heroes then + for i = 1, 5 do + if data[i] and data[i].heroes then + local clientFormation = {} + for matchType, heroId in pairs(data[i].heroes) do + clientFormation[tonumber(matchType)] = heroId + end + self.formations[tostring(i)] = clientFormation + else + self.formations[tostring(i)] = {0,0,0,0,0} + end + end + self:setDirty() +end + +-- 初始化主线阵容 +function FormationData:initStage(data) + data = data or {} + self.formations = self.formations or {} + + if data.heroes then local clientFormation = {} for matchType, heroId in pairs(data.heroes) do clientFormation[tonumber(matchType)] = heroId end self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = clientFormation + else + self.formations[GConst.BattleConst.FORMATION_TYPE.STAGE] = {0,0,0,0,0} end self:setDirty() end + -- 初始化竞技场阵容 function FormationData:initArena(attack, defend) - if self.formations == nil then - self.formations = {} - end + self.formations = self.formations or {} -- 位置顺序特殊处理 self.formations[GConst.BattleConst.FORMATION_TYPE.ARENA_ATTACK] = {0,0,0,0,0} @@ -46,33 +65,33 @@ function FormationData:initArena(attack, defend) self:setDirty() end -function FormationData:initDungeonWeapon(heroes) - if self.formations == nil then - self.formations = {} - end +-- function FormationData:initDungeonWeapon(heroes) +-- if self.formations == nil then +-- self.formations = {} +-- end - self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON] = {} - for idx, id in pairs(heroes) do - if id and id ~= 0 then - local matchType = DataManager.HeroData:getHeroById(id):getMatchType() - self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON][matchType] = id - end - end -end +-- self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON] = {} +-- for idx, id in pairs(heroes) do +-- if id and id ~= 0 then +-- local matchType = DataManager.HeroData:getHeroById(id):getMatchType() +-- self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON][matchType] = id +-- end +-- end +-- end -function FormationData:initDungeonArmor(heroes) - if self.formations == nil then - self.formations = {} - end +-- function FormationData:initDungeonArmor(heroes) +-- if self.formations == nil then +-- self.formations = {} +-- end - self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR] = {} - for idx, id in pairs(heroes) do - if id and id ~= 0 then - local matchType = DataManager.HeroData:getHeroById(id):getMatchType() - self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR][matchType] = id - end - end -end +-- self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR] = {} +-- for idx, id in pairs(heroes) do +-- if id and id ~= 0 then +-- local matchType = DataManager.HeroData:getHeroById(id):getMatchType() +-- self.formations[GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR][matchType] = id +-- end +-- end +-- end function FormationData:initFormationByType(formationType, heroes) if self.formations == nil then @@ -100,41 +119,41 @@ function FormationData:getArenaDefendFormation() return self:getFormation(GConst.BattleConst.FORMATION_TYPE.ARENA_DEFEND) end -function FormationData:getDungeonWeaponFormation() - local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON) - if table.nums(formation) <= 0 then - self:setFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 - formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON) - end - return formation -end +-- function FormationData:getDungeonWeaponFormation() +-- local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON) +-- if table.nums(formation) <= 0 then +-- self:setFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 +-- formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_WEAPON) +-- end +-- return formation +-- end -function FormationData:getDungeonArmorFormation() - local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR) - if table.nums(formation) <= 0 then - self:setFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 - formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR) - end - return formation -end +-- function FormationData:getDungeonArmorFormation() +-- local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR) +-- if table.nums(formation) <= 0 then +-- self:setFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 +-- formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR) +-- end +-- return formation +-- end -function FormationData:getBossRushFormation() - local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH) - if table.nums(formation) <= 0 then - self:setFormation(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 - formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH) - end - return formation -end +-- function FormationData:getBossRushFormation() +-- local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH) +-- if table.nums(formation) <= 0 then +-- self:setFormation(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 +-- formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.BOSS_RUSH) +-- end +-- return formation +-- end -function FormationData:getDungeonRuneFormation() - local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_RUNE) - if table.nums(formation) <= 0 then - self:setFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_RUNE, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 - formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_RUNE) - end - return formation -end +-- function FormationData:getDungeonRuneFormation() +-- local formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_RUNE) +-- if table.nums(formation) <= 0 then +-- self:setFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_RUNE, self:getFormation(GConst.BattleConst.FORMATION_TYPE.STAGE)) -- 如果没有,则用默认关卡 +-- formation = self:getFormation(GConst.BattleConst.FORMATION_TYPE.DUNGEON_RUNE) +-- end +-- return formation +-- end function FormationData:getFormation(formationType) local formation = self.formations[formationType] diff --git a/lua/app/userdata/hero/hero_data_other.lua b/lua/app/userdata/hero/hero_data_other.lua new file mode 100644 index 00000000..a9db75b7 --- /dev/null +++ b/lua/app/userdata/hero/hero_data_other.lua @@ -0,0 +1,60 @@ +local HeroEntity = require "app/userdata/hero/hero_entity_other" +local HeroDataOther = class("HeroDataOther", BaseData) + +function HeroDataOther:ctor() + self.allAtkpAttr = {} + self.allAtkpAttrByHero = {} + self.allAtkpAttrByTalent = {} +end + +function HeroDataOther:clear() + self.allAtkpAttr = {} + self.allAtkpAttrByHero = {} + self.allAtkpAttrByTalent = {} +end + +function HeroDataOther:getEntity(heroStruct) + return HeroEntity:create(heroStruct.id, heroStruct.level, heroStruct.skin, heroStruct.star) +end + +function HeroDataOther:getMatchType(heroId) + return DataManager.HeroData:getHeroConfig(heroId).position +end + +-- region 属性相关 +function HeroDataOther:getAttrByMatchType(matchType, attrType) + self.allAtkpAttr[matchType] = self.allAtkpAttr[matchType] or {} + return self.allAtkpAttr[matchType][attrType] or 0 +end + +function HeroDataOther:setHeroAttr(heroId, attr) + self.allAtkpAttrByHero[heroId] = attr + self:calcAttr() +end + +function HeroDataOther:setTalentAttr(attr) + self.allAtkpAttrByTalent = attr + self:calcAttr() +end + +function HeroDataOther:calcAttr() + self.allAtkpAttr = {} + for heroId, attrs in pairs(self.allAtkpAttrByHero) do + -- self.baseAttrOriginal[ATTR_NAME.ATK_RED] = 0 + local matchType = self:getMatchType(heroId) + self.allAtkpAttr[matchType] = self.allAtkpAttr[matchType] or {} + for k,v in pairs(attrs) do + self.allAtkpAttr[matchType][k] = (self.allAtkpAttr[matchType][k] or 0) + v + end + end + + for k, v in pairs(self.allAtkpAttrByTalent) do + for matchType = 1, 5 do + self.allAtkpAttr[matchType] = self.allAtkpAttr[matchType] or {} + self.allAtkpAttr[matchType][k] = (self.allAtkpAttr[matchType][k] or 0) + v + end + end +end +-- endregion + +return HeroDataOther \ No newline at end of file diff --git a/lua/app/userdata/hero/hero_data_other.lua.meta b/lua/app/userdata/hero/hero_data_other.lua.meta new file mode 100644 index 00000000..1679af98 --- /dev/null +++ b/lua/app/userdata/hero/hero_data_other.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 77692c43fec474d1d9c0c9d40d129157 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/hero/hero_entity_other.lua b/lua/app/userdata/hero/hero_entity_other.lua new file mode 100644 index 00000000..613ad5fd --- /dev/null +++ b/lua/app/userdata/hero/hero_entity_other.lua @@ -0,0 +1,801 @@ +local HeroEntity = class("HeroEntity", BaseData) +local ATTR_NAME = GConst.BattleConst.ATTR_NAME + +function HeroEntity:ctor(cfgId, lv, skin, star) + self.cfgId = cfgId + self.data.isDirty = false + self.data.lv = lv + self.data.skin = skin + self.data.star = star or 0 + self.config = ConfigManager:getConfig("hero")[self.cfgId] + self.beginLv = 1 -- 激活等级 + self.isNew = false + + self.baseAttrOriginal = {} + self.starAttr = {} + self.skinAttr = {} + self.allBaseAttr = {} + self.allAttr = {} + self.attrDirty = true + self.attrBaseDirty = true +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() + self.allAttr = {} + self.allBaseAttr = self:_getAllBaseAttr() + for k, v in pairs(self.allBaseAttr) do + self.allAttr[k] = v + end + +-- GConst.ALL_ATTR = { +-- ATTR_ATK_ALL = "atk_all", -- 全体英雄攻击(固定值) +-- ATTR_HP_ALL = "attr_hp_all", -- 全体英雄生命(固定值) +-- ATTR_DMGDEC_ALL = "attr_dmgdec_all", -- 全体减伤(固定值) +-- ATTR_CRIT_ALL = "attr_crit_all", -- 全体暴击率 +-- ATTR_CRIT_TIME_ALL = "attr_crit_time_all", -- 全体暴击伤害 +-- ATTR_NORMAL_HURTP_ALL = "attr_normal_hurtp_all",-- 全体普攻增伤(百分比) +-- ATTR_SKILL_HURTP_ALL = "attr_skill_hurtp_all", -- 全体技能增伤(百分比) +-- ATTR_ATKP_ALL = "attr_atkp_all", -- 全体攻击(百分比) +-- } + + -- 同属性通用加成 + self.allAttr[GConst.MATCH_ALL_ATKP_NAME[self:getMatchType()]] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_ATK_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_HP_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_DMGDEC_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_CRIT_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_CRIT_TIME_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_NORMAL_HURTP_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_SKILL_HURTP_ALL] = nil + self.allAttr[GConst.ALL_ATTR.ATTR_ATKP_ALL] = nil + + -- 攻击力(百分比) + local atkType = GConst.MATCH_ATTACK_NAME[self:getMatchType()] + local allAtk = DataManager.HeroDataOther:getAttrByMatchType(self:getMatchType(), GConst.ALL_ATTR.ATTR_ATK_ALL) + local atkpType = GConst.MATCH_ALL_ATKP_NAME[self:getMatchType()] + local allFactorValue = DataManager.HeroDataOther:getAttrByMatchType(self:getMatchType(), atkpType) + local factorValue = self.allAttr[GConst.MATCH_ATTACK_ADD_NAME[self:getMatchType()]] or 0 + local allAtkP = self:getGlobalAttrByType(GConst.ALL_ATTR.ATTR_ATKP_ALL) + local atk = self.allAttr[atkType] + allAtk + self.allAttr[atkType] = math.floor(atk * (1 + (factorValue + allFactorValue + allAtkP) / GConst.DEFAULT_FACTOR) + 0.0000001) + self.allAttr[GConst.MATCH_ATTACK_ADD_NAME[self:getMatchType()]] = nil + + -- 生命(百分比) + local hpType = GConst.MATCH_HP_NAME[self:getMatchType()] + local allHp = DataManager.HeroDataOther:getAttrByMatchType(self:getMatchType(), GConst.ALL_ATTR.ATTR_HP_ALL) + local factorValue = self.allAttr[GConst.MATCH_HP_ADD_NAME[self:getMatchType()]] or 0 + local hp = self.allAttr[hpType] + allHp + self.allAttr[hpType] = math.floor(hp * (1 + factorValue / GConst.DEFAULT_FACTOR) + 0.0000001) + self.allAttr[GConst.MATCH_HP_ADD_NAME[self:getMatchType()]] = nil + + self.allAttr[ATTR_NAME.DMGDEC] = (self.allAttr[ATTR_NAME.DMGDEC] or 0) + self:getGlobalAttrByType(GConst.ALL_ATTR.ATTR_DMGDEC_ALL) + self.allAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ALL_ATTR.ATTR_CRIT_ALL) + self.allAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ALL_ATTR.ATTR_CRIT_TIME_ALL) + self.allAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ALL_ATTR.ATTR_NORMAL_HURTP_ALL) + self.allAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ALL_ATTR.ATTR_SKILL_HURTP_ALL) + + self:calcPower() +end + +function HeroEntity:getGlobalAttrByType(attrType) + return DataManager.HeroDataOther:getAttrByMatchType(self:getMatchType(), attrType) or 0 +end + +function HeroEntity:_getAllBaseAttr() + if self.attrBaseDirty == true then + self.attrBaseDirty = false + self:_updateAllBaseAttr() + end + return self.allBaseAttr +end + +-- 更新所有属性(自己) +function HeroEntity:_updateAllBaseAttr() + self:_updateBaseAttr() + 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.ALL_ATTR.ATTR_ATK_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_ATK_ALL] + attr[GConst.ALL_ATTR.ATTR_HP_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_HP_ALL] + attr[GConst.ALL_ATTR.ATTR_DMGDEC_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_DMGDEC_ALL] + attr[GConst.ALL_ATTR.ATTR_CRIT_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_CRIT_ALL] + attr[GConst.ALL_ATTR.ATTR_CRIT_TIME_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_CRIT_TIME_ALL] + attr[GConst.ALL_ATTR.ATTR_NORMAL_HURTP_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_NORMAL_HURTP_ALL] + attr[GConst.ALL_ATTR.ATTR_SKILL_HURTP_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_SKILL_HURTP_ALL] + attr[GConst.ALL_ATTR.ATTR_ATKP_ALL] = self.allBaseAttr[GConst.ALL_ATTR.ATTR_ATKP_ALL] + + 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:_updateStarAttr() + self.starAttr = {} + for i = 1, self.data.star do + local attr = self:getStarAttrCfg()[i] + self.starAttr[attr.type] = attr.num + end +end + +function HeroEntity:getStarAttr() + 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.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.oldLv = self.data.lv + 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 cost = self:getLvUpMaterials() + if not cost then + return false, GConst.HeroConst.CHECK_LV_UP_STATE.NO_COST + end + + local fragmentCost = cost[1] or 0 + if not GFunc.checkCost(self:getFragmentId(), fragmentCost, showToast) then + return false, GConst.HeroConst.CHECK_LV_UP_STATE.FRAGMENT_NOT_ENOUGH + end + local goldCost = cost[2] or 0 + if not GFunc.checkCost(self:getLvUpCostId(), goldCost, 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: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:getLvUpMaterials() + 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.cost +end + +function HeroEntity:getLvUpLv() + local count = 0 + 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 fragmentCost = nextLvInfo.cost[1] or 0 + local itemCost = nextLvInfo.cost[2] or 0 + totalCost1 = totalCost1 + fragmentCost + totalCost2 = totalCost2 + itemCost + if not GFunc.checkCost(self:getFragmentId(), totalCost1, false) then + break + end + if not GFunc.checkCost(self:getLvUpCostId(), totalCost2, false) then + break + 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() + return self.config.level_id +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) + if star then + return self.config.star_attr[star] + end + return self.config.star_attr +end + +function HeroEntity:getStarAttrTxt() + return self.config.star_txt +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.oldLv 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.lv >= ids[ii][1] and self.oldLv < ids[ii][1] then + skillIdx = i + needPop = true + isUnlock = ii == 1 + break + end + end + else + break + end + if needPop then + break + end + end + self.oldLv = 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.lv >= 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:getRogueSkillListByIdx(idx) + local ids = self.config["rouge_skill_" .. idx] + local lv = 0 + if ids then + for i = #ids, 1, -1 do + if self.data.lv >= 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.lv < 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.lv >= 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:getStarUpMaterials() + 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 cost = self:getStarUpMaterials() + if not cost then + return false, GConst.HeroConst.CHECK_LV_UP_STATE.NO_COST + end + + local fragmentCost = cost[1] or 0 + if not GFunc.checkCost(self:getFragmentId(), fragmentCost, 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.data.star = self.data.star + 1 + self:setBaseAttrDirty() + self:setDirty() + self:setAttrDirty() +end + +function HeroEntity:getMaxStar() + return #self:getStarAttrCfg() +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() + end +end +--@endregion +return HeroEntity \ No newline at end of file diff --git a/lua/app/userdata/hero/hero_entity_other.lua.meta b/lua/app/userdata/hero/hero_entity_other.lua.meta new file mode 100644 index 00000000..17c5eb9e --- /dev/null +++ b/lua/app/userdata/hero/hero_entity_other.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3dcf1afbea0244a9a8d40c608ef21dfd +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}