public LogicArrayList <AvatarChange> RemoveAvatarChanges() { LogicArrayList <AvatarChange> arrayList = new LogicArrayList <AvatarChange>(); arrayList.AddAll(this.m_avatarChanges); this.m_avatarChanges.Clear(); return(arrayList); }
public LogicArrayList <LogicServerCommand> RemoveExecutedServerCommands() { LogicArrayList <LogicServerCommand> arrayList = new LogicArrayList <LogicServerCommand>(); arrayList.AddAll(this.m_executedServerCommands); this.m_executedServerCommands.Clear(); return(arrayList); }
public static void LoadDebugJSONArray(LogicLevel level, LogicJSONArray jsonArray, LogicGameObjectType gameObjectType, int villageType) { if (jsonArray != null) { LogicGameObjectManager gameObjectManager = level.GetGameObjectManagerAt(villageType); LogicArrayList <LogicGameObject> prevGameObjects = new LogicArrayList <LogicGameObject>(); prevGameObjects.AddAll(gameObjectManager.GetGameObjects(gameObjectType)); for (int i = 0; i < prevGameObjects.Size(); i++) { gameObjectManager.RemoveGameObject(prevGameObjects[i]); } for (int i = 0; i < jsonArray.Size(); i++) { LogicJSONObject jsonObject = jsonArray.GetJSONObject(i); LogicJSONNumber dataNumber = jsonObject.GetJSONNumber("data"); LogicJSONNumber lvlNumber = jsonObject.GetJSONNumber("lvl"); LogicJSONBoolean lockedBoolean = jsonObject.GetJSONBoolean("locked"); LogicJSONNumber xNumber = jsonObject.GetJSONNumber("x"); LogicJSONNumber yNumber = jsonObject.GetJSONNumber("y"); if (dataNumber != null && xNumber != null && yNumber != null) { LogicGameObjectData data = (LogicGameObjectData)LogicDataTables.GetDataById(dataNumber.GetIntValue()); if (data != null) { LogicGameObject gameObject = LogicGameObjectFactory.CreateGameObject(data, level, villageType); if (gameObjectType == LogicGameObjectType.BUILDING) { ((LogicBuilding)gameObject).StartConstructing(true); } if (lockedBoolean != null && lockedBoolean.IsTrue()) { ((LogicBuilding)gameObject).Lock(); } gameObject.Load(jsonObject); gameObjectManager.AddGameObject(gameObject, -1); if (lvlNumber != null) { LogicDebugUtil.SetBuildingUpgradeLevel(level, gameObject.GetGlobalID(), lvlNumber.GetIntValue(), villageType); } } } } } }
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); }