miduo_client/Assets/ManagedResources/~Lua/Modules/HandBook/HandBookRoleInfoLayout.lua

473 lines
23 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 allBtns={}
local breakId,upStarId
local orginLayer=0
--初始化组件(用于子类重写)
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/bg/proPre1/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[2].Info)
Util.GetGameObject(self.gameObject,"pro/bg/proPre2/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[1].Info)
Util.GetGameObject(self.gameObject,"pro/bg/proPre3/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[3].Info)
Util.GetGameObject(self.gameObject,"pro/bg/proPre4/proName"):GetComponent("Text").text = GetLanguageStrById(propertyConfig[4].Info)
self.atkPro=Util.GetGameObject(self.gameObject,"pro/bg/proPre1/proValue"):GetComponent("Text")
self.hpPro=Util.GetGameObject(self.gameObject,"pro/bg/proPre2/proValue"):GetComponent("Text")
self.phyDef=Util.GetGameObject(self.gameObject,"pro/bg/proPre3/proValue"):GetComponent("Text")
self.magDef=Util.GetGameObject(self.gameObject,"pro/bg/proPre4/proValue"):GetComponent("Text")
self.allProButton=Util.GetGameObject(self.gameObject,"pro/allProButton")
self.skillGrid=Util.GetGameObject(self.gameObject,"skill")
self.skillGrid2=Util.GetGameObject(self.gameObject,"skill2")
self.line1=Util.GetGameObject(self.skillGrid,"line1")
self.line2=Util.GetGameObject(self.skillGrid,"line2")
self.line3=Util.GetGameObject(self.gameObject,"skillBtns/line3")
self.line4=Util.GetGameObject(self.gameObject,"skillBtns/line4")
self.selsectSkillImage=Util.GetGameObject(self.gameObject,"selsectSkillImage")
self.posBtn= Util.GetGameObject(self.gameObject,"dingwei")
self.posTxt=Util.GetGameObject(self.gameObject,"dingwei/PosInfo"):GetComponent("Text")
self.lvTxt=Util.GetGameObject(self.gameObject,"lvObj/lvTxt"):GetComponent("Text")
self.proImg=Util.GetGameObject(self.gameObject,"posImage"):GetComponent("Image")
self.proTxt=Util.GetGameObject(self.gameObject,"posText2"):GetComponent("Text")
self.btnsLayer=Util.GetGameObject(self.gameObject,"skillBtns"):GetComponent("Canvas")
allBtns={}
for i = 1, 6 do
local btn=Util.GetGameObject(self.gameObject,"skillBtns/sBg"..i)
btn.gameObject:SetActive(false)
table.insert(allBtns,btn)
end
end
--绑定事件(用于子类重写)
function HandBookRoleInfoLayout:BindEvent()
Util.AddClick(self.allProButton, function()
UIManager.OpenPanel(UIName.RoleProInfoPopup,allAddProVal,heroConFigData,false,nil)
end)
end
local curStar
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function HandBookRoleInfoLayout:OnShow(sortingOrder,parent,_heroConFigData,_curStar)
self.gameObject:SetActive(true)
end
function HandBookRoleInfoLayout:SetData(sortingOrder,parent,_heroConFigData,_curStar,_lv)
self.sortingOrder = sortingOrder
orginLayer=self.sortingOrder+2
self.btnsLayer.sortingOrder=orginLayer
heroConFigData = _heroConFigData
curStar=_curStar
if _curStar and _curStar > 5 then
self:OnShowHeroData(2,_curStar,_lv)
else
self:OnShowHeroData(1,heroConFigData.Star,_lv)
end
end
local CurrOpenPanel=nil
local currPanelName=0
--展示英雄信息 第一个参数 1初始 2 6星和10星 第三个参数 显示星级
function HandBookRoleInfoLayout:OnShowHeroData(_starType,star,_lv)
local lv=0
local rankUpConfig=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.HeroRankupConfig,"Type",2,"OpenStar",star)
if rankUpConfig then
lv=rankUpConfig.OpenLevel
else
if star==1 then
lv=40
elseif star==2 then
lv=50
elseif star==3 then
lv=60
elseif star==4 then
lv=80
else
lv=1
end
end
--计算面板属性
allAddProVal=self:CalculateHeroAllProValList(_starType,star,lv)
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.lvTxt.text= " "..lv
self.posTxt.text=star >= HeroManager.awakeNextStarIndex and GetLanguageStrById(heroConFigData.HeroLocationDesc4) or GetLanguageStrById(heroConFigData.HeroLocationDesc1)
self.proImg.sprite=this.spLoader:LoadSprite(GetHeroPosStr(heroConFigData.Profession))
self.proTxt.text=GetLanguageStrById(heroConFigData.HeroLocation)
--技能点击特殊处理
self.posTxt.gameObject:SetActive(heroConFigData.ShowHeroLocation==1)
self.posBtn.gameObject:SetActive(heroConFigData.ShowHeroLocation==1)
self.selsectSkillImage:SetActive(false)
-- self.skillGrid:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1
local triggerCallBack
local skillList = HeroManager.GetCurHeroSkillDatasAndEquip(heroConFigData.Id,star)
--local awakeSkillList=HeroManager.GetCurHeroAllAwakeSkillDatas(heroConFigData.Id,star)
for i = 1, self.skillGrid.transform.childCount do
self.skillGrid.transform:GetChild(i-1).gameObject:SetActive(false)
end
for i = 1, 6 do
allBtns[i].gameObject:SetActive(false)
end
local len=#skillList
local btnCount=len
if heroConFigData.OpenPassiveSkillRules then
btnCount=btnCount+1
local passObj=Util.GetGameObject(self.skillGrid,"sBg"..len+1)--self.skillGrid.transform:GetChild(len).gameObject
passObj:SetActive(true)
allBtns[len+1].gameObject:SetActive(true)
Util.GetGameObject(passObj,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetTianFuIcon(star))
Util.GetGameObject(passObj,"frame"):SetActive(false)
local aaa=5
if star>=9 then
if star>=11 then
Util.GetGameObject(passObj,"frame"):SetActive(true)
aaa=7
else
aaa=star-3
end
end
Util.GetGameObject(passObj,"pos/icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SkillIconType[aaa])
Util.GetGameObject(passObj,"pos/icon"):GetComponent("Image"):SetNativeSize()
local OpenPassiveSkillRules = star >= HeroManager.awakeNextStarIndex and heroConFigData.Awaken or heroConFigData.OpenPassiveSkillRules
OpenPassiveSkillRules=GetPassiveByMaxStar(heroConFigData,OpenPassiveSkillRules)
local openlists,compoundOpenNum,compoundNum = HeroManager.GetAllPassiveSkillIds(heroConFigData,breakId,upStarId)
if star==11 then
Util.GetGameObject(passObj,"Text"):GetComponent("Text").text = #openlists - compoundOpenNum .."/"..10
else
Util.GetGameObject(passObj,"Text"):GetComponent("Text").text = #openlists - compoundOpenNum .."/"..#OpenPassiveSkillRules - compoundNum
end
Util.AddOnceClick(allBtns[len+1],function()
UIManager.ClosePanel(currPanelName)
if star==11 then
CurrOpenPanel=UIManager.OpenPanel(UIName.RoleAwakeTalentPopup,heroConFigData)
currPanelName=UIName.RoleAwakeTalentPopup
else
CurrOpenPanel=UIManager.OpenPanel(UIName.RoleTalentPopup,heroConFigData,breakId,upStarId)
currPanelName=UIName.RoleTalentPopup
end
self.selsectSkillImage:SetActive(true)
self.selsectSkillImage.transform.position=Util.GetGameObject(self.skillGrid,"sBg"..len+1 .."/s").transform.position
self.selsectSkillImage.transform:SetParent(Util.GetGameObject(self.skillGrid,"sBg"..len+1 .."/s").transform)
self:SetBtnsLayer()
end)
end
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.shenhun) and heroConFigData.IsSoulOpen == 1 and star > 10 then
btnCount=btnCount+1
local passObj=Util.GetGameObject(self.skillGrid,"sBg"..len+2)--self.skillGrid.transform:GetChild(len+1).gameObject
passObj:SetActive(true)
allBtns[len+2].gameObject:SetActive(true)
Util.GetGameObject(passObj,"s"):GetComponent("Image").sprite=this.spLoader:LoadSprite("r_tongyong_shenhun_icon")
Util.GetGameObject(passObj,"skillName"):SetActive(false)
Util.GetGameObject(passObj,"pos/icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SkillIconType[9])
Util.GetGameObject(passObj,"pos/icon"):GetComponent("Image"):SetNativeSize()
Util.AddOnceClick(allBtns[len+2],function()
UIManager.ClosePanel(currPanelName)
CurrOpenPanel=UIManager.OpenPanel(UIName.RoleGodSoulLayout,heroConFigData,star)
self.selsectSkillImage:SetActive(true)
self.selsectSkillImage.transform.position=Util.GetGameObject(self.skillGrid,"sBg"..len+2 .."/s").transform.position
self.selsectSkillImage.transform:SetParent(Util.GetGameObject(self.skillGrid,"sBg"..len+2 .."/s").transform)
currPanelName=UIName.RoleGodSoulLayout
self:SetBtnsLayer()
end)
end
for i = 1, len do
--and GetLanguageStrById(skillList[i].skillConfig.Name)
if skillList[i] and skillList[i].skillConfig then
local go = Util.GetGameObject(self.skillGrid,"sBg"..i) --self.skillGrid.transform:GetChild(i-1).gameObject
go:SetActive(true)
allBtns[i].gameObject:SetActive(true)
--local line=Util.GetGameObject(go.transform,"line")
--line:SetActive(false)
--local bg=Util.GetGameObject(go.transform,"Image"):GetComponent("Image")
Util.GetGameObject(go.transform,"frame"):SetActive(false)
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(skillList[i].skillConfig.Icon))
--Util.GetGameObject(go.transform,"skillName"):SetActive(false)
local index=i
if index==3 then
Util.GetGameObject(go.transform,"pos/icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SkillIconType[4])
else
Util.GetGameObject(go.transform,"pos/icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetSkillType(skillList[i]))
end
Util.GetGameObject(go.transform,"pos/icon"):GetComponent("Image"):SetNativeSize()
local di=Util.GetGameObject(go.transform,"pro"):GetComponent("Image")
local diTxt=Util.GetGameObject(go.transform,"pro/Text"):GetComponent("Text")
if skillList[i].skillConfig.Skilltips and skillList[i].skillConfig.Skilltips > 0 then
if skillList[i].skillConfig.Skilltips == 6 then
di.sprite=this.spLoader:LoadSprite("r_hero_lvdi")--被动技
else
di.sprite=this.spLoader:LoadSprite("r_hero_hongdi")--被动技
end
di.gameObject:SetActive(true)
di:SetNativeSize()
diTxt.text=SkillProType[skillList[i].skillConfig.Skilltips]
else
di.gameObject:SetActive(false)
end
Util.AddOnceClick(allBtns[i], function()
local skillData = {}
skillData.skillConfig = skillList[i].skillConfig
local maxLv= HeroManager.GetHeroSkillMaxLevel(heroConFigData.Id,skillData.skillConfig.Type)
if index~=3 then
if Game.GlobalEvent:HasEvent(GameEvent.UI.OnClose, triggerCallBack) then
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
end
-- if currPanelName~= UIName.SkillInfoPopup then
UIManager.ClosePanel(currPanelName)
-- end
self.selsectSkillImage.transform.position=Util.GetGameObject(go.transform,"s").transform.position
self.selsectSkillImage.transform:SetParent(Util.GetGameObject(go.transform,"s").transform)
local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,1,10,maxLv,i)
self.selsectSkillImage:SetActive(true)
CurrOpenPanel=panel
currPanelName=UIName.SkillInfoPopup
self:SetBtnsLayer()
--self.skillGrid:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1
else
UIManager.ClosePanel(currPanelName)
currPanelName=UIName.TalismanInfoPopup
CurrOpenPanel=UIManager.OpenPanel(UIName.TalismanInfoPopup,heroConFigData,1,1)
self.selsectSkillImage.transform.position=Util.GetGameObject(go.transform,"s").transform.position
self.selsectSkillImage.transform:SetParent(Util.GetGameObject(go.transform,"s").transform)
self.selsectSkillImage:SetActive(true)
self:SetBtnsLayer()
end
end)
triggerCallBack = function (panelType, p)
if panelType == UIName.SkillInfoPopup or panelType==currPanelName then --监听到SkillInfoPopup关闭把层级设回去
--self.skillGrid:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1
self.btnsLayer.sortingOrder=orginLayer+2
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
--self.selsectSkillImage:SetActive(false)
end
end
self:SetBtnsLayer()
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack)
end
end
if btnCount>2 then
self.line1:SetActive(true)
self.line3:SetActive(true)
else
self.line1:SetActive(false)
self.line3:SetActive(false)
end
if btnCount>4 then
self.line2:SetActive(true)
self.line4:SetActive(true)
else
self.line2:SetActive(false)
self.line4:SetActive(false)
end
Util.AddClick(self.posBtn, function()
UIManager.OpenPanel(UIName.RolePosInfoPopup,heroConFigData,star)
end)
self:SkillInfo()
end
function HandBookRoleInfoLayout:SetBtnsLayer()
if CurrOpenPanel then
self.btnsLayer.sortingOrder=CurrOpenPanel.sortingOrder + 1
end
end
--计算英雄属性 1 初始 2 指定星级 _starNum星级变化
function HandBookRoleInfoLayout:CalculateHeroAllProValList(_starType,_starNum,curLvNum)
local allAddProVal = {}
for i, v in ConfigPairs(propertyConfig) do
allAddProVal[i] = 0
end
breakId = 0
upStarId = 0
if _starType == 2 then
--等级
--解锁天赋
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
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:SkillInfo()
self.skillGrid2:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1
local skillList = HeroManager.GetCurHeroSidAndCurStarAllSkillDatas2(heroConFigData.Id,heroConFigData.MaxRank)
local skillList2
local maxStar=heroConFigData.MaxRank
if maxStar>9 then
skillList2 = HeroManager.GetCurHeroSidAndCurStarAllSkillDatas2(heroConFigData.Id,10)
else
end
for i = 1, self.skillGrid2.transform.childCount do
self.skillGrid2.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.skillGrid2.transform:GetChild(i-1).gameObject
go:SetActive(true)
Util.GetGameObject(go.transform,"icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetResourcePath(skillList[i].skillConfig.Icon))
local typeImg=Util.GetGameObject(go.transform,"pos/icon")
typeImg:GetComponent("Image").sprite=this.spLoader:LoadSprite(GetSkillType(skillList[i]))
local sText = Util.GetGameObject(go.transform,"skillName"):GetComponent("Text")
sText.text=GetLanguageStrById(skillList[i].skillConfig.Name)
-- sText.fontSize = GetCurLanguage() ~= 2 and 30 or 25
Util.SetGray(go,skillList[i].isOpen)
if skillList[i].isOpen then
LogError("skillList[i].needStar=="..skillList[i].needStar)
if skillList[i].needStar==13 then
sText.text="飞升2解锁"
else
sText.text=NumToSimplenessFont[skillList[i].needStar].."星解锁"
end
end
local pro=Util.GetGameObject(go.transform,"pro")
local proText=Util.GetGameObject(go.transform,"pro/Text"):GetComponent("Text")
if skillList[i].skillConfig.Skilltips and skillList[i].skillConfig.Skilltips~=0 then
pro:SetActive(true)
LogError("skillList[i].skillConfig.Skilltips="..skillList[i].skillConfig.Skilltips)
proText.text=SkillProType[skillList[i].skillConfig.Skilltips]
else
pro:SetActive(false)
end
Util.AddOnceClick(go, 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,"icon").transform.position
local skillData = {}
skillData.skillConfig = skillList[i].skillConfig
skillData.isOpen=skillList[i].isOpen
skillData.needStar=skillList[i].needStar
local nextData=nil
-- if curStar<11 and i>2 then
-- nextData=skillList2[i]
-- end
local maxLv= HeroManager.GetHeroSkillMaxLevel(heroConFigData.Id,skillData.skillConfig.Type)
local panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,1,10,maxLv,i,nextData)
if skillList2 and skillList2[i] and i>2 then
nextData=skillList2[i]
nextData.isOpen=skillList2[i].isOpen
nextData.needStar=skillList2[i].needStar
--飞升技能
if i==6 then
panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,1,10,maxLv,i)
else
local training=HeroManager.GetTrainingPasivvSkill(nextData.needStar,heroConFigData.Id)
panel = UIManager.OpenPanel(UIName.SkillInfoPopup,nextData,1,10,maxLv,i,skillData,nil,nil,training)
end
else
panel = UIManager.OpenPanel(UIName.SkillInfoPopup,skillData,1,10,maxLv,i)
end
-- self.skillGrid2:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1
triggerCallBack = function (panelType, p)
if panelType == UIName.SkillInfoPopup and panel == p then --监听到SkillInfoPopup关闭把层级设回去
-- self.skillGrid2: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
end
--界面关闭时调用(用于子类重写)
function HandBookRoleInfoLayout:OnClose()
end
--界面销毁时调用(用于子类重写)
function HandBookRoleInfoLayout:OnDestroy()
this.spLoader:Destroy()
end
return HandBookRoleInfoLayout