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

275 lines
9.8 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
MonsterCampPanel = Inherit(BasePanel)
local this = MonsterCampPanel
local orginLayer
local monsterGroup = ConfigManager.GetConfig(ConfigName.MonsterGroup)
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
--初始化组件(用于子类重写)
function MonsterCampPanel:InitComponent()
orginLayer = 0
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack")
this.waveNum = Util.GetGameObject(self.gameObject, "Bg/waveImg/wave"):GetComponent("Text")
this.btnFight = Util.GetGameObject(self.gameObject, "Bg/btnFight")
this.nextWave = Util.GetGameObject(self.gameObject, "Bg/btnWave")
this.btnRank = Util.GetGameObject(self.gameObject, "Bg/btnRank")
this.btnReward = Util.GetGameObject(self.gameObject, "Bg/btnReward")
2020-05-09 13:31:21 +08:00
-- 跳过战斗
this.battleJumpRoot = Util.GetGameObject(self.gameObject, "passBattle")
this.battleToggleBg = Util.GetGameObject(this.battleJumpRoot, "Background")
this.battleToggle = Util.GetGameObject(this.battleJumpRoot, "Background/Checkmark")
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
this.effect = Util.GetGameObject(self.gameObject, "MonsterCampPanel_effect (1)")
effectAdapte(Util.GetGameObject(this.effect, "lizi/ziti mask"))
--怪物预览
--this.nameTxt = Util.GetGameObject(self.gameObject, "Bg/name"):GetComponent("Text")
--this.lvlTxt = Util.GetGameObject(self.gameObject, "Bg/lv"):GetComponent("Text")
this.rewardList = Util.GetGameObject(self.gameObject, "Bg/reward/rewardlist")
this.power=Util.GetGameObject(self.gameObject,"Bg/powerBg/power"):GetComponent("Text")
this.rewardItemList = {}
2020-06-08 13:57:30 +08:00
for i = 1, 8 do
2020-05-09 13:31:21 +08:00
this.rewardItemList[i] = SubUIManager.Open(SubUIConfig.ItemView, this.rewardList.transform)
this.rewardItemList[i].gameObject:SetActive(false)
end
this.btnText = Util.GetGameObject(self.gameObject, "Bg/btnFight/Text"):GetComponent("Text")
--4个妖怪头像
this.monsterRoot = Util.GetGameObject(self.gameObject, "Bg/monsterRoot")
this.monsterList = {}
for i = 1, 6 do
this.monsterList[i] = Util.GetGameObject(this.monsterRoot, "monterRoot/frame_" .. i)
end
end
--绑定事件(用于子类重写)
function MonsterCampPanel:BindEvent()
Util.AddClick(this.btnBack, function ()
2020-05-25 19:16:23 +08:00
-- UIManager.OpenPanel(UIName.MainPanel)
2020-07-28 20:51:28 +08:00
PlayerManager.carbonType = 1
UIManager.OpenPanel(UIName.CarbonTypePanelV2)
2020-05-09 13:31:21 +08:00
self:ClosePanel()
end)
Util.AddClick(this.nextWave, function ()
UIManager.OpenPanel(UIName.NextMonsterInfoPopup, function ()
this.effect:SetActive(true)
end)
-- 隐藏特效
this.effect:SetActive(false)
end)
Util.AddClick(this.btnFight, function ()
-- 打到最高波次时提示
if MonsterCampManager.monsterWave > MonsterCampManager.GetMaxNum() then
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11397])
2020-05-09 13:31:21 +08:00
return
end
2020-05-25 19:16:23 +08:00
-- if this.ShowTip() then
-- return
-- end
2020-05-09 13:31:21 +08:00
if MonsterCampManager.monsterWave > 1 then
if MonsterCampManager.GetBattleJump() then -- 跳过战斗
this.GetQuickResult()
2020-06-23 18:36:24 +08:00
Log(Language[11398])
2020-05-09 13:31:21 +08:00
else
this.GoBattle()
end
else
this.GoBattle()
end
end)
Util.AddClick(this.btnRank, function ()
UIManager.OpenPanel(UIName.CarbonScoreSortPanel, 2, function ()
this.effect:SetActive(true)
end)
-- 隐藏特效
this.effect:SetActive(false)
end)
Util.AddClick(this.battleJumpRoot, function ()
if not MonsterCampManager.CheckBattleJump() then
PopupTipPanel.ShowTip(PrivilegeManager.GetPrivilegeOpenTip(PRIVILEGE_TYPE.MonsterCampJump))
return
end
local isOn = MonsterCampManager.GetBattleJump()
MonsterCampManager.SetBattleJump(not isOn)
this.InitShow()
end)
Util.AddClick(this.btnReward, function ()
UIManager.OpenPanel(UIName.TrialRewardPopup,MonsterCampManager.SetRewardData(),function(id,rewardFunc)
NetManager.RequestLevelReward(id, function(msg)
MonsterCampManager.SetRewardWave({id}) --本地记录已领奖励信息
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
if rewardFunc then
rewardFunc()
end
CheckRedPointStatus(RedPointType.TrialReward)
CheckRedPointStatus(RedPointType.Trial)
end)
end)
end)
end)
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function MonsterCampPanel:AddListener()
end
--移除事件监听(用于子类重写)
function MonsterCampPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function MonsterCampPanel:OnOpen(...)
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp })
-- 初始化界面数据
this.InitShow()
this.ChangePreview()
end
function MonsterCampPanel:OnSortingOrderChange()
Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
end
--界面关闭时调用(用于子类重写)
function MonsterCampPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function MonsterCampPanel:OnDestroy()
SubUIManager.Close(this.UpView)
end
function this.InitShow()
this.effect:SetActive(true)
this.waveNum.text = MonsterCampManager.monsterWave
2020-06-13 11:47:13 +08:00
this.battleJumpRoot:SetActive(false)--MonsterCampManager.monsterWave > 1)
2020-05-09 13:31:21 +08:00
if MonsterCampManager.CheckBattleJump() then
this.battleToggleBg:GetComponent("Image").sprite = Util.LoadSprite("r_hero_renwukuang-001")
this.battleToggle:SetActive(MonsterCampManager.GetBattleJump())
else
this.battleToggleBg:GetComponent("Image").sprite = Util.LoadSprite("r_renwu_suo_001")
end
end
-- 购买温馨提示,亲,该充值了
function this.ShowTip()
local itemNum = BagManager.GetItemCountById(53)
if itemNum <= 0 then
UIManager.OpenPanel(UIName.QuickPurchasePanel,{ type = UpViewRechargeType.MonsterCampTicket })
return true
else
return false
end
end
-- 直接请求战斗结果
function this.GetQuickResult()
2020-06-08 13:57:30 +08:00
NetManager.GetMonsterFightResult(MonsterCampManager.monsterWave, FormationTypeDef.MONSTER_CAMP_ATTACK, function (msg)
2020-05-09 13:31:21 +08:00
-- 设置战斗数据用于统计战斗
--Log(msg.fightData)
2020-06-03 19:09:01 +08:00
local _fightData = BattleManager.GetBattleServerData({fightData = msg.fightData}, 0)
BattleRecordManager.SetBattleRecord(_fightData)
2020-05-09 13:31:21 +08:00
-- 判断战斗结果
local haveRecord = BattleRecordManager.isHaveRecord()
if msg.result == 0 then
UIManager.OpenPanel(UIName.BattleFailPopup, nil, haveRecord)
else
local result = {}
result.drop = msg.enventDrop
2020-06-03 19:09:01 +08:00
UIManager.OpenPanel(UIName.BattleWinPopup, nil, false, 5, result, not haveRecord, nil, function()end)
2020-05-09 13:31:21 +08:00
MonsterCampManager.monsterWave = MonsterCampManager.monsterWave + 1
-- 刷新波次显示
this.waveNum.text = MonsterCampManager.monsterWave
this.ChangePreview()
end
end)
end
-- 正常战斗
function this.GoBattle()
--屏蔽掉挑战进入怪物预览界面 直接进入编队 预览界面在本界面显示
--UIManager.OpenPanel(UIName.MonsterShowPanel, MonsterCampManager.GetCurWaveMonsterGroupId(), function ()
-- UIManager.OpenPanel(UIName.FormationPanel, FORMATION_TYPE.MONSTER_CAMP)
--end, function ()
-- this.effect:SetActive(true)
--end, false, 3)
-- UIManager.OpenPanel(UIName.FormationPanel, FORMATION_TYPE.MONSTER_CAMP)
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.MONSTER_CAMP)
-- 隐藏特效
this.effect:SetActive(false)
end
--改变预览
function this.ChangePreview()
local monsterGroupId= MonsterCampManager.GetCurWaveMonsterGroupId()
if not monsterGroupId then return end
local monsterData = monsterGroup[monsterGroupId]
if not monsterData then
2020-06-23 18:36:24 +08:00
Log(Language[10478] .. monsterGroupId) return
2020-05-09 13:31:21 +08:00
end
local monsterId = monsterData.Contents[1][1]
local monsterInfo = monsterConfig[monsterId]
--this.nameTxt.text = monsterInfo.ReadingName
--this.lvlTxt.text = "Lv."..monsterInfo.Level
this.power.text=ConfigManager.GetConfigDataByKey(ConfigName.FloodConfig,"Monster",monsterId).Force--怪物战力走表 等策划配表
2020-06-23 18:36:24 +08:00
this.btnText.text =Language[10512]
2020-05-09 13:31:21 +08:00
this.waveNum.text =MonsterCampManager.monsterWave
-- 显示4只小怪头像
this.ShowMonsterIcon()
end
-- 设置显示小怪
function this.ShowMonsterIcon()
local monsterInfo, mainInfo = MonsterCampManager.GetCurMonsterInfo()
-- 初始化隐藏
2020-06-23 18:36:24 +08:00
for i = 1, 6 do
2020-05-09 13:31:21 +08:00
this.monsterList[i]:SetActive(false)
end
--Log("怪物图标数量是 === ".. #monsterInfo.icon)
for i = 1, #monsterInfo.icon do
Util.GetGameObject(this.monsterList[i], "icon"):GetComponent("Image").sprite = monsterInfo.icon[i]
Util.GetGameObject(this.monsterList[i],"lvRoot/lv"):GetComponent("Text").text=monsterInfo.level[i]
this.monsterList[i]:SetActive(true)
end
-- 设置奖励
this.SetRewardShow(monsterInfo.rewardShow)
end
function this.SetRewardShow(rewardData)
2020-06-08 13:57:30 +08:00
for i = 1, 8 do
2020-05-09 13:31:21 +08:00
this.rewardItemList[i].gameObject:SetActive(false)
end
for i = 1, #rewardData do
local item = {}
local itemId = rewardData[i][1]
item[#item + 1] = itemId
item[#item + 1] = rewardData[i][2]
this.rewardItemList[i]:OnOpen(false, item, 1.1, false)
this.rewardItemList[i].gameObject:SetActive(true)
end
end
2020-06-23 18:36:24 +08:00
return MonsterCampPanel