战斗力
This commit is contained in:
parent
ab824968e0
commit
667d76fcde
@ -2,392 +2,392 @@ local attr = {
|
||||
[1]={
|
||||
["id"]=1,
|
||||
["name"]="hp",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[2]={
|
||||
["id"]=2,
|
||||
["name"]="atk_red",
|
||||
["fight"]=200
|
||||
["power"]=200
|
||||
},
|
||||
[3]={
|
||||
["id"]=3,
|
||||
["name"]="atk_yellow",
|
||||
["fight"]=200
|
||||
["power"]=200
|
||||
},
|
||||
[4]={
|
||||
["id"]=4,
|
||||
["name"]="atk_green",
|
||||
["fight"]=200
|
||||
["power"]=200
|
||||
},
|
||||
[5]={
|
||||
["id"]=5,
|
||||
["name"]="atk_blue",
|
||||
["fight"]=200
|
||||
["power"]=200
|
||||
},
|
||||
[6]={
|
||||
["id"]=6,
|
||||
["name"]="atk_purple",
|
||||
["fight"]=200
|
||||
["power"]=200
|
||||
},
|
||||
[7]={
|
||||
["id"]=7,
|
||||
["name"]="attr_crit_red",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[8]={
|
||||
["id"]=8,
|
||||
["name"]="attr_crit_yellow",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[9]={
|
||||
["id"]=9,
|
||||
["name"]="attr_crit_green",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[10]={
|
||||
["id"]=10,
|
||||
["name"]="attr_crit_blue",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[11]={
|
||||
["id"]=11,
|
||||
["name"]="attr_crit_purple",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[12]={
|
||||
["id"]=12,
|
||||
["name"]="attr_crit_time_red",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[13]={
|
||||
["id"]=13,
|
||||
["name"]="attr_crit_time_yellow",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[14]={
|
||||
["id"]=14,
|
||||
["name"]="attr_crit_time_green",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[15]={
|
||||
["id"]=15,
|
||||
["name"]="attr_crit_time_blue",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[16]={
|
||||
["id"]=16,
|
||||
["name"]="attr_crit_time_purple",
|
||||
["fight"]=500
|
||||
["power"]=500
|
||||
},
|
||||
[17]={
|
||||
["id"]=17,
|
||||
["name"]="attr_cured_red",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[18]={
|
||||
["id"]=18,
|
||||
["name"]="attr_cured_yellow",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[19]={
|
||||
["id"]=19,
|
||||
["name"]="attr_cured_green",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[20]={
|
||||
["id"]=20,
|
||||
["name"]="attr_cured_blue",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[21]={
|
||||
["id"]=21,
|
||||
["name"]="attr_cured_purple",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[22]={
|
||||
["id"]=22,
|
||||
["name"]="attr_atkp_red",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[23]={
|
||||
["id"]=23,
|
||||
["name"]="attr_atkp_yellow",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[24]={
|
||||
["id"]=24,
|
||||
["name"]="attr_atkp_green",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[25]={
|
||||
["id"]=25,
|
||||
["name"]="attr_atkp_blue",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[26]={
|
||||
["id"]=26,
|
||||
["name"]="attr_atkp_purple",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[27]={
|
||||
["id"]=27,
|
||||
["name"]="attr_hpp_red",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[28]={
|
||||
["id"]=28,
|
||||
["name"]="attr_hpp_yellow",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[29]={
|
||||
["id"]=29,
|
||||
["name"]="attr_hpp_green",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[30]={
|
||||
["id"]=30,
|
||||
["name"]="attr_hpp_blue",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[31]={
|
||||
["id"]=31,
|
||||
["name"]="attr_hpp_purple",
|
||||
["fight"]=100
|
||||
["power"]=100
|
||||
},
|
||||
[32]={
|
||||
["id"]=32,
|
||||
["name"]="attr_normal_hurt_red",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[33]={
|
||||
["id"]=33,
|
||||
["name"]="attr_normal_hurt_yellow",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[34]={
|
||||
["id"]=34,
|
||||
["name"]="attr_normal_hurt_green",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[35]={
|
||||
["id"]=35,
|
||||
["name"]="attr_normal_hurt_blue",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[36]={
|
||||
["id"]=36,
|
||||
["name"]="attr_normal_hurt_purple",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[37]={
|
||||
["id"]=37,
|
||||
["name"]="attr_skill_hurt_red",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[38]={
|
||||
["id"]=38,
|
||||
["name"]="attr_skill_hurt_yellow",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[39]={
|
||||
["id"]=39,
|
||||
["name"]="attr_skill_hurt_green",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[40]={
|
||||
["id"]=40,
|
||||
["name"]="attr_skill_hurt_blue",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[41]={
|
||||
["id"]=41,
|
||||
["name"]="attr_skill_hurt_purple",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[42]={
|
||||
["id"]=42,
|
||||
["name"]="attr_normal_hurtp_red",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[43]={
|
||||
["id"]=43,
|
||||
["name"]="attr_normal_hurtp_yellow",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[44]={
|
||||
["id"]=44,
|
||||
["name"]="attr_normal_hurtp_green",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[45]={
|
||||
["id"]=45,
|
||||
["name"]="attr_normal_hurtp_blue",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[46]={
|
||||
["id"]=46,
|
||||
["name"]="attr_normal_hurtp_purple",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[47]={
|
||||
["id"]=47,
|
||||
["name"]="attr_skill_hurtp_red",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[48]={
|
||||
["id"]=48,
|
||||
["name"]="attr_skill_hurtp_yellow",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[49]={
|
||||
["id"]=49,
|
||||
["name"]="attr_skill_hurtp_green",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[50]={
|
||||
["id"]=50,
|
||||
["name"]="attr_skill_hurtp_blue",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[51]={
|
||||
["id"]=51,
|
||||
["name"]="attr_skill_hurtp_purple",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[52]={
|
||||
["id"]=52,
|
||||
["name"]="attr_hp_red",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[53]={
|
||||
["id"]=53,
|
||||
["name"]="attr_hp_yellow",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[54]={
|
||||
["id"]=54,
|
||||
["name"]="attr_hp_green",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[55]={
|
||||
["id"]=55,
|
||||
["name"]="attr_hp_blue",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[56]={
|
||||
["id"]=56,
|
||||
["name"]="attr_hp_purple",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[57]={
|
||||
["id"]=57,
|
||||
["name"]="attr_all_hurtp_red",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[58]={
|
||||
["id"]=58,
|
||||
["name"]="attr_all_hurtp_yellow",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[59]={
|
||||
["id"]=59,
|
||||
["name"]="attr_all_hurtp_green",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[60]={
|
||||
["id"]=60,
|
||||
["name"]="attr_all_hurtp_blue",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[61]={
|
||||
["id"]=61,
|
||||
["name"]="attr_all_hurtp_purple",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[62]={
|
||||
["id"]=62,
|
||||
["name"]="attr_atkp_red_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[63]={
|
||||
["id"]=63,
|
||||
["name"]="attr_atkp_yellow_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[64]={
|
||||
["id"]=64,
|
||||
["name"]="attr_atkp_green_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[65]={
|
||||
["id"]=65,
|
||||
["name"]="attr_atkp_blue_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[66]={
|
||||
["id"]=66,
|
||||
["name"]="attr_atkp_purple_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[67]={
|
||||
["id"]=67,
|
||||
["name"]="atk_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[68]={
|
||||
["id"]=68,
|
||||
["name"]="attr_hp_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[69]={
|
||||
["id"]=69,
|
||||
["name"]="attr_dmgdec_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[70]={
|
||||
["id"]=70,
|
||||
["name"]="attr_crit_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[71]={
|
||||
["id"]=71,
|
||||
["name"]="attr_crit_time_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[72]={
|
||||
["id"]=72,
|
||||
["name"]="attr_normal_hurtp_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[73]={
|
||||
["id"]=73,
|
||||
["name"]="attr_skill_hurtp_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[74]={
|
||||
["id"]=74,
|
||||
["name"]="attr_atkp_all",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[75]={
|
||||
["id"]=75,
|
||||
["name"]="attr_atk",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[76]={
|
||||
["id"]=76,
|
||||
["name"]="attr_hp",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[77]={
|
||||
["id"]=77,
|
||||
["name"]="attr_normal_hurt",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
},
|
||||
[78]={
|
||||
["id"]=78,
|
||||
["name"]="attr_skill_hurt",
|
||||
["fight"]=50
|
||||
["power"]=50
|
||||
}
|
||||
}
|
||||
local keys = {
|
||||
|
||||
@ -2033,4 +2033,9 @@ function GFunc.getUnevenSliderValue(list, value, defaultValue)
|
||||
return per
|
||||
end
|
||||
|
||||
function GFunc.getAttrNameCfg()
|
||||
local AttrNameCfg = ConfigManager:getConfigWithOtherKey("attr", "name")
|
||||
return AttrNameCfg
|
||||
end
|
||||
|
||||
return GFunc
|
||||
@ -54,6 +54,7 @@ function HeroComp:init()
|
||||
-- self.uiMap["hero_ui.bottom_bg.filter_bg.btn_0.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.COLLECTION_DESC_10))
|
||||
self.uiMap["hero_ui.bottom_bg.filter_bg.btn_0.desc_tx"]:setText("ALL")
|
||||
|
||||
self.powerTx = self.uiMap["hero_ui.power_img.power_tx"]
|
||||
local attrTx = self.uiMap["hero_ui.bottom_bg.attr_bg.attr_tx"]
|
||||
local infoBtn = self.uiMap["hero_ui.bottom_bg.attr_bg.info_btn"]
|
||||
self.elementType = 0
|
||||
@ -225,10 +226,13 @@ end
|
||||
function HeroComp:refreshScrollRect()
|
||||
self.heroList = DataManager.HeroData:getAllHeroesSort(self.battleType, self.elementType) -- 每次都重新算一次
|
||||
|
||||
local power = 0
|
||||
|
||||
for i = 1, 5 do
|
||||
local heroId = self.curFormation[i]
|
||||
local hero = DataManager.HeroData:getHeroById(heroId)
|
||||
if hero and hero:getLv() > 0 then
|
||||
power = power + hero:getPower()
|
||||
self.heroAddImgList[i]:setVisible(false)
|
||||
if self.heroSpineList[i] and self.heroSpineList[i]:getModelId() == hero:getModelId() then
|
||||
self.heroSpineList[i]:setActive(true)
|
||||
@ -254,6 +258,7 @@ function HeroComp:refreshScrollRect()
|
||||
end
|
||||
end
|
||||
end
|
||||
self.powerTx:setText(GFunc.num2Str2(power, 2))
|
||||
|
||||
self.allHeroCount = #self.heroList
|
||||
self.unlockCount = DataManager.HeroData:getUnlockHeroCount(self.elementType)
|
||||
|
||||
@ -100,7 +100,7 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
-- self.txStar2:setText("升星")
|
||||
-- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
|
||||
-- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
|
||||
self.powerTx:setText(1313213)
|
||||
-- self.powerTx:setText(self.heroEntity:getPower())
|
||||
-- if not DataManager.HeroData:isStarOpen() then
|
||||
-- self.lockStar:setVisible(true)
|
||||
-- GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5)
|
||||
@ -272,6 +272,8 @@ function HeroDetailUI:showHeroInfo()
|
||||
-- self.selectSkin:setActive(false)
|
||||
self.bg:setActive(true)
|
||||
|
||||
local power = self.heroEntity:getPower()
|
||||
self.powerTx:setText(GFunc.num2Str2(power, 2))
|
||||
if not self.compHero then
|
||||
self.heroInfo:initPrefabHelper()
|
||||
self.heroInfo:genAllChildren()
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
local EquipEntity = class("EquipEntity", BaseData)
|
||||
|
||||
local AttrNameCfg = ConfigManager:getConfigWithOtherKey("attr", "name")
|
||||
|
||||
function EquipEntity:setDirty()
|
||||
self.allAttrs = nil
|
||||
end
|
||||
@ -161,7 +159,7 @@ function EquipEntity:_getAttrPower()
|
||||
|
||||
local power = 0
|
||||
for attrName, attrNum in pairs(self:getAllAttr()) do
|
||||
local cfg = AttrNameCfg[attrName]
|
||||
local cfg = GFunc.getAttrNameCfg()[attrName]
|
||||
if cfg then
|
||||
local realValue = attrNum
|
||||
-- 特殊处理,玩家基础暴击伤害不算
|
||||
@ -169,7 +167,7 @@ function EquipEntity:_getAttrPower()
|
||||
realValue = attrNum - 15000
|
||||
end
|
||||
|
||||
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR)
|
||||
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR / GConst.DEFAULT_FACTOR + 0.0000001)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -85,6 +85,8 @@ function HeroEntity:_updateAllAttr()
|
||||
if factorValue > 0 then
|
||||
self.allAttr[atkType] = math.floor(self.allAttr[atkType] * (1 + factorValue / GConst.DEFAULT_FACTOR) + 0.0000001)
|
||||
end
|
||||
|
||||
self:calcPower()
|
||||
end
|
||||
|
||||
function HeroEntity:_getAllBaseAttr()
|
||||
@ -223,10 +225,10 @@ function HeroEntity:getTotalBaseAtk()
|
||||
-- local logStr = self:getCfgId() .. "总基础攻击值:\n英雄:" .. result
|
||||
-- 武器 + 防具
|
||||
-- for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
|
||||
-- local equipEntity = self:getEquips(partType)
|
||||
-- if equipEntity then
|
||||
-- -- logStr = logStr .. "\n" .. partName .. ":" .. equipEntity:getBaseAttack()
|
||||
-- result = result + equipEntity:getBaseAttack()
|
||||
-- local HeroEntity = self:getEquips(partType)
|
||||
-- if HeroEntity then
|
||||
-- -- logStr = logStr .. "\n" .. partName .. ":" .. HeroEntity:getBaseAttack()
|
||||
-- result = result + HeroEntity:getBaseAttack()
|
||||
-- end
|
||||
-- end
|
||||
-- logStr = logStr .. "\nSKIN:" .. DataManager.SkinData:getBaseAttack(self)
|
||||
@ -666,4 +668,50 @@ function HeroEntity:setSkins(skinIds)
|
||||
end
|
||||
-- endregion
|
||||
|
||||
--@region 战力
|
||||
function HeroEntity:setPowerDirty()
|
||||
self.data.isPowerDirty = not self.data.isPowerDirty
|
||||
end
|
||||
|
||||
function HeroEntity:getPower()
|
||||
if not self.curPower 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 / GConst.DEFAULT_FACTOR + 0.0000001)
|
||||
end
|
||||
end
|
||||
|
||||
return power
|
||||
end
|
||||
--@endregion
|
||||
|
||||
return HeroEntity
|
||||
Loading…
x
Reference in New Issue
Block a user