public bool IsInside(LogicRect rect) { if (this.m_startX <= rect.m_startX) { if (this.m_startY <= rect.m_startY) { return(this.m_endX > rect.m_endX && this.m_endY > rect.m_endY); } } return(false); }
public override int Execute(LogicLevel level) { LogicRect playArea = level.GetPlayArea(); LogicArrayList <LogicGameObject> gameObjects = new LogicArrayList <LogicGameObject>(); LogicArrayList <LogicGameObject> staticObjects = new LogicArrayList <LogicGameObject>(); LogicGameObjectFilter filter = new LogicGameObjectFilter(); filter.AddGameObjectType(LogicGameObjectType.BUILDING); filter.AddGameObjectType(LogicGameObjectType.TRAP); filter.AddGameObjectType(LogicGameObjectType.DECO); LogicArrayList <LogicGameObject> buildings = level.GetGameObjectManager().GetGameObjects(LogicGameObjectType.BUILDING); LogicArrayList <LogicGameObject> obstacles = level.GetGameObjectManager().GetGameObjects(LogicGameObjectType.OBSTACLE); staticObjects.AddAll(obstacles); for (int i = 0; i < buildings.Size(); i++) { LogicBuilding building = (LogicBuilding)buildings[i]; if (building.IsLocked()) { filter.AddIgnoreObject(building); staticObjects.Add(building); } } level.GetGameObjectManager().GetGameObjects(gameObjects, filter); for (int i = 0; i < gameObjects.Size(); i++) { LogicGameObject gameObject = gameObjects[i]; LogicVector2 editModePosition = gameObject.GetPositionLayout(this.m_layoutId, true); if (editModePosition.m_x != -1 && editModePosition.m_y != -1) { int newX = editModePosition.m_x + this.m_x; int newY = editModePosition.m_y + this.m_y; int width = gameObject.GetWidthInTiles(); int height = gameObject.GetHeightInTiles(); if (newX < playArea.GetStartX() || newY < playArea.GetStartY() || newX + width > playArea.GetEndX() || newY + height > playArea.GetEndY()) { return(-1); } if (this.m_layoutId <= 3 && this.m_layoutId != 1) { for (int j = 0; j < staticObjects.Size(); j++) { LogicGameObject staticObject = staticObjects[j]; if (staticObject != gameObject) { int staticX = staticObject.GetTileX(); int staticY = staticObject.GetTileY(); int staticWidth = staticObject.GetWidthInTiles(); int staticHeight = staticObject.GetHeightInTiles(); if (staticX != -1 && staticY != -1) { if (newX + width > staticX && newY + height > staticY && newX < staticX + staticWidth && newY < staticY + staticHeight) { return(-1); } } } } } } } for (int i = 0; i < gameObjects.Size(); i++) { LogicGameObject gameObject = gameObjects[i]; LogicVector2 editModePosition = gameObject.GetPositionLayout(this.m_layoutId, true); if (editModePosition.m_x != -1 && editModePosition.m_y != -1) { gameObject.SetPositionLayoutXY(editModePosition.m_x + this.m_x, editModePosition.m_y + this.m_y, this.m_layoutId, true); } } filter.Destruct(); return(0); }
public override int Execute(LogicLevel level) { if (this.m_layoutId != 6) { if (this.m_layoutId != 7) { LogicGameObject gameObject = level.GetGameObjectManager().GetGameObjectByID(this.m_gameObjectId); if (gameObject != null) { LogicGameObjectType gameObjectType = gameObject.GetGameObjectType(); if (gameObjectType == LogicGameObjectType.BUILDING || gameObjectType == LogicGameObjectType.TRAP || gameObjectType == LogicGameObjectType.DECO) { LogicRect playArea = level.GetPlayArea(); if (playArea.IsInside(this.m_x, this.m_y) && playArea.IsInside(this.m_x + gameObject.GetWidthInTiles(), this.m_y + gameObject.GetHeightInTiles()) || this.m_x == -1 || this.m_y == -1) { if (gameObjectType == LogicGameObjectType.BUILDING) { LogicBuilding building = (LogicBuilding)gameObject; if (building.GetWallIndex() != 0) { return(-23); } } gameObject.SetPositionLayoutXY(this.m_x, this.m_y, this.m_layoutId, true); LogicGlobals globals = LogicDataTables.GetGlobals(); if (!globals.NoCooldownFromMoveEditModeActive()) { if (level.GetActiveLayout(level.GetVillageType()) == this.m_layoutId) { LogicAvatar homeOwnerAvatar = level.GetHomeOwnerAvatar(); if (homeOwnerAvatar.GetExpLevel() >= globals.GetChallengeBaseCooldownEnabledTownHall()) { level.SetLayoutCooldownSecs(this.m_layoutId, globals.GetChallengeBaseSaveCooldown()); } } } return(0); } return(-2); // EditModeOutsideMap } return(-1); } return(-3); } return(-6); } return(-5); }