241 lines
8.1 KiB
Lua
241 lines
8.1 KiB
Lua
local ShengXingYouLi = quick_class("ShengXingYouLi")
|
|
local actData={}
|
|
local itemsGrid = {}--item重复利用
|
|
local activityId
|
|
|
|
--live2D位置和大小
|
|
local NamePosSize = {
|
|
[10040] = {name = "live2d_c_yj_00040" , size = Vector3.one*0.8 , pos = Vector2.New(231,-333)},
|
|
[10086] = {name = "live2d_c_0001" , size = Vector3.one*0.8 , pos = Vector2.New(174,-926)},
|
|
[10090] = {name = "live2d_c_zn_001" , size = Vector3.one*0.8 , pos = Vector2.New(174,-960)},
|
|
[10091] = {name = "live2d_c_bgj_00091" , size = Vector3.one*0.8 , pos = Vector2.New(137,-769)},
|
|
[10092] = {name = "live2d_c_gy_00092" , size = Vector3.one*0.8 , pos = Vector2.New(171,-1060)},
|
|
}
|
|
|
|
function ShengXingYouLi:New(gameObject)
|
|
local b = {}
|
|
b.gameObject = gameObject
|
|
b.transform = gameObject.transform
|
|
setmetatable(b, { __index = ShengXingYouLi })
|
|
return b
|
|
end
|
|
|
|
function ShengXingYouLi:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.time = Util.GetGameObject(self.gameObject, "tiao/time"):GetComponent("Text")
|
|
self.itemPre = Util.GetGameObject(self.gameObject, "ItemPre3")
|
|
self.grid = Util.GetGameObject(self.gameObject, "titleImg/aniRoot")
|
|
self.scrollItem = Util.GetGameObject(self.gameObject, "scrollItem")
|
|
local rootHight = self.scrollItem.transform.rect.height
|
|
local width = self.scrollItem.transform.rect.width
|
|
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollItem.transform,
|
|
self.itemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 35))
|
|
self.ScrollView.moveTween.MomentumAmount = 1
|
|
self.ScrollView.moveTween.Strength = 2
|
|
self.effect = Util.GetGameObject(self.gameObject, "titleImg/effect")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function ShengXingYouLi:BindEvent()
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function ShengXingYouLi:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function ShengXingYouLi:RemoveListener()
|
|
end
|
|
--界面打开时调用(用于子类重写)
|
|
function ShengXingYouLi:OnOpen(_activityConfig,_index,parent)
|
|
self.actConfig = _activityConfig
|
|
self.pageIndex = _index
|
|
self.parent = parent
|
|
end
|
|
|
|
function ShengXingYouLi:OnSortingOrderChange()
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function ShengXingYouLi:OnShow(_sortingOrder)
|
|
self.sortingOrder = _sortingOrder
|
|
self.gameObject:SetActive(true)
|
|
Util.SetParticleSortLayer(self.effect, self.sortingOrder + 1)
|
|
self.actId = self.actConfig.ActId
|
|
self.actType = self.actConfig.ActiveType > 0 and self.actConfig.ActiveType or self.actConfig.FunType
|
|
if self.actConfig.IfBack == 1 then
|
|
if self.actConfig.ActiveType > 0 then
|
|
local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType)
|
|
if id and id > 0 then
|
|
self.actId = id
|
|
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups,"PageType",self.actConfig.PageType,"ActiveType",self.actConfig.ActiveType,"ActId",id)
|
|
if config then
|
|
self.actConfig = config
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
self:OnShowData(true,true)
|
|
self:SetTime()
|
|
self:ShowLive()
|
|
end
|
|
function ShengXingYouLi:OnShowData(isTop,isAni)
|
|
actData={}
|
|
actData = DynamicActivityManager.ShengXingYouLiGetData()
|
|
activityId = actData.activityId
|
|
if actData.mission then
|
|
self:SortData(actData.mission)
|
|
self.ScrollView:SetData(actData.mission, function (index, go)
|
|
self:SingleDataShow(go, actData.mission[index])
|
|
end,not isTop,not isAni)
|
|
end
|
|
|
|
end
|
|
|
|
function ShengXingYouLi:ShowLive()
|
|
self.bgName = NamePosSize[actData.heroId].name
|
|
if self.Live then
|
|
poolManager:UnLoadLive(self.bgName, self.Live)
|
|
end
|
|
self.Live = poolManager:LoadLive(self.bgName, self.grid.transform, NamePosSize[actData.heroId].size, NamePosSize[actData.heroId].pos)
|
|
end
|
|
|
|
--刷新每一条的显示数据
|
|
function ShengXingYouLi:SingleDataShow(pre,value)
|
|
if pre==nil or value==nil then
|
|
return
|
|
end
|
|
--绑定组件
|
|
local sData = value
|
|
local btnText = Util.GetGameObject(pre, "btnGet/btn"):GetComponent("Text")
|
|
local btnGet = Util.GetGameObject(pre, "btnGet")
|
|
local btnGo = Util.GetGameObject(pre, "btnGo")
|
|
local grid = Util.GetGameObject(pre, "scrollView/grid")
|
|
local shadow = Util.GetGameObject(pre, "shadow")
|
|
local finishImg = Util.GetGameObject(pre, "finish")
|
|
local redPot = Util.GetGameObject(pre, "btnGet/redPoint")
|
|
local text = Util.GetGameObject(pre, "titleImage/titleText"):GetComponent("Text")
|
|
|
|
local canDo = 0
|
|
if sData.progress >= sData.need then
|
|
if sData.state == 0 then
|
|
canDo = 1
|
|
else
|
|
canDo = 2
|
|
end
|
|
end
|
|
btnGo:SetActive(canDo == 0)
|
|
btnGet:SetActive(canDo == 1)
|
|
redPot:SetActive(canDo == 1)
|
|
finishImg:SetActive(canDo == 2)
|
|
text.text = sData.word
|
|
|
|
local shows = sData.reward
|
|
--滚动条复用重设itemview
|
|
if itemsGrid[pre] then
|
|
for i = 1, 4 do
|
|
itemsGrid[pre][i].gameObject:SetActive(false)
|
|
end
|
|
for i = 1, #shows do
|
|
if itemsGrid[pre][i] then
|
|
itemsGrid[pre][i]:OnOpen(false, {shows[i][1],shows[i][2]}, 0.9,false,false,false,self.sortingOrder)
|
|
itemsGrid[pre][i].gameObject:SetActive(true)
|
|
end
|
|
end
|
|
else
|
|
itemsGrid[pre]={}
|
|
for i = 1, 4 do
|
|
itemsGrid[pre][i] = SubUIManager.Open(SubUIConfig.ItemView, grid.transform)
|
|
itemsGrid[pre][i].gameObject:SetActive(false)
|
|
local obj= newObjToParent(shadow,itemsGrid[pre][i].transform)
|
|
obj.transform:SetAsFirstSibling()
|
|
obj.transform:DOAnchorPos(Vector3(0,-3,0),0)
|
|
obj:GetComponent("RectTransform").transform.localScale=Vector3.one*1.1
|
|
obj.gameObject:SetActive(true)
|
|
end
|
|
for i = 1, #shows do
|
|
itemsGrid[pre][i]:OnOpen(false, {shows[i][1],shows[i][2]}, 0.9,false,false,false,self.sortingOrder)
|
|
itemsGrid[pre][i].gameObject:SetActive(true)
|
|
end
|
|
end
|
|
|
|
Util.AddOnceClick(btnGet,function ()
|
|
if canDo == 1 then
|
|
NetManager.GetActivityRewardRequest(sData.missionId,activityId,function (drop)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function ()
|
|
self:OnShowData(false,false)
|
|
CheckRedPointStatus(RedPointType.ShengXingYouLi)
|
|
end)
|
|
end)
|
|
end
|
|
end)
|
|
|
|
Util.AddOnceClick(btnGo,function ()
|
|
JumpManager.GoJump(sData.jump)
|
|
end)
|
|
|
|
end
|
|
|
|
function ShengXingYouLi:SortData(tempData)
|
|
if tempData==nil then
|
|
return
|
|
end
|
|
table.sort(tempData, function(a,b)
|
|
if a.state == b.state then
|
|
return a.missionId < b.missionId
|
|
else
|
|
return a.state < b.state
|
|
end
|
|
end)
|
|
end
|
|
|
|
function ShengXingYouLi:SetTime()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
local endTime = actData.endTime--ActivityGiftManager.GetTaskEndTime(ActivityTypeDef.DynamicAct_Treasure)
|
|
local timeDown = endTime - GetTimeStamp()
|
|
self.time.text = Language[10470]..TimeToDHMS(timeDown)
|
|
self.timer = Timer.New(function()
|
|
self.time.text = Language[10470]..TimeToDHMS(timeDown)
|
|
if timeDown < 1 then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
self.parent:ClosePanel()
|
|
return
|
|
end
|
|
timeDown = timeDown - 1
|
|
end, 1, -1, true)
|
|
self.timer:Start()
|
|
end
|
|
|
|
function ShengXingYouLi:OnClose()
|
|
self.gameObject:SetActive(false)
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
if self.Live then
|
|
poolManager:UnLoadLive(self.bgName, self.Live)
|
|
end
|
|
self.Live = nil
|
|
self.sortingOrder = 0
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function ShengXingYouLi:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
if self.timer then
|
|
self.timer:Stop()
|
|
self.timer = nil
|
|
end
|
|
if self.Live then
|
|
poolManager:UnLoadLive(self.bgName, self.Live)
|
|
end
|
|
self.Live = nil
|
|
self.sortingOrder = 0
|
|
end
|
|
|
|
return ShengXingYouLi |