miduo_client/Assets/ManagedResources/~Lua/Modules/Map/TrialMapPanel.lua

670 lines
24 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
TrialMapPanel = {}
2020-05-09 13:31:21 +08:00
local this = TrialMapPanel
local istrialMap = false
local MapPanel
local powerValue = 0
local ctrlView = require("Modules/Map/View/MapControllView")
local targetPos = Vector2.New(109, 289)
local orginLayer = 0
2020-06-03 19:09:01 +08:00
local heroList={} --选择英雄预设容器
local trailConfig = ConfigManager.GetConfig(ConfigName.TrialConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
2020-06-08 13:57:30 +08:00
local trialSetting=ConfigManager.GetConfig(ConfigName.TrialSetting)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
2020-06-19 20:19:35 +08:00
local MonsterConfig=ConfigManager.GetConfig(ConfigName.MonsterConfig)
local MonsterGroupConfig = ConfigManager.GetConfig(ConfigName.MonsterGroup)
local ArtConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
2020-06-03 19:09:01 +08:00
local oldChoosed=nil--上一个选中英雄
local monsterGroupId
2020-05-09 13:31:21 +08:00
function TrialMapPanel:InitComponent(root, mapPanel)
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
orginLayer = 0
MapPanel = mapPanel
-- 精气
this.powerRoot = Util.GetGameObject(root, "leftDown/active")
this.powerPercent = Util.GetGameObject(root, "leftDown/active/value"):GetComponent("Text")
this.sliderValue = Util.GetGameObject(root, "leftDown/active/progress"):GetComponent("Image")
-- 显示时间
2021-05-21 16:39:08 +08:00
this.levelNum = Util.GetGameObject(root, "leftUp/Image/curLevel"):GetComponent("Text")
2020-06-08 20:18:49 +08:00
this.timeRoot=Util.GetGameObject(root,"leftUp/timeRoot")
this.mapTime = Util.GetGameObject(this.timeRoot, "Time"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
2021-05-21 16:39:08 +08:00
this.DragCtrl = Util.GetGameObject(root, "Ctrl")
-- -- 初始化任务显示
-- this.targetRoot = Util.GetGameObject(root, "TargetRoot/textShowRoot/missionRoot/MisPre1")
-- this.targetText = Util.GetGameObject(this.targetRoot, "context"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
-- 炸弹
this.btnBomb = Util.GetGameObject(root, "rightDown/btnBomb")
this.bombNum = Util.GetGameObject(this.btnBomb, "num"):GetComponent("Text")
2022-08-17 14:23:45 +08:00
this.buffShop = Util.GetGameObject(root, "rightUp/buff")
2020-05-09 13:31:21 +08:00
this.buffNum = Util.GetGameObject(this.buffShop, "num"):GetComponent("Text")
2020-06-08 20:18:49 +08:00
-- 试炼副本商店
2020-05-09 13:31:21 +08:00
this.normalShop = Util.GetGameObject(root, "rightDown/shop")
this.shopNum = Util.GetGameObject(this.normalShop, "num"):GetComponent("Text")
2020-08-04 16:18:48 +08:00
--回春散
this.btnXingYao=Util.GetGameObject(root,"rightDown/btnXingYao")
this.xingYaoNum=Util.GetGameObject(this.btnXingYao,"num"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
this.effectRoot = Util.GetGameObject(root, "fireRoot")
this.fire = Util.GetGameObject(this.effectRoot, "UI_effect_shilian_huo")
this.guiji = Util.GetGameObject(this.effectRoot, "UI_effect_shilian_guiji")
this.chufa = Util.GetGameObject(this.powerRoot, "UI_effect_shilian_chufa")
-- 月卡福利炸弹提示
this.bombTip = Util.GetGameObject(this.btnBomb, "bombTip")
2020-06-03 19:09:01 +08:00
--选择英雄
this.selectHero=Util.GetGameObject(root,"centerDown/selectHero")
this.s_grid=Util.GetGameObject(this.selectHero,"grid")
2021-05-21 16:39:08 +08:00
this.s_pre=Util.GetGameObject(this.selectHero,"pre")
2020-06-03 19:09:01 +08:00
this.upView = SubUIManager.Open(SubUIConfig.UpView, root.transform, { showType = UpViewOpenType.ShowLeft })
-- this.helpBtn=Util.GetGameObject(root,"helpBtn")
-- this.helpPos=this.helpBtn:GetComponent("RectTransform").localPosition
2020-07-29 20:18:19 +08:00
--boss召唤特效
this.bossEffect = Util.GetGameObject(root, "UI_effect_shilian_tab")
2020-08-18 21:03:55 +08:00
this.energyRoot = Util.GetGameObject(root, "stepROot")
2020-08-28 13:48:09 +08:00
this.rewardRedPoint = Util.GetGameObject(root,"leftCenter/btnReward/redPoint")
2022-08-17 14:23:45 +08:00
this.btn_sweep=Util.GetGameObject(root, "btn_sweep")
2020-08-28 13:48:09 +08:00
BindRedPointObject(RedPointType.TrialReward, this.rewardRedPoint)
2020-05-09 13:31:21 +08:00
end
function TrialMapPanel:BindEvent()
2020-06-03 19:09:01 +08:00
2020-08-04 16:18:48 +08:00
--炸弹按钮
2020-05-09 13:31:21 +08:00
Util.AddClick(this.btnBomb, function ()
if ctrlView.GetCallListCount() > 1 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11259])
return
end
2020-07-16 17:28:48 +08:00
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialBomb)
2020-05-09 13:31:21 +08:00
end)
2022-08-17 14:23:45 +08:00
--扫荡按钮
Util.AddClick(this.btn_sweep,function()
if MapTrialManager.isSweep then
PopupTipPanel.ShowTip("无法再次扫荡")
return
end
2022-08-17 14:23:45 +08:00
NetManager.TowerCleanfloorRequest(function()
NetManager.MapInfoRequest(MapManager.curCarbonType, function(msg)
MapPanel.Dispose()
2022-08-17 14:23:45 +08:00
MapManager.isReloadEnter = false
MapTrialManager.firstEnter = true
MapManager.SetViewSize(20)--设置视野范围(明雷形式)
MapManager.curAreaId =FormationTypeDef.FORMATION_DREAMLAND
MapTrialManager.isHaveBoss = false
MapManager.isTimeOut = false
MapTrialManager.isSweep=true
2022-08-17 14:23:45 +08:00
SwitchPanel.OpenPanel(UIName.MapPanel)
end)
end)
end)
2020-08-04 16:18:48 +08:00
--回春散
Util.AddClick(this.btnXingYao,function()
if ctrlView.GetCallListCount() > 1 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11259])
return
end
2020-08-04 16:18:48 +08:00
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialXingYao)
end)
2020-05-09 13:31:21 +08:00
-- 打开补给点
Util.AddClick(this.buffShop, function()
if ctrlView.GetCallListCount() > 1 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11259])
return
end
2020-05-09 13:31:21 +08:00
-- 判断是否有保存的补给点
2020-06-13 11:47:13 +08:00
if #FoodBuffManager.GetBuffPropList()<=0 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11261])
2020-06-13 11:47:13 +08:00
return
end
2020-06-08 20:18:49 +08:00
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialGain,0)
2020-05-09 13:31:21 +08:00
end)
-- 打开商店
Util.AddClick(this.normalShop, function()
if ctrlView.GetCallListCount() > 1 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11259])
return
end
2020-05-09 13:31:21 +08:00
if not ShopManager.IsActive(SHOP_TYPE.TRIAL_SHOP) then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[10323])
2020-05-09 13:31:21 +08:00
return
end
UIManager.OpenPanel(UIName.MapShopPanel, SHOP_TYPE.TRIAL_SHOP)
end)
2020-06-03 19:09:01 +08:00
--帮助按钮
-- Util.AddClick(this.helpBtn,function()
-- if ctrlView.GetCallListCount() > 1 then
-- PopupTipPanel.ShowTip(Language[11259])
-- return
-- end
-- UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Sunro,this.helpPos.x,this.helpPos.y)
-- end)
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function TrialMapPanel:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.TrialMap.OnPowerValueChanged, this.OnPowerValueChange)
-- Game.GlobalEvent:AddEvent(GameEvent.Bag.OnTempBagChanged, this.OnTempBagChanged)
2020-05-09 13:31:21 +08:00
Game.GlobalEvent:AddEvent(GameEvent.FoodBuff.OnFoodBuffStateChanged, this.InitBuffInfo)
2020-06-03 19:09:01 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Map.ShowEnemyInfo, this.ShowEnemyInfo)
Game.GlobalEvent:AddEvent(GameEvent.Map.RefreshHeroHp, this.SetSelectHero)
2020-07-20 16:42:20 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.InitShopInfo)
2020-08-04 20:22:56 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Bag.OnTempBagChanged, this.InitRightDown)
2020-05-09 13:31:21 +08:00
end
--移除事件监听(用于子类重写)
function TrialMapPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.TrialMap.OnPowerValueChanged, this.OnPowerValueChange)
-- Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnTempBagChanged, this.OnTempBagChanged)
2020-05-09 13:31:21 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.FoodBuff.OnFoodBuffStateChanged, this.InitBuffInfo)
2020-06-03 19:09:01 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Map.ShowEnemyInfo, this.ShowEnemyInfo)
Game.GlobalEvent:RemoveEvent(GameEvent.Map.RefreshHeroHp, this.SetSelectHero)
2020-07-20 16:42:20 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.InitShopInfo)
2020-08-04 20:22:56 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnTempBagChanged, this.InitRightDown)
2020-05-09 13:31:21 +08:00
end
--界面打开时调用(用于子类重写)
function TrialMapPanel:OnOpen()
2020-08-18 15:48:41 +08:00
this.upView.gameObject:SetActive(CarbonManager.difficulty == 2)
2020-05-09 13:31:21 +08:00
this.powerRoot:SetActive(CarbonManager.difficulty == 2)
2020-07-29 20:18:19 +08:00
this.btnBomb:SetActive(CarbonManager.difficulty == 2)
2020-05-09 13:31:21 +08:00
-- 商店
this.buffShop:SetActive(CarbonManager.difficulty == CARBON_TYPE.TRIAL)
this.normalShop:SetActive(CarbonManager.difficulty == CARBON_TYPE.TRIAL)
2020-08-18 21:03:55 +08:00
this.energyRoot:SetActive(CarbonManager.difficulty == CARBON_TYPE.ENDLESS)
2020-05-09 13:31:21 +08:00
if CarbonManager.difficulty ~= 2 then return end
this.InitShowState()
if MapTrialManager.curTowerLevel<=MapTrialManager.towerCleanFloor then
this.btn_sweep:SetActive(true)
else
this.btn_sweep:SetActive(false)
end
2020-05-09 13:31:21 +08:00
-- 检测引导
GuideManager.CheckCarbonGuild(CARBON_TYPE.TRIAL)
2020-08-28 16:35:08 +08:00
-- PlayerPrefs.SetInt(PlayerManager.uid.."TrialIsOpen",1)
2020-05-09 13:31:21 +08:00
end
function TrialMapPanel:OnShow()
2020-08-19 19:37:59 +08:00
2020-05-09 13:31:21 +08:00
end
function this.InitShowState()
if CarbonManager.difficulty ~= 2 then return end
istrialMap = CarbonManager.difficulty == 2
if istrialMap then this.InitTrial() end
2020-08-18 15:48:41 +08:00
this.upView.gameObject:SetActive(CarbonManager.difficulty ~= 4)
2020-06-03 19:09:01 +08:00
this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main })
this.CheckTrialHeroInfo()
2020-05-09 13:31:21 +08:00
this.InitTrialMission()
this.UpdatePowerValue()
2020-06-03 19:09:01 +08:00
-- this.UpdateDeadTimes()
2020-08-04 20:22:56 +08:00
this.InitRightDown()
2020-06-03 19:09:01 +08:00
-- this.InitBossInfo()
2020-05-09 13:31:21 +08:00
this.powerRoot:SetActive(istrialMap)
this.InitEffect()
this.InitTip()
2020-06-08 20:18:49 +08:00
this.TrialShowTime()
2020-05-09 13:31:21 +08:00
end
2020-08-04 20:22:56 +08:00
function this.InitRightDown()
this.RefreshBombNum()
this.InitShopInfo()
this.InitBuffInfo()
end
2020-05-09 13:31:21 +08:00
function this.InitEffect()
this.guiji:SetActive(false)
this.chufa:SetActive(false)
this.fire:SetActive(false)
end
function this.InitTip()
this.bombTip:SetActive(false)
if MapTrialManager.firstEnter then
Log("试炼副本第一次进图!")
2020-05-09 13:31:21 +08:00
-- 月卡蛋蛋福利
if MapTrialManager.firstEnter and BagManager.GetTempBagCountById(43) >= 2 then
this.bombTip:SetActive(true)
local index = 0
local timer
timer = Timer.New(function()
index = index + 1
if index == 5 then
this.bombTip:SetActive(false)
timer:Stop()
end
end, 1, 5, true)
timer:Start()
end
end
end
-- 刷新精气值
function this.UpdatePowerValue()
2020-06-03 19:09:01 +08:00
if MapTrialManager.curTowerLevel>10000 then
2021-04-09 12:26:35 +08:00
this.levelNum.text = string.format(Language[11262], "?")
2020-06-03 19:09:01 +08:00
else
2021-04-09 12:26:35 +08:00
this.levelNum.text = string.format(Language[11262], MapTrialManager.curTowerLevel)
2020-06-03 19:09:01 +08:00
end
powerValue = MapTrialManager.powerValue
2020-05-09 13:31:21 +08:00
2021-05-24 11:51:11 +08:00
--this.SetTargetState(powerValue)
2020-06-03 19:09:01 +08:00
local _value= powerValue--表现值
_value= _value <= 0 and 0 or _value
_value = _value >= 100 and 100 or _value
2020-05-09 13:31:21 +08:00
--Log("更新数值")
2020-06-03 19:09:01 +08:00
this.powerPercent.text = _value
this.sliderValue.fillAmount = _value / 100
2020-08-04 16:18:48 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
-- LogPurple("战斗结束")
Game.GlobalEvent:DispatchEvent(GameEvent.Map.MaskState,0)
2020-06-03 19:09:01 +08:00
-- -1时召唤boss
if powerValue == -1 then
2020-07-29 20:18:19 +08:00
this.bossEffect:SetActive(true)--进图显示召唤boss
-- 界面打开时删除所有小怪
this.KillAllBitch()
ctrlView.CallListPop()
local timer1 = Timer.New(function ()
MapTrialManager.canMove = true
this.bossEffect:SetActive(false)
end, 1.5)
timer1:Start()
2020-05-09 13:31:21 +08:00
end
end
function this.PlayEffect()
2020-06-03 19:09:01 +08:00
if MapTrialManager.powerValue == -1 or MapTrialManager.powerValue == 0 then
2020-05-09 13:31:21 +08:00
this.UpdatePowerValue()
else
this.fire:SetActive(true)
this.fire:GetComponent("RectTransform").anchoredPosition = MapTrialManager.rolePos
this.guiji:GetComponent("RectTransform").anchoredPosition = MapTrialManager.rolePos
local timer = Timer.New(function ()
this.fire:SetActive(false)
this.guiji:SetActive(true)
-- 设置动画
this.guiji:GetComponent("RectTransform"):DOAnchorPos(targetPos, 0.5, false):OnComplete(function ()
--Log("轨迹完成")
this.chufa:SetActive(true)
this.guiji:SetActive(false)
end)
end, 0.3):Start()
Timer.New(function ()
this.UpdatePowerValue()
this.InitEffect()
end, 1):Start()
end
end
function this.OnPowerValueChange()
if CarbonManager.difficulty ~= 2 then return end
-- 先放特效在更新数值
this.PlayEffect()
end
function this.OnSortingOrderChange()
if this.starGridList then
for _, starGrid in pairs(this.starGridList) do
Util.SetParticleSortLayer(starGrid,MapPanel.sortingOrder + 1)
end
end
2022-01-15 12:26:12 +08:00
if this.effectList then
for key, value in pairs(this.effectList) do
Util.SetParticleSortLayer(value,MapPanel.sortingOrder + 1)
end
end
2020-05-09 13:31:21 +08:00
Util.AddParticleSortLayer(this.chufa, MapPanel.sortingOrder - orginLayer)
orginLayer = MapPanel.sortingOrder
end
-- 初始化部buff显示
function this.InitBuffInfo()
if CarbonManager.difficulty ~= 2 then return end
-- 补给点数量显示
local num = 0
2020-07-29 20:18:19 +08:00
local buffList = FoodBuffManager.GetBuffPropList()
2020-05-09 13:31:21 +08:00
if buffList then
num = #buffList
end
this.buffNum.text = num
end
-- 初始化部商店显示
function this.InitShopInfo()
-- 刷新一遍商店数据
ShopManager.RequestAllShopData(function()
local shopData = ShopManager.GetShopDataByType(SHOP_TYPE.TRIAL_SHOP)
if not shopData or #shopData.storeItem <= 0 then
this.shopNum.text = "0"
return
end
-- 获取可购买的商品数量
local itemNum = 0
for _, item in ipairs(shopData.storeItem) do
local limitCount = ShopManager.GetShopItemLimitBuyCount(item.id)
if limitCount == -1 or limitCount - item.buyNum > 0 then
itemNum = itemNum + 1
end
end
this.shopNum.text = itemNum
end)
end
-- 试炼副本任务初始化
function this.InitTrialMission()
this.powerRoot:SetActive(istrialMap)
2021-05-21 16:39:08 +08:00
-- local imgDone = Util.GetGameObject(this.targetRoot, "imgDone")
-- local imgDoing = Util.GetGameObject(this.targetRoot, "imgDoing")
-- imgDone:SetActive(false)
-- imgDoing:SetActive(false)
-- this.SetTargetState()
2021-04-09 12:26:35 +08:00
this.mapTime.text = Language[11263]
2020-05-09 13:31:21 +08:00
end
2020-08-04 16:18:48 +08:00
-- 刷新砸炸弹、回春散数量
2020-05-09 13:31:21 +08:00
function this.RefreshBombNum()
-- 试炼副本才执行
2020-08-04 16:18:48 +08:00
local bombNum = 0
local yaoNum = 0
2020-05-09 13:31:21 +08:00
if CarbonManager.difficulty ~= CARBON_TYPE.TRIAL then return end
2020-08-04 20:22:56 +08:00
if BagManager.GetTotalItemNum(43) == 0 or not BagManager.GetTotalItemNum(43) then
2020-05-09 13:31:21 +08:00
bombNum = 0
else
2020-08-04 20:22:56 +08:00
bombNum = BagManager.GetTotalItemNum(43)
2020-05-09 13:31:21 +08:00
end
this.bombNum.text = bombNum
2020-08-04 20:22:56 +08:00
if BagManager.GetTotalItemNum(31) == 0 or not BagManager.GetTotalItemNum(31) then
2020-08-04 16:18:48 +08:00
yaoNum = 0
else
2020-08-04 20:22:56 +08:00
yaoNum = BagManager.GetTotalItemNum(31)
2020-08-04 16:18:48 +08:00
end
this.xingYaoNum.text = yaoNum
2020-05-09 13:31:21 +08:00
end
2021-05-21 16:39:08 +08:00
-- -- 设置目标
-- function this.SetTargetState(value)
-- local showStr = ""
-- if value == -1 then
-- showStr = Language[11264]
-- else
-- showStr = Language[11265]
-- end
-- this.targetText.text = showStr
-- end
2020-05-09 13:31:21 +08:00
-- 试炼副本的初始化
function this.InitTrial()
Log("MapManager.isOpen " .. tostring(MapManager.isOpen))
-- 初始化状态
this.DragCtrl:SetActive(true)
MapTrialManager.isChangeLevel = false
MapTrialManager.canMove = true
MapManager.isRemoving = false
MapManager.deadTime = 0
end
-- 试炼副本显示时间
2020-06-08 20:18:49 +08:00
function this.TrialShowTime()
if this.timer then
this.timer:Stop()
this.timer = nil
2020-05-09 13:31:21 +08:00
end
2020-06-08 20:18:49 +08:00
local serData = ActTimeCtrlManager.GetSerDataByTypeId(30)
local freshTime = serData.endTime
this.timer = Timer.New(function()
if not this.timer or not this.mapTime then
return
end
local t=freshTime - PlayerManager.serverTime
if t<=0 then
t=0
2020-06-13 11:47:13 +08:00
MapTrialManager.ClearTrialRewardInfo() --清空奖励信息
MapTrialManager.SetKillCount(0) --重置已杀小怪数量
2020-06-08 20:18:49 +08:00
end
2021-04-09 12:26:35 +08:00
this.mapTime.text = TimeToHMS(t)..Language[11266]
2020-06-08 20:18:49 +08:00
end, 1, -1, true)
this.timer:Start()
2020-05-09 13:31:21 +08:00
end
-- 转换时间
function this.FormatTime(time)
local str = ""
local ten_minute = math.modf(time / 600)
local minute = math.modf(time / 60) % 10
local ten_second = math.modf( time / 10) % 6
local second = time % 10
str = ten_minute ..minute .. ":" .. ten_second .. second
return str
end
2020-06-03 19:09:01 +08:00
--检查试炼阵容信息
function this.CheckTrialHeroInfo()
MapTrialManager.isFirstIn=true
if #MapManager.trialHeroInfo==0 then
LogPink("阵容为空")
2020-06-03 19:09:01 +08:00
UIManager.OpenPanel(UIName.FormationEditPopup,function(d)
2020-06-13 11:47:13 +08:00
this.SetSelectHero(true,d,false)
2020-06-03 19:09:01 +08:00
end)
else
2020-06-13 11:47:13 +08:00
this.SetSelectHero(false,nil,true) --true从入口进入副本 默认选择第一个Hero
2020-05-09 13:31:21 +08:00
end
end
function TrialMapPanel:OnClose()
2020-06-03 19:09:01 +08:00
oldChoosed=nil
2020-06-08 20:18:49 +08:00
if this.timer then
this.timer:Stop()
this.timer = nil
end
2021-05-24 11:51:11 +08:00
Util.ClearChild(this.s_grid.transform)
2021-11-08 16:31:34 +08:00
this.starGridList = {}
2022-01-15 12:26:12 +08:00
this.effectList={}
2021-05-24 11:51:11 +08:00
heroList={}
2020-05-09 13:31:21 +08:00
end
function TrialMapPanel:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-08-28 13:48:09 +08:00
ClearRedPointObject(RedPointType.TrialReward)
2020-06-03 19:09:01 +08:00
SubUIManager.Close(this.upView)
-- 清空数据
this.starGridList = {}
2022-01-15 12:26:12 +08:00
this.effectList={}
2020-06-03 19:09:01 +08:00
end
2020-06-13 11:47:13 +08:00
--设置选择英雄界面 isFirstIn你的第一次 isFirstData你第一次射的东西 isMainIn你每次
function this.SetSelectHero(isFirstIn,isFirstData,isMainIn)
2020-06-08 13:57:30 +08:00
local itemId=trialSetting[1].HealingId[1]
local itemNum=trialSetting[1].HealingId[2]
2021-05-24 11:51:11 +08:00
this.selectHero:SetActive(true)
local d = MapManager.trialHeroInfo
2021-05-25 18:07:53 +08:00
for k = 1, #heroList do
heroList[k].gameObject:SetActive(false)
2020-06-03 19:09:01 +08:00
end
2020-06-13 11:47:13 +08:00
local closeChoosed=function() --有开着选择的全关了
for i, v in ipairs(heroList) do
local c=Util.GetGameObject(v,"choosed").gameObject
if c.activeSelf then
c:SetActive(false)
end
end
end
2020-06-30 18:59:44 +08:00
for i, v in ipairs(d) do
if MapTrialManager.selectHeroDid ~= "" then
if MapTrialManager.selectHeroDid==v.heroId and v.heroHp <= 0 then
MapTrialManager.selectHeroDid = ""
end
end
end
2020-06-03 19:09:01 +08:00
for i, v in ipairs(d) do
local o= heroList[i]
if not o then
o=newObjToParent(this.s_pre,this.s_grid)
o.name="pre"..i
o:GetComponent("RectTransform").localScale = Vector3.New(0.9, 0.9,1)
2020-06-03 19:09:01 +08:00
heroList[i]=o
end
o.gameObject:SetActive(true)
local frame=Util.GetGameObject(o,"frame"):GetComponent("Image")
local icon=Util.GetGameObject(o,"icon"):GetComponent("Image")
local pro=Util.GetGameObject(o,"proIcon"):GetComponent("Image")
local lv=Util.GetGameObject(o,"lv/Text"):GetComponent("Text")
2021-10-26 16:00:31 +08:00
local starGrid=Util.GetGameObject(o,"star")
2020-06-03 19:09:01 +08:00
local choosed=Util.GetGameObject(o,"choosed")
local hpExp=Util.GetGameObject(o,"hpExp"):GetComponent("Slider")
2021-04-21 13:12:04 +08:00
frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroConfig[v.tmpId].Quality, v.star))
SetHeroIcon(this.spLoader, v,icon,heroConfig[v.tmpId])
2022-04-01 16:01:36 +08:00
pro.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(v.propertyId))
2020-06-03 19:09:01 +08:00
lv.text=v.level
2021-10-26 16:00:31 +08:00
local star,starType = GetStarOrGodSoulLv(1,v)
if not this.starGridList then
this.starGridList = {}
end
2022-01-15 12:26:12 +08:00
if not this.effectList then
this.effectList={}
end
this.starGridList[i] = starGrid
2021-10-26 16:00:31 +08:00
SetHeroStars(this.spLoader, starGrid, star,starType)
2022-01-15 12:26:12 +08:00
local effect=SetHeroFlyEffect(o,this.spLoader,v.star,MapPanel.sortingOrder+1,1,2)
if effect then
table.insert(this.effectList,effect)
end
2021-11-05 13:18:55 +08:00
Util.SetParticleSortLayer(starGrid,MapPanel.sortingOrder + 1)
2020-06-08 13:57:30 +08:00
--选择
2020-06-30 18:59:44 +08:00
if isFirstIn then
2020-06-13 11:47:13 +08:00
choosed:SetActive(i==1)
if i==1 then
MapTrialManager.selectHeroDid=v.heroId
end
2020-06-30 18:59:44 +08:00
elseif isMainIn then
if MapTrialManager.selectHeroDid ~= "" then
choosed:SetActive(MapTrialManager.selectHeroDid==v.heroId and v.heroHp >0)
else
if v.heroHp >0 then
choosed:SetActive(true)
MapTrialManager.selectHeroDid=v.heroId
else
choosed:SetActive(false)
MapTrialManager.selectHeroDid=""
end
end
2020-06-13 11:47:13 +08:00
else
2020-10-15 21:26:19 +08:00
if MapTrialManager.selectHeroDid ~= "" then
choosed:SetActive(MapTrialManager.selectHeroDid==v.heroId and v.heroHp >0)
else
if v.heroHp >0 then
choosed:SetActive(true)
MapTrialManager.selectHeroDid=v.heroId
else
choosed:SetActive(false)
MapTrialManager.selectHeroDid=""
end
end
2020-06-03 19:09:01 +08:00
end
2020-06-08 13:57:30 +08:00
--血量相关
hpExp.value=v.heroHp/10000
Util.SetGray(o,v.heroHp<=0)--死啦
2020-06-30 18:59:44 +08:00
Util.AddOnceClick(o,function()
if v.heroHp>0 then
closeChoosed()
choosed:SetActive(true)
MapTrialManager.selectHeroDid=v.heroId
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(Language[11260])
2020-06-30 18:59:44 +08:00
end
end)
2020-06-08 13:57:30 +08:00
end
--刷新英雄选择面板时 检测血量 若有低于40%血量的英雄 给选择Hero加血
--再遍历一次防止下面的return 打断上面for循环表现的正常赋值
--这里只关于自动嗑药逻辑
for k, v in ipairs(d) do
--若存在该设置参数并为已勾选状态 =1 否则=0
local t=(PlayerPrefs.HasKey(PlayerManager.uid.."GeneralPopup_TrialSettingBtn"..2)
and PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_TrialSettingBtn"..2)==1) and 1 or 0
if t==0 then return end
if MapTrialManager.selectHeroDid== v.heroId then
if v.heroHp<=0 then
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(string.format(Language[11267],itemConfig[itemId].Name))
2020-06-08 13:57:30 +08:00
return
end
end
--若血量小于自动回复百分比 并且 有血量
2020-08-31 19:54:14 +08:00
if v.heroHp/10000<trialSetting[1].HealingPercent/10000 and v.heroHp>0 and v.heroId == MapTrialManager.selectHeroDid then
2020-06-08 13:57:30 +08:00
if (itemNum-MapManager.addHpCount)<=0 then
-- PopupTipPanel.ShowTip(string.format("自动使用%s失败可使用次数不足",itemConfig[itemId].Name))
2020-06-08 13:57:30 +08:00
return
end
if BagManager.GetItemCountById(itemId)<=0 then
-- PopupTipPanel.ShowTip(string.format("自动使用%s失败%s不足",itemConfig[itemId].Name,itemConfig[itemId].Name))
2020-06-08 13:57:30 +08:00
return
end
NetManager.UseAddHpItemRequest(MapTrialManager.selectHeroDid,function()
local curHeroHp=0
if v.heroId==MapTrialManager.selectHeroDid then
curHeroHp=v.heroHp
end
curHeroHp=curHeroHp+5000 --5000增加的血量也是要配表的
if curHeroHp>=10000 then
curHeroHp=10000
end
MapTrialManager.SetHeroHp({curHeroHp},MapTrialManager.selectHeroDid,function()
MapManager.addHpCount=MapManager.addHpCount+1
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip(string.format(Language[11268],itemConfig[itemId].Name))
Game.GlobalEvent:DispatchEvent(GameEvent.Map.RefreshHeroHp,false,nil,false)--打完刷新血量
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged)
2020-06-08 13:57:30 +08:00
end)
end)
end
2020-06-03 19:09:01 +08:00
end
end
--显示敌人信息面板
2020-06-28 17:52:29 +08:00
2020-06-03 19:09:01 +08:00
function this.ShowEnemyInfo(_monsterGroupId,eventId,showValues)
2020-08-19 17:18:38 +08:00
UIManager.OpenPanel(UIName.ShowEnemyInfoPanel,MapPanel,_monsterGroupId)
2020-06-03 19:09:01 +08:00
end
function this.KillAllBitch()
--杀死所有的小怪
MapManager.isRemoving = true
local pointData = trailConfig[MapTrialManager.curTowerLevel].MonsterPoint
for i = 1, #pointData do
local mapPointId = pointData[i][1]
if mapPointId then
MapManager.DeletePos(mapPointId)
end
end
MapManager.isRemoving = false
2020-05-09 13:31:21 +08:00
end
2021-04-21 13:12:04 +08:00
return TrialMapPanel