----- 法宝面板 ----- 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 = {} local teamHero = {} function RoleTalismanPanelV2:InitComponent() this.spLoader = SpriteLoader.New() orginLayer =0 this.effect = Util.GetGameObject(this.gameObject,"Effect")--背景特效 this.backBtn= Util.GetGameObject(this.gameObject, "BackBtn/Btn") this.advanceBtn=Util.GetGameObject(this.gameObject,"AdvanceBtn")--进阶按钮 this.advanceBtnRedPot=Util.GetGameObject(this.gameObject,"AdvanceBtn/redPoint") this.RecallBtn=Util.GetGameObject(this.gameObject,"RecallBtn")--归元按钮 this.RecallBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_fabao_guiyuan_zh") 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.coreText1=Util.GetGameObject(this.core,"Mask1/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) -- if RoleInfoPanel.RefreshHeroDatas then -- RoleInfoPanel:RefreshHeroDatas(curHeroData,HeroManager.GetAllHeroDatas(),teamHero[curHeroData.dynamicId]~=nil) -- end 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() -- if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then -- PopupTipPanel.ShowTip(Language[12184]) -- return -- end if curHeroData.talismanList1) this.rightBtn.gameObject:SetActive(#heroListData>1) this.OnShowHeroAndTalisman() end function RoleTalismanPanelV2:OnClose() end function RoleTalismanPanelV2:OnDestroy() this.spLoader:Destroy() 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() --print(tostring(curHeroData.harmonyFaGongMing)) --this.advanceBtnRedPot:SetActive(teamHero[curHeroData.dynamicId] and HeroManager.GetIsShowTalismanRedPoint(curHeroData) and (not HarmonyManager.IsChangeColor(curHeroData.dynamicId))) this.advanceBtnRedPot:SetActive(teamHero[curHeroData.dynamicId] and HeroManager.GetIsShowTalismanRedPoint(curHeroData)) this.content:DOAnchorPosY(0, 0) local data = ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroData.id).EquipTalismana--当前法宝数据 data[1]星级 data[2]法宝ID --获取法宝最大等级 TalismanManager.GetStartAndEndStar() maxLv=tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig, 156).Value) --获取当前法宝等级 curLv=HeroManager.GetTalismanLv(curHeroData.dynamicId) --当前法宝数据 curTalismanConFig= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",curLv) --判断共鸣状态 置灰按钮 -- if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then -- Util.SetGray(this.advanceBtn,true) -- else -- Util.SetGray(this.advanceBtn,false) -- end if curLv>=maxLv then Util.GetGameObject(this.advanceBtn,"Text"):GetComponent("Text").text=Language[11836] else Util.GetGameObject(this.advanceBtn,"Text"):GetComponent("Text").text=Language[11815] end this.heroIcon.sprite = this.spLoader:LoadSprite(curHeroData.icon)--英雄头像 this.heroIcon.gameObject:GetComponent("RectTransform").localScale=Vector3.one*0.72 this.force.text = TalismanManager.CalculateWarForceBase(curTalismanConFig,0)--法宝战力 this.talismanIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[data[2]].ResourceID)) this.talismanImage:GetComponent("Image").sprite = this.spLoader:LoadSprite(TalismanBubble[itemConfig[data[2]].Quantity]) this.talismanName.text = string.format( "%s +%s",GetLanguageStrById(itemConfig[data[2]].Name),curLv) --显示核心特性(25级解锁) local skillLv_25= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",30).OpenSkillRules[1] if skillLv_25 then if curLv<30 then this.coreText.text=string.format( Language[11532],GetLanguageStrById(passiveSkillConfig[skillLv_25].Desc),30) else this.coreText.text=string.format( "%s【%s】",GetLanguageStrById(passiveSkillConfig[t].Desc),Language[11533]) end end --显示核心特性(50级解锁) local skillLv_50= ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",data[2],"Level",50).OpenSkillRules[1] if skillLv_50 then if curLv<50 then this.coreText1.text=string.format( Language[11532],GetLanguageStrById(passiveSkillConfig[skillLv_50].Desc),50) else this.coreText1.text=string.format( "%s【%s】",GetLanguageStrById(passiveSkillConfig[skillLv_50].Desc),Language[11533]) 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] proName.text= " "..GetLanguageStrById(propertyConfig[skillId].Info).."+"..curValue.."" proImage.sprite=this.spLoader: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.Level=dowerData[n].Level then --如果已激活 显示绿色 strTable[n]= string.format(Language[11534], dowerData[n].Level,GetLanguageStrById(passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc),"\n") else --否则就正常显示 strTable[n]=string.format(Language[11535], dowerData[n].Level,GetLanguageStrById(passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc),"\n") end if dowerData[n].Level==30 or dowerData[n].Level==50 then --特性显示 strTable[n]=string.gsub(strTable[n],"·","") local str=Language[11536]..strTable[n] strTable[n]=string.gsub(str," "," ") --unity text中的单词过长 避免自动添加空格并换行 将那个空格替换 end end end local str=string.sub(table.concat(strTable),1,-2)--将表里字符串拼接 --去除最后\n LogError("str====="..str) this.dowerText.text=str end function this.RefrehsHeroAndTalisman() curHeroData = HeroManager.GetSingleHeroData(curHeroData.dynamicId) for i = 1, #heroListData do if curHeroData.dynamicId == heroListData[i].dynamicId then heroListData[i] = curHeroData end end this:OnShowHeroAndTalisman()--刷新界面方法 FormationManager.UserPowerChanged() end return RoleTalismanPanelV2