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

333 lines
14 KiB
Lua
Raw Normal View History

2023-03-20 11:22:44 +08:00
require("Base/BasePanel")
require("View/GodsWaySingleSingleWave")
GodsWayTowerPanel = Inherit(BasePanel)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
2024-11-13 14:58:05 +08:00
local SpecialConfig = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 159)
2023-03-20 11:22:44 +08:00
local this = GodsWayTowerPanel
this.grid = {}
this.singledataList = {}
--this.singlePreList = {}
local curType = 0
local trailData = {}
local itemId = 0
local costNum = 0
local freeTimes = 0
local buyTimes = 0
local storeDataId = 0
local callBack
local screenwidth
2024-11-13 14:58:05 +08:00
local maxTime = 0
local curFloor = 0
2023-03-20 11:22:44 +08:00
local showTime
local redTrailType = {
[1] = RedPointType.PersonTrailHelp,
[2] = RedPointType.BuddishTrailHelp,
[3] = RedPointType.DemonTrailHelp,
[4] = RedPointType.TaoistTrailHelp,
}
--初始化组件(用于子类重写)
function GodsWayTowerPanel:InitComponent()
2024-11-13 14:58:05 +08:00
maxTime = tonumber(SpecialConfig.Value) * 60
screenwidth = self.gameObject.transform.rect.width
2023-03-20 11:22:44 +08:00
this.spLoader = SpriteLoader.New()
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
2024-11-13 14:58:05 +08:00
this.btnBack = Util.GetGameObject(self.gameObject, "InfoRoot/btnBack")
this.helpBtn = Util.GetGameObject(self.gameObject, "InfoRoot/help")
2023-03-28 13:57:59 +08:00
this.helpBtn:SetActive(false)
2024-11-13 14:58:05 +08:00
this.helpPosition = this.helpBtn:GetComponent("RectTransform").localPosition
2023-03-20 11:22:44 +08:00
this.pre = Util.GetGameObject(self.gameObject, "InfoRoot/pre")
2024-11-13 14:58:05 +08:00
this.grid = Util.GetGameObject(self.gameObject, "InfoRoot/grid")
2023-03-20 11:22:44 +08:00
local rootHight = this.grid.transform.rect.height
local width = this.grid.transform.rect.width
2024-11-13 14:58:05 +08:00
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.grid.transform,
this.pre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 0))
2023-03-20 11:22:44 +08:00
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
-- 挂机奖励
this.rewardList = {}
2024-11-13 14:58:05 +08:00
this.titleText = Util.GetGameObject(self.gameObject, "InfoRoot/tiitleRoot/title"):GetComponent("Text")
2023-03-20 11:22:44 +08:00
this.moppingUpBtn = Util.GetGameObject(self.gameObject, "InfoRoot/bottomLayout/moppingUpBtn")
2024-11-13 14:58:05 +08:00
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")
2023-03-20 11:22:44 +08:00
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.btnHelpFightRed = Util.GetGameObject(this.btnHelpFight, "redPoint")
2024-11-13 14:58:05 +08:00
-- this.btnHelpFight:GetComponent("Image").sprite = this.spLoader:LoadSprite("godsWayTower_treasure_zh")
this.rewardItemPre = Util.GetGameObject(self.gameObject, "InfoRoot/rewardContent/item")
this.rewardGrid = Util.GetGameObject(self.gameObject, "InfoRoot/rewardContent")
2025-03-24 20:46:48 +08:00
this.rewardTxt = Util.GetGameObject(self.gameObject, "InfoRoot/getBoxReward/time/Text"):GetComponent("Text")
--this.progress = Util.GetGameObject(self.gameObject, "InfoRoot/getBoxReward/fill"):GetComponent("Image")
2024-11-13 14:58:05 +08:00
this.rewardRed = Util.GetGameObject(self.gameObject, "InfoRoot/getBoxReward/rewardBoxRedPoint")
this.btn_reward = Util.GetGameObject(self.gameObject, "InfoRoot/getBoxReward")
2023-03-20 11:22:44 +08:00
end
--绑定事件(用于子类重写)
function GodsWayTowerPanel:BindEvent()
2024-11-13 14:58:05 +08:00
Util.AddClick(this.btnBack, function()
2023-03-20 11:22:44 +08:00
self:ClosePanel()
if callBack then callBack() end
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.helpBtn, function()
2023-03-20 11:22:44 +08:00
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.btn_reward, function()
if curFloor == 0 then
2023-03-20 11:22:44 +08:00
PopupTipPanel.ShowTip("至少通关一层才可领取挂机奖励")
return
end
2024-11-13 14:58:05 +08:00
LogError("GetTimeStamp()==" .. GetTimeStamp() .. " showTime==" .. showTime)
if GetTimeStamp() - showTime < 60 then
2023-03-20 11:22:44 +08:00
PopupTipPanel.ShowTip("累计挂机奖励中")
return
end
2024-11-13 14:58:05 +08:00
NetManager.RequestDuoDuiReward(curType, 1, function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1)
GodsWayTowerManager.SetTowerTimeByType(curType, GetTimeStamp())
showTime = GodsWayTowerManager.GetTowerTimeByType(curType)
2023-03-20 11:22:44 +08:00
this.GetBoxShowState(GetTimeStamp())
end)
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.addBtn, function()
2023-03-20 11:22:44 +08:00
if buyTimes < 1 then
PopupTipPanel.ShowTip("今日已无购买次数")
return
else
if BagManager.GetItemCountById(itemId) < costNum then
PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[itemId].Name))
return
end
2024-11-13 14:58:05 +08:00
MsgPanel.ShowTwo(string.format("是否花费%s%s购买一次扫荡次数", costNum, itemConfig[itemId].Name), function() end,
function()
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP, storeDataId, 1, function()
local buyId = GodsWayTowerManager.GetTowerBuyIdByType(curType)
PrivilegeManager.RefreshPrivilegeUsedTimes(buyId, 1)
this.UpdatePrivilage()
end)
end, "取消", "确定")
2023-03-20 11:22:44 +08:00
end
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.btnRank, function()
UIManager.OpenPanel(UIName.RankingSingleListPanel, rankKingList[curType + 48])
2023-03-20 11:22:44 +08:00
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.btnFormation, function()
UIManager.OpenPanel(UIName.GodsWayMyTeamPanel, curType)
2023-03-20 11:22:44 +08:00
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.btnHelpFight, function()
UIManager.OpenPanel(UIName.GodsWayTreasurePanel, curType)
2023-03-20 11:22:44 +08:00
end)
2024-11-13 14:58:05 +08:00
Util.AddClick(this.moppingUpBtn, function()
2023-03-20 11:22:44 +08:00
if freeTimes < 1 then
PopupTipPanel.ShowTip("扫荡次数不足")
return
end
2023-09-06 14:43:33 +08:00
-- if not ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.DuoDuiTower,"Type",curType,"TowerNumber",curFloor + 1) then
-- PopupTipPanel.ShowTip("已通关全部层数,无法继续挑战")
-- return
-- end
2023-03-20 11:22:44 +08:00
-- if FormationManager.CheckFormationValid(curType + 3000) then
-- MonsterCampManager.ExecuteFightBattle(trailData.monsterWave + 1 ,0,function() this:OnShow() end,curType,true)
-- else
-- PopupTipPanel.ShowTip("编队不能为空")
-- return
-- end
2024-11-13 14:58:05 +08:00
NetManager.RequestDuoDuiReward(curType, 2, function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1)
local freeId = GodsWayTowerManager.GetTowerFreeIdByType(curType)
2023-03-20 11:22:44 +08:00
PrivilegeManager.RefreshPrivilegeUsedTimes(freeId, 1)
self.UpdatePrivilage()
end)
end)
end
2024-11-13 14:58:05 +08:00
this.UpdatePrivilage = function()
2023-03-20 11:22:44 +08:00
-- if this.singledataList[trailData.monsterWave] then
-- this.singledataList[trailData.monsterWave]:UpdatePrivilage()
-- end
2024-11-13 14:58:05 +08:00
storeDataId, itemId, costNum = GodsWayTowerManager.GetCost(curType)
freeTimes, buyTimes = GodsWayTowerManager.GetTimeTip(curType)
2023-08-28 18:52:15 +08:00
this.freeMoppingTimes.text = freeTimes
2024-11-13 14:58:05 +08:00
this.buyMoppingTimes.text = buyTimes
end
2023-03-20 11:22:44 +08:00
--添加事件监听(用于子类重写)
function GodsWayTowerPanel:AddListener()
2024-11-13 14:58:05 +08:00
Game.GlobalEvent:AddEvent(GameEvent.FourEle.UpdatePri, self.UpdatePrivilage, self)
Game.GlobalEvent:AddEvent(GameEvent.FourEle.RefreshView, self.OnShow, self)
2023-03-20 11:22:44 +08:00
end
--移除事件监听(用于子类重写)
function GodsWayTowerPanel:RemoveListener()
2024-11-13 14:58:05 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.FourEle.UpdatePri, self.UpdatePrivilage, self)
Game.GlobalEvent:RemoveEvent(GameEvent.FourEle.RefreshView, self.OnShow, self)
2023-03-20 11:22:44 +08:00
end
--界面打开时调用(用于子类重写)
function GodsWayTowerPanel:OnOpen(index)
2024-11-13 14:58:05 +08:00
curType = index
--BindRedPointObject(redTrailType[curType],this.btnHelpFightRed)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp })
2023-03-20 11:22:44 +08:00
end
function this.GetBoxShowState(hangupTime)
-- Log("挂机时长 hangupTime " .. hangupTime)
local state = 0
2024-11-13 14:58:05 +08:00
local curTime = GetTimeStamp()
local addTime = curTime - hangupTime
if addTime > maxTime then
hangupTime = maxTime
2023-03-20 11:22:44 +08:00
else
2024-11-13 14:58:05 +08:00
hangupTime = addTime
2023-03-20 11:22:44 +08:00
end
if hangupTime < AdventureManager.adventureRefresh then
state = 0
elseif hangupTime >= AdventureManager.adventureRefresh and hangupTime < AdventureManager.adventureBoxShow[1] then
state = 1
elseif hangupTime >= AdventureManager.adventureRefresh and hangupTime < AdventureManager.adventureBoxShow[2] then
state = 2
else
state = 3
end
--FightPointPassManager.SetBoxState(state)
-- if hangupTime > (AdventureManager.adventureOffline*3600) then
-- hangupTime = AdventureManager.adventureOffline*3600
-- end
if hangupTime < 0 then
hangupTime = 0
end
this.rewardTxt.text = TimeToHM(hangupTime)
2025-03-24 20:46:48 +08:00
--this.progress.fillAmount = hangupTime / (AdventureManager.adventureOffline * 3600)
2023-03-20 11:22:44 +08:00
return state
end
--界面打开时调用(用于子类重写)
function GodsWayTowerPanel:OnShow()
LogError("刷新多队塔界面---------")
--trailData = MonsterCampManager.GetCurFourElementMonsterInfo(curType)
-- if trailData.openState == 0 then
-- self:ClosePanel()
-- return
-- end
2024-11-13 14:58:05 +08:00
curFloor = GodsWayTowerManager.GetTowerFloorByType(curType)
this.moppingUpBtn:SetActive(curFloor ~= 0)
local curId = 0
if curType == 1 then
curId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.godsWayTowerTreasure_two)
2024-01-03 15:24:49 +08:00
else
2024-11-13 14:58:05 +08:00
curId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.godsWayTowerTreasure_three)
2024-01-03 15:24:49 +08:00
end
2024-11-13 14:58:05 +08:00
this.btnHelpFight:SetActive(curId ~= 0)
storeDataId, itemId, costNum = GodsWayTowerManager.GetCost(curType)
if curType == 1 then
2024-09-12 19:29:03 +08:00
this.titleText.text = "双队比拼"
2023-03-20 11:22:44 +08:00
else
2024-09-12 19:29:03 +08:00
this.titleText.text = "三连决战"
2023-03-20 11:22:44 +08:00
end
--this.canFightWaves.text = "可挑战层数:"..trailData.canFightTime
this.canFightWaves.gameObject:SetActive(false)
2024-11-13 14:58:05 +08:00
freeTimes, buyTimes = GodsWayTowerManager.GetTimeTip(curType)
this.freeMoppingTimes.text = freeTimes
2024-11-13 14:58:05 +08:00
this.buyMoppingTimes.text = buyTimes
2023-03-20 11:22:44 +08:00
this.InitMonsterShow()
this.IntiReward()
2024-11-13 14:58:05 +08:00
showTime = GodsWayTowerManager.GetTowerTimeByType(curType)
2023-03-20 11:22:44 +08:00
this.GetBoxShowState(showTime)
-- 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
-- Timer.New(function()
2024-11-13 14:58:05 +08:00
-- UIManager.OpenPanel(UIName.RewardItemPopup,nil,nil,nil,CompShowType.fourElement,nil,nil,nil,propertyId)
-- end,0.2):Start()
2023-03-20 11:22:44 +08:00
-- local power = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
-- if power - MonsterCampManager.oldpower > 0 then
-- UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = MonsterCampManager.oldpower,newValue = power})
2024-11-13 14:58:05 +08:00
-- end
2023-03-20 11:22:44 +08:00
-- end
-- end
end
function this.SingleDataShow(go, data)
local singledata = GodsWaySingleSingleWave:New(go)
--go:GetComponent("RectTransform").sizeDelta=Vector2.New(screenwidth,380)
2024-11-13 14:58:05 +08:00
singledata:InitComponent(go, data, curType)
singledata:OnOpen()
2023-03-20 11:22:44 +08:00
return singledata
end
function this.InitMonsterShow()
--local curwaves = trailData.monsterWave + 1 --当前可挑战层
2024-11-13 14:58:05 +08:00
local monsterInfo = GodsWayTowerManager.GetTowerDataByType(curType) --MonsterCampManager.GetFourElementMonstersInfo(curType,curwaves)
LogError("monsterInfo==" .. #monsterInfo)
table.sort(monsterInfo, function(a, b) return a.wave > b.wave end)
this.scrollView:SetData(monsterInfo, function(index, go)
2023-03-20 11:22:44 +08:00
local tempData = this.SingleDataShow(go, monsterInfo[index])
this.singledataList[monsterInfo[index].wave] = tempData
--this.singlePreList[go] = this.singledataList[monsterInfo[index].wave]
2024-11-13 14:58:05 +08:00
end, true, true)
this.scrollView:SetIndex(#monsterInfo)
2023-03-20 11:22:44 +08:00
-- if MonsterCampManager.CurOffsetIndex < 0 then
-- this.scrollView:SetIndex((#monsterInfo-trailData.monsterWave-2))
-- else
-- this.scrollView:SetIndex((#monsterInfo-MonsterCampManager.CurOffsetIndex-2))
-- end
end
function this.IntiReward()
local rewardData
rewardData = GodsWayTowerManager.GetCurrFloorRewardByType(curType)
LogError("获取当前层挂机奖励")
for i = 1, #rewardData do
if not this.rewardList[i] then
local go = {}
go.item = newObjToParent(this.rewardItemPre, this.rewardGrid)
go.icon = Util.GetGameObject(go.item, "iconBg/icon"):GetComponent("Image")
go.text = Util.GetGameObject(go.item, "rewardbg/context"):GetComponent("Text")
this.rewardList[i] = go
end
this.rewardList[i].icon.sprite = SetIcon(this.spLoader, rewardData[i][1])
local addValue = FightPointPassManager.GetItemVipValue(rewardData[i][1])
local baseValue = rewardData[i][2]
if addValue - 1 <= 0 then
2024-11-13 14:58:05 +08:00
this.rewardList[i].text.text = "+" .. rewardData[i][2]
2023-03-20 11:22:44 +08:00
else
2024-11-13 14:58:05 +08:00
local valueShow = math.round((addValue - 1) * baseValue)
this.rewardList[i].text.text = string.format("+%s\n<color=#00FF00>(+%s)</color>", baseValue, valueShow)
2023-03-20 11:22:44 +08:00
end
end
end
--界面关闭时调用(用于子类重写)
2024-11-13 14:58:05 +08:00
function GodsWayTowerPanel:OnClose()
ClearRedPointObject(redTrailType[curType], this.btnHelpFightRed)
2023-03-20 11:22:44 +08:00
MonsterCampManager.CurOffsetIndex = -1
2023-03-22 14:58:19 +08:00
CheckRedPointStatus(RedPointType.godsWayTower)
2023-03-20 11:22:44 +08:00
end
--界面销毁时调用(用于子类重写)
2024-11-13 14:58:05 +08:00
function GodsWayTowerPanel:OnDestroy()
2023-03-20 11:22:44 +08:00
this.spLoader:Destroy()
2024-11-13 14:58:05 +08:00
for k, v in pairs(this.singledataList) do
2023-03-20 11:22:44 +08:00
v:OnDestroy()
end
--this.singlePreList = {}
this.singledataList = {}
SubUIManager.Close(this.scrollView)
this.spLoader:Destroy()
end
2024-11-13 14:58:05 +08:00
return GodsWayTowerPanel