local XinJiangLaiXi = quick_class("XinJiangLaiXi") local this=XinJiangLaiXi local allData={} local itemsGrid = {}--item重复利用 local sortingOrder = 0 local parent = {} -- local properTypeConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) -- local rechargeConfigId = 0 -- local rechargeData = {} -- local fakeId = 0 this.LiveObj = nil function XinJiangLaiXi:ctor(mainPanel, gameObject) this.mainPanel = mainPanel.transform this.gameObject = gameObject this:InitComponent() this:BindEvent() end function XinJiangLaiXi:InitComponent() this.time = Util.GetGameObject(this.gameObject, "time/times"):GetComponent("Text") this.money = Util.GetGameObject(this.gameObject, "money/times"):GetComponent("Text") this.fightBtn = Util.GetGameObject(this.gameObject, "layout/fightBtn") this.storeBtn = Util.GetGameObject(this.gameObject, "storeBtn") this.helpBtn = Util.GetGameObject(this.gameObject, "helpBtn") this.scrollItem = Util.GetGameObject(this.gameObject, "scroller/grid") this.liveRoot = Util.GetGameObject(this.gameObject, "bg/liveRoot") this.tip1 = Util.GetGameObject(this.gameObject, "layout/Text1"):GetComponent("Text") this.tip2 = Util.GetGameObject(this.gameObject, "layout/Text2"):GetComponent("Text") this.addBtn = Util.GetGameObject(this.gameObject, "layout/addBtn") --shop this.tabList = Util.GetGameObject(this.mainPanel,"bg/tabbox") this.btnBack = Util.GetGameObject(this.mainPanel,"bg/btnBack") this.bottomBar = Util.GetGameObject(this.mainPanel,"bg/bottomBar") this.shop = Util.GetGameObject(this.gameObject,"shop") this.shopBack = Util.GetGameObject(this.shop,"shopBack/btnBack") this.content = Util.GetGameObject(this.shop,"content") end --绑定事件(用于子类重写) function XinJiangLaiXi:BindEvent() Util.AddClick(this.fightBtn,function() local fdata, fseed = BattleManager.GetFakeBattleData(1006) local testFightData = { fightData = fdata, fightSeed = fseed, fightType = 0, maxRound = 20 } UIManager.OpenPanel(UIName.BattlePanel, testFightData, BATTLE_TYPE.Test) end) Util.AddClick(this.storeBtn,function() this.shop:SetActive(true) this.btnBack:SetActive(false) this.tabList:SetActive(false) this.bottomBar:SetActive(false) this:StoreShow()--商店 end) Util.AddClick(this.shopBack,function() this.shop:SetActive(false) this.btnBack:SetActive(true) this.tabList:SetActive(true) this.bottomBar:SetActive(true) end) end --添加事件监听(用于子类重写) function XinJiangLaiXi:AddListener() end --移除事件监听(用于子类重写) function XinJiangLaiXi:RemoveListener() end --界面打开时调用(用于子类重写) function XinJiangLaiXi:OnOpen() end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function XinJiangLaiXi:OnShow(_sortingOrder,_parent) parent = _parent sortingOrder = _sortingOrder allData = DynamicActivityManager.XinJiangBuildData() XinJiangLaiXi:OnShowData() XinJiangLaiXi:SetTime() end function XinJiangLaiXi:OnShowData() if not itemsGrid then itemsGrid = {} end for k,v in ipairs(itemsGrid) do v.gameObject:SetActive(false) end for i = 1,#allData.reward do if not itemsGrid[i] then itemsGrid[i] = SubUIManager.Open(SubUIConfig.ItemView,this.scrollItem.transform) end itemsGrid[i].gameObject:SetActive(true) itemsGrid[i]:OnOpen(false, allData.reward[i], 1,false,false,false,sortingOrder) end if this.LiveObj then poolManager:UnLoadLive(this.LiveObj.name,this.LiveObj) this.LiveObj = nil end this.LiveObj = poolManager:LoadLive("live2d_c_dj_0008",this.liveRoot.transform, Vector3.one, Vector3.zero) this.tip1.text = "剩余挑战次数:"..""..allData.fightTime.."" this.tip2.text = "剩余购买次数:"..""..allData.buyTime.."" this.money.text = allData.money end function XinJiangLaiXi:SetTime() if self.timer then self.timer:Stop() self.timer = nil end local timeDown = allData.endTime - GetTimeStamp() this.time.text = Language[12321]..TimeToFelaxible(timeDown) self.timer = Timer.New(function() timeDown = timeDown - 1 if timeDown < 1 then self.timer:Stop() self.timer = nil parent:ClosePanel() return end this.time.text = Language[12321]..TimeToFelaxible(timeDown) end, 1, -1, true) self.timer:Start() end --界面打开时调用(用于子类重写) function XinJiangLaiXi:OnOpen() end --商店 function XinJiangLaiXi:StoreShow() if not this.shopView then this.shopView = SubUIManager.Open(SubUIConfig.ShopView, this.content.transform) end this.shopView:ShowShop(SHOP_TYPE.XINJIANG_SHOP,sortingOrder) end function XinJiangLaiXi:OnClose() end --界面销毁时调用(用于子类重写) function XinJiangLaiXi:OnDestroy() if self.timer then self.timer:Stop() self.timer = nil end -- if this.LiveObj then -- poolManager:UnLoadLive(this.LiveObj.name,this.LiveObj) -- this.LiveObj = nil -- end sortingOrder = 0 -- itemsGrid = {} end function XinJiangLaiXi:OnHide() if self.timer then self.timer:Stop() self.timer = nil end sortingOrder = 0 end return XinJiangLaiXi