2021-04-21 13:12:04 +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 ( )
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New ( )
2020-05-09 13:31:21 +08:00
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 " )
2021-03-30 16:36:00 +08:00
this.RecallBtn = Util.GetGameObject ( this.gameObject , " RecallBtn " ) --归元按钮
2021-04-21 13:12:04 +08:00
this.RecallBtn : GetComponent ( " Image " ) . sprite = this.spLoader : LoadSprite ( " r_fabao_guiyuan_zh " )
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 " )
2022-08-30 15:55:37 +08:00
this.coreText1 = Util.GetGameObject ( this.core , " Mask1/Text " ) : GetComponent ( " Text " )
2020-05-09 13:31:21 +08:00
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 ( )
2022-08-31 11:18:55 +08:00
-- if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
-- PopupTipPanel.ShowTip(Language[12184])
-- return
-- end
2020-05-09 13:31:21 +08:00
if curHeroData.talismanList < maxLv then
UIManager.OpenPanel ( UIName.TalismanInfoPanel , curHeroData , heroListData )
end
end )
2021-03-30 16:36:00 +08:00
--进阶按钮
Util.AddClick ( this.RecallBtn , function ( )
2022-08-31 14:21:28 +08:00
-- if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
-- PopupTipPanel.ShowTip(Language[12184])
-- return
-- end
2021-03-30 16:36:00 +08:00
if curHeroData.talismanList and curHeroData.talismanList <= 1 then
2021-04-01 18:36:34 +08:00
PopupTipPanel.ShowTip ( Language [ 12265 ] )
2021-03-30 16:36:00 +08:00
return
end
local selectHero = { }
selectHero [ curHeroData.dynamicId ] = curHeroData
UIManager.OpenPanel ( UIName.GeneralPopup , GENERAL_POPUP_TYPE.TalismanResolve ,
HeroManager.GetHeroReturnItems ( selectHero , GENERAL_POPUP_TYPE.TalismanResolve ) , selectHero )
end )
2020-05-09 13:31:21 +08:00
end
function RoleTalismanPanelV2 : AddListener ( )
2021-03-30 16:36:00 +08:00
Game.GlobalEvent : AddEvent ( GameEvent.Role . UpdateTalismanInfoPanel , this.RefrehsHeroAndTalisman )
2020-05-09 13:31:21 +08:00
end
function RoleTalismanPanelV2 : RemoveListener ( )
2021-03-30 16:36:00 +08:00
Game.GlobalEvent : RemoveEvent ( GameEvent.Role . UpdateTalismanInfoPanel , this.RefrehsHeroAndTalisman )
2020-05-09 13:31:21 +08:00
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 ( )
2021-04-21 13:12:04 +08:00
this.spLoader : Destroy ( )
2020-05-09 13:31:21 +08:00
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))
2022-08-31 14:21:28 +08:00
--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 ) )
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 ( )
2022-08-30 18:12:25 +08:00
maxLv = tonumber ( ConfigManager.GetConfigData ( ConfigName.SpecialConfig , 156 ) . Value )
2020-05-09 13:31:21 +08:00
--获取当前法宝等级
curLv = HeroManager.GetTalismanLv ( curHeroData.dynamicId )
--当前法宝数据
curTalismanConFig = ConfigManager.GetConfigDataByDoubleKey ( ConfigName.EquipTalismana , " TalismanaId " , data [ 2 ] , " Level " , curLv )
2020-12-18 16:37:56 +08:00
--判断共鸣状态 置灰按钮
2022-08-31 15:53:27 +08:00
-- if HarmonyManager.IsChangeColor(curHeroData.dynamicId) then
-- Util.SetGray(this.advanceBtn,true)
-- else
-- Util.SetGray(this.advanceBtn,false)
-- end
2020-12-17 10:41:00 +08:00
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
2021-04-21 13:12:04 +08:00
this.heroIcon . sprite = this.spLoader : 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 ) --法宝战力
2021-04-21 13:12:04 +08:00
this.talismanIcon . sprite = this.spLoader : LoadSprite ( GetResourcePath ( itemConfig [ data [ 2 ] ] . ResourceID ) )
this.talismanImage : GetComponent ( " Image " ) . sprite = this.spLoader : 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级解锁)
2023-08-29 17:58:24 +08:00
local skillLv_25 = ConfigManager.GetConfigDataByDoubleKey ( ConfigName.EquipTalismana , " TalismanaId " , data [ 2 ] , " Level " , 30 ) . OpenSkillRules [ 1 ]
if skillLv_25 then
2023-08-11 19:03:48 +08:00
if curLv < 30 then
2023-08-29 17:58:24 +08:00
this.coreText . text = string.format ( Language [ 11532 ] , GetLanguageStrById ( passiveSkillConfig [ skillLv_25 ] . Desc ) , 30 )
2020-05-09 13:31:21 +08:00
else
2023-08-11 19:03:48 +08:00
this.coreText . text = string.format ( " %s【%s】 " , GetLanguageStrById ( passiveSkillConfig [ t ] . Desc ) , Language [ 11533 ] )
2022-08-30 15:55:37 +08:00
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 ] )
2020-05-09 13:31:21 +08:00
end
end
--显示基础属性
for i = 1 , # curTalismanConFig.Property do
local item = proList [ i ]
2023-08-29 17:58:24 +08:00
if not item then
2020-05-09 13:31:21 +08:00
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-11-12 09:40:13 +08:00
proName.text = " <size=40> " .. GetLanguageStrById ( propertyConfig [ skillId ] . Info ) .. " + " .. curValue .. " </size> "
2021-04-21 13:12:04 +08:00
proImage.sprite = this.spLoader : LoadSprite ( artResourcesConfig [ propertyConfig [ skillId ] . PropertyIcon ] . Name )
2020-05-09 13:31:21 +08:00
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
2022-08-30 18:12:25 +08:00
table.sort ( dowerData , function ( a , b ) return a.Level < b.Level end )
2020-05-09 13:31:21 +08:00
--赋值到表现
local strTable = { }
for n = 1 , # dowerData do
2022-08-30 18:12:25 +08:00
if dowerData [ n ] . Level <= maxLv then
if curLv >= dowerData [ n ] . Level then --如果已激活 显示绿色
2023-08-29 17:58:24 +08:00
strTable [ n ] = string.format ( Language [ 11534 ] , dowerData [ n ] . Level , GetLanguageStrById ( passiveSkillConfig [ dowerData [ n ] . OpenSkillRules [ 1 ] ] . Desc ) , " \n " )
2022-08-30 18:12:25 +08:00
else --否则就正常显示
2023-08-29 17:58:24 +08:00
strTable [ n ] = string.format ( Language [ 11535 ] , dowerData [ n ] . Level , GetLanguageStrById ( passiveSkillConfig [ dowerData [ n ] . OpenSkillRules [ 1 ] ] . Desc ) , " \n " )
2022-08-30 18:12:25 +08:00
end
2023-08-29 17:58:24 +08:00
if dowerData [ n ] . Level == 30 or dowerData [ n ] . Level == 50 then --特性显示
2022-08-30 18:12:25 +08:00
strTable [ n ] = string.gsub ( strTable [ n ] , " · " , " " )
local str = Language [ 11536 ] .. strTable [ n ]
strTable [ n ] = string.gsub ( str , " " , " " ) --unity text中的单词过长 避免自动添加空格并换行 将那个空格替换
end
2020-05-09 13:31:21 +08:00
end
end
local str = string.sub ( table.concat ( strTable ) , 1 , - 2 ) --将表里字符串拼接 --去除最后\n
2023-08-29 17:58:24 +08:00
LogError ( " str===== " .. str )
2020-05-09 13:31:21 +08:00
this.dowerText . text = str
end
2021-03-30 16:36:00 +08:00
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 ( ) --刷新界面方法
2021-03-30 20:20:42 +08:00
FormationManager.UserPowerChanged ( )
2021-03-30 16:36:00 +08:00
end
2020-05-09 13:31:21 +08:00
return RoleTalismanPanelV2