local EventSystem = require('Event/EventSystem') local Base = require("Battle/Expression/ExpLevel/ExpLevelFunction/ExpSyncLevelFunction") local ExpSyncCityWarBaseLevelFunction = class("ExpSyncCityWarBaseLevelFunction",Base) local EStatisticType = LuaConst.EStatisticType local LevelItemManager_GetItemByID = LevelItemManager.GetItemByID local LEVELITEMTYPE_MONSTER = LuaConst.LevelItemType.Monster function ExpSyncCityWarBaseLevelFunction:OnInitLevel() Base.OnInitLevel(self) self.drivedFlagDic = {} --key为EntityID,value为bool值,标记这个单位有没有被驾驶过 self.playerID2towerDamageTimestampDic = {} end function ExpSyncCityWarBaseLevelFunction:OnEntityBorn(entity) end function ExpSyncCityWarBaseLevelFunction:OnTowerActive(entity) entity.ExpEntity:SetModelUIDefendTower() end function ExpSyncCityWarBaseLevelFunction:OnCrushCarActive(entity) entity.ExpEntity:SetModelUICrushCar(false) end function ExpSyncCityWarBaseLevelFunction:OnAttackerVehicleActive(entity) entity.ExpEntity:SetModelUIAttackVehicle() end local CityWarTowerLevelItemIdList = DataSheetManager.ConstData:GetDataByID("CityWarTowerLevelItemIdList").IntListValue --可以造塔的LevelItem列表 function ExpSyncCityWarBaseLevelFunction:OnTowerCauseDamage(entity, caster, delta, op, realDelta) local originEntity = entity:GetOriginEntity() if originEntity:IsPlayerSelf() then local playerID = originEntity:GetPlayerID() local lastTimestamp = self.playerID2towerDamageTimestampDic[playerID] if not lastTimestamp or LogicUpdateManager._clientHandleFrame - lastTimestamp >= 100 then --策划需求写死,100帧 self.playerID2towerDamageTimestampDic[playerID] = LogicUpdateManager._clientHandleFrame local nameID local index for i,itemId in ipairs(CityWarTowerLevelItemIdList) do if LevelItemManager_GetItemByID(itemId, LEVELITEMTYPE_MONSTER):GetMonsterEntity() == caster then if i == 1 then nameID = "IDS_SiegeCity_Map_Position_11" --西1塔 elseif i == 2 then nameID = "IDS_SiegeCity_Map_Position_22" --西2塔 elseif i == 3 then nameID = "IDS_SiegeCity_Map_Position_33" --西3塔 elseif i == 4 then nameID = "IDS_SiegeCity_Map_Position_44" --东1塔 elseif i == 5 then nameID = "IDS_SiegeCity_Map_Position_55" --东2塔 elseif i == 6 then nameID = "IDS_SiegeCity_Map_Position_66" --东3塔 end index = i break end end if nameID then EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey("IDS_SiegeCity_TowerAttacked", UIUtils.GetLocalizedTxt(Const_IDS[nameID]))) EventSystem.Dispatch(EventID.ChangAnSiege_TowerAttackSelf, index, caster) end end end end function ExpSyncCityWarBaseLevelFunction:OnDrive(driver, beDrivedEntity) local featureID = beDrivedEntity.components.base.CurMonsterFeature.ID if self.levelFunction.IsMiddleBossFeatureID and self.levelFunction:IsMiddleBossFeatureID(featureID) then local IDS if self.levelFunction.defendCampID == driver:GetCampID() then IDS = "IDS_SiegeCity_PossessForDefender" else IDS = "IDS_SiegeCity_PossessForAttacker" end EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey(IDS, driver._logicInitData.Name)) end end function ExpSyncCityWarBaseLevelFunction:BeforeClearHeroComboKillNum(deadEntity, comboKillNum, killer) Base.BeforeClearHeroComboKillNum(self, deadEntity, comboKillNum) if comboKillNum >= 10 then --战场内10连杀及以上玩家被击杀终结时提示,“XXX手起刀落,终结了YYY的M连杀”,己方名字显示为蓝色,敌方名字显示为红色 if LogicUpdateManager._curEntity then local IDS if LogicUpdateManager._curEntity:GetCampID() == deadEntity:GetCampID() then IDS = "IDS_SiegeCity_ShutDownByEnemy" else IDS = "IDS_SiegeCity_ShutDownByFriend" end EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey(IDS, BattleDataGetter.GetEntityName(killer), deadEntity._logicInitData.Name, comboKillNum)) end end end function ExpSyncCityWarBaseLevelFunction:OnHandleHeroDead(killer, deadEntity, involveKillPlayerIDList, assistHeroEntityIDList, kStatistic, relaxAssistPlayerIDList) Base.OnHandleHeroDead(self, killer, deadEntity, involveKillPlayerIDList, assistHeroEntityIDList, kStatistic, relaxAssistPlayerIDList) if deadEntity:IsPlayerSelf() then --自己死亡时提示“你被XXX击为重伤” EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey("IDS_WorldBoss_AttackedBySomeone", BattleDataGetter.GetEntityName(killer))) end --战场内玩家10连杀及以上每多5连杀(比如15,20)时提示“进攻/防守方的XXX所有披靡,连杀敌方X员大将”,己方名字显示为蓝色,敌方名字显示为红色 if LogicUpdateManager._curEntity then if kStatistic then local comboHeroKillNum = kStatistic[EStatisticType.CurComboHeroKillNum] if comboHeroKillNum >= 10 and (comboHeroKillNum - 10) % 5 == 0 then if killer:GetCampID() == self.levelFunction.defendCampID then if killer:GetCampID() == LogicUpdateManager._curEntity:GetCampID() then EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey("IDS_SiegeCity_DefenderMultiKillForDef", BattleDataGetter.GetEntityName(killer), comboHeroKillNum)) else EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey("IDS_SiegeCity_DefenderMultiKillForAtc", BattleDataGetter.GetEntityName(killer), comboHeroKillNum)) end else if killer:GetCampID() == LogicUpdateManager._curEntity:GetCampID() then EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey("IDS_SiegeCity_AttackerMultiKillForAtc", BattleDataGetter.GetEntityName(killer), comboHeroKillNum)) else EventSystem.Dispatch(EventID.UI_MainShowTips, string.FormatByIdsKey("IDS_SiegeCity_AttackerMultiKillForDef", BattleDataGetter.GetEntityName(killer), comboHeroKillNum)) end end end end end end return ExpSyncCityWarBaseLevelFunction