miduo_client/Assets/ManagedResources/~Lua/Modules/QiJieShiLian/QiJieShiLianPanel.lua

309 lines
14 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
local QiJieShiLianPanel = Inherit(BasePanel)
local QijieStage = ConfigManager.GetConfig(ConfigName.QijieStage)
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local roleConfig = ConfigManager.GetConfig(ConfigName.RoleConfig)
--初始化组件(用于子类重写)
function QiJieShiLianPanel:InitComponent()
self.spLoader = SpriteLoader.New()
-- 屏幕适配修改
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
self.backBtn = Util.GetGameObject(self.gameObject,"backBtn")
self.helpBtn = Util.GetGameObject(self.gameObject,"HelpBtn")
self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition
self.aniRoot = Util.GetGameObject(self.gameObject,"aniRoot")
--上部
self.topBar = Util.GetGameObject(self.gameObject,"TopBar")
self.name = Util.GetGameObject(self.topBar,"Name"):GetComponent("Text")
self.info = Util.GetGameObject(self.topBar,"Info"):GetComponent("Text")
--左侧按钮
self.leftBtns = Util.GetGameObject(self.gameObject,"leftBtns")
self.goalBtn = Util.GetGameObject(self.leftBtns,"goalBtn")
self.giftBtn = Util.GetGameObject(self.leftBtns,"giftBtn")
self.treasureBtn = Util.GetGameObject(self.leftBtns,"treasureBtn")
self.treasureRed = Util.GetGameObject(self.treasureBtn,"redPoint")
--右侧按钮
self.rightBtns = Util.GetGameObject(self.gameObject,"rightBtns")
self.rewardBtn = Util.GetGameObject(self.rightBtns,"rewardBtn")
--屏蔽七界排名奖励
self.rewardBtn:SetActive(false)
self.sortBtn = Util.GetGameObject(self.rightBtns,"sortBtn")
self.shopBtn = Util.GetGameObject(self.rightBtns,"shopBtn")
--下部
self.bottomBar = Util.GetGameObject(self.gameObject,"BottomBar")
--挑战加成
self.addtions = Util.GetGameObject(self.bottomBar,"Info/Content")
self.addNum = Util.GetGameObject(self.addtions,"Text"):GetComponent("Text")
self.goalList = {}
for i = 1, 3 do
self.goalList[i] = Util.GetGameObject(self.addtions,"goal ("..i..")")
end
--挑战奖励
self.rewards = Util.GetGameObject(self.bottomBar,"Reward/Content")
--挑战
self.goBtn = Util.GetGameObject(self.bottomBar,"goBtn")
--次数
self.freeTime = Util.GetGameObject(self.bottomBar,"times/freeTime"):GetComponent("Text")
self.buyTime = Util.GetGameObject(self.bottomBar,"times/buyTime"):GetComponent("Text")
self.buyBtn = Util.GetGameObject(self.bottomBar,"times/buyBtn")
--下方按钮
self.TabBox = Util.GetGameObject(self.gameObject,"TabBox")
self.box = Util.GetGameObject(self.TabBox,"box")
self.tabPre = Util.GetGameObject(self.TabBox,"tabPre")
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.box.transform,
self.tabPre, nil, Vector2.New(940.6, 240), 2, 1, Vector2.New(20, 0))
self.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(-8, 0)
self.ScrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
self.ScrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
self.ScrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
self.ScrollView.moveTween.MomentumAmount = 1
self.ScrollView.moveTween.Strength = 2
self.ScrollView.elastic = false
self.rewardPre = Util.GetGameObject(self.bottomBar,"rewardPre")
self.ScrollView2 = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.rewards.transform,
self.rewardPre, nil, Vector2.New(450, 235), 2, 1, Vector2.New(30, 0))
self.ScrollView2.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(-8, 0)
self.ScrollView2.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
self.ScrollView2.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
self.ScrollView2.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
self.ScrollView2.moveTween.MomentumAmount = 1
self.ScrollView2.moveTween.Strength = 2
self.ScrollView2.elastic = false
--左右切换按钮
self.lastBtn = Util.GetGameObject(self.gameObject,"lastBtn")
self.nextBtn = Util.GetGameObject(self.gameObject,"nextBtn")
self.itemViewList = {}
end
--绑定事件(用于子类重写)
function QiJieShiLianPanel:BindEvent()
Util.AddClick(self.backBtn,function()
self:ClosePanel()
end)
Util.AddOnceClick(self.helpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.QiJieShiLian,self.helpPosition.x,self.helpPosition.y)
end)
Util.AddClick(self.goalBtn,function()
UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.QiJieGoalAttri,self.configData,Vector2(0,450))
end)
Util.AddClick(self.giftBtn,function()
NetManager.SevenWorldRelicRequest(0,function (msg)
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.QiJieTreasure)
end)
end)
Util.AddClick(self.treasureBtn,function()
local actInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.QiJieTreasure)
if not actInfo then
PopupTipPanel.ShowTip("活动暂未开启。")
else
UIManager.OpenPanel(UIName.GeneralTreasurePanel,ActivityTypeDef.QiJieTreasure)
end
end)
Util.AddClick(self.rewardBtn,function()
UIManager.OpenPanel(UIName.GeneralRankRewardPanel,4,QiJieShiLianManager.curRank)--需要活动id和我的排名
end)
Util.AddClick(self.sortBtn,function()
UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[32])
end)
Util.AddClick(self.shopBtn,function()
JumpManager.GoJump(40035)
end)
Util.AddClick(self.goBtn,function()
if PrivilegeManager.GetPrivilegeRemainValue(3201) <= 0 then
if PrivilegeManager.GetPrivilegeRemainValue(3202) > 0 then
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10042, 1)
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
MsgPanel.ShowTwo(string.format( Language[10516],finalNum,itemName), nil, function()
--买东西
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10042,1,function()
PopupTipPanel.ShowTip(Language[10517])
PrivilegeManager.RefreshPrivilegeUsedTimes(3202, 1)--更新特权
-- UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.QIJIESHILIAN,self.configData)
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.QiJieShiLianMonster,self.configData)
self:SetBuyTime()
end)
end)
else
PopupTipPanel.ShowTip("<color=red>今日已无挑战次数!</color>")
end
else
-- UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.QIJIESHILIAN,self.configData)
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.QiJieShiLianMonster,self.configData)
end
end)
Util.AddClick(self.buyBtn,function()
if PrivilegeManager.GetPrivilegeRemainValue(3202) > 0 then
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10042, 1)
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
MsgPanel.ShowTwo(string.format( Language[10516],finalNum,itemName), nil, function()
--买东西
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10042,1,function()
PopupTipPanel.ShowTip(Language[10517])
PrivilegeManager.RefreshPrivilegeUsedTimes(3202, 1)--更新特权
self:SetBuyTime()
end)
end)
else
PopupTipPanel.ShowTip("<color=red>今日已无购买次数!</color>")
end
end)
Util.AddClick(self.lastBtn,function()
QiJieShiLianManager.SwitchBtnCheck(-1,function ()
self:Refresh()
end)
end)
Util.AddClick(self.nextBtn,function()
QiJieShiLianManager.SwitchBtnCheck(1,function ()
self:Refresh()
end)
end)
end
--添加事件监听(用于子类重写)
function QiJieShiLianPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.QiJieShiLian.RefreshPanel, self.Refresh,self)
Game.GlobalEvent:AddEvent(GameEvent.Privilege.OnPrivilegeZeroUpdate, self.SetBuyTime,self)
end
--移除事件监听(用于子类重写)
function QiJieShiLianPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.QiJieShiLian.RefreshPanel, self.Refresh,self)
Game.GlobalEvent:RemoveEvent(GameEvent.Privilege.OnPrivilegeZeroUpdate, self.SetBuyTime,self)
end
--跨服
function QiJieShiLianPanel:OnOpen()
self.UpView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.QiJie})
end
--界面打开时调用(用于子类重写)
function QiJieShiLianPanel:OnShow()
if QiJieShiLianManager.IsLock then
NetManager.SevenWorldInfoRequest(QiJieShiLianManager.curLevelId)
else
NetManager.SevenWorldInfoRequest(0)
end
self:Refresh()
end
function QiJieShiLianPanel:Refresh()
self.qijieData = QiJieShiLianManager.GetQiJieData()
CheckRedPointStatus(RedPointType.QiJieShiLian)
self.configData = self.qijieData.curStageData
Log("七界试炼当前层数Id:"..tostring(QiJieShiLianManager.curLevelId).." 最大层数Id:"..tostring(QiJieShiLianManager.curMaxStage))
local num = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,128).Value)
self.giftBtn:SetActive(self.qijieData.curProgress >= num)
self.lastBtn:SetActive(not not QijieStage[QiJieShiLianManager.curLevelId-1])
self.nextBtn:SetActive(QiJieShiLianManager.curMaxStage~=QiJieShiLianManager.curLevelId)
self.treasureRed:SetActive(QiJieShiLianManager.CheckQiJieTreasureRedPoint())
self.treasureBtn:SetActive(not not ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.QiJieTreasure))
PlayUIAnims(self.lastBtn)
PlayUIAnims(self.nextBtn)
self:SetTabBox()
self:SetTopBar()
self:SetBottomBar()
--设置立绘
if self.Live then
poolManager:UnLoadLive(self.bgName, self.Live)
end
self.tempId = self.configData.BossId
if not heroConfig[self.tempId] then
return
end
local herodata = heroConfig[self.tempId]
local pos = herodata.Position
local scale = herodata.Scale
self.bgName = artConfig[herodata.Painting].Name
self.Live = poolManager:LoadLive(self.bgName, self.aniRoot.transform, Vector3.one*roleConfig[self.tempId].play_liveScale, Vector2.New(pos[1],pos[2]))
self:SetBuyTime()
end
function QiJieShiLianPanel:SetBuyTime()
self.freeTime.text = string.format( "<color=#F7F8F8>免费次数:</color>%s",PrivilegeManager.GetPrivilegeRemainValue(3201))
self.buyTime.text = string.format( "<color=#F7F8F8>购买次数:</color>%s",PrivilegeManager.GetPrivilegeRemainValue(3202))
end
--设置下方滑动条
function QiJieShiLianPanel:SetTabBox()
local tabList = QiJieShiLianManager.GetTabList()
self.ScrollView:SetData(tabList, function (index, go)
Util.GetGameObject(go,"Text"):GetComponent("Text").text = tabList[index].Chapter
local state = tabList[index].QijieType == self.configData.QijieType
local name = state and "UI_hz_kuang_bg_01" or "UI_hz_kuang_bg_01"
Util.GetGameObject(go,"Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(name)
Util.GetGameObject(go,"LockImage"):SetActive(not state)
Util.AddOnceClick(go,function ()
if not state then
PopupTipPanel.ShowTip(string.format( "%s开启<color=red>【%s】试炼</color>",NumToWeek[index],tabList[index].Chapter))
end
end)
end,false,true)
local num = (self.configData.QijieType - 2) > 0 and (self.configData.QijieType - 2) or 1
self.ScrollView:SetIndex(num)
end
--设置上方信息
function QiJieShiLianPanel:SetTopBar()
local text = self.qijieData.curRank > 0 and self.qijieData.curRank or "未上榜"
local text2 = self.qijieData.curScore >= 0 and self.qijieData.curScore or "0"
self.info.text = string.format( "<color=#F7F8F8>本周排名:</color>%s <color=#F7F8F8>本周积分:</color>%s",text,text2)
self.name.text = string.format( "%s·%s层",self.configData.Chapter,self.configData.Stage)
end
--设置下方挑战信息和奖励信息
function QiJieShiLianPanel:SetBottomBar()
--设置挑战加成数据
self.addNum.text = string.format( "每满足一种获得界灵数量+%s",self.configData.ConditionValue[1][2]/100).."%"
for i = 1, #self.goalList do
local text = Util.GetGameObject(self.goalList[i],"Text"):GetComponent("Text")
local image = Util.GetGameObject(self.goalList[i],"Image"):GetComponent("Image")
local state = QiJieShiLianManager.CheckGoalIsFinish(self.configData.ConditionValue[i][1],text)--检测是否完成此条目(顺便设置文字)
local imgname = state and "UI_hz_qj_04" or "UI_hz_qj_05"
image.sprite = self.spLoader:LoadSprite(imgname)
end
--拿取奖励列表
local rewardList = {}
table.insert(rewardList,self.configData.JielingReward[1])
for i = 1, #self.configData.Reward do
table.insert(rewardList,self.configData.Reward[i])
end
--设置显示
for key, value in pairs(self.itemViewList) do
value.gameObject:SetActive(false)
end
self.ScrollView2:SetData(rewardList, function (index, go)
if not self.itemViewList[index] then
self.itemViewList[index] = SubUIManager.Open(SubUIConfig.ItemView, go.transform)
end
self.itemViewList[index]:OnOpen(false, rewardList[index], 1,false,false,false,self.sortingOrder)
self.itemViewList[index].gameObject:SetActive(true)
end,false,true)
end
--界面关闭时调用(用于子类重写)
function QiJieShiLianPanel:OnClose()
if self.Live then
poolManager:UnLoadLive(self.bgName, self.Live)
end
self.Live = nil
end
--界面销毁时调用(用于子类重写)
function QiJieShiLianPanel:OnDestroy()
self.spLoader:Destroy()
if self.Live then
poolManager:UnLoadLive(self.bgName, self.Live)
end
self.Live = nil
self.goalList = {}
self.itemViewList = {}
end
return QiJieShiLianPanel