227 lines
11 KiB
Lua
227 lines
11 KiB
Lua
require("Base/BasePanel")
|
||
HandBookRoleInfoLayout = Inherit(BasePanel)
|
||
local this = HandBookRoleInfoLayout
|
||
local heroConFigData
|
||
|
||
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
||
local heroLevelConfig = ConfigManager.GetConfig(ConfigName.HeroLevelConfig)
|
||
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
local allAddProVal = {}
|
||
|
||
local breakId,upStarId
|
||
--初始化组件(用于子类重写)
|
||
|
||
function HandBookRoleInfoLayout:New(gameObject)
|
||
local b = {}
|
||
b.gameObject = gameObject
|
||
b.transform = gameObject.transform
|
||
setmetatable(b, { __index = HandBookRoleInfoLayout })
|
||
return b
|
||
end
|
||
|
||
function HandBookRoleInfoLayout:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
--LogGreen("self.gameObject:"..tostring(self.gameObject))
|
||
--详情
|
||
Util.GetGameObject(self.gameObject,"pro/atk/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[2].Info)
|
||
Util.GetGameObject(self.gameObject,"pro/hp/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[1].Info)
|
||
Util.GetGameObject(self.gameObject,"pro/phyDef/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[3].Info)
|
||
Util.GetGameObject(self.gameObject,"pro/magDef/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[4].Info)
|
||
|
||
self.atkPro=Util.GetGameObject(self.gameObject,"pro/atk/proValue"):GetComponent("Text")
|
||
self.hpPro=Util.GetGameObject(self.gameObject,"pro/hp/proValue"):GetComponent("Text")
|
||
self.phyDef=Util.GetGameObject(self.gameObject,"pro/phyDef/proValue"):GetComponent("Text")
|
||
self.magDef=Util.GetGameObject(self.gameObject,"pro/magDef/proValue"):GetComponent("Text")
|
||
self.allProButton=Util.GetGameObject(self.gameObject,"allProButton")
|
||
|
||
self.skillGrid=Util.GetGameObject(self.gameObject,"Panel/Skill/skill")
|
||
self.selsectSkillImage=Util.GetGameObject(self.gameObject,"selsectSkillImage")
|
||
self.talismanBtn=Util.GetGameObject(self.gameObject,"Panel/Other/TalismanBtn")
|
||
self.talismanIcon=Util.GetGameObject(self.gameObject,"Panel/Other/TalismanBtn/Icon"):GetComponent("Image")
|
||
|
||
self.talentBtn=Util.GetGameObject(self.gameObject,"Panel/Other/talentBtn")
|
||
self.talentProgress=Util.GetGameObject(self.gameObject,"Panel/Other/talentBtn/progress"):GetComponent("Text")
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function HandBookRoleInfoLayout:BindEvent()
|
||
Util.AddClick(self.allProButton, function()
|
||
UIManager.OpenPanel(UIName.RoleProInfoPopup,allAddProVal,heroConFigData,false,nil)
|
||
end)
|
||
end
|
||
|
||
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
||
function HandBookRoleInfoLayout:OnShow(sortingOrder,parent,_heroConFigData,_curStar)
|
||
self.gameObject:SetActive(true)
|
||
|
||
end
|
||
|
||
function HandBookRoleInfoLayout:SetData(sortingOrder,parent,_heroConFigData,_curStar)
|
||
self.sortingOrder = sortingOrder
|
||
heroConFigData = _heroConFigData
|
||
if _curStar and _curStar > 5 then
|
||
self:OnShowHeroData(2,_curStar)
|
||
else
|
||
self:OnShowHeroData(1,heroConFigData.Star)
|
||
end
|
||
end
|
||
|
||
|
||
--展示英雄信息 第一个参数 1初始 2 6星和10星 第三个参数 显示星级
|
||
function HandBookRoleInfoLayout:OnShowHeroData(_starType,_star)
|
||
--计算面板属性
|
||
allAddProVal=self:CalculateHeroAllProValList(_starType,_star)
|
||
self.atkPro.text=allAddProVal[HeroProType.Attack]
|
||
self.hpPro.text=allAddProVal[HeroProType.Hp]
|
||
self.phyDef.text=allAddProVal[HeroProType.PhysicalDefence]
|
||
self.magDef.text=allAddProVal[HeroProType.MagicDefence]
|
||
|
||
--天赋
|
||
self.talentBtn:SetActive(heroConFigData.OpenPassiveSkillRules ~= nil)
|
||
local talentBtnImage = _star == HeroManager.awakeNextStarIndex and "r_hero_tianfu2_zh" or "r_hero_tianfu1_zh"
|
||
self.talentBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite(talentBtnImage)
|
||
local OpenPassiveSkillRules = _star == HeroManager.awakeNextStarIndex and heroConFigData.Awaken or heroConFigData.OpenPassiveSkillRules
|
||
if OpenPassiveSkillRules then
|
||
local openlists,compoundOpenNum,compoundNum = HeroManager.GetAllPassiveSkillIds(heroConFigData,breakId,upStarId)
|
||
self.talentProgress.text = #openlists - compoundOpenNum .."/"..#OpenPassiveSkillRules - compoundNum
|
||
end
|
||
|
||
--技能点击特殊处理
|
||
self.selsectSkillImage:SetActive(false)
|
||
self.skillGrid:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1
|
||
local triggerCallBack
|
||
local skillList = HeroManager.GetCurHeroSidAndCurStarAllSkillDatas(heroConFigData.Id,_star)
|
||
for i = 1, self.skillGrid.transform.childCount do
|
||
self.skillGrid.transform:GetChild(i-1).gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #skillList do
|
||
if skillList[i] and skillList[i].skillConfig and GetLanguageStrById(skillList[i].skillConfig.Name) then
|
||
local go = self.skillGrid.transform:GetChild(i-1).gameObject
|
||
go:SetActive(true)
|
||
Util.GetGameObject(go.transform,"s"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(skillList[i].skillConfig.Icon))
|
||
if GetCurLanguage() ~= 0 and LengthString(GetLanguageStrById(skillList[i].skillConfig.Name)) > 10 then
|
||
Util.GetGameObject(go.transform,"s/Text"):GetComponent("Text").text = SubString(GetLanguageStrById(skillList[i].skillConfig.Name),10).."..."
|
||
else
|
||
Util.GetGameObject(go.transform,"s/Text"):GetComponent("Text").text=GetLanguageStrById(skillList[i].skillConfig.Name)--Language[10453].. 1(skillList[i].skillConfig.Id % 10)
|
||
end
|
||
Util.GetGameObject(go.transform,"SkillTypeImage"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetSkillType(skillList[i]))
|
||
Util.AddOnceClick(Util.GetGameObject(go.transform,"s"), function()
|
||
if Game.GlobalEvent:HasEvent(GameEvent.UI.OnClose, triggerCallBack) then
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
|
||
end
|
||
self.selsectSkillImage:SetActive(true)
|
||
self.selsectSkillImage.transform.position=Util.GetGameObject(go.transform,"s").transform.position
|
||
local skillData = {}
|
||
skillData.skillConfig = skillList[i].skillConfig
|
||
local maxLv= HeroManager.GetHeroSkillMaxLevel(heroConFigData.Id,skillData.skillConfig.Type)
|
||
local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,1,10,maxLv,i)
|
||
self.skillGrid:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1
|
||
triggerCallBack = function (panelType, p)
|
||
if panelType == UIName.SkillInfoPopup and panel == p then --监听到SkillInfoPopup关闭,把层级设回去
|
||
self.skillGrid:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
|
||
self.selsectSkillImage:SetActive(false)
|
||
end
|
||
end
|
||
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack)
|
||
end)
|
||
end
|
||
end
|
||
--法宝
|
||
self.talismanBtn.gameObject:SetActive(heroConFigData.EquipTalismana~=nil)
|
||
if heroConFigData.EquipTalismana~=nil then
|
||
self.talismanIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[heroConFigData.EquipTalismana[2]].ResourceID))
|
||
end
|
||
|
||
--法宝
|
||
Util.AddOnceClick(self.talismanBtn.gameObject,function()
|
||
if _starType == 1 then
|
||
UIManager.OpenPanel(UIName.TalismanInfoPopup,heroConFigData,1,1)
|
||
else
|
||
UIManager.OpenPanel(UIName.TalismanInfoPopup,heroConFigData,1,75)
|
||
end
|
||
end)
|
||
end
|
||
|
||
--计算英雄属性 1 初始 2 指定星级 _starNum星级变化
|
||
function HandBookRoleInfoLayout:CalculateHeroAllProValList(_starType,_starNum)
|
||
local allAddProVal = {}
|
||
for i, v in ConfigPairs(propertyConfig) do
|
||
allAddProVal[i] = 0
|
||
end
|
||
local heroRankupConfig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.HeroRankupConfig, "Star", heroConFigData.Star, "OpenStar", _starNum)
|
||
local curLvNum=1
|
||
breakId = 0
|
||
upStarId = 0
|
||
if _starType == 2 then
|
||
--等级
|
||
curLvNum = heroRankupConfig.OpenLevel
|
||
--解锁天赋
|
||
for i, v in ConfigPairs(ConfigManager.GetConfig(ConfigName.HeroRankupConfig)) do
|
||
if v.OpenStar == _starNum and v.Star==heroConFigData.Star then
|
||
if v.Type == 1 then
|
||
breakId = v.Id
|
||
end
|
||
if v.Type == 2 then
|
||
upStarId = v.Id
|
||
end
|
||
end
|
||
end
|
||
if breakId==0 then
|
||
breakId=6
|
||
end
|
||
end
|
||
|
||
|
||
local allOpenPassiveSkillIds = HeroManager.GetAllPassiveSkillIds(heroConFigData, breakId, upStarId)
|
||
--单体加成 --单体等级限制加成 --团体加成 --减乘
|
||
local singleHeroProVal, lvProVal, allHeroProVal, specialProVal =
|
||
HeroManager.CalculatePassiveSkillsValList(WarPowerType.Hero, allOpenPassiveSkillIds)
|
||
|
||
HeroManager.DoubleTableCompound(allAddProVal, singleHeroProVal)
|
||
HeroManager.DoubleTableCompound(allAddProVal, lvProVal)
|
||
HeroManager.DoubleTableCompound(allAddProVal, allHeroProVal)
|
||
for k, v in pairs(allAddProVal) do
|
||
allAddProVal[k] = allAddProVal[k] / 100
|
||
end
|
||
allAddProVal[HeroProType.Attack]=HeroManager.CalculateProVal(heroConFigData.Attack, curLvNum, breakId,upStarId,HeroProType.Attack) + allAddProVal[HeroProType.Attack]
|
||
allAddProVal[HeroProType.Hp]=HeroManager.CalculateProVal(heroConFigData.Hp, curLvNum, breakId,upStarId,HeroProType.Hp) + allAddProVal[HeroProType.Hp]
|
||
allAddProVal[HeroProType.PhysicalDefence]=HeroManager.CalculateProVal(heroConFigData.PhysicalDefence, curLvNum, breakId,upStarId,HeroProType.PhysicalDefence) + allAddProVal[HeroProType.PhysicalDefence]
|
||
allAddProVal[HeroProType.MagicDefence]=HeroManager.CalculateProVal(heroConFigData.MagicDefence, curLvNum, breakId,upStarId,HeroProType.MagicDefence) + allAddProVal[HeroProType.MagicDefence]
|
||
--allAddProVal[HeroProType.Speed]= math.floor(((curSpeedFormulaData[1] * math.pow(breakId, 3) + curSpeedFormulaData[2] * math.pow(breakId, 2) + curSpeedFormulaData[3] * breakId + curSpeedFormulaData[4]) + heroConFigData.Speed * speedNum))
|
||
--for i = 1, #heroConFigData.SecondaryFactor do
|
||
-- local proId = heroConFigData.SecondaryFactor[i][1]
|
||
-- if propertyConfig[proId].Style ==2 then
|
||
-- allAddProVal[heroConFigData.SecondaryFactor[i][1]] = heroConFigData.SecondaryFactor[i][2]/10000
|
||
-- else
|
||
-- allAddProVal[heroConFigData.SecondaryFactor[i][1]] = heroConFigData.SecondaryFactor[i][2]
|
||
-- end
|
||
--end
|
||
|
||
|
||
Util.AddOnceClick(self.talentBtn,function()
|
||
UIManager.OpenPanel(UIName.RoleTalentPopup,heroConFigData,breakId,upStarId)
|
||
end)
|
||
|
||
for key, value in pairs(allAddProVal) do
|
||
allAddProVal[key] = math.floor(value)
|
||
end
|
||
return allAddProVal
|
||
end
|
||
function HandBookRoleInfoLayout:OnHide()
|
||
self.gameObject:SetActive(false)
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function HandBookRoleInfoLayout:OnClose()
|
||
|
||
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function HandBookRoleInfoLayout:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
|
||
end
|
||
|
||
return HandBookRoleInfoLayout |