2021-05-25 14:51:26 +08:00
|
|
|
|
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
|
2021-07-03 18:28:18 +08:00
|
|
|
|
local screenwidth
|
2021-07-12 16:35:54 +08:00
|
|
|
|
local isClick = false
|
2021-05-25 14:51:26 +08:00
|
|
|
|
-- local redTrailType = {
|
|
|
|
|
-- [1] = RedPointType.PersonTrailHelp,
|
|
|
|
|
-- [2] = RedPointType.BuddishTrailHelp,
|
|
|
|
|
-- [3] = RedPointType.DemonTrailHelp,
|
|
|
|
|
-- [4] = RedPointType.TaoistTrailHelp,
|
|
|
|
|
-- }
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function MonsterCampNewPanel:InitComponent()
|
2021-05-28 14:18:41 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2021-05-25 14:51:26 +08:00
|
|
|
|
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
|
|
|
|
|
|
|
|
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "InfoRoot/btnBack")
|
2021-05-25 20:50:23 +08:00
|
|
|
|
this.helpBtn = Util.GetGameObject(self.gameObject, "InfoRoot/help")
|
|
|
|
|
this.helpBtn:SetActive(false)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
this.pre = Util.GetGameObject(self.gameObject, "InfoRoot/pre")
|
2021-07-03 18:28:18 +08:00
|
|
|
|
this.grid = Util.GetGameObject(self.gameObject, "InfoRoot/grid")
|
|
|
|
|
screenwidth=self.gameObject.transform.rect.width
|
2021-05-25 14:51:26 +08:00
|
|
|
|
local rootHight = this.grid.transform.rect.height
|
|
|
|
|
local width = this.grid.transform.rect.width
|
|
|
|
|
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.grid.transform,
|
2021-07-03 18:28:18 +08:00
|
|
|
|
this.pre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 0))
|
2021-05-25 14:51:26 +08:00
|
|
|
|
this.scrollView.moveTween.MomentumAmount = 1
|
|
|
|
|
this.scrollView.moveTween.Strength = 2
|
|
|
|
|
|
|
|
|
|
this.titleText = Util.GetGameObject(self.gameObject, "InfoRoot/tiitleRoot/title"):GetComponent("Text")
|
2021-05-25 20:50:23 +08:00
|
|
|
|
this.moppingUpBtn = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/moppingUpBtn")
|
2021-07-06 16:50:48 +08:00
|
|
|
|
Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/moppingUpBtn/Text"):GetComponent("Text").text = "快速挑战"
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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")
|
2021-06-09 20:12:11 +08:00
|
|
|
|
this.btnHelpFight:GetComponent("Image").sprite = this.spLoader:LoadSprite("g_guanka_tongguanjiangli_zh")
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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 ()
|
2021-05-26 10:00:30 +08:00
|
|
|
|
if buyTimes <= 0 then
|
2021-05-25 14:51:26 +08:00
|
|
|
|
PopupTipPanel.ShowTip("今日已无购买次数")
|
|
|
|
|
else
|
|
|
|
|
if BagManager.GetItemCountById(itemId) < costNum then
|
2021-05-25 20:50:23 +08:00
|
|
|
|
PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[itemId].Name))
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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)
|
2021-05-26 11:48:44 +08:00
|
|
|
|
this.UpdatePrivilage()
|
|
|
|
|
CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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
|
2021-05-26 11:48:44 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.EpicExplore_LevleReward)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end,2)
|
|
|
|
|
end)
|
2021-05-25 20:50:23 +08:00
|
|
|
|
Util.AddClick(this.moppingUpBtn, function ()
|
2021-10-28 17:59:56 +08:00
|
|
|
|
local waveConfig = ConfigManager.GetConfigData(ConfigName.FloodConfig,MonsterCampManager.monsterWave)
|
|
|
|
|
if not waveConfig then
|
|
|
|
|
PopupTipPanel.ShowTip("已通过最高层,无法快速挑战!")
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-07-06 16:50:48 +08:00
|
|
|
|
if FormationManager.CheckFormationValid(FormationTypeDef.MONSTER_CAMP_ATTACK) then
|
|
|
|
|
this.QuickStartMonsterFightRequest()
|
|
|
|
|
else
|
|
|
|
|
local formationList = FormationManager.GetFormationByID(FormationTypeDef.MONSTER_CAMP_ATTACK)
|
|
|
|
|
if formationList.teamHeroInfos > 0 then
|
|
|
|
|
this.QuickStartMonsterFightRequest()
|
2021-05-26 11:48:44 +08:00
|
|
|
|
end
|
2021-07-06 16:50:48 +08:00
|
|
|
|
end
|
2021-05-25 20:50:23 +08:00
|
|
|
|
end)
|
2021-05-26 11:48:44 +08:00
|
|
|
|
BindRedPointObject(RedPointType.EpicExplore_LevleReward,Util.GetGameObject(this.btnHelpFight, "redPoint"))
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-07-06 16:50:48 +08:00
|
|
|
|
--快速战斗
|
|
|
|
|
function this.QuickStartMonsterFightRequest()
|
2021-07-08 18:08:16 +08:00
|
|
|
|
if isClick then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
isClick = true
|
2021-07-06 16:50:48 +08:00
|
|
|
|
-- 请求战斗结果
|
|
|
|
|
NetManager.GetMonsterFightResult(MonsterCampManager.monsterWave, FormationTypeDef.MONSTER_CAMP_ATTACK, function (msg)
|
|
|
|
|
local result = {}
|
|
|
|
|
result.drop = msg.enventDrop
|
|
|
|
|
-- 设置战斗数据用于统计战斗
|
|
|
|
|
local _fightData = BattleManager.GetBattleServerData(msg)
|
|
|
|
|
BattleRecordManager.SetBattleRecord(_fightData)
|
|
|
|
|
--用一个变量接收最近的战斗结果
|
|
|
|
|
this.lastBattleResult = {
|
|
|
|
|
result = msg.result,
|
|
|
|
|
hpList = {},
|
|
|
|
|
drop = msg.enventDrop,
|
|
|
|
|
}
|
|
|
|
|
BattleManager.SetLastBattleResult(this.lastBattleResult,BATTLE_TYPE.MONSTER_CAMP)
|
|
|
|
|
if msg.result == 0 then
|
2021-07-23 17:43:30 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.BattleFailPopup, nil, true, UIName.MonsterCampNewPanel,BATTLE_TYPE.MONSTER_CAMP)
|
2021-07-08 18:08:16 +08:00
|
|
|
|
isClick = false
|
2021-07-06 16:50:48 +08:00
|
|
|
|
else
|
2021-07-12 16:35:54 +08:00
|
|
|
|
Timer.New(function ()
|
|
|
|
|
isClick = false
|
|
|
|
|
end,1):Start()
|
2021-07-06 16:50:48 +08:00
|
|
|
|
MonsterCampManager.monsterWave = MonsterCampManager.monsterWave + 1
|
|
|
|
|
UIManager.OpenPanel(UIName.BattleWinPopup, nil, false, BATTLE_TYPE.MONSTER_CAMP, result, true, true,function()
|
|
|
|
|
-- UIManager.OpenPanel(UIName.RewardItemPopup,msg.enventDrop,1,function()
|
|
|
|
|
this.OnShowPanel()--刷新界面
|
|
|
|
|
-- end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2021-05-25 14:51:26 +08:00
|
|
|
|
this.UpdatePrivilage = function()
|
2021-05-25 20:50:23 +08:00
|
|
|
|
if this.singledataList[MonsterCampManager.monsterWave - 1] then
|
|
|
|
|
this.singledataList[MonsterCampManager.monsterWave - 1]:UpdatePrivilage()
|
|
|
|
|
end
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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)
|
2021-05-27 14:06:20 +08:00
|
|
|
|
-- Game.GlobalEvent:AddEvent(GameEvent.MonsterCamp.UpdatePanel, this.OnShowPanel)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function MonsterCampNewPanel:RemoveListener()
|
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MonsterCamp.UpdatePri, self.UpdatePrivilage,self)
|
2021-05-27 14:06:20 +08:00
|
|
|
|
-- Game.GlobalEvent:RemoveEvent(GameEvent.MonsterCamp.UpdatePanel, this.OnShowPanel)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function MonsterCampNewPanel:OnOpen()
|
|
|
|
|
this.UpView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp })
|
2021-07-12 16:35:54 +08:00
|
|
|
|
isClick = false
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function MonsterCampNewPanel:OnShow()
|
2021-09-02 11:19:29 +08:00
|
|
|
|
this.sortingOrder = self.sortingOrder
|
2021-05-27 11:07:32 +08:00
|
|
|
|
this.OnShowPanel()
|
|
|
|
|
end
|
|
|
|
|
function this.OnShowPanel()
|
2021-06-10 14:43:45 +08:00
|
|
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
2021-05-26 15:47:29 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.EpicExplore_LevleReward)
|
|
|
|
|
CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp)
|
2021-10-28 16:03:23 +08:00
|
|
|
|
CheckRedPointStatus(RedPointType.DemonSlayerNew)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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()
|
2021-05-27 11:07:32 +08:00
|
|
|
|
PatFaceManager.RefreshPatface()
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
function this.SingleDataShow(go, data)
|
|
|
|
|
local singledata = MonsterCampSingleWave:New(go)
|
2021-07-03 18:28:18 +08:00
|
|
|
|
go:GetComponent("RectTransform").sizeDelta=Vector2.New(screenwidth,380)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
singledata:InitComponent(go,data)
|
2021-09-02 11:19:29 +08:00
|
|
|
|
singledata:OnOpen(this.sortingOrder)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
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
|
2021-05-27 11:07:32 +08:00
|
|
|
|
end,true,true)
|
2021-05-26 11:48:44 +08:00
|
|
|
|
this.scrollView:SetIndex(#monsterInfo - MonsterCampManager.monsterWave - 1)
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function MonsterCampNewPanel:OnClose()
|
|
|
|
|
MonsterCampManager.CurOffsetIndex = -1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function MonsterCampNewPanel:OnDestroy()
|
2021-05-26 11:48:44 +08:00
|
|
|
|
ClearRedPointObject(RedPointType.EpicExplore_LevleReward,Util.GetGameObject(this.btnHelpFight, "redPoint"))
|
2021-05-25 14:51:26 +08:00
|
|
|
|
for k,v in pairs(this.singledataList) do
|
|
|
|
|
v:OnDestroy()
|
|
|
|
|
end
|
|
|
|
|
this.singledataList = {}
|
|
|
|
|
SubUIManager.Close(this.scrollView)
|
2021-05-28 14:18:41 +08:00
|
|
|
|
|
|
|
|
|
this.spLoader:Destroy()
|
2021-05-25 14:51:26 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return MonsterCampNewPanel
|