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

235 lines
9.9 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)
--初始化组件(用于子类重写)
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.rightBtns = Util.GetGameObject(self.gameObject,"rightBtns")
self.rewardBtn = Util.GetGameObject(self.rightBtns,"rewardBtn")
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/freeTime"):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, 150), 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(0, 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.tempId = 10030
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.XiangYaoDuoBao,self.helpPosition.x,self.helpPosition.y)
end)
Util.AddClick(self.goalBtn,function()
UIManager.OpenPanel(UIName.GeneralInfoPopup,GENERALINFO_TYPE.QiJieGoalAttri,self.configData)
end)
Util.AddClick(self.giftBtn,function()
PopupTipPanel.ShowTip("遗物!")
end)
Util.AddClick(self.treasureBtn,function()
PopupTipPanel.ShowTip("七界秘宝!")
end)
Util.AddClick(self.rewardBtn,function()
UIManager.OpenPanel(UIName.GeneralRankRewardPanel,4,1)--需要活动id和我的排名
end)
Util.AddClick(self.sortBtn,function()
PopupTipPanel.ShowTip("排行!")
end)
Util.AddClick(self.shopBtn,function()
PopupTipPanel.ShowTip("商店!")
end)
Util.AddClick(self.goBtn,function()
PopupTipPanel.ShowTip("挑战!")
end)
Util.AddClick(self.buyBtn,function()
PopupTipPanel.ShowTip("购买次数!")
end)
Util.AddClick(self.lastBtn,function()
self.tempId = self.tempId - 1
self:Refresh()
end)
Util.AddClick(self.nextBtn,function()
self.tempId = self.tempId + 1
self:Refresh()
end)
end
--添加事件监听(用于子类重写)
function QiJieShiLianPanel:AddListener()
end
--移除事件监听(用于子类重写)
function QiJieShiLianPanel:RemoveListener()
end
--跨服
function QiJieShiLianPanel:OnOpen()
self.UpView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
end
--界面打开时调用(用于子类重写)
function QiJieShiLianPanel:OnShow()
self:Refresh()
end
function QiJieShiLianPanel:Refresh()
self.qijieData = QiJieShiLianManager.GetQiJieData()
self.configData = self.qijieData.curStageData
LogGreen("当前层数Id:"..tostring(self.qijieData.curLevelId))
self:SetTabBox()
self:SetTopBar()
self:SetBottomBar()
--设置立绘
if self.Live then
poolManager:UnLoadLive(self.bgName, self.Live)
end
LogRed("self.tempId:"..tostring(self.tempId))
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.Live].Name
self.Live = poolManager:LoadLive(self.bgName, self.aniRoot.transform, Vector3.one*scale, Vector2.New(pos[1],pos[2]))
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 "r_hero_xuanze_001" or "r_hero_xuanze_002"
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[self.configData.QijieType],self.configData.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()
self.info.text = string.format( "本周排名:%s 本周积分:%s",self.qijieData.curRank,self.qijieData.curScore)
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.Addition[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],text)--检测是否完成此条目(顺便设置文字)
local imgname = state and "q_qjsl_wfzjm_yjh" or "q_qjsl_wfzjm_wjh"
image.sprite = self.spLoader:LoadSprite(imgname)
end
--拿取奖励列表
local rewardList = {}
table.insert(rewardList,self.configData.JielingReward)
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