263 lines
11 KiB
Lua
263 lines
11 KiB
Lua
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 screenwidth
|
|
local isClick = false
|
|
-- local redTrailType = {
|
|
-- [1] = RedPointType.PersonTrailHelp,
|
|
-- [2] = RedPointType.BuddishTrailHelp,
|
|
-- [3] = RedPointType.DemonTrailHelp,
|
|
-- [4] = RedPointType.TaoistTrailHelp,
|
|
-- }
|
|
--初始化组件(用于子类重写)
|
|
function MonsterCampNewPanel:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
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")
|
|
screenwidth = self.gameObject.transform.rect.width
|
|
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(width, rootHight), 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 = Language
|
|
[11896]
|
|
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.btnFormation = Util.GetGameObject(self.gameObject, "InfoRoot/btnFormation")
|
|
this.btnHelpFight = Util.GetGameObject(self.gameObject, "InfoRoot/btnHelpFight")
|
|
this.hintTxt = Util.GetGameObject(self.gameObject, "InfoRoot/hintTxt"):GetComponent("Text")
|
|
this.hintTxt.fontSize = 40
|
|
this.hintTxt.text = Language[11897]
|
|
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(Language[11884])
|
|
else
|
|
if BagManager.GetItemCountById(itemId) < costNum then
|
|
PopupTipPanel.ShowTip(string.format(Language[10320], GetLanguageStrById(itemConfig[itemId].Name)))
|
|
return
|
|
end
|
|
MsgPanel.ShowTwo(string.format(Language[10684], costNum, GetLanguageStrById(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, Language[10685], Language[10686])
|
|
end
|
|
end)
|
|
Util.AddClick(this.btnRank, function()
|
|
-- UIManager.OpenPanel(UIName.RankingSingleListPanel,rankKingList[4])]\
|
|
UIManager.OpenPanel(UIName.CarbonScoreSortPanel, 2)
|
|
end)
|
|
Util.AddClick(this.btnFormation, function()
|
|
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.MONSTER_CAMP, 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()
|
|
local waveConfig = ConfigManager.TryGetConfigData(ConfigName.FloodConfig, MonsterCampManager.monsterWave)
|
|
if not waveConfig then
|
|
PopupTipPanel.ShowTip(Language[11898])
|
|
return
|
|
end
|
|
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()
|
|
end
|
|
end
|
|
end)
|
|
BindRedPointObject(RedPointType.EpicExplore_LevleReward, Util.GetGameObject(this.btnHelpFight, "redPoint"))
|
|
end
|
|
|
|
--快速战斗
|
|
function this.QuickStartMonsterFightRequest()
|
|
if isClick then
|
|
return
|
|
end
|
|
isClick = true
|
|
-- 请求战斗结果
|
|
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
|
|
UIManager.OpenPanel(UIName.BattleFailPopup, nil, true, UIName.MonsterCampNewPanel, BATTLE_TYPE.MONSTER_CAMP)
|
|
isClick = false
|
|
else
|
|
Timer.New(function()
|
|
isClick = false
|
|
end, 1):Start()
|
|
MonsterCampManager.SetMonsterCampCurWave(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
|
|
|
|
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 = Language[11887] .. freeTimes
|
|
this.buyMoppingTimes.text = Language[11643] .. buyTimes
|
|
end
|
|
--添加事件监听(用于子类重写)
|
|
function MonsterCampNewPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.MonsterCamp.UpdatePri, self.UpdatePrivilage, self)
|
|
-- Game.GlobalEvent:AddEvent(GameEvent.MonsterCamp.UpdatePanel, this.OnShowPanel)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function MonsterCampNewPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.MonsterCamp.UpdatePri, self.UpdatePrivilage, self)
|
|
-- Game.GlobalEvent:RemoveEvent(GameEvent.MonsterCamp.UpdatePanel, this.OnShowPanel)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function MonsterCampNewPanel:OnOpen()
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp })
|
|
isClick = false
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function MonsterCampNewPanel:OnShow()
|
|
this.sortingOrder = self.sortingOrder
|
|
this.OnShowPanel()
|
|
end
|
|
|
|
function this.OnShowPanel()
|
|
local mission = ActivityGiftManager.GetActivityInfo(ActivityTypeDef.shuaChongTeQuan, 2202)
|
|
local isBuy = OperatingManager.IsBuyGift(2202) or OperatingManager.IsBuyGift(2203) or
|
|
OperatingManager.IsBuyGift(2204) or PrivilegeManager.GetPrivilegeRemainValue(2038) > 0 or
|
|
(mission and mission.state > 0)
|
|
--local isBuy=PrivilegeManager.GetPrivilegeRemainValue(2038)>0
|
|
if isBuy then
|
|
this.moppingUpBtn:SetActive(true)
|
|
this.hintTxt.gameObject:SetActive(false)
|
|
else
|
|
this.moppingUpBtn:SetActive(false)
|
|
this.hintTxt.gameObject:SetActive(true)
|
|
end
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
|
CheckRedPointStatus(RedPointType.EpicExplore_LevleReward)
|
|
CheckRedPointStatus(RedPointType.EpicExplore_MoppingUp)
|
|
CheckRedPointStatus(RedPointType.DemonSlayerNew)
|
|
storeDataId, itemId, costNum = MonsterCampManager.MonsterCampGetCost()
|
|
this.titleText.text = Language[11899]
|
|
freeTimes = MonsterCampManager.GetCanBattleCount()
|
|
buyTimes = MonsterCampManager.GetCanBuyBattleCount()
|
|
this.freeMoppingTimes.text = Language[11887] .. freeTimes
|
|
this.buyMoppingTimes.text = Language[11643] .. buyTimes
|
|
this.InitMonsterShow()
|
|
PatFaceManager.RefreshPatface()
|
|
end
|
|
|
|
function this.SingleDataShow(go, data)
|
|
local singledata = MonsterCampSingleWave:New(go)
|
|
go:GetComponent("RectTransform").sizeDelta = Vector2.New(screenwidth, 380)
|
|
singledata:InitComponent(go, data)
|
|
singledata:OnOpen(this.sortingOrder)
|
|
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, true, true)
|
|
LogError("#monsterInfo==" .. #monsterInfo .. " MonsterCampManager.monsterWave==" ..
|
|
MonsterCampManager.monsterWave)
|
|
--this.scrollView:SetIndex(#monsterInfo - MonsterCampManager.monsterWave - 1)
|
|
this.scrollView:SetIndex(10)
|
|
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)
|
|
|
|
this.spLoader:Destroy()
|
|
end
|
|
|
|
return MonsterCampNewPanel
|