miduo_client/Assets/ManagedResources/~Lua/Modules/RoleInfo/RoleInfoPanel.lua

719 lines
31 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
RoleInfoPanel = Inherit(BasePanel)
local this = RoleInfoPanel
2020-11-03 15:17:48 +08:00
local RoleSkinPanel = require("Modules/RoleInfo/RoleSkinPanel")
local RoleInfoLayout = require("Modules/RoleInfo/RoleInfoLayout")
local RoleUpStarLayout = require("Modules/RoleInfo/RoleUpStarLayout")
2020-11-09 15:04:48 +08:00
local RoleAwakeLayout = require("Modules/RoleInfo/RoleAwakeLayout")
2020-11-03 15:17:48 +08:00
local RoleStoryLayout = require("Modules/RoleInfo/RoleStoryLayout")
local _CurPageIndex = 1
local orginLayer
local tabsList = {}
local tabs = {
2021-03-02 16:53:12 +08:00
[1] = {default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",title = Language[11093],rpType = -1,
2020-11-03 15:17:48 +08:00
},
2021-03-02 16:53:12 +08:00
[2] = {default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",title = Language[11815],rpType = -1,
2020-11-03 15:17:48 +08:00
},
2021-03-02 16:53:12 +08:00
[3] = {default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",title = Language[10373],rpType = -1,
2020-11-03 15:17:48 +08:00
},
2021-03-02 16:53:12 +08:00
[4] = {default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",title = Language[11095],rpType = -1,
2020-11-09 15:04:48 +08:00
},
2021-03-02 16:53:12 +08:00
[5] = {default = "r_hero_xuanze_002", lock = "r_hero_xuanze_002", select = "r_hero_xuanze_001",title = Language[11816],rpType = -1,
2020-11-03 15:17:48 +08:00
},
}
2020-05-09 13:31:21 +08:00
local curHeroData--当前英雄信息
local leftHeroData--左边预加载英雄信息
local rightHeroData--右边预加载英雄信息
local curHeroPosition --
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
local heroDatas--所有英雄list信息
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local heroRankupConfig = ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2020-11-03 15:17:48 +08:00
local heroSkinConfig = ConfigManager.GetConfig(ConfigName.HeroSkin)
2020-05-09 13:31:21 +08:00
local index--当前英雄在 英雄列表中的索引
local soulPrintData={}--魂印数据
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
local isUpZhen = false--当前英雄是否上阵
local isClickLeftOrRightBtn = true--点击左右按钮切换英雄播放动画状态
local teamHero = {}--主线编队成员信息
local talismanIsOpen = false--法宝是否开启
local soulPrintIsOpen = false--魂印是否开启
--初始化组件(用于子类重写)
function RoleInfoPanel:InitComponent()
2020-11-03 15:17:48 +08:00
orginLayer = 0
this.BtnBack = Util.GetGameObject(self.transform, "btnBack")
2020-08-25 15:11:32 +08:00
this.bgImageList = {}
2020-08-24 23:38:17 +08:00
for i = 1, 4 do
2020-08-25 15:11:32 +08:00
this.bgImageList[i] = Util.GetGameObject(self.transform, "bg/di ("..i..")")
2020-08-24 23:38:17 +08:00
end
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
this.optionUp=Util.GetGameObject(self.gameObject,"optionUp")--上部按钮组
this.helpBtn = Util.GetGameObject(this.optionUp, "helpBtn")
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
this.posBtn=Util.GetGameObject(this.optionUp,"posBtn")--角色定位按钮
2021-02-23 10:51:52 +08:00
this.posBtn:GetComponent("Image").sprite = Util.LoadSprite("r_hero_dingweianniu_zh")
2020-05-09 13:31:21 +08:00
this.shareBtn=Util.GetGameObject(this.optionUp,"shareBtn")--分享按钮
2020-11-03 15:17:48 +08:00
this.bg = Util.GetGameObject(self.gameObject, "bg")
screenAdapte(this.bg)
2020-05-09 13:31:21 +08:00
2020-11-03 15:17:48 +08:00
this.starGrid = Util.GetGameObject(self.transform, "rolePanel/info/sartAndLvLayout")
this.profession = Util.GetGameObject(self.transform, "rolePanel/info/nameAndPossLayout/proImage/proImage"):GetComponent("Image")
this.heroName = Util.GetGameObject(self.transform, "rolePanel/info/nameAndPossLayout/heroName"):GetComponent("Text")
this.level = Util.GetGameObject(self.transform, "rolePanel/info/sartAndLvLayout/lvText"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
2020-11-03 15:17:48 +08:00
this.rolePanelOp = Util.GetGameObject(self.transform, "rolePanel/layout")
2020-05-09 13:31:21 +08:00
--装备
this.equipBtn=Util.GetGameObject(self.transform,"option/equipBtn")
2021-02-23 10:51:52 +08:00
this.equipBtn:GetComponent("Image").sprite = Util.LoadSprite("r_hero_zhuanbeianniu_zh")
2020-05-09 13:31:21 +08:00
this.soulPrintBtn=Util.GetGameObject(self.transform,"option/soulPrintBtn")
2021-02-23 10:51:52 +08:00
this.soulPrintBtn:GetComponent("Image").sprite = Util.LoadSprite("r_hero_hunyinanniu_zh")
2020-05-09 13:31:21 +08:00
this.soulPrintBtnRedPoint=Util.GetGameObject(self.transform,"option/soulPrintBtn/redPoint")
this.equipBtnRedPoint=Util.GetGameObject(self.transform,"option/equipBtn/redPoint")
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--法宝
2020-06-08 13:57:30 +08:00
this.talismanBtn=Util.GetGameObject(self.transform,"option/talismanBtn") --该按钮控制入口显隐
this.talismanClick=Util.GetGameObject(self.transform,"option/talismanBtn/panel") --控制按钮的点击事件 置灰
2021-02-23 10:51:52 +08:00
this.talismanClick:GetComponent("Image").sprite = Util.LoadSprite("r_hero_fabaoanniu_zh")
2020-06-08 13:57:30 +08:00
this.talismanBtnRedPoint=Util.GetGameObject(self.transform,"option/talismanBtn/panel/redPoint")
this.talismanInfo=Util.GetGameObject(self.transform,"option/talismanBtn/info") --查看法宝特性按钮
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--上锁
this.lockBtn=Util.GetGameObject(this.optionUp,"lockBtn")
2020-05-09 13:31:21 +08:00
this.lockImage=Util.GetGameObject(this.lockBtn.transform,"lock")
2021-02-23 10:57:38 +08:00
this.lockImage:GetComponent("Image").sprite = Util.LoadSprite("r_tongyong_suoding_zh")
2020-05-09 13:31:21 +08:00
this.unlockImage=Util.GetGameObject(this.lockBtn.transform,"unlock")
2021-02-23 10:57:38 +08:00
this.unlockImage:GetComponent("Image").sprite = Util.LoadSprite("r_tongyong_jiesuo_zh")
2020-11-03 15:17:48 +08:00
this.talentBtn=Util.GetGameObject(self.transform,"talentBtn")
this.talentProgress=Util.GetGameObject(self.transform,"talentBtn/progress"):GetComponent("Text")
this.talentTipStr=Util.GetGameObject(self.transform,"talentBtn/tipStr"):GetComponent("Text")
this.talentTipStrGo=Util.GetGameObject(self.transform,"talentBtn/tipStr")
this.force = Util.GetGameObject(self.transform, "powerBtn/value"):GetComponent("Text")
2021-02-23 10:51:52 +08:00
Util.GetGameObject(self.transform, "powerBtn"):GetComponent("Image").sprite = Util.LoadSprite("t_tongyong-zhanli_zh")
2020-11-03 15:17:48 +08:00
this.upLvEffect = Util.GetGameObject(self.transform,"powerBtn/effect")
this.posBgImage=Util.GetGameObject(self.transform,"powerBtn/Pos"):GetComponent("Image")
this.posImage=Util.GetGameObject(self.transform,"powerBtn/Pos/PosImage"):GetComponent("Image")
this.posText=Util.GetGameObject(self.transform,"powerBtn/Pos/PosText"):GetComponent("Text")
this.curObj= Util.GetGameObject(self.transform, "curObj")
this.leftObj= Util.GetGameObject(self.transform, "leftObj")
this.rightObj= Util.GetGameObject(self.transform, "rightObj")
2020-05-09 13:31:21 +08:00
2020-11-03 15:17:48 +08:00
this.PageList = {
[1] = RoleInfoLayout:InitComponent(Util.GetGameObject(self.transform, "rolePanel/layout/roleInfoLayout")),
[2] = RoleUpStarLayout:InitComponent(Util.GetGameObject(self.transform, "rolePanel/layout/roleUpStarLayout")),
2020-11-09 15:04:48 +08:00
[3] = RoleAwakeLayout:InitComponent(Util.GetGameObject(self.transform, "rolePanel/layout/roleAwakelayout")),
[4] = RoleStoryLayout:InitComponent(Util.GetGameObject(self.transform, "rolePanel/layout/roleStoryLayout")),
[5] = RoleSkinPanel:InitComponent(Util.GetGameObject(self.transform, "rolePanel/layout/roleSkinLayout")),
2020-11-03 15:17:48 +08:00
}
this.dragView = SubUIManager.Open(SubUIConfig.DragView, self.gameObject.transform)
this.dragView.transform:SetSiblingIndex(1)
2020-05-09 13:31:21 +08:00
this.trigger=Util.GetEventTriggerListener(self.dragView.gameObject)
this.trigger.onBeginDrag = this.trigger.onBeginDrag + this.OnBeginDrag
this.trigger.onDrag = this.trigger.onDrag + this.OnDrag
this.trigger.onEndDrag = this.trigger.onEndDrag + this.OnEndDrag
2020-11-03 15:17:48 +08:00
this.btnList = Util.GetGameObject(self.transform,"rolePanel/btnList")
this.btnPre = Util.GetGameObject(self.transform,"rolePanel/btnInfo")
this.selectBtn = Util.GetGameObject(self.transform, "rolePanel/selectBtn")
this.leftBtn = Util.GetGameObject(self.transform, "leftBtn/GameObject")
this.rightBtn = Util.GetGameObject(self.transform, "rightBtn/GameObject")
-- 上部货币显示
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--绑定事件(用于子类重写)
function RoleInfoPanel:BindEvent()
2020-11-03 15:17:48 +08:00
Util.AddClick(this.BtnBack, function()
2020-05-09 13:31:21 +08:00
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--角色定位按钮
Util.AddClick(this.posBtn,function()
UIManager.OpenPanel(UIName.RolePosInfoPopup,curHeroData.heroConfig,curHeroData.star)
2020-05-09 13:31:21 +08:00
end)
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--左切换按钮
Util.AddClick(this.leftBtn, function()
this:LeftBtnOnClick()
end)
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--右切换按钮
Util.AddClick(this.rightBtn, function()
this:RightBtnOnClick()
end)
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
Util.AddClick(this.dragView.gameObject, function()
local SkeletonGraphic = this.curLiveObj:GetComponent("SkeletonGraphic")
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
end)
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--装备
Util.AddClick(this.equipBtn, function()
UIManager.OpenPanel(UIName.RoleEquipPanel,curHeroData,heroDatas,this,isUpZhen)
end)
--魂印
Util.AddClick(this.soulPrintBtn, function()
if soulPrintIsOpen then
UIManager.OpenPanel(UIName.SoulPrintPanel,curHeroData,heroDatas)
else
local EquipSignUnlock = ConfigManager.GetConfigData(ConfigName.GameSetting,1).EquipSignUnlock
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10536]..NumToSimplenessFont[EquipSignUnlock[2][2]] .. Language[11817])
2020-05-09 13:31:21 +08:00
end
end)
--法宝
2020-06-08 13:57:30 +08:00
Util.AddClick(this.talismanClick,function()
2020-05-09 13:31:21 +08:00
if talismanIsOpen then
UIManager.OpenPanel(UIName.RoleTalismanPanelV2,curHeroData,heroDatas)
else
PopupTipPanel.ShowTip(TalismanManager.GetCurHeroIsOpenTalismanTip())
end
end)
2020-06-08 13:57:30 +08:00
--查看法宝特性按钮
Util.AddClick(this.talismanInfo,function()
UIManager.OpenPanel(UIName.TalismanInfoPopup,curHeroData.heroConfig,1,1)
end)
2020-05-09 13:31:21 +08:00
--上锁
Util.AddClick(this.lockBtn,function()
2020-11-03 15:17:48 +08:00
this:HeroLockEvent()
2020-05-09 13:31:21 +08:00
end)
Util.AddClick(this.talentBtn,function()
2020-11-09 20:05:51 +08:00
UIManager.OpenPanel(UIName.RoleTalentPopup,curHeroData.heroConfig,curHeroData.breakId,curHeroData.upStarId)
2020-05-09 13:31:21 +08:00
end)
2020-11-03 15:17:48 +08:00
for i = 1, #this.PageList do
if this.PageList[i] then
this.PageList[i]:BindEvent()
end
end
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function RoleInfoPanel:AddListener()
2020-11-14 14:16:10 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Role.UpdateSkin, this.UpdateSkinShow)
2020-11-03 15:17:48 +08:00
for i = 1, #this.PageList do
if this.PageList[i] then
this.PageList[i]:AddListener()
end
end
2020-05-09 13:31:21 +08:00
end
--移除事件监听(用于子类重写)
2020-11-03 15:17:48 +08:00
function RoleInfoPanel:RemoveListener()
2020-11-14 14:16:10 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Role.UpdateSkin,this.UpdateSkinShow)
2020-11-03 15:17:48 +08:00
for i = 1, #this.PageList do
if this.PageList[i] then
this.PageList[i]:RemoveListener()
end
end
2020-05-09 13:31:21 +08:00
end
2020-11-14 14:16:10 +08:00
this.UpdateSkinShow = function()
2020-11-09 15:04:48 +08:00
if _CurPageIndex == 5 then
2020-11-14 14:16:10 +08:00
this:OnPageTabChange(_CurPageIndex)
end
end
2020-05-09 13:31:21 +08:00
--界面打开时调用(用于子类重写)
2020-11-05 16:02:49 +08:00
function RoleInfoPanel:OnOpen(_curHeroData, _heroDatas,_isUpZhen,_index)
2020-05-09 13:31:21 +08:00
curHeroData, heroDatas,isUpZhen = _curHeroData, _heroDatas,_isUpZhen
2020-11-05 16:02:49 +08:00
if _index and _index > 0 then
_CurPageIndex = _index
else
_CurPageIndex = 1
end
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
-- 打开,重新打开时回调
2020-05-09 13:31:21 +08:00
function RoleInfoPanel:OnShow()
2020-11-03 15:17:48 +08:00
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.RoleInfo })
2020-05-09 13:31:21 +08:00
isClickLeftOrRightBtn = true
2020-11-03 15:17:48 +08:00
this.upLvEffect:SetActive(false)
2020-05-09 13:31:21 +08:00
for i = 1, #heroDatas do
2020-11-05 16:02:49 +08:00
if curHeroData.dynamicId == heroDatas[i].dynamicId then
2020-05-09 13:31:21 +08:00
index = i
end
end
2020-11-03 15:17:48 +08:00
teamHero = FormationManager.GetWuJinFormationHeroIds(FormationTypeDef.FORMATION_NORMAL)
2020-05-09 13:31:21 +08:00
this:UpdateLiveList()--加载当前 和 左右数据
if this.leftLiveObj and leftHeroData then
poolManager:UnLoadLive(this.leftLiveObj.name, this.leftLiveObj)
2020-05-09 13:31:21 +08:00
this.leftLiveObj = nil
end
if this.rightLiveObj and rightHeroData then
poolManager:UnLoadLive(this.rightLiveObj.name, this.rightLiveObj)
2020-05-09 13:31:21 +08:00
this.rightLiveObj = nil
end
if this.curLiveObj and curHeroData then
poolManager:UnLoadLive(this.curLiveObj.name, this.curLiveObj)
2020-05-09 13:31:21 +08:00
this.curLiveObj = nil
end
2020-11-03 15:17:48 +08:00
Util.ClearChild(this.curObj.transform)
Util.ClearChild(this.leftObj.transform)
Util.ClearChild(this.rightObj.transform)
this.leftLiveObj = HeroManager.LoadHerolive(leftHeroData,this.leftObj)
this.rightLiveObj = HeroManager.LoadHerolive(rightHeroData,this.rightObj)
this.curLiveObj = HeroManager.LoadHerolive(curHeroData,this.curObj)
2020-08-03 13:37:21 +08:00
if this.curLiveObj then
2020-11-03 15:17:48 +08:00
this.dragView.gameObject:SetActive(true)
this.dragView:SetDragGO(this.curLiveObj)
2020-08-03 13:37:21 +08:00
else
2020-11-03 15:17:48 +08:00
this.dragView.gameObject:SetActive(false)
2020-08-03 13:37:21 +08:00
end
2020-11-03 15:17:48 +08:00
this:SetPanelBg(curHeroData.heroConfig)
this:UpdateHeroInfoData()--刷新界面方法
2020-05-09 13:31:21 +08:00
end
--更新界面已存数据
function this:UpdateLiveList()
local leftIndex = (index - 1 > 0 and index - 1 or #heroDatas)
leftHeroData = heroDatas[leftIndex]
curHeroData = heroDatas[index]
local rightIndex = (index + 1 <= #heroDatas and index + 1 or 1)
rightHeroData = heroDatas[rightIndex]
end
2020-11-03 15:17:48 +08:00
function this:SetPanelBg(heroData)
for i = 1, 4 do
if heroData.PropertyName == i then
this.bgImageList[i]:SetActive(true)
2020-05-09 13:31:21 +08:00
else
2020-11-03 15:17:48 +08:00
this.bgImageList[i]:SetActive(false)
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
end
2020-05-09 13:31:21 +08:00
end
--右切换按钮点击
function this:RightBtnOnClick()
if isClickLeftOrRightBtn == false then
return
end
isClickLeftOrRightBtn = false
2020-07-03 18:24:44 +08:00
local oldIndexConfigData = heroDatas[index]
2020-05-09 13:31:21 +08:00
index = (index + 1 <= #heroDatas and index + 1 or 1)
curHeroData = heroDatas[index]
if this.leftLiveObj then
poolManager:UnLoadLive(leftHeroData.live, this.leftLiveObj)
this.leftLiveObj = nil
end
2020-11-04 16:51:45 +08:00
this.curLiveObj.transform:SetParent(this.leftObj.transform)
2020-07-03 18:24:44 +08:00
this.curLiveObj:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(oldIndexConfigData.position[1],oldIndexConfigData.position[2]), 0.5, false):SetEase(Ease.Linear)
2020-11-04 16:51:45 +08:00
this.rightLiveObj.transform:SetParent(this.curObj.transform)
2020-05-09 13:31:21 +08:00
this.rightLiveObj:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(rightHeroData.position[1],rightHeroData.position[2]), 0.5, false):OnComplete(function ()
2020-11-06 20:36:38 +08:00
this:UpdateLiveList()
2020-11-03 17:27:32 +08:00
if this.curLiveObj then
poolManager:UnLoadLive(this.curLiveObj.name, this.leftLiveObj)
this.curLiveObj = nil
end
Util.ClearChild(this.leftObj.transform)
this.leftLiveObj = HeroManager.LoadHerolive(leftHeroData,this.leftObj)
2020-05-09 13:31:21 +08:00
this.curLiveObj = this.rightLiveObj
2020-11-04 16:51:45 +08:00
this.rightLiveObj = HeroManager.LoadHerolive(rightHeroData,this.rightObj)
2020-05-09 13:31:21 +08:00
local SkeletonGraphic = this.curLiveObj:GetComponent("SkeletonGraphic")
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
this.rightBtn:GetComponent("Button").enabled = true
isClickLeftOrRightBtn = true
2020-11-06 20:36:38 +08:00
this:UpdateHeroInfoData()
2020-05-09 13:31:21 +08:00
end):SetEase(Ease.Linear)
2020-11-03 17:27:32 +08:00
this:SetPanelBg(curHeroData.heroConfig)
2020-11-06 20:36:38 +08:00
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--左切换按钮点击
function this:LeftBtnOnClick()
if isClickLeftOrRightBtn == false then
return
end
isClickLeftOrRightBtn = false
2020-11-03 17:27:32 +08:00
this.leftBtn:GetComponent("Button").enabled = false
2020-07-03 18:24:44 +08:00
local oldIndexConfigData = heroDatas[index]
2020-05-09 13:31:21 +08:00
index = (index - 1 > 0 and index - 1 or #heroDatas)
curHeroData = heroDatas[index]
if this.rightLiveObj then
2020-11-03 17:27:32 +08:00
poolManager:UnLoadLive(this.rightLiveObj.name, this.rightLiveObj)
2020-05-09 13:31:21 +08:00
this.rightLiveObj = nil
end
2020-11-03 17:27:32 +08:00
this.curLiveObj.transform:SetParent(this.rightObj.transform)
2020-07-03 18:24:44 +08:00
this.curLiveObj:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(oldIndexConfigData.position[1],oldIndexConfigData.position[2]), 0.5, false):SetEase(Ease.Linear)
2020-11-03 17:27:32 +08:00
this.leftLiveObj.transform:SetParent(this.curObj.transform)
2020-05-09 13:31:21 +08:00
this.leftLiveObj:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(leftHeroData.position[1],leftHeroData.position[2]), 0.5, false):OnComplete(function ()
this:UpdateLiveList()
2020-11-03 17:27:32 +08:00
if this.curLiveObj then
poolManager:UnLoadLive(this.curLiveObj.name, this.rightLiveObj)
this.curLiveObj = nil
end
Util.ClearChild(this.rightObj.transform)
this.rightLiveObj = HeroManager.LoadHerolive(rightHeroData,this.rightObj)
2020-05-09 13:31:21 +08:00
this.curLiveObj = this.leftLiveObj
2020-11-03 17:27:32 +08:00
this.leftLiveObj = HeroManager.LoadHerolive(leftHeroData,this.leftObj)
2020-05-09 13:31:21 +08:00
local SkeletonGraphic = this.curLiveObj:GetComponent("SkeletonGraphic")
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
this.leftBtn:GetComponent("Button").enabled = true
isClickLeftOrRightBtn = true
2020-11-06 20:36:38 +08:00
this:UpdateHeroInfoData()
2020-05-09 13:31:21 +08:00
end):SetEase(Ease.Linear)
2020-11-03 17:27:32 +08:00
this:SetPanelBg(curHeroData.heroConfig)
2020-11-06 20:36:38 +08:00
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
function this:UpdateBtnList()
if not tabsList then
tabsList = {}
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
for k,v in pairs(tabsList) do
tabsList[k].gameObject:SetActive(false)
end
for k,v in ipairs(tabs) do
if not tabsList[k] then
tabsList[k] = newObjToParent(this.btnPre,this.btnList)
2020-05-09 13:31:21 +08:00
end
2020-11-09 15:04:48 +08:00
if k == 5 then
2020-11-03 15:17:48 +08:00
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.HeroSkin,"HeroId",curHeroData.id)
local HeoSkin = {}
for i = 1 ,#configs do
if not HeoSkin[configs[i].Type] then
HeoSkin[configs[i].Type] = configs[i]
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
end
if LengthOfTable(HeoSkin) > 1 then
tabsList[k].gameObject:SetActive(true)
2020-05-09 13:31:21 +08:00
else
2020-11-03 15:17:48 +08:00
tabsList[k].gameObject:SetActive(false)
2020-05-09 13:31:21 +08:00
end
else
2020-11-03 15:17:48 +08:00
tabsList[k].gameObject:SetActive(true)
end
local title = Util.GetGameObject(tabsList[k], "Text"):GetComponent("Text")
local redpot = Util.GetGameObject(tabsList[k], "redPoint")
title.text = GetCurLanguage() == 0 and v.title or "<size=45>"..v.title.."</size>"
2020-11-03 15:17:48 +08:00
-- 判断是否需要检测红点
redpot:SetActive(false)
2020-11-07 16:41:25 +08:00
if k == 1 then
local upLvRedpoint = HeroManager.LvUpBtnRedPoint(curHeroData)
redpot.gameObject:SetActive(upLvRedpoint)
elseif k == 2 then
local upStarRedPointState = HeroManager.IsShowUpStarRedPoint(curHeroData)
redpot.gameObject:SetActive(upStarRedPointState)
2020-11-12 13:55:15 +08:00
elseif k == 3 then
local upStarRedPointState = HeroManager.IsShowUpStarRedPoint(curHeroData)
redpot.gameObject:SetActive(upStarRedPointState)
2020-11-07 16:41:25 +08:00
else
redpot.gameObject:SetActive(false)
2020-11-03 15:17:48 +08:00
end
Util.AddOnceClick(tabsList[k],function()
if k == _CurPageIndex then
2020-05-09 13:31:21 +08:00
else
2020-11-03 15:17:48 +08:00
this:SetSelectBtn(k)
this:OnPageTabChange(k)
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
end)
end
2020-11-09 15:04:48 +08:00
--根据星级决定叶签现隐
if tabsList[2] and tabsList[3] then
if curHeroData.star < 10 then
if _CurPageIndex == 3 then
_CurPageIndex = 1
this:OnPageTabChange(_CurPageIndex)
end
2020-11-09 15:04:48 +08:00
tabsList[2].gameObject:SetActive(true)
tabsList[3].gameObject:SetActive(false)
2020-11-12 13:55:15 +08:00
elseif curHeroData.star == 10 and curHeroData.heroConfig.Awaken and #curHeroData.heroConfig.Awaken > 0 and ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.RoleAwake) then
if _CurPageIndex == 2 then
_CurPageIndex = 1
this:OnPageTabChange(_CurPageIndex)
end
2020-11-09 15:04:48 +08:00
tabsList[2].gameObject:SetActive(false)
tabsList[3].gameObject:SetActive(true)
else
if _CurPageIndex == 2 or _CurPageIndex == 3 then
_CurPageIndex = 1
this:OnPageTabChange(_CurPageIndex)
end
2020-11-09 15:04:48 +08:00
tabsList[2].gameObject:SetActive(false)
tabsList[3].gameObject:SetActive(false)
end
end
2020-11-03 15:17:48 +08:00
end
2020-11-07 16:41:25 +08:00
function this:CheckRedPointType(index,isShowRedPoint)
if tabsList[index] then
local redpot = Util.GetGameObject(tabsList[index], "redPoint")
redpot.gameObject:SetActive(isShowRedPoint)
2020-05-09 13:31:21 +08:00
end
end
2020-11-03 15:17:48 +08:00
2020-11-07 16:41:25 +08:00
-- 绑定数据
local _PageBindData = {}
2020-11-03 15:17:48 +08:00
--页签选中效果设置
function this:SetSelectBtn(index)
this.selectBtn.transform:SetParent(tabsList[index].transform)
this.selectBtn.transform.localScale = Vector3.one
this.selectBtn.transform.localPosition=Vector3.zero
Util.GetGameObject(this.selectBtn.transform, "Text"):GetComponent("Text").text = GetCurLanguage() == 0 and tabs[index].title or "<size=45>"..tabs[index].title.."</size>"--tabs[index].title--
Util.GetGameObject(self.transform,"talentBtn/tipStr"):SetActive(false)
if index == 2 then
Util.GetGameObject(self.transform,"talentBtn/tipStr"):SetActive(true)
end
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
-- tab改变事件
function this:OnPageTabChange(index)
2020-11-06 20:36:38 +08:00
this:ChangeCurentHeroSkinLive()
2020-11-03 15:17:48 +08:00
_CurPageIndex = index
for i = 1, #this.PageList do
if this.PageList[i] then
this.PageList[i]:OnHide()
end
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
this.PageList[index]:OnShow(this.sortingOrder,this,curHeroData,isUpZhen,heroDatas)
end
function this:UpdateHeroInfoData()
this:UpdateBtnList()
2020-11-09 15:04:48 +08:00
if _CurPageIndex == 5 then
2020-11-03 15:17:48 +08:00
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.HeroSkin,"HeroId",curHeroData.id)
local HeoSkin = {}
for i = 1 ,#configs do
if not HeoSkin[configs[i].Type] then
HeoSkin[configs[i].Type] = configs[i]
end
end
if LengthOfTable(HeoSkin) < 2 then
2020-11-06 20:36:38 +08:00
_CurPageIndex = 1
2020-11-03 15:17:48 +08:00
end
end
this:SetSelectBtn(_CurPageIndex)
this:OnPageTabChange(_CurPageIndex)
local EquipSignUnlock = ConfigManager.GetConfigData(ConfigName.GameSetting,1).EquipSignUnlock
2021-01-20 17:26:31 +08:00
local EquipSignUnlockTwo = ConfigManager.GetConfigData(ConfigName.GlobalSystemConfig,87).OpenRules[2]
2020-11-03 15:17:48 +08:00
if teamHero[curHeroData.dynamicId] then
isUpZhen = true
this.equipBtnRedPoint:SetActive(#HeroManager.GetHeroIsUpEquip(curHeroData.dynamicId) > 0)
this.talismanBtnRedPoint:SetActive(HeroManager.GetIsShowTalismanRedPoint(curHeroData))
this.soulPrintBtnRedPoint:SetActive(HeroManager.GetIsShowSoulPrintRedPoint(curHeroData))
else
isUpZhen = false
this.equipBtnRedPoint:SetActive(false)
this.talismanBtnRedPoint:SetActive(false)
this.soulPrintBtnRedPoint:SetActive(false)
end
--角色定位按钮
this.posBtn.gameObject:SetActive(curHeroData.heroConfig.ShowHeroLocation==1)
--法宝按钮逻辑
this.talismanBtn.gameObject:SetActive(TalismanManager.CheckTalismanIsInConfig(curHeroData))
if TalismanManager.CheckTalismanIsInConfig(curHeroData) then
talismanIsOpen = TalismanManager.GetCurHeroIsOpenTalisman(curHeroData)
this.talismanInfo.gameObject:SetActive(not talismanIsOpen)
Util.SetGray(this.talismanClick, not talismanIsOpen)
Util.GetGameObject(this.talismanClick.transform, "lock"):SetActive(not talismanIsOpen)
if not talismanIsOpen then
Util.GetGameObject(this.talismanClick, "lock/Text"):GetComponent("Text").text = TalismanManager.GetCurHeroIsOpenTalismanStr()
end
end
--魂印按钮逻辑
2021-01-20 17:26:31 +08:00
-- print(EquipSignUnlockTwo,"@@@@@@@@@@@@@@")
2020-11-03 15:17:48 +08:00
if curHeroData.heroConfig.RankupConsumeMaterial then
2021-01-20 17:26:31 +08:00
this.soulPrintBtn:SetActive(PlayerManager.level>=EquipSignUnlockTwo and (#curHeroData.heroConfig.RankupConsumeMaterial + curHeroData.heroConfig.Star) >= EquipSignUnlock[2][2])
2020-11-03 15:17:48 +08:00
else
2021-01-20 17:26:31 +08:00
this.soulPrintBtn:SetActive(PlayerManager.level>=EquipSignUnlockTwo and curHeroData.heroConfig.Star >= EquipSignUnlock[2][2])
2020-11-03 15:17:48 +08:00
end
2020-11-06 20:36:38 +08:00
this:SetDragView()
2020-11-03 15:17:48 +08:00
local starSize = Vector2.New(60,60)
SetHeroStars(this.starGrid, curHeroData.star,2,starSize,-10,Vector2.New(0.5,0.5))
this.posImage.sprite =Util.LoadSprite(curHeroData.professionIcon)
this.heroName.text = curHeroData.name
this.profession.sprite =Util.LoadSprite(GetProStrImageByProNum(curHeroData.heroConfig.PropertyName))
--定位描述相关
this.posBgImage.sprite=Util.LoadSprite(GetHeroPosBgStr(curHeroData.heroConfig.Profession))
this.posImage.sprite=Util.LoadSprite(GetHeroPosStr(curHeroData.heroConfig.Profession))
2021-01-26 17:08:39 +08:00
this.posText.text=GetLanguageStrById(curHeroData.heroConfig.HeroLocation)
2021-03-03 17:45:34 +08:00
SetTextVerTial(this.posText.gameObject,Vector3.New(64,21,0),"MiddleLeft")
2020-11-03 15:17:48 +08:00
this.unlockImage:SetActive(curHeroData.lockState == 0)
this.lockImage:SetActive(curHeroData.lockState == 1)
--魂印
soulPrintIsOpen=SoulPrintManager.GetSoulPrintIsOpen(curHeroData)
Util.GetGameObject(this.soulPrintBtn, "lock"):SetActive(not soulPrintIsOpen)
Util.SetGray(this.soulPrintBtn, not soulPrintIsOpen)
if not soulPrintIsOpen then
2021-03-02 16:53:12 +08:00
Util.GetGameObject(this.soulPrintBtn, "lock/Text"):GetComponent("Text").text= NumToSimplenessFont[EquipSignUnlock[2][2]]..Language[10535]
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
--天赋
this.talentBtn:SetActive(curHeroData.heroConfig.OpenPassiveSkillRules ~= nil)
2021-01-26 17:08:39 +08:00
local talentBtnImage = curHeroData.star == HeroManager.awakeNextStarIndex and "r_hero_tianfu2_zh" or "r_hero_tianfu1_zh"
2020-11-11 19:50:49 +08:00
this.talentBtn:GetComponent("Image").sprite = Util.LoadSprite(talentBtnImage)
2020-11-10 18:35:37 +08:00
local OpenPassiveSkillRules = curHeroData.star == HeroManager.awakeNextStarIndex and curHeroData.heroConfig.Awaken or curHeroData.heroConfig.OpenPassiveSkillRules
if OpenPassiveSkillRules then
2020-11-03 15:17:48 +08:00
local openlists,compoundOpenNum,compoundNum,allUpStarOpenData = HeroManager.GetAllPassiveSkillIds(curHeroData.heroConfig,curHeroData.breakId,curHeroData.upStarId)
2020-11-10 18:35:37 +08:00
this.talentProgress.text = #openlists - compoundOpenNum .."/"..#OpenPassiveSkillRules - compoundNum
2020-11-03 15:17:48 +08:00
if allUpStarOpenData[curHeroData.star + 1] then
2021-03-02 16:53:12 +08:00
this.talentTipStr.text = Language[11818].. NumToSimplenessFont[curHeroData.star + 1] ..Language[11819]
2020-11-03 15:17:48 +08:00
else
this.talentTipStr.text = ""
2020-05-09 13:31:21 +08:00
end
end
2020-11-03 15:17:48 +08:00
local allAddProVal = {}
if isUpZhen then
local formationList = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(formationList.teamHeroInfos,curHeroData.dynamicId)
allAddProVal = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false,nil,nil,true,allHeroTeamAddProVal)
2020-05-09 13:31:21 +08:00
else
2020-11-03 15:17:48 +08:00
allAddProVal = HeroManager.CalculateHeroAllProValList(1,curHeroData.dynamicId,false)
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
this.force.text =allAddProVal[HeroProType.WarPower]
end
2020-11-06 20:36:38 +08:00
function this:ChangeCurentHeroSkinLive(herodata)
if this.curLiveObj then
poolManager:UnLoadLive(this.curLiveObj.name, this.curLiveObj)
this.curLiveObj = nil
end
if herodata then
this.curLiveObj=HeroManager.LoadHerolive1(herodata,this.curObj)
-- 临时保存皮肤位置
curHeroPosition = herodata.Position
2020-11-06 20:36:38 +08:00
else
2020-11-14 14:31:38 +08:00
local allAddProVal = {}
if isUpZhen then
local formationList = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
local allHeroTeamAddProVal = HeroManager.GetAllHeroTeamAddProVal(formationList.teamHeroInfos,curHeroData.dynamicId)
allAddProVal = HeroManager.CalculateHeroAllProValList(1, curHeroData.dynamicId, false,nil,nil,true,allHeroTeamAddProVal)
else
allAddProVal = HeroManager.CalculateHeroAllProValList(1,curHeroData.dynamicId,false)
end
this.force.text =allAddProVal[HeroProType.WarPower]
2020-11-06 20:36:38 +08:00
this.curLiveObj=HeroManager.LoadHerolive(curHeroData,this.curObj)
-- 清空临时保存的皮肤位置
curHeroPosition = nil
2020-11-06 20:36:38 +08:00
end
this:SetDragView()
end
function this:SetDragView()
if this.curLiveObj then
this.dragView.gameObject:SetActive(true)
this.dragView:SetDragGO(this.curLiveObj)
else
this.dragView.gameObject:SetActive(false)
end
end
2020-11-03 15:17:48 +08:00
local beginV3
local endV3
local distance
function RoleInfoPanel:OnBeginDrag(Pointgo, data)
beginV3=this.curLiveObj.transform.anchoredPosition
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
function RoleInfoPanel:OnDrag(Pointgo, data)
distance=Vector2.Distance(beginV3,this.curLiveObj.transform.anchoredPosition)
end
function RoleInfoPanel:OnEndDrag(Pointgo, data)
endV3=this.curLiveObj.transform.anchoredPosition
if distance>250 and endV3.x<0 then
this:RightBtnOnClick()
elseif distance>250 and endV3.x>0 then
this:LeftBtnOnClick()
else
local pos = curHeroPosition or curHeroData.position
this.curLiveObj:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(pos[1], pos[2]), 0.5, false):SetEase(Ease.Linear)
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
distance=0
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--界面关闭时调用(用于子类重写)
function RoleInfoPanel:OnClose()
if this.leftLiveObj and leftHeroData then
2020-11-06 21:05:39 +08:00
poolManager:UnLoadLive(this.leftLiveObj.name, this.leftLiveObj)
2020-05-09 13:31:21 +08:00
this.leftLiveObj = nil
end
if this.rightLiveObj and rightHeroData then
2020-11-06 21:05:39 +08:00
poolManager:UnLoadLive(this.rightLiveObj.name, this.rightLiveObj)
2020-05-09 13:31:21 +08:00
this.rightLiveObj = nil
end
if this.curLiveObj and curHeroData then
2020-11-06 21:05:39 +08:00
poolManager:UnLoadLive(this.curLiveObj.name, this.curLiveObj)
2020-05-09 13:31:21 +08:00
this.curLiveObj = nil
end
this.leftBtn:GetComponent("Button").enabled = true
this.rightBtn:GetComponent("Button").enabled = true
2020-11-03 15:17:48 +08:00
if _CurPageIndex then
this.PageList[_CurPageIndex]:OnClose()
this.PageList[_CurPageIndex].gameObject:SetActive(false)
2020-05-09 13:31:21 +08:00
end
2020-11-06 21:05:39 +08:00
Util.ClearChild(this.curObj.transform)
Util.ClearChild(this.leftObj.transform)
Util.ClearChild(this.rightObj.transform)
2020-05-09 13:31:21 +08:00
end
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--界面销毁时调用(用于子类重写)
function RoleInfoPanel:OnDestroy()
2020-11-03 15:17:48 +08:00
tabsList = {}
2020-05-09 13:31:21 +08:00
SubUIManager.Close(this.UpView)
2020-11-03 15:17:48 +08:00
-- 这里管理全部子界面的销毁,保证子界面生命周期完整
for _, page in pairs(this.PageList) do
if page.OnDestroy then
page:OnDestroy()
2020-05-09 13:31:21 +08:00
end
end
end
2020-11-03 15:17:48 +08:00
2020-05-09 13:31:21 +08:00
--跳转显示新手提示圈
function this.ShowGuideGo(type)--1 升级突破 2 进阶
if type == 1 then
JumpManager.ShowGuide(UIName.RoleInfoPanel,this.upLvBtn)
elseif type == 2 then
-- 我要变强跳转过来显示小手
elseif type == -1 then
JumpManager.ShowGuide(UIName.RoleInfoPanel,this.upLvBtn)
elseif type == -2 then
JumpManager.ShowGuide(UIName.RoleInfoPanel,this.equipBtn)
elseif type == -3 then
JumpManager.ShowGuide(UIName.RoleInfoPanel,this.soulPrintBtn)
elseif type == -4 then
2020-06-08 13:57:30 +08:00
JumpManager.ShowGuide(UIName.RoleInfoPanel,this.talismanClick)
2020-05-09 13:31:21 +08:00
end
end
2020-11-03 15:17:48 +08:00
function this:HeroLockEvent()
2020-05-09 13:31:21 +08:00
if curHeroData.lockState == 1 then
curHeroData.lockState = 0
elseif curHeroData.lockState == 0 then
curHeroData.lockState = 1
end
NetManager.HeroLockEvent(curHeroData.dynamicId,curHeroData.lockState,function ()
if curHeroData.lockState == 1 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11820])
2020-05-09 13:31:21 +08:00
elseif curHeroData.lockState == 0 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[11741])
2020-05-09 13:31:21 +08:00
end
HeroManager.UpdateSingleHeroLockState(curHeroData.dynamicId,curHeroData.lockState)
this.unlockImage:SetActive(curHeroData.lockState == 0)
this.lockImage:SetActive(curHeroData.lockState == 1)
for i, v in pairs(heroDatas) do
if curHeroData == v then
v.lockState = curHeroData.lockState
end
end
end)
end
2020-11-03 15:17:48 +08:00
return this