miduo_client/Assets/ManagedResources/~Lua/Modules/Resolve/ResolvePanel.lua

287 lines
11 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
---献祭坛主面板---
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
ResolvePanel = Inherit(BasePanel)
local this = ResolvePanel
local isSha=false--筛选按钮状态
--Tab
local TabBox = require("Modules/Common/TabBox")
2020-08-07 12:22:10 +08:00
local _TabData={
2023-09-28 17:05:40 +08:00
[1] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_32", name = Language[11732] },
2021-04-01 18:41:50 +08:00
-- [2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "神将归元" },
-- [3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "法宝归元" },
2023-09-28 17:05:40 +08:00
[2] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_32", name = Language[11603] },
[3] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_32", name = Language[11735] },
[4] = { default = "UI_hz_gonghui_31", select = "UI_hz_gonghui_32", name = "神兵分解" },
2020-08-07 12:22:10 +08:00
}
2023-09-28 17:05:40 +08:00
local _TabFontColor = { default = Color.New(255 / 255, 255 / 255, 255 / 255, 1),
2020-05-09 13:31:21 +08:00
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
--子模块脚本
this.contents = {
--献祭
2020-08-07 12:22:10 +08:00
[1] = {view = require("Modules/Resolve/View/Resolve_Dismantle"), panelName = "Resolve_Dismantle"},
--回溯
-- [2] = {view = require("Modules/Resolve/View/Resolve_Recall"), panelName = "Resolve_Recall"},
2020-08-07 12:22:10 +08:00
--法宝归元
-- [3] = {view = require("Modules/Resolve/View/Resolve_Talisman"), panelName = "Resolve_Talisman"},
2020-07-06 16:27:27 +08:00
--宝物分解
[2] = {view = require("Modules/Resolve/View/Resolve_EquipTreasure"), panelName = "Resolve_EquipTreasure"},
--放生灵兽
[3] = {view = require("Modules/Resolve/View/Resolve_Pokemon"), panelName = "Resolve_Pokemon"},
2023-03-28 13:57:59 +08:00
[4] = {view = require("Modules/Resolve/View/Resolve_GodWeapon"), panelName = "Resolve_GodWeapon"},
2020-05-09 13:31:21 +08:00
}
--子模块预设
this.prefabs={}
--上一子模块索引
local curIndex=0
--Title资源名
2023-03-28 13:57:59 +08:00
local titleImageName={"gongsong_zh","h_xianji_fenjie_zh","lingshou_lingshoufangshengzi_zh","GodWeaponAtlas_fenjie_title_zh"}--,"guiyuan_zh","h_guiyuan_zi_zh"
2023-09-28 17:05:40 +08:00
local titleName={"恭送神将","宝物分解","灵兽放置","神兵分解"}
local titleColor={Color.New(243 / 255, 235 / 255, 202 / 255, 1),Color.New(243 / 255, 235 / 255, 202 / 255, 1),Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
local bgImageName={"UI_hz_ls_01","UI_hz_ls_07","UI_hz_ls_08"}--,"h_huisu_ditu","h_xianji_guiyuanditu"
2020-05-09 13:31:21 +08:00
local heroEndBtns = {}
local tabSortType
function ResolvePanel:InitComponent()
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.panel = Util.GetGameObject(self.gameObject, "Panel")
this.bgIma=Util.GetGameObject(self.gameObject,"Bg"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
this.title=Util.GetGameObject(self.gameObject,"Title"):GetComponent("Image")
2023-09-28 17:05:40 +08:00
this.titleDes=Util.GetGameObject(this.title.gameObject,"Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
this.backBtn = Util.GetGameObject(this.panel, "BackBtn")
this.content = Util.GetGameObject(this.panel, "Content")
this.itemListRoot=Util.GetGameObject(this.panel,"ItemListRoot")
this.shaiBtn = Util.GetGameObject(this.panel, "leftUp/shaiBtn")
2023-09-28 17:05:40 +08:00
this.shaiBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_hz_shenjiang_32")
2020-05-09 13:31:21 +08:00
this.btnHeroGrid = Util.GetGameObject(this.panel, "endTabs/btnHeroGrid")
this.endTabs = Util.GetGameObject(this.panel, "endTabs")
this.endTabs:SetActive(false)
--预设赋值
for i=1,#this.contents do
this.prefabs[i]=Util.GetGameObject(this.panel,this.contents[i].panelName)
end
this.selectHeroBtn = Util.GetGameObject(this.panel, "endTabs/selectBtn")
2021-03-31 17:40:51 +08:00
for i = 1, 5 do
heroEndBtns[i]=Util.GetGameObject(this.panel, "endTabs/btnHeroGrid/btnHeroGrid/Btn"..i-1)
2021-04-21 13:12:04 +08:00
Util.GetGameObject(heroEndBtns[i],"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(PropertyIcon[i-1])
2020-05-09 13:31:21 +08:00
end
for i = 1, #this.contents do
this.contents[i].view:InitComponent(this.panel)
end
end
function ResolvePanel:BindEvent()
for i = 1, #this.contents do
this.contents[i].view:BindEvent()
end
--返回按钮
Util.AddClick(this.backBtn,function()
if isSha then
isSha=not isSha
this.RewardGridGoMov(isSha,function()
self:ClosePanel()
end)
else
self:ClosePanel()
end
end)
Util.AddClick(this.shaiBtn, function()
isSha=not isSha
this.RewardGridGoMov(isSha)
end)
2020-07-10 18:29:38 +08:00
2020-05-09 13:31:21 +08:00
for i = 1, 6 do
Util.AddClick( heroEndBtns[i], function()
2021-04-09 12:26:35 +08:00
print(Language[12153]..tabSortType)
2020-07-10 18:29:38 +08:00
if tabSortType == i-1 then
2020-05-09 13:31:21 +08:00
tabSortType = 0
2021-11-05 15:48:22 +08:00
this.contents[curIndex].view.SortTypeClick(this.sortingOrder,0)--全部
this.EndTabBtnSelect()
2020-05-09 13:31:21 +08:00
else
2020-07-10 18:29:38 +08:00
tabSortType = i-1
2021-11-05 15:48:22 +08:00
this.contents[curIndex].view.SortTypeClick(this.sortingOrder,i-1)
this.EndTabBtnSelect(heroEndBtns[i])
2020-05-09 13:31:21 +08:00
end
PlayerManager.now_index = tabSortType
2021-04-09 12:26:35 +08:00
print(Language[12154]..tabSortType)
2020-05-09 13:31:21 +08:00
end)
end
end
function ResolvePanel:AddListener()
for i = 1, #this.contents do
this.contents[i].view:AddListener()
end
end
function ResolvePanel:RemoveListener()
for i = 1, #this.contents do
this.contents[i].view:RemoveListener()
end
end
function ResolvePanel:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
end
function ResolvePanel:OnOpen(...)
local args = {...}
if args[1] then
curIndex=args[1]
else
curIndex=1
end
tabSortType = 0
this.EndTabBtnSelect()
end
function ResolvePanel:OnShow()
this.upView = SubUIManager.Open(SubUIConfig.UpView, self.transform, {showType = UpViewOpenType.ShowLeft})
this.tabBox = Util.GetGameObject(this.panel, "TabBox")
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
this.TabCtrl:Init(this.tabBox, _TabData,curIndex)
end
function ResolvePanel:OnClose()
SubUIManager.Close(this.upView)
for i = 1, #this.contents do
this.contents[i].view:OnClose()
end
this.RewardGridGoMov(false)
PlayerManager.now_index = 0
this.EndTabBtnSelect()
2020-05-09 13:31:21 +08:00
end
function ResolvePanel:OnDestroy()
2021-04-22 14:37:16 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
for i = 1, #this.contents do
this.contents[i].view:OnDestroy()
end
end
--切换视图
2021-02-26 14:52:59 +08:00
function this.SwitchView(index,isNotTop,isNotAni)
2020-05-09 13:31:21 +08:00
--先执行上一面板关闭逻辑
local oldSelect
oldSelect, curIndex = curIndex, index
if oldSelect ~= curIndex then
-- body
this.RewardGridGoMov(false)
2021-01-07 14:39:27 +08:00
isSha = false
PlayerManager.now_index = 0
2021-01-07 14:39:27 +08:00
end
2020-05-09 13:31:21 +08:00
for i = 1, #this.contents do
if oldSelect~=0 then this.contents[oldSelect].view:OnClose() break end
end
--切换预设显隐
for i = 1, #this.prefabs do
this.prefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐
end
--区分显示
this.shaiBtn:SetActive(true)
2020-05-09 13:31:21 +08:00
if index==1 then
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeartFireStone})
2021-04-21 13:12:04 +08:00
this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[1])
this.title.sprite=this.spLoader:LoadSprite(titleImageName[1])
2023-09-28 17:05:40 +08:00
this.titleDes.text=titleName[1]
-- elseif index==2 then
-- this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn})
2021-04-21 13:12:04 +08:00
-- this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[2])
-- this.title.sprite=this.spLoader:LoadSprite(titleImageName[2])
-- elseif index==3 then
-- this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn})
2021-04-21 13:12:04 +08:00
-- this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[3])
-- this.title.sprite=this.spLoader:LoadSprite(titleImageName[3])
2020-05-09 13:31:21 +08:00
elseif index==2 then
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn})
2021-04-21 13:12:04 +08:00
this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[2])
this.title.sprite=this.spLoader:LoadSprite(titleImageName[2])
2023-09-28 17:05:40 +08:00
this.titleDes.text=titleName[2]
2020-07-06 16:27:27 +08:00
elseif index==3 then
this.shaiBtn:SetActive(false)
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn})
2021-04-21 13:12:04 +08:00
this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[3])
this.title.sprite=this.spLoader:LoadSprite(titleImageName[3])
2023-09-28 17:05:40 +08:00
this.titleDes.text=titleName[3]
2023-03-28 13:57:59 +08:00
elseif index==4 then
this.shaiBtn:SetActive(false)
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.HeroReturn})
this.bgIma.sprite=this.spLoader:LoadSprite(bgImageName[3])
this.title.sprite=this.spLoader:LoadSprite(titleImageName[4])
2023-09-28 17:05:40 +08:00
this.titleDes.text=titleName[4]
2020-05-09 13:31:21 +08:00
end
this.title:SetNativeSize()
--执行子模块初始化
2021-02-26 14:52:59 +08:00
this.contents[index].view:OnShow(this.sortingOrder,this.itemListRoot,isNotTop,isNotAni)
--刷新选择按钮
tabSortType = 0
this.EndTabBtnSelect(heroEndBtns[PlayerManager.now_index + 1])
2020-05-09 13:31:21 +08:00
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
2021-04-21 13:12:04 +08:00
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_TabData[index][status])
2021-02-23 17:41:59 +08:00
tabLab:GetComponent("Text").text = GetCurLanguage() ~= 2 and _TabData[index].name or "<size=30>".._TabData[index].name.."</size>"
2020-05-09 13:31:21 +08:00
tabLab:GetComponent("Text").color = _TabFontColor[status]
this.SetBottomBarIsActive(tab, index)
end
--特殊的开启条件
function this.SetBottomBarIsActive(tab, index)
local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig)
if index == 2 then
local string = ConfigData[40].Value
local num = string.split(string.split(string,"|")[1],"#")[2]
tab:SetActive(PlayerManager.level >= tonumber(num))
elseif index == 3 then
tab.gameObject:SetActive(ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.POKEMON))
end
2020-05-09 13:31:21 +08:00
end
function this.RewardGridGoMov(isSha,fun)
this.shaiBtn:GetComponent("Button").enabled = false
if isSha then
this.endTabs:SetActive(true)
--this.btnHeroGrid.transform:DOAnchorPosY(-670, 0.5, false)
this.endTabs.transform:DOAnchorPosY(251.62, 0.5, false):OnComplete(function()
this.shaiBtn:GetComponent("Button").enabled = true
if fun then
fun()
end
end)
else
--this.btnHeroGrid.transform:DOAnchorPosY(-766, 0.5, false)
this.endTabs.transform:DOAnchorPosY(-38.64, 0.5, false):OnComplete(function()
this.shaiBtn:GetComponent("Button").enabled = true
this.endTabs:SetActive(false)
if fun then
fun()
end
end)
end
end
--下部页签排序
function this.EndTabBtnSelect(_btn)
-- this.selectHeroBtn:SetActive(tabSortType > 0)
2020-05-09 13:31:21 +08:00
if _btn then
this.selectHeroBtn.transform:SetParent(_btn.transform)
this.selectHeroBtn.transform.localScale = Vector3.one
this.selectHeroBtn.transform.localPosition=Vector3.New(0.8,-1.3,0)
else
this.selectHeroBtn.transform:SetParent(heroEndBtns[1].transform)
this.selectHeroBtn.transform.localScale = Vector3.one
this.selectHeroBtn.transform.localPosition=Vector3.New(0.8,-1.3,0)
2020-05-09 13:31:21 +08:00
end
end
2020-06-23 18:36:24 +08:00
return ResolvePanel