require("Base/BasePanel") require("View/MonsterCampSingleWave") MonsterCampNewPanel = Inherit(BasePanel) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local this = MonsterCampNewPanel this.grid = {} this.singledataList = {} local itemId = 0 local costNum = 0 local freeTimes = 0 local buyTimes = 0 local storeDataId = 0 local callBack -- local redTrailType = { -- [1] = RedPointType.PersonTrailHelp, -- [2] = RedPointType.BuddishTrailHelp, -- [3] = RedPointType.DemonTrailHelp, -- [4] = RedPointType.TaoistTrailHelp, -- } --初始化组件(用于子类重写) function MonsterCampNewPanel:InitComponent() this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform) this.btnBack = Util.GetGameObject(self.gameObject, "InfoRoot/btnBack") this.helpBtn = Util.GetGameObject(self.gameObject, "InfoRoot/help") this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition this.pre = Util.GetGameObject(self.gameObject, "InfoRoot/pre") this.grid = Util.GetGameObject(self.gameObject, "InfoRoot/grid") local rootHight = this.grid.transform.rect.height local width = this.grid.transform.rect.width this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.grid.transform, this.pre, nil, Vector2.New(1080, 1544.8), 1, 1, Vector2.New(0, 0)) this.scrollView.moveTween.MomentumAmount = 1 this.scrollView.moveTween.Strength = 2 this.titleText = Util.GetGameObject(self.gameObject, "InfoRoot/tiitleRoot/title"):GetComponent("Text") this.canFightWaves = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/canFightWaves"):GetComponent("Text") this.freeMoppingTimes = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/freeMoppingTimes"):GetComponent("Text") this.buyMoppingTimes = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/buyMoppingTimes"):GetComponent("Text") this.addBtn = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/addBtn") this.btnRank = Util.GetGameObject(self.gameObject, "InfoRoot/btnRank") this.btnHelpFight = Util.GetGameObject(self.gameObject, "InfoRoot/btnHelpFight") this.btnHelpFight:GetComponent("Image").sprite = Util.LoadSprite("g_guanka_tongguanjiangli_zh") end --绑定事件(用于子类重写) function MonsterCampNewPanel:BindEvent() Util.AddClick(this.btnBack, function () self:ClosePanel() if callBack then callBack() end end) Util.AddClick(this.helpBtn, function () UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.FoueElementPeo,this.helpPosition.x,this.helpPosition.y) end) Util.AddClick(this.addBtn, function () if buyTimes < 0 then PopupTipPanel.ShowTip("今日已无购买次数") else if BagManager.GetItemCountById(itemId) < costNum then PopupTipPanel.ShowTip(string.format(Language[10343], itemConfig[itemId].Name)) return end MsgPanel.ShowTwo(string.format("是否花费%s%s购买一次扫荡次数?",costNum,itemConfig[itemId].Name),function() end,function() ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,storeDataId,1,function() PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM, 1) this.UpdatePrivilage() end) end,"取消","确定") end end) Util.AddClick(this.btnRank, function () -- UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[4])]\ UIManager.OpenPanel(UIName.CarbonScoreSortPanel, 2) end) Util.AddClick(this.btnHelpFight, function () MonsterCampManager.preType = 2 UIManager.OpenPanel(UIName.TrialRewardPopup,MonsterCampManager.SetRewardData(),function(id,rewardFunc) NetManager.DemonsTrialRewardRequest(id, function(msg) MonsterCampManager.SetRewardWave({id}) --本地记录已领奖励信息 UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function() if rewardFunc then rewardFunc() end CheckRedPointStatus(RedPointType.EpicExplore) end) end) end,2) end) BindRedPointObject(RedPointType.EpicExplore,Util.GetGameObject(this.btnHelpFight, "redPoint")) end this.UpdatePrivilage = function() -- if this.singledataList[trailData.monsterWave] then -- this.singledataList[trailData.monsterWave]:UpdatePrivilage() -- end storeDataId,itemId,costNum = MonsterCampManager.MonsterCampGetCost() freeTimes = MonsterCampManager.GetCanBattleCount() buyTimes = MonsterCampManager.GetCanBuyBattleCount() this.freeMoppingTimes.text = "免费扫荡:" ..freeTimes this.buyMoppingTimes.text = "购买次数:" ..buyTimes end --添加事件监听(用于子类重写) function MonsterCampNewPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.MonsterCamp.UpdatePri, self.UpdatePrivilage,self) -- Game.GlobalEvent:AddEvent(GameEvent.FourEle.RefreshView, self.OnShow,self) end --移除事件监听(用于子类重写) function MonsterCampNewPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.MonsterCamp.UpdatePri, self.UpdatePrivilage,self) -- Game.GlobalEvent:RemoveEvent(GameEvent.FourEle.RefreshView, self.OnShow,self) end --界面打开时调用(用于子类重写) function MonsterCampNewPanel:OnOpen() this.UpView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp }) end --界面打开时调用(用于子类重写) function MonsterCampNewPanel:OnShow() storeDataId,itemId,costNum = MonsterCampManager.MonsterCampGetCost() this.titleText.text = Language[12099] this.canFightWaves.text = "可挑战层数:"..MonsterCampManager.monsterWave freeTimes = MonsterCampManager.GetCanBattleCount() buyTimes = MonsterCampManager.GetCanBuyBattleCount() this.freeMoppingTimes.text = "免费扫荡:" ..freeTimes this.buyMoppingTimes.text= "购买次数:" ..buyTimes this.InitMonsterShow() -- local waves = MonsterCampManager.GetFourElementTotalWave() -- if not PlayerPrefs.HasKey("FourElement"..PlayerManager.uid) then -- PlayerPrefs.SetInt("FourElement"..PlayerManager.uid,-1) -- end -- if waves ~= PlayerPrefs.GetInt("FourElement"..PlayerManager.uid) then -- PlayerPrefs.SetInt("FourElement"..PlayerManager.uid,waves) -- local propertyId = SacredTreeManager.GetUnLockNewProperty(waves) -- if propertyId > 0 then -- UIManager.OpenPanel(UIName.RewardItemPopup,nil,nil,nil,CompShowType.fourElement,nil,nil,nil,propertyId) -- local power = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) -- if power - MonsterCampManager.oldpower > 0 then -- UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = MonsterCampManager.oldpower,newValue = power}) -- end -- end -- end end function this.SingleDataShow(go, data) local singledata = MonsterCampSingleWave:New(go) singledata:InitComponent(go,data) singledata:OnOpen() return singledata end function this.InitMonsterShow() local monsterInfo = MonsterCampManager.GetMonstersInfo() table.sort(monsterInfo,function(a,b) return a.Id > b.Id end) this.scrollView:SetData(monsterInfo, function (index, go) local tempData = this.SingleDataShow(go, monsterInfo[index]) this.singledataList[monsterInfo[index].Id] = tempData end) LogYellow("MonsterCampManager.monsterWave "..MonsterCampManager.monsterWave) this.scrollView:SetIndex(#monsterInfo - MonsterCampManager.monsterWave) end --界面关闭时调用(用于子类重写) function MonsterCampNewPanel:OnClose() MonsterCampManager.CurOffsetIndex = -1 end --界面销毁时调用(用于子类重写) function MonsterCampNewPanel:OnDestroy() ClearRedPointObject(RedPointType.EpicExplore,Util.GetGameObject(this.btnHelpFight, "redPoint")) for k,v in pairs(this.singledataList) do v:OnDestroy() end this.singledataList = {} SubUIManager.Close(this.scrollView) end return MonsterCampNewPanel