public override int Execute(LogicLevel level) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId); if (gameObject != null) { if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicBuilding building = (LogicBuilding)gameObject; LogicBuildingData buildingData = building.GetBuildingData(); if (buildingData.GetGearUpBuildingData() == null || building.GetGearLevel() != 0) { if (building.GetAttackerItemData().HasAlternativeAttackMode()) { LogicCombatComponent combatComponent = building.GetCombatComponent(false); if (combatComponent != null) { combatComponent.ToggleAttackMode(this.m_layout, this.m_draftMode); if (this.m_updateListener) { } return(0); } } return(-1); } return(-95); } if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP) { LogicTrap trap = (LogicTrap)gameObject; if (trap.HasAirMode()) { trap.ToggleAirMode(this.m_layout, this.m_draftMode); if (this.m_updateListener) { } return(0); } } } return(-1); }
public override int Execute(LogicLevel level) { if (this.m_inputLayoutId != 6) { if (this.m_outputLayoutId != 6) { if (this.m_inputLayoutId != 7) { if (this.m_outputLayoutId != 7) { int townHallLevel = level.GetTownHallLevel(level.GetVillageType()); if (townHallLevel >= level.GetRequiredTownHallLevelForLayout(this.m_inputLayoutId, -1) && townHallLevel >= level.GetRequiredTownHallLevelForLayout(this.m_outputLayoutId, -1)) { LogicGameObjectFilter filter = new LogicGameObjectFilter(); LogicArrayList <LogicGameObject> gameObjects = new LogicArrayList <LogicGameObject>(500); filter.AddGameObjectType(LogicGameObjectType.BUILDING); filter.AddGameObjectType(LogicGameObjectType.TRAP); filter.AddGameObjectType(LogicGameObjectType.DECO); level.GetGameObjectManager().GetGameObjects(gameObjects, filter); if (this.m_outputLayoutId == level.GetActiveLayout()) { LogicMoveMultipleBuildingsCommand moveMultipleBuildingsCommand = new LogicMoveMultipleBuildingsCommand(); for (int i = 0; i < gameObjects.Size(); i++) { LogicGameObject gameObject = gameObjects[i]; LogicVector2 position = gameObject.GetPositionLayout(this.m_inputLayoutId, false); moveMultipleBuildingsCommand.AddNewMove(gameObject.GetGlobalID(), position.m_x, position.m_y); } int result = moveMultipleBuildingsCommand.Execute(level); moveMultipleBuildingsCommand.Destruct(); if (result != 0) { filter.Destruct(); return(-2); } } for (int i = 0; i < gameObjects.Size(); i++) { LogicGameObject gameObject = gameObjects[i]; LogicVector2 layoutPosition = gameObject.GetPositionLayout(this.m_inputLayoutId, false); LogicVector2 editModePosition = gameObject.GetPositionLayout(this.m_inputLayoutId, true); gameObject.SetPositionLayoutXY(layoutPosition.m_x, layoutPosition.m_y, this.m_outputLayoutId, false); gameObject.SetPositionLayoutXY(editModePosition.m_x, editModePosition.m_y, this.m_outputLayoutId, true); if (gameObject.GetGameObjectType() == LogicGameObjectType.BUILDING) { LogicCombatComponent combatComponent = gameObject.GetCombatComponent(false); if (combatComponent != null) { if (combatComponent.HasAltAttackMode()) { if (combatComponent.UseAltAttackMode(this.m_inputLayoutId, false) ^ combatComponent.UseAltAttackMode(this.m_outputLayoutId, false)) { combatComponent.ToggleAttackMode(this.m_outputLayoutId, false); } if (combatComponent.UseAltAttackMode(this.m_inputLayoutId, true) ^ combatComponent.UseAltAttackMode(this.m_outputLayoutId, true)) { combatComponent.ToggleAttackMode(this.m_outputLayoutId, true); } } if (combatComponent.GetAttackerItemData().GetTargetingConeAngle() != 0) { int aimAngle1 = combatComponent.GetAimAngle(this.m_inputLayoutId, false); int aimAngle2 = combatComponent.GetAimAngle(this.m_outputLayoutId, false); if (aimAngle1 != aimAngle2) { combatComponent.ToggleAimAngle(aimAngle1 - aimAngle2, this.m_outputLayoutId, false); } } } } else if (gameObject.GetGameObjectType() == LogicGameObjectType.TRAP) { LogicTrap trap = (LogicTrap)gameObject; if (trap.HasAirMode()) { if (trap.IsAirMode(this.m_inputLayoutId, false) ^ trap.IsAirMode(this.m_outputLayoutId, false)) { trap.ToggleAirMode(this.m_outputLayoutId, false); } if (trap.IsAirMode(this.m_inputLayoutId, true) ^ trap.IsAirMode(this.m_outputLayoutId, true)) { trap.ToggleAirMode(this.m_outputLayoutId, true); } } } } filter.Destruct(); level.SetLayoutState(this.m_outputLayoutId, level.GetVillageType(), level.GetLayoutState(this.m_inputLayoutId, level.GetVillageType())); LogicAvatar homeOwnerAvatar = level.GetHomeOwnerAvatar(); if (homeOwnerAvatar.GetTownHallLevel() >= LogicDataTables.GetGlobals().GetChallengeBaseCooldownEnabledTownHall()) { level.SetLayoutCooldownSecs(this.m_outputLayoutId, level.GetLayoutCooldown(this.m_inputLayoutId) / 15); } return(0); } return(-1); } return(-8); } return(-7); } return(-6); } return(-5); }