2020-08-25 15:46:38 +08:00
|
|
|
|
----- 法宝面板 -----
|
2020-05-09 13:31:21 +08:00
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
RoleTalismanPanelV2 = Inherit(BasePanel)
|
|
|
|
|
local this=RoleTalismanPanelV2
|
|
|
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
|
local propertyConfig=ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
|
|
|
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
|
|
|
|
|
local artResourcesConfig=ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
|
|
|
|
|
|
local index
|
|
|
|
|
local curHeroData --当前英雄数据
|
|
|
|
|
local heroListData = {}--全部英雄数据
|
|
|
|
|
|
|
|
|
|
local curTalismanConFig --当前法宝表数据
|
|
|
|
|
local nextTalismanConFig --EquipTalismana下一等级表数据
|
|
|
|
|
|
|
|
|
|
local maxLv=0 --法宝最大进阶等级
|
|
|
|
|
local curLv=0 --当前法宝等级
|
|
|
|
|
local orginLayer
|
|
|
|
|
--属性容器
|
|
|
|
|
local proList = {}
|
2020-08-31 19:47:57 +08:00
|
|
|
|
local teamHero = {}
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:InitComponent()
|
|
|
|
|
orginLayer =0
|
|
|
|
|
this.effect = Util.GetGameObject(this.gameObject,"Effect")--背景特效
|
|
|
|
|
this.backBtn= Util.GetGameObject(this.gameObject, "BackBtn/Btn")
|
|
|
|
|
this.advanceBtn=Util.GetGameObject(this.gameObject,"AdvanceBtn")--进阶按钮
|
2020-08-31 19:47:57 +08:00
|
|
|
|
this.advanceBtnRedPot=Util.GetGameObject(this.gameObject,"AdvanceBtn/redPoint")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.leftBtn = Util.GetGameObject(this.gameObject, "LeftBtn")
|
|
|
|
|
this.rightBtn = Util.GetGameObject(this.gameObject, "RightBtn")
|
|
|
|
|
this.helpBtn= Util.GetGameObject(this.transform, "HelpBtn")
|
|
|
|
|
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
|
|
|
|
|
this.force = Util.GetGameObject(this.gameObject, "PowerBtn/Value"):GetComponent("Text")--战力
|
|
|
|
|
this.heroIcon=Util.GetGameObject(this.gameObject,"TalismanRoot/HeroHead/icon"):GetComponent("Image")
|
|
|
|
|
|
|
|
|
|
this.talismanImage = Util.GetGameObject(this.gameObject, "TalismanRoot/TalismanImage")
|
|
|
|
|
this.talismanIcon = Util.GetGameObject(this.gameObject, "TalismanRoot/TalismanImage/Icon"):GetComponent("Image")
|
|
|
|
|
this.talismanName = Util.GetGameObject(this.gameObject, "TalismanRoot/TalismanImage/Name/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
--滚动条
|
|
|
|
|
this.content=Util.GetGameObject(this.gameObject,"ScrollView/Viewport/Content"):GetComponent("RectTransform")
|
|
|
|
|
|
|
|
|
|
this.basics=Util.GetGameObject(this.gameObject,"ScrollView/Viewport/Content/Basics")
|
|
|
|
|
--属性预设
|
|
|
|
|
this.proPre=Util.GetGameObject(this.basics,"Root/ProPre")
|
|
|
|
|
--属性列表父物体
|
|
|
|
|
this.proRoot=Util.GetGameObject(this.basics,"Root")
|
|
|
|
|
|
|
|
|
|
this.core=Util.GetGameObject(this.gameObject,"ScrollView/Viewport/Content/Core")
|
|
|
|
|
this.coreText=Util.GetGameObject(this.core,"Mask/Text"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
this.dower=Util.GetGameObject(this.gameObject,"ScrollView/Viewport/Content/Dower")
|
|
|
|
|
this.dowerText=Util.GetGameObject(this.dower,"Mask/Text"):GetComponent("Text")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:BindEvent()
|
|
|
|
|
--返回按钮
|
|
|
|
|
Util.AddClick(this.backBtn, function()
|
|
|
|
|
local teamHero=FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL)
|
|
|
|
|
--PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
|
2020-08-26 22:15:23 +08:00
|
|
|
|
-- if RoleInfoPanel.RefreshHeroDatas then
|
|
|
|
|
-- RoleInfoPanel:RefreshHeroDatas(curHeroData,HeroManager.GetAllHeroDatas(),teamHero[curHeroData.dynamicId]~=nil)
|
|
|
|
|
-- end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end)
|
|
|
|
|
--帮助按钮
|
|
|
|
|
Util.AddClick(this.helpBtn, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.NewTalisman,this.helpPosition.x,this.helpPosition.y)
|
|
|
|
|
end)
|
|
|
|
|
--左右按钮
|
|
|
|
|
Util.AddClick(this.leftBtn, function()
|
|
|
|
|
this.LeftBtnOnClick()
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(this.rightBtn, function()
|
|
|
|
|
this.RightBtnOnClick()
|
|
|
|
|
end)
|
|
|
|
|
--进阶按钮
|
|
|
|
|
Util.AddClick(this.advanceBtn, function()
|
2021-01-08 17:29:54 +08:00
|
|
|
|
if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
|
2021-03-04 15:16:23 +08:00
|
|
|
|
PopupTipPanel.ShowTip(Language[12184])
|
2020-12-18 16:37:56 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if curHeroData.talismanList<maxLv then
|
|
|
|
|
UIManager.OpenPanel(UIName.TalismanInfoPanel,curHeroData,heroListData)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:AddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:RemoveListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:OnSortingOrderChange()
|
|
|
|
|
Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
|
|
|
|
|
orginLayer = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:OnOpen(_curHeroData,_heroListData)
|
|
|
|
|
curHeroData=_curHeroData
|
|
|
|
|
heroListData = {}
|
|
|
|
|
if _heroListData then
|
|
|
|
|
for i = 1, #_heroListData do
|
|
|
|
|
if TalismanManager.GetCurHeroIsOpenTalisman(_heroListData[i]) then
|
|
|
|
|
table.insert(heroListData,_heroListData[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
local curheroListData=HeroManager.GetAllHeroDatas()
|
|
|
|
|
for i = 1, #curheroListData do
|
|
|
|
|
if TalismanManager.GetCurHeroIsOpenTalisman(curheroListData[i]) then
|
|
|
|
|
table.insert(heroListData,curheroListData[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-08-31 19:47:57 +08:00
|
|
|
|
teamHero = FormationManager.GetAllFormationHeroId()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RoleTalismanPanelV2:OnShow()
|
|
|
|
|
for i = 1, #heroListData do
|
|
|
|
|
if curHeroData == heroListData[i] then
|
|
|
|
|
index = i
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--已激活法宝的Hero为1时 隐藏左右按钮
|
|
|
|
|
this.leftBtn.gameObject:SetActive(#heroListData>1)
|
|
|
|
|
this.rightBtn.gameObject:SetActive(#heroListData>1)
|
|
|
|
|
this.OnShowHeroAndTalisman()
|
|
|
|
|
end
|
|
|
|
|
function RoleTalismanPanelV2:OnClose()
|
|
|
|
|
end
|
|
|
|
|
function RoleTalismanPanelV2:OnDestroy()
|
|
|
|
|
proList={}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--右切换按钮点击
|
|
|
|
|
function this.RightBtnOnClick()
|
|
|
|
|
index = (index + 1 <= #heroListData and index + 1 or 1)
|
|
|
|
|
curHeroData = heroListData[index]
|
|
|
|
|
this.OnShowHeroAndTalisman()
|
|
|
|
|
end
|
|
|
|
|
--左切换按钮点击
|
|
|
|
|
function this.LeftBtnOnClick()
|
|
|
|
|
index = (index - 1 > 0 and index - 1 or #heroListData)
|
|
|
|
|
curHeroData = heroListData[index]
|
|
|
|
|
this.OnShowHeroAndTalisman()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新界面
|
|
|
|
|
function this.OnShowHeroAndTalisman()
|
2021-01-08 17:29:54 +08:00
|
|
|
|
--print(tostring(curHeroData.harmonyFaGongMing))
|
|
|
|
|
this.advanceBtnRedPot:SetActive(teamHero[curHeroData.dynamicId] and HeroManager.GetIsShowTalismanRedPoint(curHeroData) and (not HarmonyManager.IsChangeColor(curHeroData.dynamicId)))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.content:DOAnchorPosY(0, 0)
|
|
|
|
|
local data = ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroData.id).EquipTalismana--当前法宝数据 data[1]星级 data[2]法宝ID
|
|
|
|
|
--获取法宝最大等级
|
|
|
|
|
TalismanManager.GetStartAndEndStar()
|
|
|
|
|
maxLv=TalismanManager.AllTalismanEndStar[data[2]]
|
|
|
|
|
--获取当前法宝等级
|
|
|
|
|
curLv=HeroManager.GetTalismanLv(curHeroData.dynamicId)
|
|
|
|
|
--当前法宝数据
|
|
|
|
|
curTalismanConFig= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",curLv)
|
|
|
|
|
|
2020-12-18 16:37:56 +08:00
|
|
|
|
--判断共鸣状态 置灰按钮
|
2021-01-08 17:29:54 +08:00
|
|
|
|
if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
|
2020-12-18 16:37:56 +08:00
|
|
|
|
Util.SetGray(this.advanceBtn,true)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
else
|
2020-12-18 16:37:56 +08:00
|
|
|
|
Util.SetGray(this.advanceBtn,false)
|
2020-12-17 10:41:00 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
if curLv>=maxLv then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
Util.GetGameObject(this.advanceBtn,"Text"):GetComponent("Text").text=Language[11836]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2021-03-02 16:53:12 +08:00
|
|
|
|
Util.GetGameObject(this.advanceBtn,"Text"):GetComponent("Text").text=Language[11815]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-11-07 15:39:01 +08:00
|
|
|
|
this.heroIcon.sprite = Util.LoadSprite(curHeroData.icon)--英雄头像
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.heroIcon.gameObject:GetComponent("RectTransform").localScale=Vector3.one*0.72
|
|
|
|
|
this.force.text = TalismanManager.CalculateWarForceBase(curTalismanConFig,0)--法宝战力
|
|
|
|
|
this.talismanIcon.sprite = Util.LoadSprite(GetResourcePath(itemConfig[data[2]].ResourceID))
|
|
|
|
|
this.talismanImage:GetComponent("Image").sprite = Util.LoadSprite(TalismanBubble[itemConfig[data[2]].Quantity])
|
2021-01-26 17:08:39 +08:00
|
|
|
|
this.talismanName.text = string.format( "%s <color=#FE5022><size=42>+%s</size></color>",GetLanguageStrById(itemConfig[data[2]].Name),curLv)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
--显示核心特性(25级解锁)
|
|
|
|
|
local skillLv= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",25).OpenSkillRules[1]
|
|
|
|
|
if skillLv then
|
|
|
|
|
if curLv<25 then
|
2021-03-02 16:53:12 +08:00
|
|
|
|
this.coreText.text=string.format( Language[11532],GetLanguageStrById(passiveSkillConfig[skillLv].Desc),25)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
2021-03-02 16:53:12 +08:00
|
|
|
|
this.coreText.text=string.format( "%s【%s】",GetLanguageStrById(passiveSkillConfig[skillLv].Desc),Language[11533])
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--显示基础属性
|
|
|
|
|
for i=1,#curTalismanConFig.Property do
|
|
|
|
|
local item= proList[i]
|
|
|
|
|
if not item then
|
|
|
|
|
item= newObjToParent(this.proPre,this.proRoot)
|
|
|
|
|
item.name="ProPre"..i
|
|
|
|
|
proList[i]=item
|
|
|
|
|
end
|
|
|
|
|
local proName=proList[i]:GetComponent("Text")
|
|
|
|
|
local proImage=Util.GetGameObject(proList[i],"Image"):GetComponent("Image")
|
|
|
|
|
|
|
|
|
|
local skillId=curTalismanConFig.Property[i][1]
|
|
|
|
|
local curValue=curTalismanConFig.Property[i][2]
|
2021-01-26 17:08:39 +08:00
|
|
|
|
proName.text= " "..GetLanguageStrById(propertyConfig[skillId].Info).."+<size=40>"..curValue.."</size>"
|
2020-05-09 13:31:21 +08:00
|
|
|
|
proImage.sprite=Util.LoadSprite(artResourcesConfig[propertyConfig[skillId].PropertyIcon].Name)
|
|
|
|
|
Util.GetGameObject(proImage.gameObject,"Image"):GetComponent("Image"):SetNativeSize()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--显示法宝天赋
|
|
|
|
|
--筛选出符合要求的数据
|
|
|
|
|
local dowerAllData={}--当前法宝全部天赋数据(天赋可能为空)
|
|
|
|
|
dowerAllData= ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipTalismana,"TalismanaId",data[2])
|
|
|
|
|
local dowerData={}--当前法宝全部技能数据(天赋不为空)
|
|
|
|
|
for i=1,#dowerAllData do
|
|
|
|
|
if dowerAllData[i].OpenSkillRules then
|
|
|
|
|
table.insert( dowerData, dowerAllData[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.sort(dowerData, function(a,b) return a.OpenSkillRules[1]<b.OpenSkillRules[1] end)
|
|
|
|
|
|
|
|
|
|
--赋值到表现
|
|
|
|
|
local strTable={}
|
|
|
|
|
for n=1,#dowerData do
|
|
|
|
|
if curLv>=dowerData[n].Level then --如果已激活 显示绿色
|
2021-03-02 16:53:12 +08:00
|
|
|
|
strTable[n]= string.format( Language[11534], "<color=#66FF00>",GetLanguageStrById(passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc),dowerData[n].Level,"</color>\n")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else --否则就正常显示
|
2021-03-02 16:53:12 +08:00
|
|
|
|
strTable[n]=string.format( Language[11535],GetLanguageStrById(passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc),dowerData[n].Level,"\n")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
if dowerData[n].Level==25 then --特性显示
|
|
|
|
|
strTable[n]=string.gsub(strTable[n],"·","")
|
2021-03-02 16:53:12 +08:00
|
|
|
|
local str=Language[11536]..strTable[n]
|
2020-05-09 13:31:21 +08:00
|
|
|
|
strTable[n]=string.gsub(str," "," ") --unity text中的单词过长 避免自动添加空格并换行 将那个空格替换
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local str=string.sub(table.concat(strTable),1,-2)--将表里字符串拼接 --去除最后\n
|
|
|
|
|
this.dowerText.text=str
|
|
|
|
|
end
|
|
|
|
|
return RoleTalismanPanelV2
|