英雄基础数据
This commit is contained in:
parent
d719ceeb74
commit
10575642e1
@ -16,7 +16,6 @@ function DataManager:init()
|
||||
self:initManager("BagData", "app/userdata/bag/bag_data")
|
||||
self:initManager("EquipData", "app/userdata/equip/equip_data")
|
||||
self:initManager("SkinData", "app/userdata/skin/skin_data")
|
||||
self:initManager("RunesData", "app/userdata/runes/runes_data")
|
||||
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
||||
self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data")
|
||||
self:initManager("FormationData", "app/userdata/formation/formation_data")
|
||||
@ -111,7 +110,6 @@ function DataManager:clear()
|
||||
self.BagData:clear()
|
||||
self.EquipData:clear()
|
||||
self.SkinData:clear()
|
||||
self.RunesData:clear()
|
||||
self.FormationData:clear()
|
||||
self.ActivityData:clear()
|
||||
self.MailData:clear()
|
||||
@ -158,13 +156,11 @@ function DataManager:initWithServerData(data)
|
||||
self.DailyChallengeData:init(data.chapter_daily_challenge)
|
||||
self.DungeonData:initDungeonGold(data.chapter_gold_challenge)
|
||||
self.DungeonData:initDungeonShards(data.chapter_shards_challenge)
|
||||
-- FormationData要在RunesData之前初始化,依赖阵容数据进行上报
|
||||
self.FormationData:init(data.fight_info)
|
||||
self.EquipData:init(data.heroes_equips)
|
||||
self.EquipData:initGifts(data.act_weapon_armor_gift)
|
||||
self.SkinData:init(data.bag.skins)
|
||||
self.RunesData:init(data.rune)
|
||||
-- HeroData要在EquipData、SkinData、RunesData之后初始化,依赖它们的属性数据
|
||||
-- HeroData要在EquipData、SkinData之后初始化,依赖它们的属性数据
|
||||
self.HeroData:init(data.bag.heroes)
|
||||
self.BagData:init(data.bag)
|
||||
self.DungeonData:initDungeonWeapon(data.chapter_weapon_challenge)
|
||||
@ -200,7 +196,6 @@ function DataManager:initWithServerData(data)
|
||||
end
|
||||
self.HeroFundData:init(data.hero_fund)
|
||||
self.FourteenDayData:init(data.fourteen_bounty)
|
||||
self.DungeonData:initDungeonRune(data.chapter_rune_challenge)
|
||||
|
||||
-- 任务数据最后初始化,依赖其他模块的数据
|
||||
self.TaskData:init()
|
||||
|
||||
@ -54,8 +54,6 @@ EventManager.CUSTOM_EVENT = {
|
||||
EQUIP_UPGRADE_SUCCESS = "EQUIP_UPGRADE_SUCCESS",
|
||||
EQUIP_UPSECTION_SUCCESS = "EQUIP_UPSECTION_SUCCESS",
|
||||
HERO_UPGRADE_SUCCESS = "HERO_UPGRADE_SUCCESS",
|
||||
-- 符文
|
||||
RUNE_QUENCHING_SUCCESS = "RUNE_QUENCHING_SUCCESS",
|
||||
GO_DUNGEON_UI = "GO_DUNGEON_UI",
|
||||
-- 皮肤
|
||||
SKIN_SELECT = "SKIN_SELECT",
|
||||
|
||||
@ -28,9 +28,8 @@ HeroConst.CHECK_LV_UP_STATE = {
|
||||
-- 英雄界面显示类型
|
||||
HeroConst.PANEL_TYPE = {
|
||||
HERO = 1,
|
||||
WEAPON = 2,
|
||||
ARMOR = 3,
|
||||
RUNES = 4,
|
||||
STAR = 2,
|
||||
SKIN = 3,
|
||||
}
|
||||
|
||||
-- 总计
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
local HeroDetailUI = class("HeroDetailUI", BaseUI)
|
||||
local COMP_HERO = "app/ui/hero/hero_info_comp"
|
||||
local COMP_WEAPON = "app/ui/hero/weapon_info_comp"
|
||||
local COMP_ARMOR = "app/ui/hero/armor_info_comp"
|
||||
local COMP_RUNES = "app/ui/hero/runes_info_comp"
|
||||
local COMP_STAR = "app/ui/hero/star_info_comp"
|
||||
local COMP_SKIN = "app/ui/hero/skin_info_comp"
|
||||
local SIZE_DELTA_Y_HERO = 942
|
||||
local SIZE_DELTA_Y_LOOK_HERO = 802
|
||||
|
||||
@ -18,12 +17,6 @@ function HeroDetailUI:onPressBackspace()
|
||||
self:closeUI()
|
||||
end
|
||||
|
||||
function HeroDetailUI:onClose()
|
||||
if self.compRunes then
|
||||
self.compRunes:onClose()
|
||||
end
|
||||
end
|
||||
|
||||
function HeroDetailUI:ctor(parmas)
|
||||
self.panelType = parmas.panelType or GConst.HeroConst.PANEL_TYPE.HERO
|
||||
self.formationType = parmas.formationType
|
||||
@ -41,9 +34,8 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
|
||||
self.commonInfo = uiMap["hero_detail_ui.common"]
|
||||
self.heroInfo = uiMap["hero_detail_ui.hero_info"]
|
||||
self.weaponInfo = uiMap["hero_detail_ui.weapon_info"]
|
||||
self.armorInfo = uiMap["hero_detail_ui.armor_info"]
|
||||
self.runesInfo = uiMap["hero_detail_ui.runes_info"]
|
||||
self.starInfo = uiMap["hero_detail_ui.star_info"]
|
||||
self.skinInfo = uiMap["hero_detail_ui.skin_info"]
|
||||
self.txTitle = uiMap["hero_detail_ui.common.img_title.tx_title"]
|
||||
self.btnClose = uiMap["hero_detail_ui.common.btn_close"]
|
||||
self.bg = uiMap["hero_detail_ui.common.bg.bg"]
|
||||
@ -51,51 +43,37 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
self.txHero1 = uiMap["hero_detail_ui.common.btns.btn_hero.tx_btn"]
|
||||
self.selectHero = uiMap["hero_detail_ui.common.btns.btn_hero.select"]
|
||||
self.txHero2 = uiMap["hero_detail_ui.common.btns.btn_hero.select.tx_select"]
|
||||
self.btnWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon"]
|
||||
self.lockWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon.img_lock"]
|
||||
self.txWeapon1 = uiMap["hero_detail_ui.common.btns.btn_weapon.tx_btn"]
|
||||
self.selectWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon.select"]
|
||||
self.txWeapon2 = uiMap["hero_detail_ui.common.btns.btn_weapon.select.tx_select"]
|
||||
self.btnArmor = uiMap["hero_detail_ui.common.btns.btn_armor"]
|
||||
self.lockArmor = uiMap["hero_detail_ui.common.btns.btn_armor.img_lock"]
|
||||
self.txArmor1 = uiMap["hero_detail_ui.common.btns.btn_armor.tx_btn"]
|
||||
self.selectArmor = uiMap["hero_detail_ui.common.btns.btn_armor.select"]
|
||||
self.txArmor2 = uiMap["hero_detail_ui.common.btns.btn_armor.select.tx_select"]
|
||||
self.btnRunes = uiMap["hero_detail_ui.common.btns.btn_runes"]
|
||||
self.lockRunes = uiMap["hero_detail_ui.common.btns.btn_runes.content.img_lock"]
|
||||
self.txRunes1 = uiMap["hero_detail_ui.common.btns.btn_runes.content.tx_btn"]
|
||||
self.selectRunes = uiMap["hero_detail_ui.common.btns.btn_runes.select"]
|
||||
self.txRunes2 = uiMap["hero_detail_ui.common.btns.btn_runes.select.tx_select"]
|
||||
self.btnStar = uiMap["hero_detail_ui.common.btns.btn_star"]
|
||||
self.lockStar = uiMap["hero_detail_ui.common.btns.btn_star.content.img_lock"]
|
||||
self.txStar1 = uiMap["hero_detail_ui.common.btns.btn_star.content.tx_btn"]
|
||||
self.selectStar = uiMap["hero_detail_ui.common.btns.btn_star.select"]
|
||||
self.txStar2 = uiMap["hero_detail_ui.common.btns.btn_star.select.tx_select"]
|
||||
self.btnSkin = uiMap["hero_detail_ui.common.btns.btn_skin"]
|
||||
self.lockSkin = uiMap["hero_detail_ui.common.btns.btn_skin.content.img_lock"]
|
||||
self.txSkin1 = uiMap["hero_detail_ui.common.btns.btn_skin.content.tx_btn"]
|
||||
self.selectSkin = uiMap["hero_detail_ui.common.btns.btn_skin.select"]
|
||||
self.txSkin2 = uiMap["hero_detail_ui.common.btns.btn_skin.select.tx_select"]
|
||||
self.btnLeft = uiMap["hero_detail_ui.common.btn_left"]
|
||||
self.btnRight = uiMap["hero_detail_ui.common.btn_right"]
|
||||
|
||||
self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
|
||||
self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
|
||||
self.txWeapon1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
|
||||
self.txWeapon2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
|
||||
self.txArmor1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
|
||||
self.txArmor2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
|
||||
self.txRunes1:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_6))
|
||||
self.txRunes2:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_6))
|
||||
if not DataManager.EquipData:isWeaponOpen() then
|
||||
self.lockWeapon:setVisible(true)
|
||||
GFunc.centerImgAndTx(self.lockWeapon, self.txWeapon1, 5)
|
||||
self.txStar1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
|
||||
self.txStar2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
|
||||
self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
|
||||
self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
|
||||
if not DataManager.HeroData:isStarOpen() then
|
||||
self.lockStar:setVisible(true)
|
||||
GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5)
|
||||
else
|
||||
self.lockWeapon:setVisible(false)
|
||||
self.lockStar:setVisible(false)
|
||||
end
|
||||
if not DataManager.EquipData:isArmorOpen() then
|
||||
self.lockArmor:setVisible(true)
|
||||
GFunc.centerImgAndTx(self.lockArmor, self.txArmor1, 5)
|
||||
if not DataManager.HeroData:isSkinOpen() then
|
||||
self.lockSkin:setVisible(true)
|
||||
GFunc.centerImgAndTx(self.lockSkin, self.txSkin1, 5)
|
||||
else
|
||||
self.lockArmor:setVisible(false)
|
||||
self.lockSkin:setVisible(false)
|
||||
end
|
||||
if not DataManager.RunesData:isOpen() then
|
||||
self.lockRunes:setVisible(true)
|
||||
GFunc.centerImgAndTx(self.lockRunes, self.txRunes1, 5)
|
||||
else
|
||||
self.lockRunes:setVisible(false)
|
||||
end
|
||||
|
||||
self.heroList = DataManager.HeroData:getAllHeroesSort(self.formationType)
|
||||
self:updateSide()
|
||||
self:refreshShow()
|
||||
@ -104,29 +82,18 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
self.panelType = GConst.HeroConst.PANEL_TYPE.HERO
|
||||
self:refreshShow()
|
||||
end)
|
||||
self.btnWeapon:addClickListener(function()
|
||||
if not DataManager.EquipData:isWeaponOpen(true) then
|
||||
self.btnStar:addClickListener(function()
|
||||
if not DataManager.HeroData:isStarOpen(true) then
|
||||
return
|
||||
end
|
||||
self.panelType = GConst.HeroConst.PANEL_TYPE.WEAPON
|
||||
self.panelType = GConst.HeroConst.PANEL_TYPE.STAR
|
||||
self:refreshShow()
|
||||
end)
|
||||
self.btnArmor:addClickListener(function()
|
||||
if not DataManager.EquipData:isArmorOpen(true) then
|
||||
self.btnSkin:addClickListener(function()
|
||||
if not DataManager.HeroData:isSkinOpen(true) then
|
||||
return
|
||||
end
|
||||
self.panelType = GConst.HeroConst.PANEL_TYPE.ARMOR
|
||||
self:refreshShow()
|
||||
end)
|
||||
self.btnRunes:addClickListener(function()
|
||||
if not DataManager.RunesData:isOpen(true) then
|
||||
return
|
||||
end
|
||||
if not self.heroEntity:isActived() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_24))
|
||||
return
|
||||
end
|
||||
self.panelType = GConst.HeroConst.PANEL_TYPE.RUNES
|
||||
self.panelType = GConst.HeroConst.PANEL_TYPE.SKIN
|
||||
self:refreshShow()
|
||||
end)
|
||||
self.btnClose:addClickListener(function()
|
||||
@ -148,14 +115,6 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
self:updateSide()
|
||||
self:refreshShow()
|
||||
end)
|
||||
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.RUNE_QUENCHING_SUCCESS, function(tempCount)
|
||||
if DataManager.RunesData:hasRedPoint(tempCount) then
|
||||
self.btnRunes:addRedPoint(-55, 0, 0.6)
|
||||
else
|
||||
self.btnRunes:removeRedPoint()
|
||||
end
|
||||
end)
|
||||
self:bind(DataManager.BagData.ItemData, "dirty", function()
|
||||
self:refreshRedPoint()
|
||||
end)
|
||||
@ -164,19 +123,19 @@ function HeroDetailUI:onLoadRootComplete()
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.EQUIP_UPSECTION_SUCCESS, function(part)
|
||||
Logger.logHighlight("升段:"..part)
|
||||
if part == GConst.EquipConst.PART_TYPE.WEAPON then
|
||||
self.compWeapon:playEffect(true, true)
|
||||
if part == GConst.EquipConst.PART_TYPE.STAR then
|
||||
self.compStar:playEffect(true, true)
|
||||
else
|
||||
self.compArmor:playUpgradeEffect(part)
|
||||
self.compSkin:playUpgradeEffect(part)
|
||||
end
|
||||
self:refreshRedPoint()
|
||||
end)
|
||||
self:addEventListener(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS, function(part)
|
||||
Logger.logHighlight("升级:"..part)
|
||||
if part == GConst.EquipConst.PART_TYPE.WEAPON then
|
||||
self.compWeapon:playEffect(true, false)
|
||||
if part == GConst.EquipConst.PART_TYPE.STAR then
|
||||
self.compStar:playEffect(true, false)
|
||||
else
|
||||
self.compArmor:playUpgradeEffect(part)
|
||||
self.compSkin:playUpgradeEffect(part)
|
||||
end
|
||||
self:refreshRedPoint()
|
||||
end)
|
||||
@ -198,18 +157,15 @@ function HeroDetailUI:refreshShow()
|
||||
self.txTitle:setText(self.heroEntity:getName())
|
||||
if self.panelType == GConst.HeroConst.PANEL_TYPE.HERO then
|
||||
self:showHeroInfo()
|
||||
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.WEAPON then
|
||||
self:showWeaponInfo()
|
||||
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.ARMOR then
|
||||
self:showArmorInfo()
|
||||
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.RUNES then
|
||||
self:showRunesInfo()
|
||||
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.STAR then
|
||||
self:showStarInfo()
|
||||
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.SKIN then
|
||||
self:showskinInfo()
|
||||
end
|
||||
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
|
||||
self.btnHero:setActive(false)
|
||||
self.btnWeapon:setActive(false)
|
||||
self.btnArmor:setActive(false)
|
||||
self.btnRunes:setActive(false)
|
||||
self.btnStar:setActive(false)
|
||||
self.btnSkin:setActive(false)
|
||||
self.btnLeft:setActive(false)
|
||||
self.btnRight:setActive(false)
|
||||
if self.panelType == GConst.HeroConst.PANEL_TYPE.HERO then
|
||||
@ -217,9 +173,8 @@ function HeroDetailUI:refreshShow()
|
||||
end
|
||||
else
|
||||
self.btnHero:setActive(true)
|
||||
self.btnWeapon:setActive(true)
|
||||
self.btnArmor:setActive(true)
|
||||
self.btnRunes:setActive(true)
|
||||
self.btnStar:setActive(true)
|
||||
self.btnSkin:setActive(true)
|
||||
self.btnLeft:setActive(self:isShowLeftArrow())
|
||||
self.btnRight:setActive(self:isShowRightArrow())
|
||||
self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_HERO)
|
||||
@ -234,32 +189,25 @@ function HeroDetailUI:refreshRedPoint()
|
||||
else
|
||||
self.btnHero:removeRedPoint()
|
||||
end
|
||||
if DataManager.EquipData:canUpgradeWeapon(self.heroEntity:getCfgId()) then
|
||||
self.btnWeapon:addRedPoint(-55, 0, 0.6)
|
||||
else
|
||||
self.btnWeapon:removeRedPoint()
|
||||
end
|
||||
if DataManager.EquipData:canUpgradeArmor(self.heroEntity:getCfgId()) then
|
||||
self.btnArmor:addRedPoint(-55, 0, 0.6)
|
||||
else
|
||||
self.btnArmor:removeRedPoint()
|
||||
end
|
||||
if DataManager.RunesData:hasRedPoint() then
|
||||
self.btnRunes:addRedPoint(-55, 0, 0.6)
|
||||
else
|
||||
self.btnRunes:removeRedPoint()
|
||||
end
|
||||
-- if DataManager.EquipData:canUpgradeStar(self.heroEntity:getCfgId()) then
|
||||
-- self.btnStar:addRedPoint(-55, 0, 0.6)
|
||||
-- else
|
||||
-- self.btnStar:removeRedPoint()
|
||||
-- end
|
||||
-- if DataManager.EquipData:canUpgradeSkin(self.heroEntity:getCfgId()) then
|
||||
-- self.btnSkin:addRedPoint(-55, 0, 0.6)
|
||||
-- else
|
||||
-- self.btnSkin:removeRedPoint()
|
||||
-- end
|
||||
end
|
||||
|
||||
function HeroDetailUI:showHeroInfo()
|
||||
self.heroInfo:setActive(true)
|
||||
self.selectHero:setActive(true)
|
||||
self.weaponInfo:setActive(false)
|
||||
self.selectWeapon:setActive(false)
|
||||
self.armorInfo:setActive(false)
|
||||
self.selectArmor:setActive(false)
|
||||
self.runesInfo:setActive(false)
|
||||
self.selectRunes:setActive(false)
|
||||
self.starInfo:setActive(false)
|
||||
self.selectStar:setActive(false)
|
||||
self.skinInfo:setActive(false)
|
||||
self.selectSkin:setActive(false)
|
||||
self.bg:setActive(true)
|
||||
|
||||
if not self.compHero then
|
||||
@ -272,69 +220,44 @@ function HeroDetailUI:showHeroInfo()
|
||||
self.compHero:refresh()
|
||||
end
|
||||
|
||||
function HeroDetailUI:showWeaponInfo()
|
||||
function HeroDetailUI:showStarInfo()
|
||||
self.heroInfo:setActive(false)
|
||||
self.selectHero:setActive(false)
|
||||
self.weaponInfo:setActive(true)
|
||||
self.selectWeapon:setActive(true)
|
||||
self.armorInfo:setActive(false)
|
||||
self.selectArmor:setActive(false)
|
||||
self.runesInfo:setActive(false)
|
||||
self.selectRunes:setActive(false)
|
||||
self.starInfo:setActive(true)
|
||||
self.selectStar:setActive(true)
|
||||
self.skinInfo:setActive(false)
|
||||
self.selectSkin:setActive(false)
|
||||
self.bg:setActive(true)
|
||||
|
||||
if not self.compWeapon then
|
||||
self.weaponInfo:initPrefabHelper()
|
||||
self.weaponInfo:genAllChildren()
|
||||
self.compWeapon = self.weaponInfo:addLuaComponent(COMP_WEAPON)
|
||||
self.compWeapon:setUI(self)
|
||||
if not self.compStar then
|
||||
self.starInfo:initPrefabHelper()
|
||||
self.starInfo:genAllChildren()
|
||||
self.compStar = self.starInfo:addLuaComponent(COMP_STAR)
|
||||
self.compStar:setUI(self)
|
||||
end
|
||||
|
||||
self.compWeapon:setHeroData(self.heroEntity)
|
||||
self.compWeapon:refresh()
|
||||
self.compStar:setHeroData(self.heroEntity)
|
||||
self.compStar:refresh()
|
||||
end
|
||||
|
||||
function HeroDetailUI:showArmorInfo()
|
||||
function HeroDetailUI:showskinInfo()
|
||||
self.heroInfo:setActive(false)
|
||||
self.selectHero:setActive(false)
|
||||
self.weaponInfo:setActive(false)
|
||||
self.selectWeapon:setActive(false)
|
||||
self.armorInfo:setActive(true)
|
||||
self.selectArmor:setActive(true)
|
||||
self.runesInfo:setActive(false)
|
||||
self.selectRunes:setActive(false)
|
||||
self.starInfo:setActive(false)
|
||||
self.selectStar:setActive(false)
|
||||
self.skinInfo:setActive(true)
|
||||
self.selectSkin:setActive(true)
|
||||
self.bg:setActive(true)
|
||||
|
||||
if not self.compArmor then
|
||||
self.armorInfo:initPrefabHelper()
|
||||
self.armorInfo:genAllChildren()
|
||||
self.compArmor = self.armorInfo:addLuaComponent(COMP_ARMOR)
|
||||
self.compArmor:setUI(self)
|
||||
if not self.compSkin then
|
||||
self.skinInfo:initPrefabHelper()
|
||||
self.skinInfo:genAllChildren()
|
||||
self.compSkin = self.skinInfo:addLuaComponent(COMP_Skin)
|
||||
self.compSkin:setUI(self)
|
||||
end
|
||||
|
||||
self.compArmor:setHeroData(self.heroEntity)
|
||||
self.compArmor:refresh()
|
||||
end
|
||||
|
||||
function HeroDetailUI:showRunesInfo()
|
||||
self.heroInfo:setActive(false)
|
||||
self.selectHero:setActive(false)
|
||||
self.weaponInfo:setActive(false)
|
||||
self.selectWeapon:setActive(false)
|
||||
self.armorInfo:setActive(false)
|
||||
self.selectArmor:setActive(false)
|
||||
self.runesInfo:setActive(true)
|
||||
self.selectRunes:setActive(true)
|
||||
self.bg:setActive(false)
|
||||
|
||||
if not self.compRunes then
|
||||
self.runesInfo:initPrefabHelper()
|
||||
self.runesInfo:genAllChildren()
|
||||
self.compRunes = self.runesInfo:addLuaComponent(COMP_RUNES)
|
||||
end
|
||||
|
||||
self.compRunes:setHeroData(self.heroEntity)
|
||||
self.compRunes:refresh()
|
||||
self.compSkin:setHeroData(self.heroEntity)
|
||||
self.compSkin:refresh()
|
||||
end
|
||||
|
||||
-- 是否显示左箭头
|
||||
|
||||
@ -1,333 +0,0 @@
|
||||
local RunesInfoComp = class("RunesInfoComp", LuaComponent)
|
||||
|
||||
local LOCK_ICON = "common_lock"
|
||||
local UNLOCK_ICON = "common_lock_1"
|
||||
|
||||
function RunesInfoComp:onClose()
|
||||
if self.autoSid then
|
||||
self.baseObject:unscheduleGlobal(self.autoSid)
|
||||
self.autoSid = nil
|
||||
end
|
||||
if self.autoSyncSid then
|
||||
self.baseObject:unscheduleGlobal(self.autoSyncSid)
|
||||
self.autoSyncSid = nil
|
||||
end
|
||||
end
|
||||
|
||||
function RunesInfoComp:init()
|
||||
local uiMap = self:getUIMap()
|
||||
self.btnHelp = uiMap["runes_info.btn_help"]
|
||||
self.imgProg = uiMap["runes_info.prog.img_prog"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.txProg = uiMap["runes_info.prog.tx_prog"]
|
||||
self.txLevel = uiMap["runes_info.level.tx_level"]
|
||||
self.btnSuit = uiMap["runes_info.btn_suit"]
|
||||
self.txSuit = uiMap["runes_info.btn_suit.tx_suit"]
|
||||
self.itemMaterial = uiMap["runes_info.item_material"]
|
||||
self.txNum = uiMap["runes_info.item_material.tx_num"]
|
||||
self.btnUse = uiMap["runes_info.bottom.btn_use"]
|
||||
self.txUse = uiMap["runes_info.bottom.btn_use.tx_use"]
|
||||
self.imgCost = uiMap["runes_info.bottom.btn_use.cost.img_cost"]
|
||||
self.txCost = uiMap["runes_info.bottom.btn_use.cost.tx_cost"]
|
||||
self.btnAuto = uiMap["runes_info.bottom.btn_auto"]
|
||||
self.spineAuto = uiMap["runes_info.bottom.btn_auto.spine_auto"]
|
||||
self.txAuto = uiMap["runes_info.bottom.btn_auto.tx_auto"]
|
||||
self.txEmpty = uiMap["runes_info.suits.tx_empty"]
|
||||
self.mask = uiMap["runes_info.bottom.mask"]
|
||||
self.btnAutoEnd = uiMap["runes_info.bottom.btn_auto_end"]
|
||||
self.txAutoEnd = uiMap["runes_info.bottom.btn_auto_end.tx_end"]
|
||||
self.suitsNode = uiMap["runes_info.suits"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT)
|
||||
self.suits = {}
|
||||
for i = 1, 3 do
|
||||
self.suits[i] = uiMap["runes_info.suits.item_suit_" .. i]
|
||||
end
|
||||
self.grids = {}
|
||||
for i = 1, 6 do
|
||||
self.grids[i] = uiMap["runes_info.list_attr.grid_" .. i]
|
||||
end
|
||||
|
||||
self.mask:setActive(false)
|
||||
self.txSuit:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_2))
|
||||
self.txUse:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_5))
|
||||
self.txEmpty:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_23))
|
||||
self.txAutoEnd:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_29))
|
||||
self.txAuto:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_4))
|
||||
|
||||
self.itemMaterial:addClickListener(function()
|
||||
UIManager:showUI("app/ui/runes/runes_source_ui")
|
||||
end)
|
||||
self.btnHelp:addClickListener(function()
|
||||
UIManager:showUI("app/ui/runes/runes_level_ui")
|
||||
end)
|
||||
self.btnSuit:addClickListener(function()
|
||||
UIManager:showUI("app/ui/runes/runes_suit_ui", self.heroEntity)
|
||||
end)
|
||||
self.btnAuto:addClickListener(function()
|
||||
if not DataManager.RunesData:canAutoMake() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_27, DataManager.RunesData:getAutoMakeOpenLevel()))
|
||||
return
|
||||
end
|
||||
|
||||
local checkIds = DataManager.RunesData:getCheckQualityIds()
|
||||
if #checkIds > 0 then
|
||||
local params ={
|
||||
content = I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_21, I18N:getGlobalText(I18N.GlobalConst["RUNES_QLT_" .. DataManager.RunesData:getCheckQualityIds()[1]]), I18N:getGlobalText(I18N.GlobalConst["RUNES_QLT_" .. DataManager.RunesData:getCheckQualityIds()[2]])),
|
||||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
||||
showToday = GConst.MESSAGE_BOX_SHOW_TODAY.RUNES_AUTO,
|
||||
okFunc = function()
|
||||
self:checkQuenching(true)
|
||||
end,
|
||||
}
|
||||
GFunc.showMessageBox(params)
|
||||
else
|
||||
self:checkQuenching(true)
|
||||
end
|
||||
end)
|
||||
self.btnAutoEnd:addClickListener(function()
|
||||
-- 玩家点击停止自动淬炼
|
||||
ModuleManager.RunesManager:reqSyncQuenching(true)
|
||||
end)
|
||||
self.btnUse:addClickListener(function()
|
||||
self:checkQuenching(false)
|
||||
end)
|
||||
self:bind(DataManager.BagData.ItemData, "dirty", function()
|
||||
self:refresh()
|
||||
end)
|
||||
self:bind(DataManager.RunesData, "isDirty", function()
|
||||
self:refresh()
|
||||
end)
|
||||
end
|
||||
|
||||
function RunesInfoComp:setHeroData(heroEntity)
|
||||
self.heroEntity = heroEntity
|
||||
self.runesEntity = DataManager.RunesData:getRunes(self.heroEntity:getCfgId())
|
||||
end
|
||||
|
||||
function RunesInfoComp:updateData()
|
||||
self.exp = self.runesEntity:getExp()
|
||||
end
|
||||
|
||||
function RunesInfoComp:refresh()
|
||||
if self.autoSid then
|
||||
self.baseObject:unscheduleGlobal(self.autoSid)
|
||||
self.autoSid = nil
|
||||
end
|
||||
if self.autoSyncSid then
|
||||
self.baseObject:unscheduleGlobal(self.autoSyncSid)
|
||||
self.autoSyncSid = nil
|
||||
end
|
||||
if ModuleManager.RunesManager:isInAutoQuenching() then
|
||||
self:startAutoQuenching()
|
||||
return
|
||||
end
|
||||
|
||||
self.txCost:setText(GFunc.getRewardNum(self.runesEntity:getMaterialCost()))
|
||||
GFunc.centerImgAndTx(self.imgCost, self.txCost)
|
||||
if DataManager.RunesData:canAutoMake() then
|
||||
self.spineAuto:playAnim("idle", true, true)
|
||||
else
|
||||
self.spineAuto:playAnim("idle2", true, true)
|
||||
end
|
||||
|
||||
self:refreshLevelExp()
|
||||
self:refreshSuit()
|
||||
self:refreshRunes()
|
||||
|
||||
if self.isAutoQuenching then
|
||||
-- 结束自动淬炼
|
||||
self:endAutoQuenching()
|
||||
end
|
||||
end
|
||||
|
||||
-- 自动淬炼刷新
|
||||
function RunesInfoComp:autoQuenching()
|
||||
self:refreshSuit()
|
||||
self:refreshRunes()
|
||||
|
||||
if not ModuleManager.RunesManager:isInSyncQuenching() then
|
||||
DataManager.RunesData:onAutoQuenchingOnce()
|
||||
self.tempExp = self.tempExp + self.tempCostNum
|
||||
self.tempMaterialCount = self.tempMaterialCount - self.tempCostNum
|
||||
self.tempLevel = DataManager.RunesData:getLevelByExp(self.tempExp)
|
||||
|
||||
local curCfg = DataManager.RunesData:getLevelConfig()[self.tempLevel]
|
||||
local nextCfg = DataManager.RunesData:getLevelConfig()[self.tempLevel + 1]
|
||||
local maxExp = (nextCfg and nextCfg.cost or 0) - (curCfg and curCfg.cost or 0)
|
||||
if maxExp then
|
||||
local levelExp = self.tempExp - (curCfg and curCfg.cost or 0)
|
||||
self.imgProg.value = levelExp / maxExp
|
||||
self.txProg:setText(levelExp .. "/" .. maxExp)
|
||||
else
|
||||
self.imgProg.value = 1
|
||||
self.txProg:setText(I18N:getGlobalText(I18N.GlobalConst.STR_MAX))
|
||||
end
|
||||
self.txLevel:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_1, self.tempLevel))
|
||||
self.txNum:setText(GFunc.num2Str(self.tempMaterialCount))
|
||||
if self.tempMaterialCount < self.tempCostNum then
|
||||
-- 剩余材料不够,结束自动淬炼
|
||||
ModuleManager.RunesManager:reqSyncQuenching(true)
|
||||
else
|
||||
DataManager.RunesData:checkAutoTime()
|
||||
end
|
||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.RUNE_QUENCHING_SUCCESS, self.tempMaterialCount)
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新等级经验、道具个数
|
||||
function RunesInfoComp:refreshLevelExp()
|
||||
local curExp = DataManager.RunesData:getLevelExp()
|
||||
local maxExp = DataManager.RunesData:getNextLevelTotalExp()
|
||||
if maxExp then
|
||||
self.imgProg.value = curExp / maxExp
|
||||
self.txProg:setText(curExp .. "/" .. maxExp)
|
||||
else
|
||||
self.imgProg.value = 1
|
||||
self.txProg:setText(I18N:getGlobalText(I18N.GlobalConst.STR_MAX))
|
||||
end
|
||||
self.txLevel:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_1, DataManager.RunesData:getLevel()))
|
||||
self.txNum:setText(GFunc.num2Str(DataManager.RunesData:getMaterialCount()))
|
||||
end
|
||||
|
||||
-- 刷新符文
|
||||
function RunesInfoComp:refreshRunes()
|
||||
for index, obj in ipairs(self.grids) do
|
||||
local map = obj:genAllChildren()
|
||||
local imgQlt = map["img_qlt"]
|
||||
local imgSuit = map["img_suit"]
|
||||
local txAttr = map["tx_attr"]
|
||||
local imgLock = map["img_lock"]
|
||||
local lock = map["lock"]
|
||||
local txLock = map["tx_lock"]
|
||||
obj:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = false
|
||||
|
||||
if ModuleManager.RunesManager:isInAutoQuenching() and index <= DataManager.RunesData:getLevelConfig()[self.tempLevel].grid or DataManager.RunesData:isUnlock(index) then
|
||||
lock:setActive(false)
|
||||
local qlt = self.runesEntity:getGridQuality(index)
|
||||
if qlt then
|
||||
imgQlt:setSprite(GConst.ATLAS_PATH.HERO, GConst.RunesConst.QUALITY_ICON[qlt])
|
||||
end
|
||||
local suit = self.runesEntity:getGridSuit(index)
|
||||
if suit then
|
||||
imgSuit:setSprite(GConst.ATLAS_PATH.HERO, "hero_rune_"..suit)
|
||||
end
|
||||
imgLock:setSprite(GConst.ATLAS_PATH.COMMON, self.runesEntity:isAttrLock(index) and LOCK_ICON or UNLOCK_ICON)
|
||||
local attr = self.runesEntity:getGridAttr(index)
|
||||
if attr then
|
||||
txAttr:setText(GFunc.getAttrDesc(attr.type, attr.num))
|
||||
end
|
||||
imgLock:addClickListener(function()
|
||||
ModuleManager.RunesManager:reqChangeLockGrid(self.heroEntity:getCfgId(), index, not self.runesEntity:isAttrLock(index))
|
||||
end)
|
||||
else
|
||||
lock:setActive(true)
|
||||
txLock:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_3, DataManager.RunesData:getUnlockLevel(index)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新套装
|
||||
function RunesInfoComp:refreshSuit()
|
||||
local ids = self.runesEntity:getSuitIds()
|
||||
|
||||
local isEmpty = true
|
||||
for index, obj in ipairs(self.suits) do
|
||||
local map = obj:genAllChildren()
|
||||
local img = map["img"]
|
||||
local tx = map["tx"]
|
||||
|
||||
if ids[index] then
|
||||
local level = self.runesEntity:getSuitLevel(ids[index].id)
|
||||
if level > 0 then
|
||||
isEmpty = false
|
||||
obj:setActive(true)
|
||||
img:setSprite(GConst.ATLAS_PATH.HERO, "hero_rune_"..ids[index].id)
|
||||
tx:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_26, level))
|
||||
else
|
||||
obj:setActive(false)
|
||||
end
|
||||
else
|
||||
obj:setActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
self.txEmpty:setActive(isEmpty)
|
||||
|
||||
self.suitsNode:RefreshLayout()
|
||||
end
|
||||
|
||||
-- 检查淬炼
|
||||
function RunesInfoComp:checkQuenching(isAuto)
|
||||
-- 是否全部锁定
|
||||
if DataManager.RunesData:getRunes(self.heroEntity:getCfgId()):getAttrLockCount() >= DataManager.RunesData:getUnlockCount() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_25))
|
||||
return
|
||||
end
|
||||
-- 材料是否足够
|
||||
local cost = self.runesEntity:getMaterialCost()
|
||||
if not GFunc.checkCost(GFunc.getRewardId(cost), GFunc.getRewardNum(cost), true) then
|
||||
UIManager:showUI("app/ui/runes/runes_source_ui")
|
||||
return
|
||||
end
|
||||
|
||||
if self.runesEntity:isUnlockHighQlt() then
|
||||
local params ={
|
||||
content = I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_28, I18N:getGlobalText(I18N.GlobalConst["RUNES_QLT_" .. DataManager.RunesData:getCheckQualityIds()[1]])),
|
||||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
||||
okText = I18N:getGlobalText(I18N.GlobalConst.CONTINUE_DESC),
|
||||
okFunc = function()
|
||||
self:reqQuenching(isAuto)
|
||||
end,
|
||||
}
|
||||
GFunc.showMessageBox(params)
|
||||
else
|
||||
self:reqQuenching(isAuto)
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求淬炼
|
||||
function RunesInfoComp:reqQuenching(isAuto)
|
||||
if isAuto then
|
||||
-- 自动淬炼
|
||||
self.isAutoQuenching = true
|
||||
self.mask:setActive(true)
|
||||
self.btnUse:setActive(false)
|
||||
self.txAuto:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_30))
|
||||
self.spineAuto:playAnim("attack", true, true)
|
||||
ModuleManager.RunesManager:reqAutoQuenching(self.heroEntity:getCfgId())
|
||||
else
|
||||
-- 单次淬炼
|
||||
ModuleManager.RunesManager:reqQuenching(self.heroEntity:getCfgId())
|
||||
end
|
||||
end
|
||||
|
||||
-- 开始自动淬炼
|
||||
function RunesInfoComp:startAutoQuenching()
|
||||
self.tempLevel = DataManager.RunesData:getLevel()
|
||||
self.tempExp = DataManager.RunesData:getExp()
|
||||
self.tempCostNum = self.runesEntity:getMaterialCostNum()
|
||||
self.tempMaterialCount = DataManager.RunesData:getMaterialCount()
|
||||
|
||||
self.autoSid = self.baseObject:scheduleGlobal(function() self:autoQuenching() end, 1 / GConst.RunesConst.AUTO_INTERVAL)
|
||||
self.autoSyncSid = self.baseObject:scheduleGlobal(function() ModuleManager.RunesManager:reqSyncQuenching(false, true) end, GConst.RunesConst.SYNC_INTERVAL)
|
||||
end
|
||||
|
||||
-- 结束自动淬炼
|
||||
function RunesInfoComp:endAutoQuenching()
|
||||
self.isAutoQuenching = false
|
||||
self.mask:setActive(false)
|
||||
self.btnUse:setActive(true)
|
||||
self.txAuto:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_4))
|
||||
self.spineAuto:playAnim("idle", true, true)
|
||||
|
||||
for index, obj in ipairs(self.grids) do
|
||||
local qlt = self.runesEntity:getGridQuality(index)
|
||||
if qlt and table.containValue(DataManager.RunesData:getCheckQualityIds(), qlt) and not self.runesEntity:isAttrLock(index) then
|
||||
obj:getTransform():SetAsLastSibling()
|
||||
local animator = obj:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
|
||||
animator.enabled = true
|
||||
-- CS.UnityEngine.Animator.StringToHash("runes_shake") 结果是1132417824
|
||||
animator:Play(1132417824, -1, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return RunesInfoComp
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d6ae74e1ac107c4ca73bacaafebec15
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -85,29 +85,9 @@ function HeroData:addHero(heroStruct)
|
||||
local entity = self:getEntity(heroStruct)
|
||||
|
||||
self.heroes[heroStruct.id] = entity
|
||||
self:updateSelfHeroEquipsAndRunes(entity)
|
||||
|
||||
self.data.activeCount = self.data.activeCount + 1
|
||||
end
|
||||
|
||||
-- 更新装备、符文数据
|
||||
function HeroData:updateSelfHeroEquipsAndRunes(entity)
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("更新英雄属性:" .. entity:getCfgId())
|
||||
end
|
||||
|
||||
entity:setEquips(GConst.EquipConst.PART_TYPE.WEAPON, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON), true)
|
||||
entity:setEquips(GConst.EquipConst.PART_TYPE.HAT, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.HAT), true)
|
||||
entity:setEquips(GConst.EquipConst.PART_TYPE.CLOTHES, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.CLOTHES), true)
|
||||
entity:setEquips(GConst.EquipConst.PART_TYPE.BELT, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.BELT), true)
|
||||
entity:setEquips(GConst.EquipConst.PART_TYPE.HANDGUARD, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.HANDGUARD), true)
|
||||
entity:setRunes(DataManager.RunesData:getRunes(entity:getCfgId()), true)
|
||||
|
||||
-- 手动调用更新数据
|
||||
entity:onEquipAttrChange()
|
||||
entity:onRunesAttrChange()
|
||||
end
|
||||
|
||||
function HeroData:getEntity(heroStruct)
|
||||
return HeroEntity:create(heroStruct.id, heroStruct.level, heroStruct.skin, heroStruct.star)
|
||||
end
|
||||
@ -162,7 +142,6 @@ function HeroData:setHeroLv(id, lv)
|
||||
local activeBefore = true
|
||||
if not entity:isActived() then
|
||||
self.data.activeCount = self.data.activeCount + 1
|
||||
self:updateSelfHeroEquipsAndRunes(entity)
|
||||
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_NEW_HERO_GOT)
|
||||
ModuleManager.PlayerManager:checkUnlockAvatar(id)
|
||||
activeBefore = false
|
||||
@ -343,7 +322,7 @@ function HeroData:getAllHeroesSort(formationType)
|
||||
return result
|
||||
end
|
||||
|
||||
-- region
|
||||
-- region 配置相关
|
||||
function HeroData:getHeroConfig(id)
|
||||
if id then
|
||||
return ConfigManager:getConfig("hero")[id]
|
||||
@ -374,6 +353,25 @@ function HeroData:getHeroLevelCost(lv, qlt)
|
||||
return cfg.cost
|
||||
end
|
||||
end
|
||||
-- endregion
|
||||
|
||||
-- region
|
||||
function HeroData:isStarOpen()
|
||||
return true
|
||||
end
|
||||
|
||||
function HeroData:getStarById(id)
|
||||
local hero = self.heroes[id]
|
||||
if hero then
|
||||
return hero:getStar()
|
||||
end
|
||||
return 0
|
||||
end
|
||||
-- endregion
|
||||
|
||||
-- region 皮肤相关
|
||||
function HeroData:isSkinOpen()
|
||||
return true
|
||||
end
|
||||
-- endregion
|
||||
return HeroData
|
||||
@ -8,15 +8,15 @@ function HeroEntity:ctor(cfgId, lv, skin, star)
|
||||
self.data.skin = skin
|
||||
self.data.star = star
|
||||
self.config = ConfigManager:getConfig("hero")[self.cfgId]
|
||||
self.beginLv = self.config.begin_lv -- 初始等级
|
||||
self.beginLv = 1 -- 激活等级
|
||||
|
||||
self.baseAttrOriginal = {}
|
||||
self.equipAttr = {}
|
||||
self.starAttr = {}
|
||||
self.skinAttr = {}
|
||||
self.runesAttr = {}
|
||||
self.allAttr = {}
|
||||
end
|
||||
|
||||
-- region 属性
|
||||
function HeroEntity:initAttr()
|
||||
self:setTotalAttrValue(ATTR_NAME.HP, 0)
|
||||
self:setTotalAttrValue(ATTR_NAME.ATK, 0)
|
||||
@ -25,15 +25,6 @@ function HeroEntity:initAttr()
|
||||
self:setTotalAttrValue(ATTR_NAME.ATK_GREEN, 0)
|
||||
self:setTotalAttrValue(ATTR_NAME.ATK_BLUE, 0)
|
||||
self:setTotalAttrValue(ATTR_NAME.ATK_PURPLE, 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], 0)
|
||||
self:setEquipAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()], 0)
|
||||
|
||||
self:updateAllAttr()
|
||||
end
|
||||
@ -44,8 +35,8 @@ function HeroEntity:onBaseAttrChange()
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function HeroEntity:onEquipAttrChange()
|
||||
self:updateEquipAttr()
|
||||
function HeroEntity:onStarAttrChange()
|
||||
self:updateStarAttr()
|
||||
self:updateTotalAttr()
|
||||
self:setDirty()
|
||||
end
|
||||
@ -56,12 +47,6 @@ function HeroEntity:onSkinAttrChange()
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function HeroEntity:onRunesAttrChange()
|
||||
self:updateRunesAttr()
|
||||
self:updateTotalAttr()
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function HeroEntity:setDirty()
|
||||
self.data.isDirty = not self.data.isDirty
|
||||
end
|
||||
@ -73,9 +58,8 @@ end
|
||||
-- 更新所有属性
|
||||
function HeroEntity:updateAllAttr()
|
||||
self:updateBaseAttr()
|
||||
self:updateEquipAttr()
|
||||
self:updateStarAttr()
|
||||
self:updateSkinAttr()
|
||||
self:updateRunesAttr()
|
||||
self:updateTotalAttr()
|
||||
end
|
||||
|
||||
@ -90,52 +74,33 @@ function HeroEntity:updateBaseAttr()
|
||||
self.baseAttrOriginal[GConst.MATCH_ATTACK_NAME[self.config.position]] = self:getCfgAtk()
|
||||
end
|
||||
|
||||
-- 更新装备属性
|
||||
function HeroEntity:updateEquipAttr()
|
||||
self.equipAttr = {}
|
||||
-- 更新皮肤属性
|
||||
function HeroEntity:updateStarAttr()
|
||||
self.starAttr = {}
|
||||
|
||||
local hp,atk,normalHurt,skillHurt,critPer,critHurtPer,normalHurtPer,skillHurtPer,healPer = 0
|
||||
-- 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)
|
||||
|
||||
local addArmorAttrPer = true
|
||||
for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
|
||||
local equipEntity = self:getEquips(partType)
|
||||
if equipEntity then
|
||||
-- 基础值
|
||||
hp = equipEntity:getHp()
|
||||
atk = equipEntity:getAttack()
|
||||
normalHurt = equipEntity:getNormalHurt()
|
||||
skillHurt = equipEntity:getSkillHurt()
|
||||
-- 属性值
|
||||
critPer = 0
|
||||
critHurtPer = 0
|
||||
normalHurtPer = 0
|
||||
skillHurtPer = 0
|
||||
healPer = 0
|
||||
if partType == GConst.EquipConst.PART_TYPE.WEAPON or addArmorAttrPer then
|
||||
if partType ~= GConst.EquipConst.PART_TYPE.WEAPON then
|
||||
addArmorAttrPer = false-- 防具的属性只只用计算一次
|
||||
end
|
||||
|
||||
critPer = equipEntity:getCritPercent()
|
||||
critHurtPer = equipEntity:getCritHurtPercent()
|
||||
normalHurtPer = equipEntity:getNormalHurtPercent()
|
||||
skillHurtPer = equipEntity:getSkillHurtPercent()
|
||||
healPer = equipEntity:getHealPercent()
|
||||
end
|
||||
|
||||
self:addEquipAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()], hp)
|
||||
self:addEquipAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], atk)
|
||||
self:addEquipAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()], normalHurt)
|
||||
self:addEquipAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()], skillHurt)
|
||||
self:addEquipAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()], critPer)
|
||||
self:addEquipAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()], critHurtPer)
|
||||
self:addEquipAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], normalHurtPer)
|
||||
self:addEquipAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], skillHurtPer)
|
||||
self:addEquipAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()], healPer)
|
||||
-- self.starAttr[GConst.MATCH_HP_NAME[self:getMatchType()]] = hp
|
||||
-- self.starAttr[GConst.MATCH_ATTACK_NAME[self:getMatchType()]] = atk
|
||||
-- self.starAttr[GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()]] = normalHurt
|
||||
-- self.starAttr[GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()]] = skillHurt
|
||||
-- self.starAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] = critPer
|
||||
-- self.starAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] = critHurtPer
|
||||
-- self.starAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] = normalHurtPer
|
||||
-- self.starAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] = skillHurtPer
|
||||
-- self.starAttr[GConst.MATCH_CURED_NAME[self:getMatchType()]] = healPer
|
||||
|
||||
-- if EDITOR_MODE then
|
||||
-- local printStr = ""
|
||||
-- printStr = printStr .. "更新装备数值:"..self:getCfgId().."-".. partName .. "-" .. equipEntity:getLevel() .. "\n"
|
||||
-- printStr = printStr .. "更新皮肤数值:"..self:getCfgId() .. "\n"
|
||||
-- printStr = printStr .. "生命:".. hp .. "\n"
|
||||
-- printStr = printStr .. "攻击力:".. atk .. "\n"
|
||||
-- printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
|
||||
@ -147,19 +112,6 @@ function HeroEntity:updateEquipAttr()
|
||||
-- printStr = printStr .. "治疗加成百分比:".. healPer .. "\n"
|
||||
-- Logger.logHighlight(printStr)
|
||||
-- end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HeroEntity:setEquipAttrValue(name, value)
|
||||
self.equipAttr[name] = value
|
||||
end
|
||||
|
||||
function HeroEntity:addEquipAttrValue(name, value)
|
||||
if self.equipAttr[name] == nil then
|
||||
self.equipAttr[name] = 0
|
||||
end
|
||||
self.equipAttr[name] = self.equipAttr[name] + value
|
||||
end
|
||||
|
||||
-- 更新皮肤属性
|
||||
@ -202,69 +154,15 @@ function HeroEntity:updateSkinAttr()
|
||||
-- end
|
||||
end
|
||||
|
||||
-- 更新符文属性
|
||||
function HeroEntity:updateRunesAttr()
|
||||
self.runesAttr = {}
|
||||
|
||||
local runesEntity = self:getRunes()
|
||||
if runesEntity == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local hp = runesEntity:getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getMatchType()])
|
||||
local atk = runesEntity:getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()])
|
||||
local normalHurt = runesEntity:getAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()])
|
||||
local skillHurt = runesEntity:getAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()])
|
||||
local critPer = runesEntity:getAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()])
|
||||
local critHurtPer = runesEntity:getAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()])
|
||||
local normalHurtPer = runesEntity:getAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], true)
|
||||
local skillHurtPer = runesEntity:getAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], true)
|
||||
local healPer = runesEntity:getAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()])
|
||||
local allHurtp = runesEntity:getAttrValue(GConst.MATCH_ALL_HURTP_NAME[self:getMatchType()])
|
||||
|
||||
self.runesAttr[GConst.MATCH_HP_NAME[self:getMatchType()]] = hp
|
||||
self.runesAttr[GConst.MATCH_ATTACK_NAME[self:getMatchType()]] = atk
|
||||
self.runesAttr[GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()]] = normalHurt
|
||||
self.runesAttr[GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()]] = skillHurt
|
||||
self.runesAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] = critPer
|
||||
self.runesAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] = critHurtPer
|
||||
self.runesAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] = normalHurtPer
|
||||
self.runesAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] = skillHurtPer
|
||||
self.runesAttr[GConst.MATCH_CURED_NAME[self:getMatchType()]] = healPer
|
||||
self.runesAttr[GConst.MATCH_ALL_HURTP_NAME[self:getMatchType()]] = allHurtp
|
||||
|
||||
-- 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"
|
||||
-- printStr = printStr .. "所有伤害百分比:".. allHurtp .. "\n"
|
||||
-- Logger.logHighlight(printStr)
|
||||
-- end
|
||||
end
|
||||
|
||||
-- 更新总属性
|
||||
function HeroEntity:updateTotalAttr()
|
||||
self.allAttr = {}
|
||||
for k, v in pairs(self.baseAttrOriginal) do
|
||||
self:setTotalAttrValue(k, v)
|
||||
end
|
||||
for k, v in pairs(self.equipAttr) do
|
||||
self:addTotalAttrValue(k, v)
|
||||
end
|
||||
for k, v in pairs(self.skinAttr) do
|
||||
self:addTotalAttrValue(k, v)
|
||||
end
|
||||
for k, v in pairs(self.runesAttr) do
|
||||
self:addTotalAttrValue(k, v)
|
||||
end
|
||||
end
|
||||
|
||||
function HeroEntity:setTotalAttrValue(name, value)
|
||||
@ -290,60 +188,41 @@ function HeroEntity:getTotalAttrValue(name)
|
||||
return GFunc.decryptNumber(self.allAttr[name])
|
||||
end
|
||||
|
||||
function HeroEntity:setLv(lv, onlyChangeLv)
|
||||
if not lv then
|
||||
return
|
||||
end
|
||||
if self.data.lv == lv then
|
||||
return
|
||||
end
|
||||
self.data.lv = lv
|
||||
self:updateAllAttr()
|
||||
self:setDirty()
|
||||
|
||||
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
|
||||
-- 获取总基础生命值(英雄+装备+皮肤)
|
||||
function HeroEntity:getTotalBaseHp()
|
||||
local result = self:isActived() and self:getCfgHp() or self:getCfgHp(self:getBeginLv())
|
||||
result = result + DataManager.SkinData:getBaseHp(self)
|
||||
return result
|
||||
end
|
||||
|
||||
function HeroEntity:getCfgId()
|
||||
return self.cfgId
|
||||
-- 获取总基础攻击值(英雄+装备+皮肤)
|
||||
function HeroEntity:getTotalBaseAtk()
|
||||
local result = self:isActived() and self:getCfgAtk() or self:getCfgAtk(self:getBeginLv())
|
||||
-- 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()
|
||||
-- end
|
||||
-- end
|
||||
-- logStr = logStr .. "\nSKIN:" .. DataManager.SkinData:getBaseAttack(self)
|
||||
result = result + DataManager.SkinData:getBaseAttack(self)
|
||||
-- Logger.logHighlight(logStr)
|
||||
return result
|
||||
end
|
||||
|
||||
function HeroEntity:getLv()
|
||||
return self.data.lv
|
||||
function HeroEntity:getAtk()
|
||||
local atkName = GConst.MATCH_ATTACK_NAME[self:getMatchType()]
|
||||
local atkAddName = GConst.MATCH_ATTACK_ADD_NAME[self:getMatchType()]
|
||||
return self:getTotalAttrValue(atkName) + self:getTotalAttrValue(atkAddName)
|
||||
end
|
||||
|
||||
-- 获取当前穿戴皮肤
|
||||
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:getQlt()
|
||||
return self.config.qlt
|
||||
end
|
||||
|
||||
function HeroEntity:getBeginLv()
|
||||
return self.beginLv
|
||||
end
|
||||
|
||||
function HeroEntity:getMatchType()
|
||||
return self.config.position
|
||||
end
|
||||
|
||||
-- 英雄每级可领取图鉴点数
|
||||
function HeroEntity:getCollectionPoint()
|
||||
return self.config.collection_point
|
||||
function HeroEntity:getHp()
|
||||
local hpName = ATTR_NAME.HP
|
||||
local hpAddName = GConst.MATCH_HP_ADD_NAME[self:getMatchType()]
|
||||
return self:getTotalAttrValue(hpName) + self:getTotalAttrValue(hpAddName)
|
||||
end
|
||||
|
||||
function HeroEntity:getCfgHp(lv)
|
||||
@ -369,30 +248,32 @@ function HeroEntity:getCfgAtk(lv)
|
||||
|
||||
return 0
|
||||
end
|
||||
-- endregion
|
||||
|
||||
function HeroEntity:getUnlcokChapter()
|
||||
return self.config.unlock_chapter
|
||||
-- region 基础
|
||||
function HeroEntity:setLv(lv, onlyChangeLv)
|
||||
if not lv then
|
||||
return
|
||||
end
|
||||
if self.data.lv == lv then
|
||||
return
|
||||
end
|
||||
self.data.lv = lv
|
||||
self:updateAllAttr()
|
||||
self:setDirty()
|
||||
|
||||
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:getUnlockDan()
|
||||
return self.config.unlock_arena
|
||||
|
||||
function HeroEntity:getLv()
|
||||
return self.data.lv
|
||||
end
|
||||
|
||||
function HeroEntity:getIsShowUnlcokChapter()
|
||||
return self.config.is_show == 1
|
||||
end
|
||||
|
||||
function HeroEntity:getAtk()
|
||||
local atkName = GConst.MATCH_ATTACK_NAME[self:getMatchType()]
|
||||
local atkAddName = GConst.MATCH_ATTACK_ADD_NAME[self:getMatchType()]
|
||||
return self:getTotalAttrValue(atkName) + self:getTotalAttrValue(atkAddName)
|
||||
end
|
||||
|
||||
function HeroEntity:getHp()
|
||||
local hpName = ATTR_NAME.HP
|
||||
local hpAddName = GConst.MATCH_HP_ADD_NAME[self:getMatchType()]
|
||||
return self:getTotalAttrValue(hpName) + self:getTotalAttrValue(hpAddName)
|
||||
function HeroEntity:getBeginLv()
|
||||
return self.beginLv
|
||||
end
|
||||
|
||||
function HeroEntity:isMaxLv()
|
||||
@ -436,28 +317,18 @@ function HeroEntity:isUnlock()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
local unlockChapter = self:getUnlcokChapter()
|
||||
if unlockChapter and unlockChapter <= DataManager.ChapterData:getMaxChapterId() then
|
||||
return true
|
||||
end
|
||||
local unlockDan = self:getUnlockDan()
|
||||
if unlockDan and unlockDan <= DataManager.ArenaData:getFormartMaxGrading() then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function HeroEntity:isActived()
|
||||
-- return self.data.lv >= self:getBeginLv()
|
||||
return self.data.lv >= 0
|
||||
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
|
||||
if lv < self:getBeginLv() then
|
||||
lv = self:getBeginLv()
|
||||
end
|
||||
local nextLvInfo = ConfigManager:getConfig("hero_level")[lv]
|
||||
if not nextLvInfo then
|
||||
return
|
||||
@ -465,7 +336,9 @@ function HeroEntity:getLvUpMaterials()
|
||||
-- local fieldName = "cost_" .. self:getQlt()
|
||||
return nextLvInfo.cost
|
||||
end
|
||||
-- endregion
|
||||
|
||||
-- region 配置
|
||||
function HeroEntity:getConfig()
|
||||
return self.config
|
||||
end
|
||||
@ -503,6 +376,10 @@ 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
|
||||
@ -511,6 +388,14 @@ 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
|
||||
-- endregion
|
||||
|
||||
-- function HeroEntity:getActiveRogueCount()
|
||||
-- local lvInfo = ConfigManager:getConfig("hero_level")[self.data.lv]
|
||||
@ -522,6 +407,7 @@ end
|
||||
-- return 0
|
||||
-- end
|
||||
|
||||
-- region 技能
|
||||
function HeroEntity:getUnlockRogueId()
|
||||
return self.config.rouge_skill
|
||||
end
|
||||
@ -573,69 +459,32 @@ function HeroEntity:getActiveRogueSkills()
|
||||
|
||||
return list
|
||||
end
|
||||
-- endregion
|
||||
|
||||
-- 获取总基础生命值(英雄+装备+皮肤)
|
||||
function HeroEntity:getTotalBaseHp()
|
||||
local result = self:isActived() and self:getCfgHp() or self:getCfgHp(self:getBeginLv())
|
||||
-- 武器 + 防具
|
||||
for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
|
||||
local equipEntity = self:getEquips(partType)
|
||||
if equipEntity then
|
||||
result = result + equipEntity:getBaseHp()
|
||||
end
|
||||
end
|
||||
result = result + DataManager.SkinData:getBaseHp(self)
|
||||
-- region 升星相关
|
||||
function HeroEntity:getStar()
|
||||
return self.data.star
|
||||
end
|
||||
-- endregion
|
||||
|
||||
local runesEntity = self:getRunes()
|
||||
if runesEntity then
|
||||
result = result + runesEntity:getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getMatchType()], true)
|
||||
end
|
||||
-- region 皮肤相关
|
||||
|
||||
return result
|
||||
-- 获取当前穿戴皮肤
|
||||
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:getTotalBaseAtk()
|
||||
local result = self:isActived() and self:getCfgAtk() or self:getCfgAtk(self:getBeginLv())
|
||||
-- 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()
|
||||
end
|
||||
end
|
||||
-- logStr = logStr .. "\nSKIN:" .. DataManager.SkinData:getBaseAttack(self)
|
||||
result = result + DataManager.SkinData:getBaseAttack(self)
|
||||
local runesEntity = self:getRunes()
|
||||
if runesEntity then
|
||||
-- logStr = logStr .. "\nRUNES:" .. self:getRunes():getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], true)
|
||||
result = result + runesEntity:getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], true)
|
||||
end
|
||||
-- Logger.logHighlight(logStr)
|
||||
return result
|
||||
-- 穿戴皮肤
|
||||
function HeroEntity:onChangeSkin(skinId)
|
||||
self.data.skin = skinId
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- {partType = EquipEntity}
|
||||
function HeroEntity:setEquips(partType, equipEntities, notNowUpdate)
|
||||
if self.equipEntities == nil then
|
||||
self.equipEntities = {}
|
||||
end
|
||||
self.equipEntities[partType] = equipEntities
|
||||
|
||||
if notNowUpdate then
|
||||
return
|
||||
end
|
||||
self:getTotalAttrValue() -- 防止报错
|
||||
self:onEquipAttrChange()
|
||||
end
|
||||
|
||||
function HeroEntity:getEquips(partType)
|
||||
if self.equipEntities then
|
||||
return self.equipEntities[partType]
|
||||
end
|
||||
return nil
|
||||
function HeroEntity:getSkins()
|
||||
return self.unlockSkins
|
||||
end
|
||||
|
||||
function HeroEntity:setSkins(skinIds)
|
||||
@ -643,23 +492,6 @@ function HeroEntity:setSkins(skinIds)
|
||||
self:getTotalAttrValue() -- 防止报错
|
||||
self:onSkinAttrChange()
|
||||
end
|
||||
|
||||
function HeroEntity:getSkins()
|
||||
return self.unlockSkins
|
||||
end
|
||||
|
||||
function HeroEntity:setRunes(runesEntity, notNowUpdate)
|
||||
self.runesEntity = runesEntity
|
||||
|
||||
if notNowUpdate then
|
||||
return
|
||||
end
|
||||
self:getTotalAttrValue() -- 防止报错
|
||||
self:onRunesAttrChange()
|
||||
end
|
||||
|
||||
function HeroEntity:getRunes()
|
||||
return self.runesEntity
|
||||
end
|
||||
-- endregion
|
||||
|
||||
return HeroEntity
|
||||
@ -1,390 +0,0 @@
|
||||
local RunesData = class("RunesData", BaseData)
|
||||
local RunesEntity = require "app/userdata/runes/runes_entity"
|
||||
|
||||
function RunesData:ctor()
|
||||
self.data.isDirty = false
|
||||
end
|
||||
|
||||
function RunesData:clear()
|
||||
DataManager:unregisterTryOpenFunc("RunesData")
|
||||
end
|
||||
|
||||
function RunesData:init(data)
|
||||
data = data or GConst.EMPTY_TABLE
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("符文初始化数据")
|
||||
Logger.printTable(data)
|
||||
end
|
||||
|
||||
self:updateLevelAndExp(data.level or 1, data.exp or 0)
|
||||
if data.heroes_grids then
|
||||
for heroId, grids in pairs(data.heroes_grids) do
|
||||
self:addRunes(heroId, grids.grids)
|
||||
end
|
||||
|
||||
-- 处理上报
|
||||
local formation = DataManager.FormationData:getStageFormation()
|
||||
local runesChapter = {}
|
||||
for elementType, heroId in pairs(formation) do
|
||||
runesChapter[heroId] = data.heroes_grids[heroId]
|
||||
end
|
||||
BIReport:postRunes(BIReport.RUNES_FORMATION.CHAPTER, runesChapter)
|
||||
end
|
||||
|
||||
-- 活动开启
|
||||
DataManager:registerTryOpenFunc("RunesData", function()
|
||||
if self:isOpen() then
|
||||
DataManager:unregisterTryOpenFunc("RunesData")
|
||||
self:setDirty()
|
||||
end
|
||||
end)
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function RunesData:setDirty()
|
||||
self.data.isDirty = not self.data.isDirty
|
||||
end
|
||||
|
||||
function RunesData:isOpen(showToast)
|
||||
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.RUNES_OPEN, not showToast) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function RunesData:addRunes(heroId, grids)
|
||||
if self.runes == nil then
|
||||
self.runes = {}
|
||||
end
|
||||
|
||||
if self.runes[heroId] == nil then
|
||||
self.runes[heroId] = self:createEntity(heroId, grids)
|
||||
else
|
||||
self.runes[heroId]:updateGrids(grids)
|
||||
end
|
||||
end
|
||||
|
||||
function RunesData:createEntity(heroId, grids)
|
||||
return RunesEntity:create(heroId, grids)
|
||||
end
|
||||
|
||||
function RunesData:getRunes(heroId)
|
||||
if self.runes == nil then
|
||||
self.runes = {}
|
||||
end
|
||||
if self.runes[heroId] == nil then
|
||||
self.runes[heroId] = self:createEntity(heroId)
|
||||
end
|
||||
|
||||
return self.runes[heroId]
|
||||
end
|
||||
|
||||
-- 是否有红点
|
||||
function RunesData:hasRedPoint(tempCount)
|
||||
return (tempCount or self:getMaterialCount()) > GFunc.getConstIntValue("runes_red_point")
|
||||
end
|
||||
|
||||
-- 获取等级配置
|
||||
function RunesData:getLevelConfig()
|
||||
if self.RuneCfg == nil then
|
||||
self.RuneCfg = ConfigManager:getConfig("runes_level")
|
||||
end
|
||||
|
||||
return self.RuneCfg
|
||||
end
|
||||
|
||||
-- 获取铸台最大等级
|
||||
function RunesData:getMaxLevel()
|
||||
return #self:getLevelConfig()
|
||||
end
|
||||
|
||||
-- 获取符文铸台等级
|
||||
function RunesData:getLevel()
|
||||
return self.level
|
||||
end
|
||||
|
||||
-- 获取等级当前经验
|
||||
function RunesData:getLevelExp()
|
||||
return self.exp - (self:getLevelConfig()[self:getLevel()].cost or 0)
|
||||
end
|
||||
|
||||
-- 获取总经验值
|
||||
function RunesData:getExp()
|
||||
return self.exp
|
||||
end
|
||||
|
||||
-- 根据经验获取等级
|
||||
function RunesData:getLevelByExp(exp)
|
||||
local level
|
||||
for index, value in ipairs(self:getLevelConfig()) do
|
||||
if exp >= (value.cost or 0) then
|
||||
level = index
|
||||
else
|
||||
return level
|
||||
end
|
||||
end
|
||||
|
||||
return level
|
||||
end
|
||||
|
||||
-- 获取到下一档的总经验
|
||||
function RunesData:getNextLevelTotalExp()
|
||||
local nextExp
|
||||
local cfg = self:getLevelConfig()[self:getLevel() + 1]
|
||||
if cfg then
|
||||
nextExp = cfg.cost or 0
|
||||
end
|
||||
local curExp = self:getLevelConfig()[self:getLevel()].cost or 0
|
||||
|
||||
return nextExp - curExp
|
||||
end
|
||||
|
||||
-- 获取需要检查锁定状态的品质的id
|
||||
function RunesData:getCheckQualityIds()
|
||||
local curLevel = self:getLevel()
|
||||
local ids = {}
|
||||
if curLevel <= GConst.RunesConst.NOT_CHECK_QLT_LEVEL then
|
||||
return ids
|
||||
end
|
||||
|
||||
for i = GConst.RunesConst.MAX_QUALITY_COUNT, 1, -1 do
|
||||
local weight = self:getQualityRate(self:getLevel(), i)
|
||||
if weight then
|
||||
table.insert(ids, i)
|
||||
end
|
||||
|
||||
if #ids >= GConst.RunesConst.CHECK_QLT_LOCK_NUM then
|
||||
break
|
||||
end
|
||||
end
|
||||
table.sort(ids)
|
||||
|
||||
return ids
|
||||
end
|
||||
|
||||
-- 获取相应铸台等级的品质概率
|
||||
function RunesData:getQualityRate(level, quality)
|
||||
local cfg = self:getLevelConfig()[level]
|
||||
|
||||
local total = 0
|
||||
for i = 1, GConst.RunesConst.MAX_QUALITY_COUNT do
|
||||
total = total + (cfg["weight_"..i] or 0)
|
||||
end
|
||||
|
||||
local value = cfg["weight_"..quality]
|
||||
if value then
|
||||
return string.format("%.2f",(value / total) * 100)
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 获取相应套装的相应属性
|
||||
function RunesData:getSuitAttr(id, heroType, suitLevel)
|
||||
local data = ConfigManager:getConfig("runes_suit")[id]
|
||||
local attrs
|
||||
if heroType == GConst.HeroConst.MATCH_TYPE.RED then
|
||||
attrs = data.red_suit_attr
|
||||
elseif heroType == GConst.HeroConst.MATCH_TYPE.YELLOW then
|
||||
attrs = data.yellow_suit_attr
|
||||
elseif heroType == GConst.HeroConst.MATCH_TYPE.GREEN then
|
||||
attrs = data.green_suit_attr
|
||||
elseif heroType == GConst.HeroConst.MATCH_TYPE.BLUE then
|
||||
attrs = data.blue_suit_attr
|
||||
elseif heroType == GConst.HeroConst.MATCH_TYPE.PURPLE then
|
||||
attrs = data.purple_suit_attr
|
||||
end
|
||||
|
||||
if attrs ~= nil and attrs[suitLevel] then
|
||||
return attrs[suitLevel]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 获取锻造材料基础消耗个数
|
||||
function RunesData:getMaterialCostBaseNum()
|
||||
if self.baseCostNum == nil then
|
||||
self.baseCostNum = GFunc.getConstReward("runes_cost_base").num
|
||||
end
|
||||
|
||||
return self.baseCostNum
|
||||
end
|
||||
|
||||
-- 获取锻造材料额外单个锁定消耗个数
|
||||
function RunesData:getMaterialCostAddNum()
|
||||
if self.addCostNum == nil then
|
||||
self.addCostNum = GFunc.getConstReward("runes_cost_add").num
|
||||
end
|
||||
|
||||
return self.addCostNum
|
||||
end
|
||||
|
||||
-- 获取锻造材料个数
|
||||
function RunesData:getMaterialCount()
|
||||
return DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_RUNES)
|
||||
end
|
||||
|
||||
-- 是否可以一键铸造
|
||||
function RunesData:canAutoMake()
|
||||
local cfg = self:getLevelConfig()[self:getLevel()]
|
||||
return cfg.auto and cfg.auto == 1
|
||||
end
|
||||
|
||||
-- 获取自动铸造的开启等级
|
||||
function RunesData:getAutoMakeOpenLevel()
|
||||
for level, data in ipairs(self:getLevelConfig()) do
|
||||
if data.auto and data.auto == 1 then
|
||||
return level
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 符文栏是否解锁
|
||||
function RunesData:isUnlock(index)
|
||||
local level = self:getLevel()
|
||||
return index <= self:getLevelConfig()[level].grid
|
||||
end
|
||||
|
||||
-- 获取符文栏解锁个数
|
||||
function RunesData:getUnlockCount()
|
||||
local unlock = 0
|
||||
for i = 1, GConst.RunesConst.MAX_ATTR_GRID_COUNT do
|
||||
if self:isUnlock(i) then
|
||||
unlock = unlock + 1
|
||||
end
|
||||
end
|
||||
|
||||
return unlock
|
||||
end
|
||||
|
||||
-- 获取符文栏解锁等级要求
|
||||
function RunesData:getUnlockLevel(index)
|
||||
for level, data in ipairs(self:getLevelConfig()) do
|
||||
if data.grid >= index then
|
||||
return level
|
||||
end
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
-- 获取套装名
|
||||
function RunesData:getSuitName(index)
|
||||
if index == 1 then
|
||||
return I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_10)
|
||||
elseif index == 2 then
|
||||
return I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_11)
|
||||
elseif index == 3 then
|
||||
return I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_14)
|
||||
elseif index == 4 then
|
||||
return I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_12)
|
||||
elseif index == 5 then
|
||||
return I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_13)
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 改变属性栏锁定状态成功
|
||||
function RunesData:onGridLockSuccess(heroId, grids)
|
||||
self.runes[heroId]:updateGrids(grids)
|
||||
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- 获取随机一套grids数据
|
||||
function RunesData:getRandomGrids()
|
||||
if self.fakeGrids == nil then
|
||||
self.fakeGrids = {}
|
||||
|
||||
local maxQlt = self:getCheckQualityIds()[1] - 1
|
||||
for i = 1, GConst.RunesConst.FAKE_DATA_COUNT do
|
||||
self.fakeGrids[i] = {}
|
||||
for j = 1, GConst.RunesConst.MAX_ATTR_GRID_COUNT do
|
||||
local grid = {}
|
||||
grid.quality = math.random(maxQlt)
|
||||
grid.attr = math.random(GConst.RunesConst.MAX_ATTR_COUNT)
|
||||
grid.suit = math.random(GConst.RunesConst.MAX_SUITS_COUNT)
|
||||
table.insert(self.fakeGrids[i], grid)
|
||||
end
|
||||
end
|
||||
|
||||
Logger.logHighlight("轮播假数据:")
|
||||
Logger.printTable(self.fakeGrids)
|
||||
end
|
||||
|
||||
return self.fakeGrids[math.random(GConst.RunesConst.FAKE_DATA_COUNT)]
|
||||
end
|
||||
|
||||
-- 获取本次同步已执行的自动淬炼次数
|
||||
function RunesData:getExecutedAutoCount()
|
||||
return self.executedAutoCount
|
||||
end
|
||||
|
||||
-- 获取当前自动淬炼的英雄
|
||||
function RunesData:getAutoHeroId()
|
||||
return self.autoHeroId
|
||||
end
|
||||
|
||||
-- 自动淬炼次数增加
|
||||
function RunesData:onAutoQuenchingOnce()
|
||||
self.executedTotalAutoCount = self.executedTotalAutoCount + 1
|
||||
self.executedAutoCount = self.executedAutoCount + 1
|
||||
end
|
||||
|
||||
-- 检查自动次数是否足够
|
||||
function RunesData:checkAutoTime()
|
||||
if self.executedTotalAutoCount >= self.autoTotalCount then
|
||||
-- 剩余自动次数不足,同步并请求数据
|
||||
ModuleManager.RunesManager:reqSyncQuenching(self.isCountEnd)
|
||||
end
|
||||
end
|
||||
|
||||
-- 淬炼成功
|
||||
function RunesData:onQuenchingSuccess(level, exp, heroId, grids)
|
||||
self:updateLevelAndExp(level, exp)
|
||||
self.runes[heroId]:updateGrids(grids)
|
||||
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- 自动淬炼数据获取成功
|
||||
function RunesData:onGetAutoQuenchingDataSuccess(heroId, count, isCountEnd)
|
||||
self.autoHeroId = heroId
|
||||
self.autoTotalCount = count
|
||||
self.executedTotalAutoCount = 0
|
||||
self.executedAutoCount = 0
|
||||
self.isCountEnd = isCountEnd
|
||||
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- 自动淬炼成功
|
||||
function RunesData:onAutoQuenchingSuccess(level, exp, grids)
|
||||
self:updateLevelAndExp(level, exp)
|
||||
self.runes[self:getAutoHeroId()]:updateGrids(grids)
|
||||
self.executedAutoCount = 0
|
||||
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- 更新等级和经验
|
||||
function RunesData:updateLevelAndExp(level, exp)
|
||||
if self.level and self.level ~= level then
|
||||
-- 等级变了,重置假数据
|
||||
self.fakeGrids = nil
|
||||
end
|
||||
|
||||
self.level = level
|
||||
self.exp = exp
|
||||
end
|
||||
|
||||
-- 自动淬炼失败
|
||||
function RunesData:onAutoQuenchingFailed()
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
return RunesData
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9a5f762edecf854ab9eecd7ace92c0e
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -1,245 +0,0 @@
|
||||
local RunesEntity = class("RunesEntity", BaseData)
|
||||
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
|
||||
|
||||
function RunesEntity:ctor(heroId, grids)
|
||||
self.heroId = heroId
|
||||
self.grids = grids or {}
|
||||
end
|
||||
|
||||
function RunesEntity:setDirty()
|
||||
self.data.isDirty = not self.data.isDirty
|
||||
end
|
||||
|
||||
function RunesEntity:updateGrids(grids)
|
||||
self.grids = grids or {}
|
||||
self:getHeroEntity():onRunesAttrChange()
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function RunesEntity:getHeroEntity()
|
||||
if self.heroEntity == nil then
|
||||
self.heroEntity = DataManager.HeroData:getHeroById(self.heroId)
|
||||
end
|
||||
|
||||
return self.heroEntity
|
||||
end
|
||||
|
||||
-- 符文栏是否锁定属性
|
||||
function RunesEntity:isAttrLock(index)
|
||||
if self.grids[index] then
|
||||
return self.grids[index].lock
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- 获取已锁定的符文栏个数
|
||||
function RunesEntity:getAttrLockCount()
|
||||
local lock = 0
|
||||
for i = 1, GConst.RunesConst.MAX_ATTR_GRID_COUNT do
|
||||
if self:isAttrLock(i) then
|
||||
lock = lock + 1
|
||||
end
|
||||
end
|
||||
|
||||
return lock
|
||||
end
|
||||
|
||||
-- 是否存在品质大于s的未锁定
|
||||
function RunesEntity:isUnlockHighQlt()
|
||||
for idx, data in ipairs(self.grids) do
|
||||
if table.containValue(DataManager.RunesData:getCheckQualityIds(), self:getGridQuality(idx)) and not self:isAttrLock(idx) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- 获取锻造的材料消耗
|
||||
function RunesEntity:getMaterialCost()
|
||||
local base = GFunc.getConstReward("runes_cost_base")
|
||||
local add = GFunc.getConstReward("runes_cost_add")
|
||||
local total = {id = base.id, num = base.num, type = base.type}
|
||||
|
||||
total.num = total.num + (add.num * self:getAttrLockCount())
|
||||
|
||||
return total
|
||||
end
|
||||
|
||||
-- 获取锻造的材料消耗个数
|
||||
function RunesEntity:getMaterialCostNum()
|
||||
local num = DataManager.RunesData:getMaterialCostBaseNum()
|
||||
|
||||
num = num + (DataManager.RunesData:getMaterialCostAddNum() * self:getAttrLockCount())
|
||||
|
||||
return num
|
||||
end
|
||||
|
||||
-- 获取格子的符文属性
|
||||
function RunesEntity:getGridAttr(index)
|
||||
if self.grids[index] then
|
||||
local cfg = ConfigManager:getConfig("runes_sub")[self:getGridQuality(index)]
|
||||
local attr = cfg["attr_"..self:getGridAttrIndex(index)]
|
||||
if attr then
|
||||
return attr[self:getHeroEntity():getMatchType()]
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 获取格子属性下标
|
||||
function RunesEntity:getGridAttrIndex(index)
|
||||
if not self:isAttrLock(index) and ModuleManager.RunesManager:isInAutoQuenching() then
|
||||
return DataManager.RunesData:getRandomGrids()[index].attr
|
||||
end
|
||||
|
||||
if self.grids[index] then
|
||||
return self.grids[index].attr
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
-- 获取格子的品质
|
||||
function RunesEntity:getGridQuality(index)
|
||||
if not self:isAttrLock(index) and ModuleManager.RunesManager:isInAutoQuenching() then
|
||||
return DataManager.RunesData:getRandomGrids()[index].quality
|
||||
end
|
||||
|
||||
if self.grids[index] then
|
||||
return self.grids[index].quality
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 获取格子的套装
|
||||
function RunesEntity:getGridSuit(index)
|
||||
if not self:isAttrLock(index) and ModuleManager.RunesManager:isInAutoQuenching() then
|
||||
return DataManager.RunesData:getRandomGrids()[index].suit
|
||||
end
|
||||
|
||||
if self.grids[index] then
|
||||
return self.grids[index].suit
|
||||
end
|
||||
|
||||
-- Logger.logError("英雄".. self.heroId .. "未获取到格子的符文数据:"..tostring(index))
|
||||
return nil
|
||||
end
|
||||
|
||||
-- 获取套装等级,2件套是lv1,4件套是lv2,没有就是lv0
|
||||
function RunesEntity:getSuitLevel(index)
|
||||
local data = table.find(self:getSuitIds(), function(value) return value.id == index end)
|
||||
local count = data and data.count or 0
|
||||
|
||||
if count and count >= 4 then
|
||||
return 2
|
||||
end
|
||||
if count and count >= 2 then
|
||||
return 1
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
-- 获取已有的套装id map
|
||||
function RunesEntity:getSuitIds()
|
||||
local typeCount = {}
|
||||
for i = 1, GConst.RunesConst.MAX_ATTR_GRID_COUNT do
|
||||
local t = self:getGridSuit(i)
|
||||
if t then
|
||||
local temp = table.find(typeCount, function(value) return value.id == t end)
|
||||
if temp then
|
||||
temp.count = temp.count + 1
|
||||
else
|
||||
table.insert(typeCount, {id = t, count = 1})
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(typeCount, function(a, b)
|
||||
return a.count > b.count
|
||||
end)
|
||||
|
||||
return typeCount
|
||||
end
|
||||
|
||||
-- 属性相关接口start------------------------------------------------------------------------------------
|
||||
|
||||
-- 获取所有属性加成,未经过计算加成
|
||||
function RunesEntity:getAllAttr()
|
||||
if not DataManager.RunesData:isOpen() then
|
||||
return nil
|
||||
end
|
||||
|
||||
local all = {}
|
||||
local func = function(attr)
|
||||
if attr == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
local temp = table.find(all, function(value)
|
||||
return value.type == attr.type
|
||||
end)
|
||||
|
||||
if temp then
|
||||
temp.num = temp.num + attr.num
|
||||
else
|
||||
table.insert(all, {type = attr.type, num = attr.num})
|
||||
end
|
||||
end
|
||||
|
||||
-- 格子属性
|
||||
for i = 1, GConst.RunesConst.MAX_ATTR_GRID_COUNT do
|
||||
func(self:getGridAttr(i))
|
||||
end
|
||||
-- 套装属性
|
||||
local pos = self:getHeroEntity():getMatchType()
|
||||
for idx, data in pairs(self:getSuitIds()) do
|
||||
func(DataManager.RunesData:getSuitAttr(data.id, pos, self:getSuitLevel(data.id)))
|
||||
end
|
||||
|
||||
return all
|
||||
end
|
||||
|
||||
-- 是否拥有某属性
|
||||
function RunesEntity:hasAttr(attrType)
|
||||
return self:getAttrValue(attrType) > 0
|
||||
end
|
||||
|
||||
-- 获取属性 , isBase是否是基础配置的属性
|
||||
function RunesEntity:getAttrValue(attrType, isBase)
|
||||
if type(attrType) ~= "string" then
|
||||
Logger.logError("获取符文属性传入格式错误")
|
||||
return 0
|
||||
end
|
||||
|
||||
local result
|
||||
if not isBase and attrType == GConst.MATCH_HP_FIX_NAME[self:getHeroEntity():getMatchType()] then
|
||||
result = self:getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getHeroEntity():getMatchType()], true)
|
||||
result = result + self:getHeroEntity():getTotalBaseHp() * self:getAttrValue(GConst.MATCH_HP_ADD_NAME[self:getHeroEntity():getMatchType()]) // DEFAULT_FACTOR
|
||||
return result
|
||||
elseif not isBase and attrType == GConst.MATCH_ATTACK_NAME[self:getHeroEntity():getMatchType()] then
|
||||
result = self:getAttrValue(GConst.MATCH_ATTACK_NAME[self:getHeroEntity():getMatchType()], true)
|
||||
result = result + self:getHeroEntity():getTotalBaseAtk() * self:getAttrValue(GConst.MATCH_ATTACK_ADD_NAME[self:getHeroEntity():getMatchType()]) // DEFAULT_FACTOR
|
||||
return result
|
||||
elseif not isBase and (attrType == GConst.MATCH_NORMAL_HURTP_NAME[self:getHeroEntity():getMatchType()] or attrType == GConst.MATCH_SKILL_HURTP_NAME[self:getHeroEntity():getMatchType()]) then
|
||||
result = self:getAttrValue(attrType, true)
|
||||
result = result + self:getAttrValue(GConst.MATCH_ALL_HURTP_NAME[self:getHeroEntity():getMatchType()], true)
|
||||
return result
|
||||
else
|
||||
local all = self:getAllAttr()
|
||||
if all == nil then
|
||||
return 0
|
||||
end
|
||||
result = table.find(all, function(value)
|
||||
return attrType == value.type
|
||||
end)
|
||||
end
|
||||
|
||||
return result and result.num or 0
|
||||
end
|
||||
|
||||
-- 属性相关接口end------------------------------------------------------------------------------------
|
||||
|
||||
return RunesEntity
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22f546c66a8d67842b8befee0e17a707
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
Loading…
x
Reference in New Issue
Block a user