miduo_client/Assets/ManagedResources/~Lua/Modules/Incarnation/IncarnationPanel.lua

476 lines
22 KiB
Lua

require("Base/BasePanel")
IncarnationPanel = Inherit(BasePanel)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local specialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig,155).Value
local xiuxian=ConfigManager.GetConfig(ConfigName.XiuXianConfig)
local cardPosition=ConfigManager.GetConfig(ConfigName.ChangingCardPosition)
local curLevel =PracticeManager.PracticeLevel --ConfigManager.GetConfigData(ConfigName.ChangingForce,IncarnationManager.incarnationForceLv).Level
local limits=string.split(specialConfig,"#")
local tabs = {}
local tabsRedpoints = {}
local tabsImg = {"r_hero_huo 1_zh", "r_hero_feng 1_zh", "r_hero_shui 1_zh", "r_hero_dadi 1_zh","z_icon_qingjinbao"}
local proId = 1
local curIndex=1
local allPos={1340,327,-330}
function IncarnationPanel:InitComponent()
self.spLoader = SpriteLoader.New()
for i = 1, 5 do
tabs[i] = Util.GetGameObject(self.transform, "bg/Tabs/grid/Btn" .. i)
local nameTxt=Util.GetGameObject(self.transform, "bg/Tabs/grid/Btn" .. i.."/Text"):GetComponent("Text")
nameTxt.text=PropertyType[i]
tabsRedpoints[i] = Util.GetGameObject(tabs[i], "redpoint")
if tabsImg[i] then
Util.GetGameObject(tabs[i], "Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(tabsImg[i])
end
end
self.selectBtn = Util.GetGameObject(self.gameObject,"bg/Tabs/selectBtn")
self.btnBack = Util.GetGameObject(self.gameObject,"bg/btnBack")
self.btn_left = Util.GetGameObject(self.gameObject,"bg/left")
self.btn_left:SetActive(false)
self.btn_right = Util.GetGameObject(self.gameObject,"bg/right")
self.btn_right:SetActive(false)
self.incarnationPowerBtn = Util.GetGameObject(self.gameObject,"bg/incarnationPowerBtn")
self.incarnationPowerBtn:SetActive(false)
self.powerBtnRedPoint = Util.GetGameObject(self.gameObject,"bg/incarnationPowerBtn/redPoint")
self.addBtn = Util.GetGameObject(self.gameObject,"bg/addBtn")
self.helpBtn = Util.GetGameObject(self.gameObject,"bg/helpBtn")
self.helpPos = self.helpBtn:GetComponent("RectTransform").localPosition
self.fetterItem = Util.GetGameObject(self.gameObject,"fetterItem")
local grid = Util.GetGameObject(self.gameObject,"bg/fetterGrid")
local v21 = grid.transform.rect
self.scroll = SubUIManager.Open(SubUIConfig.ScrollCycleView,grid.transform,self.fetterItem,nil,Vector2.New(v21.width, v21.height), 1, 1, Vector2.New(0,25))
self.itemPreList = {}
self.upLayoutItemList = {}
self.upLayout = Util.GetGameObject(self.gameObject,"bg/upScroll/upLayout")
self.upLayout:GetComponent("RectTransform").anchoredPosition=Vector2.New(allPos[curIndex],-300)
for i = 1,4 do
self.upLayoutItemList[i] = {}
self.upLayoutItemList[i].go = Util.GetGameObject(self.upLayout,"card"..i)
self.upLayoutItemList[i].btn = Util.GetGameObject(self.upLayoutItemList[i].go,"unLoadBtn")
self.upLayoutItemList[i].pos = Util.GetGameObject(self.upLayoutItemList[i].go,"cardPre")
self.upLayoutItemList[i].posImg = Util.GetGameObject(self.upLayoutItemList[i].go,"posText"):GetComponent("Image")
self.upLayoutItemList[i].posImg.sprite=self.spLoader:LoadSprite("r_fxgz_shuzi_"..i)
self.upLayoutItemList[i].posImg.gameObject:SetActive(false)
self.upLayoutItemList[i].getBtn = Util.GetGameObject(self.upLayoutItemList[i].pos,"getBtn")
self.upLayoutItemList[i].lv = Util.GetGameObject(self.upLayoutItemList[i].go,"lvText"):GetComponent("Text")
self.upLayoutItemList[i].desTxt = Util.GetGameObject(self.upLayoutItemList[i].go,"desText"):GetComponent("Text")
self.upLayoutItemList[i].desTxt.text=cardPosition[i].Desc
end
self.empty = Util.GetGameObject(self.gameObject,"bg/NoneImage")
self.cardList = {}
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
end
function IncarnationPanel:BindEvent()
for i = 1,5 do
Util.AddClick(tabs[i], function()
if i == proId then
return
end
proId = i
self:SetSelectBtn()
self:RefreshList(false,true)
end)
end
for i = 1,4 do
Util.AddClick(self.upLayoutItemList[i].btn, function()
if self.upLayoutData[i] and self.upLayoutData[i].id then
NetManager.UpOrDownTransformationRequest(self.upLayoutData[i].id,i,1,function()
self.upLayoutData[i] = nil
self.upLayoutItemList[i].btn.gameObject:SetActive(false)
self:RefreshSingleCardPre(self.upLayoutItemList[i].pos,nil,false,i)
self:RefreshList(true,true)
PopupTipPanel.ShowTip("成功卸下身外化身!")
end)
end
end)
end
for i = 1,4 do
Util.AddClick(self.upLayoutItemList[i].getBtn, function()
if self.upLayoutData[i] and self.upLayoutData[i].id then
local pos = self:FindDatasIndexById(self.upLayoutData[i].id)
if proId ~= self.upLayoutData[i].property then
proId = self.upLayoutData[i].property
self:SetSelectBtn()
self:RefreshList(false,true)
end
if pos > 0 then
self.scroll:SetIndex(pos)
end
end
end)
end
Util.AddClick(self.helpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Incarnation,self.helpPos.x, self.helpPos.y)
end)
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
Util.AddClick(self.btn_left, function()
-- curIndex=curIndex-1
-- if curIndex==1 then
-- self.btn_left:SetActive(false)
-- else
-- self.btn_right:SetActive(true)
-- end
-- self.upLayout:GetComponent("RectTransform").anchoredPosition=Vector2.New(allPos[curIndex],-221)
end)
Util.AddClick(self.btn_right, function()
-- curIndex=curIndex+1
-- if curIndex==3 then
-- self.btn_right:SetActive(false)
-- else
-- self.btn_left:SetActive(true)
-- end
-- self.upLayout:GetComponent("RectTransform").anchoredPosition=Vector2.New(allPos[curIndex],-221)
end)
Util.AddClick(self.incarnationPowerBtn, function()
UIManager.OpenPanel(UIName.IncarnationForcePanel)
end)
Util.AddClick(self.addBtn, function()
local data = {}
local singData = {}
singData.title = "当前奥义卡总加成"
singData.pro = IncarnationManager.GetproDesLst(IncarnationManager.GetIncarnationTotalPro(),"9E6828")
singData.tip ="" --"总加成包括化身之力提供的属性"
table.insert(data,singData)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.IncarnationDes,data)
end)
BindRedPointObject(RedPointType.incarnation_people,tabsRedpoints[1].gameObject)
BindRedPointObject(RedPointType.incarnation_buddish,tabsRedpoints[2].gameObject)
BindRedPointObject(RedPointType.incarnation_demon,tabsRedpoints[3].gameObject)
BindRedPointObject(RedPointType.incarnation_taoist,tabsRedpoints[4].gameObject)
BindRedPointObject(RedPointType.incarnation_Kong,tabsRedpoints[5].gameObject)
BindRedPointObject(RedPointType.incarnation_force,self.powerBtnRedPoint.gameObject)
end
function IncarnationPanel:FindDatasIndexById(id)
for i = 1 ,#self.datas do
if self.datas[i].id == id then
return i
end
end
return -1
end
function IncarnationPanel:SetSelectBtn()
self.selectBtn.transform:SetParent(tabs[proId].transform)
self.selectBtn:GetComponent("RectTransform").localPosition = Vector3.zero
self.selectBtn.transform:SetSiblingIndex(1)
end
function IncarnationPanel:RefreshUpLimitLevel()
curLevel =PracticeManager.PracticeLevel --ConfigManager.GetConfigData(ConfigName.ChangingForce,IncarnationManager.incarnationForceLv).Level
for i = 1,4 do
self.upLayoutItemList[i].lv.gameObject:SetActive(curLevel<tonumber(limits[i]))
end
end
function IncarnationPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.CommonEvent.RefreshIncarnationPanel,function()
self:RefreshUpList()
self:RefreshList(true,true)
end)
Game.GlobalEvent:AddEvent(GameEvent.CommonEvent.RefreshIncarnationPanelUp,function()
self:RefreshUpLimitLevel()
end)
end
function IncarnationPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.CommonEvent.RefreshIncarnationPanel,function()
self:RefreshUpList()
self:RefreshList(true,true)
end)
Game.GlobalEvent:RemoveEvent(GameEvent.CommonEvent.RefreshIncarnationPanelUp,function()
self:RefreshUpLimitLevel()
end)
end
function IncarnationPanel:OnOpen(_proId)
proId = _proId or 1
CheckRedPointStatus(RedPointType.incarnation_force)
end
function IncarnationPanel:OnShow()
curIndex=1
self.upLayout:GetComponent("RectTransform").anchoredPosition=Vector2.New(allPos[1],-300)
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
self:RefreshUpList()
self:SetSelectBtn()
self:RefreshList(false,false)
end
function IncarnationPanel:RefreshUpList()
self.upLayoutData = IncarnationManager.GetIncarnationData1()
for i = 1,4 do
self.upLayoutItemList[i].pos.gameObject:SetActive(false)
self.upLayoutItemList[i].btn.gameObject:SetActive(false)
self.upLayoutItemList[i].lv.gameObject:SetActive(PracticeManager.PracticeLevel<tonumber(limits[i]))
--local xiuxian=ConfigManager.GetConfigData(ConfigName.XiuXianConfig,tonumber(limits[i]))
if xiuxian then
self.upLayoutItemList[i].lv.text=xiuxian[tonumber(limits[i])].RealmName.."期解锁"
end
end
for k,v in pairs(self.upLayoutData) do
self:RefreshSingleCardPre(self.upLayoutItemList[k].pos,v,false,k)
self.upLayoutItemList[k].btn.gameObject:SetActive(true)
end
end
function IncarnationPanel:RefreshSingleCardPre(cardPre,data,isJump,index)
if not self.cardList[cardPre] then
self.cardList[cardPre] = {}
self.cardList[cardPre].bg = Util.GetGameObject(cardPre,"Hero/Bg1"):GetComponent("Image")
self.cardList[cardPre].bg1 = Util.GetGameObject(cardPre,"Hero/BGdedi"):GetComponent("Image")
self.cardList[cardPre].icon = Util.GetGameObject(cardPre,"Hero/Mask/icon"):GetComponent("RawImage")
self.cardList[cardPre].cardBg = Util.GetGameObject(cardPre,"Hero/Bg2"):GetComponent("Image")
self.cardList[cardPre].proImage = Util.GetGameObject(cardPre,"Hero/Pro/Image"):GetComponent("Image")
self.cardList[cardPre].getBtn = Util.GetGameObject(cardPre,"getBtn")
self.cardList[cardPre].StarGrid = Util.GetGameObject(cardPre,"StarGrid")
self.cardList[cardPre].lv = Util.GetGameObject(cardPre,"lv/Text"):GetComponent("Text")
self.cardList[cardPre].starBg = Util.GetGameObject(cardPre,"starBg")
end
if data then
cardPre.gameObject:SetActive(true)
if data.state < 0 or not isJump then
self.cardList[cardPre].getBtn.gameObject:SetActive(true)
else
self.cardList[cardPre].getBtn.gameObject:SetActive(false)
end
self.cardList[cardPre].bg.sprite = self.spLoader:LoadSprite(GetHeroCardStarImage2[data.quality])
self.cardList[cardPre].bg1.sprite = self.spLoader:LoadSprite(GetHeroCardStarImage1[data.quality])
local liveName = GetResourcePath(heroConfig[data.heroId].Painting)
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, data.heroId)
local scale = roleConfig.play_liveScale
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
if not isJump then
self.cardList[cardPre].icon.texture = CardRendererManager.GetSpineTexture(index, liveName, Vector3.one * scale, livePos, true)
else
self.cardList[cardPre].icon.texture = CardRendererManager.GetSpineTexture((index%4 == 0 and 7 or index%4 + 3), liveName, Vector3.one * scale, livePos, true)
end
self.cardList[cardPre].icon.transform.localScale = Vector3.one
self.cardList[cardPre].icon.transform.localPosition = Vector3.zero+ Vector3(0,-50,0)
SetHEeroLiveToward(self.cardList[cardPre].icon.gameObject,heroConfig[data.heroId].Toward)
self.cardList[cardPre].proImage.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(data.property))
self.cardList[cardPre].cardBg.sprite = self.spLoader:LoadSprite(GetHeroCardStarFg[data.quality])
if isJump then
Util.AddOnceClick(self.cardList[cardPre].getBtn,function()
--UIManager.OpenPanel(UIName.RewardTailsmanChipShowPopup, data.itemId)
end)
end
SetCardStars(self.cardList[cardPre].StarGrid,data.star,1,0)
self.cardList[cardPre].starBg:SetActive(data.star~=0)
for i = 0, 8 do
if i<data.star then
self.cardList[cardPre].StarGrid.transform:GetChild(i).gameObject:SetActive(true)
else
self.cardList[cardPre].StarGrid.transform:GetChild(i).gameObject:SetActive(false)
end
end
self.cardList[cardPre].lv.text=data.level
else
cardPre.gameObject:SetActive(false)
end
end
function IncarnationPanel:RefreshList(istop,isAnim)
self.datas = IncarnationManager.GetItemDataListByPro(proId)
self.scroll:ForeachItemGO(function(index,go)
go.gameObject:SetActive(false)
end)
if not self.datas or #self.datas < 1 then
self.empty.gameObject:SetActive(true)
self.scroll.gameObject:SetActive(false)
else
self.empty.gameObject:SetActive(false)
self.scroll.gameObject:SetActive(true)
self.scroll:SetData(self.datas,function(index,go)
self:SetSingleData(go,self.datas[index],index)
end,istop,isAnim)
end
end
function IncarnationPanel:SetSingleData(go,data,index)
if not self.itemPreList[go] then
self.itemPreList[go] = {}
self.itemPreList[go].preList = {}
self.itemPreList[go].obj = Util.GetGameObject(go,"bg")
self.itemPreList[go].bg = Util.GetGameObject(self.itemPreList[go].obj,"Bg1"):GetComponent("Image")
self.itemPreList[go].bg1 = Util.GetGameObject(self.itemPreList[go].obj,"BGdedi"):GetComponent("Image")
self.itemPreList[go].cardPre = Util.GetGameObject(self.itemPreList[go].obj,"cardPre")
self.itemPreList[go].nameText = Util.GetGameObject(self.itemPreList[go].obj,"nameDi/nameText"):GetComponent("Text")
self.itemPreList[go].skillLayout = Util.GetGameObject(self.itemPreList[go].obj,"skillLayout")
self.itemPreList[go].proGrid = Util.GetGameObject(self.itemPreList[go].skillLayout,"proScrolllRect/proScroll")
self.itemPreList[go].pro = Util.GetGameObject(self.itemPreList[go].skillLayout,"pro")
self.itemPreList[go].red = Util.GetGameObject(self.itemPreList[go].obj,"red")
self.itemPreList[go].unGetBtn = Util.GetGameObject(self.itemPreList[go].obj,"unGetBtn")
self.itemPreList[go].activableBtn = Util.GetGameObject(self.itemPreList[go].obj,"activableBtn")
self.itemPreList[go].incarnationBtn = Util.GetGameObject(self.itemPreList[go].obj,"incarnationBtn")
self.itemPreList[go].incarnationningBtn = Util.GetGameObject(self.itemPreList[go].obj,"incarnationningBtn")
self.itemPreList[go].upLvBtn = Util.GetGameObject(self.itemPreList[go].obj,"upLvBtn")
self.itemPreList[go].upLvRed = Util.GetGameObject(self.itemPreList[go].obj,"upLvBtn/red")
self.itemPreList[go].upStarBtn = Util.GetGameObject(self.itemPreList[go].obj,"upStarBtn")
self.itemPreList[go].upStarRed = Util.GetGameObject(self.itemPreList[go].obj,"upStarBtn/red")
self.itemPreList[go].helpBtn = Util.GetGameObject(self.itemPreList[go].obj,"helpBtn")
end
self.itemPreList[go].unGetBtn.gameObject:SetActive(false)
self.itemPreList[go].activableBtn.gameObject:SetActive(false)
self.itemPreList[go].incarnationBtn.gameObject:SetActive(false)
self.itemPreList[go].incarnationningBtn.gameObject:SetActive(false)
self.itemPreList[go].upLvBtn.gameObject:SetActive(false)
self.itemPreList[go].upStarBtn.gameObject:SetActive(false)
self.itemPreList[go].data = data
if not data then
go.gameObject:SetActive(false)
return
end
go.gameObject:SetActive(true)
self.itemPreList[go].bg.sprite = self.spLoader:LoadSprite(GetHeroCardStarImage1[data.quality])
self.itemPreList[go].bg1.sprite = self.spLoader:LoadSprite(GetHeroCardStarImage2[data.quality])
self.itemPreList[go].nameText.text = string.format("<color=#%s>%s</color>",GetIncarnationNameColor[data.quality], data.name)
self.itemPreList[go].red.gameObject:SetActive(data.state == 0)
self.itemPreList[go].upLvRed.gameObject:SetActive(IncarnationManager.CheckCardUpLvRedData(data.id))
self.itemPreList[go].upStarRed.gameObject:SetActive(IncarnationManager.CheckCardUpStarRedData(data.id))
self:RefreshSingleCardPre(self.itemPreList[go].cardPre,data,true,index)
self:SetProList(IncarnationManager.GetCardPropDesStr(data.id),self.itemPreList[go].preList,self.itemPreList[go].proGrid,self.itemPreList[go].pro.gameObject)
Util.AddOnceClick(self.itemPreList[go].activableBtn,function()
if data.state == 0 then
NetManager.UpOrDownTransformationRequest(data.id,0,1,function()
data.state = 1
self:SetSingleData(go,data,index)
PopupTipPanel.ShowTip(string.format("成功激活%s",data.name))
CheckRedPointStatus(RedPointType.incarnation_force)
end)
else
PopupTipPanel.ShowTip(string.format("成功激活%s",data.name))
end
end)
Util.AddOnceClick(self.itemPreList[go].incarnationBtn,function()
if data.state == 1 then
local pos = 0
for i = 1,4 do
if self.upLayoutData[i] and self.upLayoutData[i].id then
else
pos = i
break
end
end
--LogError("curLevel==="..curLevel.." limits[pos]==="..limits[pos].."PracticeManager.PracticeLevel=="..PracticeManager.PracticeLevel)
if PracticeManager.PracticeLevel<tonumber(limits[pos]) then
PopupTipPanel.ShowTip(xiuxian[tonumber(limits[pos])].RealmName.."期解锁")
return
end
if pos > 0 then
NetManager.UpOrDownTransformationRequest(data.id,pos,2,function()
data.state = 2
data.pos = pos
self:SetSingleData(go,data,index)
self.upLayoutData[pos] = data
self:RefreshSingleCardPre(self.upLayoutItemList[pos].pos,data,false,pos)
self.upLayoutItemList[pos].btn.gameObject:SetActive(true)
PopupTipPanel.ShowTip("化身成功!")
end)
else
PopupTipPanel.ShowTip("身外化身位置已达上限,请卸下需要替换的化身!")
end
else
PopupTipPanel.ShowTip("化身成功!")
end
end)
Util.AddOnceClick(self.itemPreList[go].incarnationningBtn,function()
if data.state == 2 then
NetManager.UpOrDownTransformationRequest(data.id,data.pos,1,function()
local oldPos = data.pos
data.state = 1
data.pos = 0
self:SetSingleData(go,data,index)
self.upLayoutData[oldPos] = nil
self:RefreshSingleCardPre(self.upLayoutItemList[oldPos].pos,nil,false,oldPos)
self.upLayoutItemList[oldPos].btn.gameObject:SetActive(false)
PopupTipPanel.ShowTip("成功卸下身外化身!")
end)
end
end)
Util.AddOnceClick(self.itemPreList[go].upLvBtn,function()
UIManager.OpenPanel(UIName.IncarnationUpPopup,1,data.id)
end)
Util.AddOnceClick(self.itemPreList[go].upStarBtn,function()
UIManager.OpenPanel(UIName.IncarnationUpPopup,2,data.id)
end)
Util.AddOnceClick(self.itemPreList[go].helpBtn,function()
UIManager.OpenPanel(UIName.IncarnationUpHelpPopup,data.id)
end)
if data.state == -1 then
self.itemPreList[go].unGetBtn.gameObject:SetActive(true)
elseif data.state == 0 then
self.itemPreList[go].activableBtn.gameObject:SetActive(true)
elseif data.state == 1 then
self.itemPreList[go].incarnationBtn.gameObject:SetActive(true)
self.itemPreList[go].upLvBtn.gameObject:SetActive(true)
self.itemPreList[go].upStarBtn.gameObject:SetActive(true)
elseif data.state == 2 then
self.itemPreList[go].incarnationningBtn.gameObject:SetActive(true)
self.itemPreList[go].upLvBtn.gameObject:SetActive(true)
self.itemPreList[go].upStarBtn.gameObject:SetActive(true)
end
end
function IncarnationPanel:SetProList(data,preList,grid,pre)
for i = 1,math.max(#data,#preList) do
if not data[i] then
preList[i].go.gameObject:SetActive(false)
else
if not preList[i] then
preList[i] = {}
preList[i].go = newObjToParent(pre,grid)
preList[i].goText = preList[i].go:GetComponent("Text")
end
preList[i].go.gameObject:SetActive(true)
preList[i].goText.text = data[i]
end
end
ForceRebuildLayout(grid.transform)
end
function IncarnationPanel:OnSortingOrderChange()
end
function IncarnationPanel:OnClose()
end
function IncarnationPanel:OnDestroy()
self.spLoader:Destroy()
self.upLayoutItemList = {}
self.itemPreList = {}
self.cardList = {}
ClearRedPointObject(RedPointType.incarnation_people,tabsRedpoints[1].gameObject)
ClearRedPointObject(RedPointType.incarnation_buddish,tabsRedpoints[2].gameObject)
ClearRedPointObject(RedPointType.incarnation_demon,tabsRedpoints[3].gameObject)
ClearRedPointObject(RedPointType.incarnation_taoist,tabsRedpoints[4].gameObject)
ClearRedPointObject(RedPointType.incarnation_Kong,tabsRedpoints[5].gameObject)
ClearRedPointObject(RedPointType.incarnation_force,self.powerBtnRedPoint.gameObject)
SubUIManager.Close(self.UpView)
end
return IncarnationPanel