miduo_client/Assets/ManagedResources/~Lua/Modules/MonsterCamp/MonsterCampNewPanel.lua

212 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")
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.helpBtn:SetActive(false)
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.moppingUpBtn = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/moppingUpBtn")
Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/moppingUpBtn/Text"):GetComponent("Text").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[10298], 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()
CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp)
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_LevleReward)
end)
end)
end,2)
end)
Util.AddClick(this.moppingUpBtn, function ()
if MonsterCampManager.monsterWave - 1 <= 0 then
PopupTipPanel.ShowTip("无法扫荡,请先挑战心魔试炼!")
return
end
if freeTimes <= 0 and buyTimes <= 0 then
PopupTipPanel.ShowTip("今日已无扫荡次数!")
return
end
local _storeDataId,_itemId,_costNum,moppingUpNum = MonsterCampManager.MonsterCampGetYJGMCost()
MsgPanel.ShowTwo(string.format("是否花费%s%s进行一键扫荡",_costNum,itemConfig[itemId].Name),function() end,function()
if BagManager.GetItemCountById(_itemId) < _costNum then
PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[itemId].Name))
else
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,storeDataId,moppingUpNum,function()
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BUY_BATTLENUM, moppingUpNum)
NetManager.SweepDemonRequest(MonsterCampManager.monsterWave - 1,true,function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup,msg.Drop,1,function()
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.MONSTERCAMP_BATTLENUM, MonsterCampManager.GetCanBattleCount() )
this.UpdatePrivilage()
end)
end)
end)
end
end,"取消","确定")
end)
BindRedPointObject(RedPointType.EpicExplore_LevleReward,Util.GetGameObject(this.btnHelpFight, "redPoint"))
end
this.UpdatePrivilage = function()
if this.singledataList[MonsterCampManager.monsterWave - 1] then
this.singledataList[MonsterCampManager.monsterWave - 1]: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()
CheckRedPointStatus(RedPointType.EpicExplore_LevleReward)
CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp)
storeDataId,itemId,costNum = MonsterCampManager.MonsterCampGetCost()
this.titleText.text = Language[12099]
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)
this.scrollView:SetIndex(#monsterInfo - MonsterCampManager.monsterWave - 1)
end
--界面关闭时调用(用于子类重写)
function MonsterCampNewPanel:OnClose()
MonsterCampManager.CurOffsetIndex = -1
end
--界面销毁时调用(用于子类重写)
function MonsterCampNewPanel:OnDestroy()
ClearRedPointObject(RedPointType.EpicExplore_LevleReward,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