TrialMapPanel = {} 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 local heroList={} --选择英雄预设容器 local trailConfig = ConfigManager.GetConfig(ConfigName.TrialConfig) local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local trialSetting=ConfigManager.GetConfig(ConfigName.TrialSetting) local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig) local MonsterConfig=ConfigManager.GetConfig(ConfigName.MonsterConfig) local MonsterGroupConfig = ConfigManager.GetConfig(ConfigName.MonsterGroup) local ArtConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig) local oldChoosed=nil--上一个选中英雄 local monsterGroupId function TrialMapPanel:InitComponent(root, mapPanel) this.spLoader = SpriteLoader.New() 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") -- 显示时间 this.levelNum = Util.GetGameObject(root, "leftUp/Image/curLevel"):GetComponent("Text") this.timeRoot=Util.GetGameObject(root,"leftUp/timeRoot") this.mapTime = Util.GetGameObject(this.timeRoot, "Time"):GetComponent("Text") this.DragCtrl = Util.GetGameObject(root, "Ctrl") -- -- 初始化任务显示 -- this.targetRoot = Util.GetGameObject(root, "TargetRoot/textShowRoot/missionRoot/MisPre1") -- this.targetText = Util.GetGameObject(this.targetRoot, "context"):GetComponent("Text") -- 炸弹 this.btnBomb = Util.GetGameObject(root, "rightDown/btnBomb") this.bombNum = Util.GetGameObject(this.btnBomb, "num"):GetComponent("Text") this.buffShop = Util.GetGameObject(root, "rightUp/buff") this.buffNum = Util.GetGameObject(this.buffShop, "num"):GetComponent("Text") -- 试炼副本商店 this.normalShop = Util.GetGameObject(root, "rightDown/shop") this.shopNum = Util.GetGameObject(this.normalShop, "num"):GetComponent("Text") --回春散 this.btnXingYao=Util.GetGameObject(root,"rightDown/btnXingYao") this.xingYaoNum=Util.GetGameObject(this.btnXingYao,"num"):GetComponent("Text") 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") --选择英雄 this.selectHero=Util.GetGameObject(root,"centerDown/selectHero") this.s_grid=Util.GetGameObject(this.selectHero,"grid") this.s_pre=Util.GetGameObject(this.selectHero,"pre") this.upView = SubUIManager.Open(SubUIConfig.UpView, root.transform, { showType = UpViewOpenType.ShowLeft }) -- this.helpBtn=Util.GetGameObject(root,"helpBtn") -- this.helpPos=this.helpBtn:GetComponent("RectTransform").localPosition --boss召唤特效 this.bossEffect = Util.GetGameObject(root, "UI_effect_shilian_tab") this.energyRoot = Util.GetGameObject(root, "stepROot") this.rewardRedPoint = Util.GetGameObject(root,"leftCenter/btnReward/redPoint") this.btn_sweep=Util.GetGameObject(root, "btn_sweep") BindRedPointObject(RedPointType.TrialReward, this.rewardRedPoint) end function TrialMapPanel:BindEvent() --炸弹按钮 Util.AddClick(this.btnBomb, function () if ctrlView.GetCallListCount() > 1 then PopupTipPanel.ShowTip(Language[11259]) return end UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialBomb) end) --扫荡按钮 Util.AddClick(this.btn_sweep,function() if MapTrialManager.powerValue==-2 then PopupTipPanel.ShowTip("无法扫荡,请前往下一层") return end if MapTrialManager.isSweep then PopupTipPanel.ShowTip("无法再次扫荡") return end NetManager.TowerCleanfloorRequest(function() NetManager.MapInfoRequest(MapManager.curCarbonType, function(msg) MapPanel.Dispose() MapManager.isReloadEnter = false MapTrialManager.firstEnter = true MapManager.SetViewSize(20)--设置视野范围(明雷形式) MapManager.curAreaId =FormationTypeDef.FORMATION_DREAMLAND MapTrialManager.isHaveBoss = false MapManager.isTimeOut = false MapTrialManager.isSweep=true SwitchPanel.OpenPanel(UIName.MapPanel) CheckRedPointStatus(RedPointType.TrialReward) CheckRedPointStatus(RedPointType.Trial) end) end) end) --回春散 Util.AddClick(this.btnXingYao,function() if ctrlView.GetCallListCount() > 1 then PopupTipPanel.ShowTip(Language[11259]) return end UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialXingYao) end) -- 打开补给点 Util.AddClick(this.buffShop, function() if ctrlView.GetCallListCount() > 1 then PopupTipPanel.ShowTip(Language[11259]) return end -- 判断是否有保存的补给点 if #FoodBuffManager.GetBuffPropList()<=0 then PopupTipPanel.ShowTip(Language[11261]) return end UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TrialGain,0) end) -- 打开商店 Util.AddClick(this.normalShop, function() if ctrlView.GetCallListCount() > 1 then PopupTipPanel.ShowTip(Language[11259]) return end if not ShopManager.IsActive(SHOP_TYPE.TRIAL_SHOP) then PopupTipPanel.ShowTip(Language[10323]) return end UIManager.OpenPanel(UIName.MapShopPanel, SHOP_TYPE.TRIAL_SHOP) end) --帮助按钮 -- 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) end --添加事件监听(用于子类重写) function TrialMapPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.TrialMap.OnPowerValueChanged, this.OnPowerValueChange) -- Game.GlobalEvent:AddEvent(GameEvent.Bag.OnTempBagChanged, this.OnTempBagChanged) Game.GlobalEvent:AddEvent(GameEvent.FoodBuff.OnFoodBuffStateChanged, this.InitBuffInfo) Game.GlobalEvent:AddEvent(GameEvent.Map.ShowEnemyInfo, this.ShowEnemyInfo) Game.GlobalEvent:AddEvent(GameEvent.Map.RefreshHeroHp, this.SetSelectHero) Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.InitShopInfo) Game.GlobalEvent:AddEvent(GameEvent.Bag.OnTempBagChanged, this.InitRightDown) end --移除事件监听(用于子类重写) function TrialMapPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.TrialMap.OnPowerValueChanged, this.OnPowerValueChange) -- Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnTempBagChanged, this.OnTempBagChanged) Game.GlobalEvent:RemoveEvent(GameEvent.FoodBuff.OnFoodBuffStateChanged, this.InitBuffInfo) Game.GlobalEvent:RemoveEvent(GameEvent.Map.ShowEnemyInfo, this.ShowEnemyInfo) Game.GlobalEvent:RemoveEvent(GameEvent.Map.RefreshHeroHp, this.SetSelectHero) Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.InitShopInfo) Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnTempBagChanged, this.InitRightDown) end --界面打开时调用(用于子类重写) function TrialMapPanel:OnOpen() this.upView.gameObject:SetActive(CarbonManager.difficulty == 2) this.powerRoot:SetActive(CarbonManager.difficulty == 2) this.btnBomb:SetActive(CarbonManager.difficulty == 2) -- 商店 this.buffShop:SetActive(CarbonManager.difficulty == CARBON_TYPE.TRIAL) this.normalShop:SetActive(CarbonManager.difficulty == CARBON_TYPE.TRIAL) this.energyRoot:SetActive(CarbonManager.difficulty == CARBON_TYPE.ENDLESS) 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 -- 检测引导 GuideManager.CheckCarbonGuild(CARBON_TYPE.TRIAL) -- PlayerPrefs.SetInt(PlayerManager.uid.."TrialIsOpen",1) end function TrialMapPanel:OnShow() end function this.InitShowState() if CarbonManager.difficulty ~= 2 then return end istrialMap = CarbonManager.difficulty == 2 if istrialMap then this.InitTrial() end this.upView.gameObject:SetActive(CarbonManager.difficulty ~= 4) this.upView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main }) this.CheckTrialHeroInfo() this.InitTrialMission() this.UpdatePowerValue() -- this.UpdateDeadTimes() this.InitRightDown() -- this.InitBossInfo() this.powerRoot:SetActive(istrialMap) this.InitEffect() this.InitTip() this.TrialShowTime() end function this.InitRightDown() this.RefreshBombNum() this.InitShopInfo() this.InitBuffInfo() end 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("试炼副本第一次进图!") -- 月卡蛋蛋福利 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() if MapTrialManager.curTowerLevel>10000 then this.levelNum.text = string.format(Language[11262], "?") else this.levelNum.text = string.format(Language[11262], MapTrialManager.curTowerLevel) end powerValue = MapTrialManager.powerValue --this.SetTargetState(powerValue) local _value= powerValue--表现值 _value= _value <= 0 and 0 or _value _value = _value >= 100 and 100 or _value --Log("更新数值") this.powerPercent.text = _value this.sliderValue.fillAmount = _value / 100 Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged) -- LogPurple("战斗结束") Game.GlobalEvent:DispatchEvent(GameEvent.Map.MaskState,0) -- -1时召唤boss if powerValue == -1 then 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() end end function this.PlayEffect() if MapTrialManager.powerValue == -1 or MapTrialManager.powerValue == 0 then 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 if this.effectList then for key, value in pairs(this.effectList) do Util.SetParticleSortLayer(value,MapPanel.sortingOrder + 1) end end 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 local buffList = FoodBuffManager.GetBuffPropList() 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) -- local imgDone = Util.GetGameObject(this.targetRoot, "imgDone") -- local imgDoing = Util.GetGameObject(this.targetRoot, "imgDoing") -- imgDone:SetActive(false) -- imgDoing:SetActive(false) -- this.SetTargetState() this.mapTime.text = Language[11263] end -- 刷新砸炸弹、回春散数量 function this.RefreshBombNum() -- 试炼副本才执行 local bombNum = 0 local yaoNum = 0 if CarbonManager.difficulty ~= CARBON_TYPE.TRIAL then return end if BagManager.GetTotalItemNum(43) == 0 or not BagManager.GetTotalItemNum(43) then bombNum = 0 else bombNum = BagManager.GetTotalItemNum(43) end this.bombNum.text = bombNum if BagManager.GetTotalItemNum(31) == 0 or not BagManager.GetTotalItemNum(31) then yaoNum = 0 else yaoNum = BagManager.GetTotalItemNum(31) end this.xingYaoNum.text = yaoNum end -- -- 设置目标 -- function this.SetTargetState(value) -- local showStr = "" -- if value == -1 then -- showStr = Language[11264] -- else -- showStr = Language[11265] -- end -- this.targetText.text = showStr -- end -- 试炼副本的初始化 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 -- 试炼副本显示时间 function this.TrialShowTime() if this.timer then this.timer:Stop() this.timer = nil end 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 MapTrialManager.ClearTrialRewardInfo() --清空奖励信息 MapTrialManager.SetKillCount(0) --重置已杀小怪数量 end this.mapTime.text = TimeToHMS(t)..Language[11266] end, 1, -1, true) this.timer:Start() 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 --检查试炼阵容信息 function this.CheckTrialHeroInfo() MapTrialManager.isFirstIn=true if #MapManager.trialHeroInfo==0 then LogPink("阵容为空") UIManager.OpenPanel(UIName.FormationEditPopup,function(d) this.SetSelectHero(true,d,false) end) else this.SetSelectHero(false,nil,true) --true从入口进入副本 默认选择第一个Hero end end function TrialMapPanel:OnClose() oldChoosed=nil if this.timer then this.timer:Stop() this.timer = nil end Util.ClearChild(this.s_grid.transform) this.starGridList = {} this.effectList={} heroList={} end function TrialMapPanel:OnDestroy() this.spLoader:Destroy() ClearRedPointObject(RedPointType.TrialReward) SubUIManager.Close(this.upView) -- 清空数据 this.starGridList = {} this.effectList={} end --设置选择英雄界面 isFirstIn你的第一次 isFirstData你第一次射的东西 isMainIn你每次 function this.SetSelectHero(isFirstIn,isFirstData,isMainIn) local itemId=trialSetting[1].HealingId[1] local itemNum=trialSetting[1].HealingId[2] this.selectHero:SetActive(true) local d = MapManager.trialHeroInfo for k = 1, #heroList do heroList[k].gameObject:SetActive(false) end 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 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 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) 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") local starGrid=Util.GetGameObject(o,"star") local choosed=Util.GetGameObject(o,"choosed") local hpExp=Util.GetGameObject(o,"hpExp"):GetComponent("Slider") frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroConfig[v.tmpId].Quality, v.star)) SetHeroIcon(this.spLoader, v,icon,heroConfig[v.tmpId]) pro.sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(v.propertyId)) lv.text=v.level local star,starType = GetStarOrGodSoulLv(1,v) if not this.starGridList then this.starGridList = {} end if not this.effectList then this.effectList={} end this.starGridList[i] = starGrid SetHeroStars(this.spLoader, starGrid, star,starType) local effect=SetHeroFlyEffect(o,this.spLoader,v.star,MapPanel.sortingOrder+1,1,2) if effect then table.insert(this.effectList,effect) end Util.SetParticleSortLayer(starGrid,MapPanel.sortingOrder + 1) --选择 if isFirstIn then choosed:SetActive(i==1) if i==1 then MapTrialManager.selectHeroDid=v.heroId end 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 else 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 end --血量相关 hpExp.value=v.heroHp/10000 Util.SetGray(o,v.heroHp<=0)--死啦 Util.AddOnceClick(o,function() if v.heroHp>0 then closeChoosed() choosed:SetActive(true) MapTrialManager.selectHeroDid=v.heroId else PopupTipPanel.ShowTip(Language[11260]) end end) 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 PopupTipPanel.ShowTip(string.format(Language[11267],itemConfig[itemId].Name)) return end end --若血量小于自动回复百分比 并且 有血量 if v.heroHp/100000 and v.heroId == MapTrialManager.selectHeroDid then if (itemNum-MapManager.addHpCount)<=0 then -- PopupTipPanel.ShowTip(string.format("自动使用%s失败,可使用次数不足!",itemConfig[itemId].Name)) return end if BagManager.GetItemCountById(itemId)<=0 then -- PopupTipPanel.ShowTip(string.format("自动使用%s失败,%s不足!",itemConfig[itemId].Name,itemConfig[itemId].Name)) 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 PopupTipPanel.ShowTip(string.format(Language[11268],itemConfig[itemId].Name)) Game.GlobalEvent:DispatchEvent(GameEvent.Map.RefreshHeroHp,false,nil,false)--打完刷新血量 Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged) end) end) end end end --显示敌人信息面板 function this.ShowEnemyInfo(_monsterGroupId,eventId,showValues) UIManager.OpenPanel(UIName.ShowEnemyInfoPanel,MapPanel,_monsterGroupId) 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 end return TrialMapPanel