local UIMiniMapMain = require "View/MiniMap/UIMiniMapMain" local UIMiniMapPointItem = require("View/MiniMap/UIMiniMapPointItem") local UIChangAnSiegeMiniMap = UIViewClass(UIMiniMapMain) local tonumberV2 = FP.tonumberV2 local RushCarFeatureId = 622001 --冲车 local TowerFoundationFeatureId = 622021 --炮塔地基 local KingStatueFeatureId = 622041 --君主雕像 local WallFeatureId = 622002 --城墙 local BossArtifact = 622063 --神器 local RushCarMoveBuff = 62200103 --冲车移动buff local ZhuYanMonsterID = 62200308 local CloseDoorFeatureId = 622004 local Defend_BOSS = 622031 --守城boss local MapPointPath = ConstAssetPathConfig.MapPointPath local MapPointLabel02Path = ConstAssetPathConfig.MapPointLabel02Path local TowerPosIDS = { "IDS_SiegeCity_Map_Position_1", "IDS_SiegeCity_Map_Position_2", "IDS_SiegeCity_Map_Position_3", "IDS_SiegeCity_Map_Position_4", "IDS_SiegeCity_Map_Position_5", "IDS_SiegeCity_Map_Position_6", } function UIChangAnSiegeMiniMap:OnCreated() self.playEffectDict = {} end function UIChangAnSiegeMiniMap:OnOpened() self.hasRefreshBornPoint = false --是否已经刷新主战场第一阶段出生点 self:RegistSystemEvent(EventID.Level_SetBornItem, self.UpdateBornPoint) self:RegistSystemEvent(EventID.SiegeCityCommand, self.PlayPointEffect) self:RegistSystemEvent(EventID.UI_ChangAnSiege_OnReviveViewOpen, self.OnDeadViewTop) self:RegistSystemEvent(EventID.UI_ChangAnSiege_MiniMapTowerAttackSelf, self.OnTowerAttackSelf) end function UIChangAnSiegeMiniMap:OnDeadViewTop(isDead) self:SetSortingLayer(isDead, "UIPopup", 0) end function UIChangAnSiegeMiniMap:UpdateMapPoint() if BattleDataGetter.IsCityWarFirstStage() then if not self.hasRefreshBornPoint then self:UpdateBornPoint() self.hasRefreshBornPoint = true end end UIMiniMapMain.UpdateMapPoint(self) --刷新自己 local myEntity = BattleDataGetter.GetMainPlayerManipulatingEntity() self:UpdatePointPos(myEntity, self.selfMapPoint, true) end function UIChangAnSiegeMiniMap:UpdateBornPoint() if self.bornPointList then for i, v in ipairs(self.bornPointList) do v:Clear() self.bornPointList[i] = nil end else self.bornPointList = {} end local isDefendCountry = MDL.ChangAnSiege.IsDefendCountry() local bornItemIdList = BattleDataGetter.GetBornItemListOfCampID(BattleDataGetter.GetCityWarDefendCampID()) if bornItemIdList then for _, itemID in ipairs(bornItemIdList) do self:RefreshBornPoint(BattleDataGetter.GetItemByID(itemID), isDefendCountry) end end local bornItemIdList = BattleDataGetter.GetBornItemListOfCampID(BattleDataGetter.GetCityWarAttackCampID()) if bornItemIdList then for _, itemID in ipairs(bornItemIdList) do self:RefreshBornPoint(BattleDataGetter.GetItemByID(itemID), not isDefendCountry) end end end function UIChangAnSiegeMiniMap:RefreshBornPoint(levelItem, isMyCamp) local lastParentX, lastParentY = self.texture_MiniMap.rectTransform:GetLocalPosition() local pointType if isMyCamp then pointType = CTL.MiniMap.MiniMapPointType.ChangAnBlueBornPoint else pointType = CTL.MiniMap.MiniMapPointType.ChangAnRedBornPoint end local mapPointItem = UIMiniMapPointItem:new(pointType, MapPointPath, self.texture_MiniMap.transform) local posX, posY = tonumberV2(levelItem.ItemData.ItemPos) posX = (posX - self.OffsetX) * self.SizeRateX + self.MapPosX - lastParentX posY = (posY - self.OffsetY) * self.SizeRateY + self.MapPosY - lastParentY mapPointItem:SetPointPos(posX, posY, nil) table.insert(self.bornPointList, mapPointItem) end --城池战小地图 function UIChangAnSiegeMiniMap:GetMapShowType(entity, myCountryId) local isDefendCountry = MDL.ChangAnSiege.IsDefendCountry() if entity.featureID == RushCarFeatureId then local pointItem = nil if entity:GetCharacterID() == MDL.ChangAnSiege.LeftCrushCarMonsterId then pointItem = self.leftCrushCarPoint elseif entity:GetCharacterID() == MDL.ChangAnSiege.RightCrushCarMonsterId then pointItem = self.rightCrushCarPoint end if BattleDataGetter.CheckHasBuff(entity, RushCarMoveBuff) or BattleDataGetter.GetCityWarIsCrushCarAttackingGate(entity) then if isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnRedRushCar else return CTL.MiniMap.MiniMapPointType.ChangAnBlueRushCar end else self:StopItemEffectCheck(pointItem) return CTL.MiniMap.MiniMapPointType.ChangAnWhiteRushCar end elseif entity.featureID == TowerFoundationFeatureId then return CTL.MiniMap.MiniMapPointType.TowerFoundation elseif entity.featureID == WallFeatureId then return nil elseif entity.featureID == BossArtifact then return CTL.MiniMap.MiniMapPointType.DragonBossArtifact elseif entity.featureID == CloseDoorFeatureId then return CTL.MiniMap.MiniMapPointType.ChangAnDoorClose else if entity:IsAlive() then local cfg = CTL.ChangAnSiege.GetSiegeCityBuildCfgByMonsterID(entity:GetCharacterID()) if cfg then if cfg.SiegeCityBuildingType == MDL.ChangAnSiege.SiegeCityBuildingType.Turret then if entity.components.drive.BeDrived then if isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnBlueTower else return CTL.MiniMap.MiniMapPointType.ChangAnRedTower end else return CTL.MiniMap.MiniMapPointType.ChangAnWhiteTower end elseif cfg.SiegeCityBuildingType == MDL.ChangAnSiege.SiegeCityBuildingType.WarCar then if entity.components.drive.BeDrived then if isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnRedVehicle else return CTL.MiniMap.MiniMapPointType.ChangAnBlueVehicle end else if not isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnWhiteVehicle else return nil end end end end if BattleDataGetter.IsCityWarMainLevel() and BattleDataGetter.IsCityWarSecondStage() then if BattleDataGetter.IsCityWarStatue(entity) then if entity.featureID == KingStatueFeatureId then if isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnKingBlueStatue else return CTL.MiniMap.MiniMapPointType.ChangAnKingRedStatue end else if isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnBlueStatue else return CTL.MiniMap.MiniMapPointType.ChangAnRedStatue end end end end if entity:GetCharacterID() == ZhuYanMonsterID then return end if entity.isBoss then if isDefendCountry then return CTL.MiniMap.MiniMapPointType.ChangAnBlueBoss else return CTL.MiniMap.MiniMapPointType.ChangAnRedBoss end end if entity.isElite then if isDefendCountry then return CTL.MiniMap.MiniMapPointType.BlueElite else return CTL.MiniMap.MiniMapPointType.RedElite end end end end end function UIChangAnSiegeMiniMap:GetMapPoint(index, type, effect, entity) local mapPointItem = UIMiniMapMain.GetMapPoint(self, index, type, effect, entity, MapPointLabel02Path) self:SetMapPointLabel(mapPointItem, entity) self:SetPointsEffect(entity, mapPointItem) local lastType = mapPointItem.PointType if lastType == CTL.MiniMap.MiniMapPointType.ChangAnRedRushCar or lastType == CTL.MiniMap.MiniMapPointType.ChangAnBlueRushCar and lastType ~= type then self:StopItemEffectCheck(mapPointItem) end return mapPointItem end function UIChangAnSiegeMiniMap:SetPointsEffect(entity, mapPointItem) if BattleDataGetter.IsCityWarSideLevel() then return end if BattleDataGetter.IsCityWarFirstStage() then --左右冲车 if entity:GetCharacterID() == MDL.ChangAnSiege.LeftCrushCarMonsterId then self.leftCrushCarPoint = mapPointItem elseif entity:GetCharacterID() == MDL.ChangAnSiege.RightCrushCarMonsterId then self.rightCrushCarPoint = mapPointItem end --镇守大将 if entity.featureID == Defend_BOSS then self.elitePoint = mapPointItem end if self.elitePoint and BattleDataGetter.GetCityWarDefendBossIsDead() then self.elitePoint = nil end local isDefendCountry = MDL.ChangAnSiege.IsDefendCountry() if entity.featureID == RushCarFeatureId then local pointItem = nil if entity:GetCharacterID() == MDL.ChangAnSiege.LeftCrushCarMonsterId then pointItem = self.leftCrushCarPoint elseif entity:GetCharacterID() == MDL.ChangAnSiege.RightCrushCarMonsterId then pointItem = self.rightCrushCarPoint end if BattleDataGetter.CheckHasBuff(entity, RushCarMoveBuff) or BattleDataGetter.GetCityWarIsCrushCarAttackingGate(entity) then if isDefendCountry then self:PlayItemEffectCheck(pointItem,5,999) else self:PlayItemEffectCheck(pointItem,4,999) end else self:StopItemEffectCheck(pointItem) end end end end function UIChangAnSiegeMiniMap:SetMapPointLabel(mapPointItem, entity) local cfg = CTL.ChangAnSiege.GetSiegeCityBuildCfgByMonsterID(entity:GetCharacterID()) if cfg or entity.featureID == TowerFoundationFeatureId then local index = 0 local cityWarTowerLevelItemIdList = DataSheetManager.ConstData:GetDataByID("CityWarTowerLevelItemIdList").IntListValue for i, id in ipairs(cityWarTowerLevelItemIdList) do if entity._logicInitData.BornItemID == id then index = i break end end if index == 0 then mapPointItem:SetMapPoint02Label("") else mapPointItem:SetMapPoint02Label(UIUtils.GetLocalizedTxt(Const_IDS[TowerPosIDS[index]])) self.towerList = self.towerList or {} self.towerList[index] = mapPointItem end else mapPointItem:SetMapPoint02Label("") end end function UIChangAnSiegeMiniMap:OnButtonClicked(comp) if comp == self.panel_Main and BattleDataGetter.IsCityWarFirstStage()then UIManager.OpenView(Const_UI_Lua.UIEnum.UIChangAnSiegeConstruct) else UIMiniMapMain.OnButtonClicked(self, comp) end end function UIChangAnSiegeMiniMap:PlayPointEffect(index) local CommandItemEnum = MDL.ChangAnSiege.CommandItemEnum -- index 对应指令顺序 if index == CommandItemEnum.GuardElite and self.elitePoint then --镇守大将 self:PlayItemEffect(self.elitePoint, 3) elseif index == CommandItemEnum.LeftCrushCar and self.leftCrushCarPoint then --西方冲车 self:PlayItemEffect(self.leftCrushCarPoint, 3) elseif index == CommandItemEnum.RightCrushCar and self.rightCrushCarPoint then --东方冲车 self:PlayItemEffect(self.rightCrushCarPoint, 3) elseif index == CommandItemEnum.LeftTower1 and self.towerList[1] then self:PlayItemEffect(self.towerList[1], 3) elseif index == CommandItemEnum.LeftTower2 and self.towerList[2] then self:PlayItemEffect(self.towerList[2], 3) elseif index == CommandItemEnum.LeftTower3 and self.towerList[3] then self:PlayItemEffect(self.towerList[3], 3) elseif index == CommandItemEnum.RightTower1 and self.towerList[4] then self:PlayItemEffect(self.towerList[4], 3) elseif index == CommandItemEnum.RightTower2 and self.towerList[5] then self:PlayItemEffect(self.towerList[5], 3) elseif index == CommandItemEnum.RightTower3 and self.towerList[6] then self:PlayItemEffect(self.towerList[6], 3) end end function UIChangAnSiegeMiniMap:PlayItemEffect(item, effect, duration) duration = duration or 2 item:PlayStressEffect(effect, duration) end function UIChangAnSiegeMiniMap:PlayItemEffectCheck(item, effect, duration) if item and not self.playEffectDict[item] then self.playEffectDict[item] = true self:PlayItemEffect(item, effect, duration) end end function UIChangAnSiegeMiniMap:StopItemEffectCheck(item, effect, duration) if item and self.playEffectDict[item] then self.playEffectDict[item] = nil item:StopPointEffect() end end function UIChangAnSiegeMiniMap:OnClosed() if self.bornPointList then for i, v in ipairs(self.bornPointList) do v:Clear() self.bornPointList[i] = nil end self.bornPointList = nil end end function UIChangAnSiegeMiniMap:OnTowerAttackSelf(index, towerEntity) local tower = self.towerList[index] if tower then self:PlayItemEffect(self.towerList[index], 6, 3) end end return UIChangAnSiegeMiniMap