Beispiel #1
0
        private void RedoObjects()
        {
            if (_historyService.RedoLevelObjects.Count > 0)
            {
                WorldObjectChange redoObject = _historyService.RedoWorldObjects.Pop();
                _historyService.UndoWorldObjects.Push(ApplyObjectChange(redoObject));
            }

            //UpdateSpriteStatus();
        }
Beispiel #2
0
        private WorldObjectChange ApplyObjectChange(WorldObjectChange objectChange)
        {
            WorldObjectChange newChange   = null;
            List <Rect>       updateRects = new List <Rect>()
            {
                objectChange.OriginalObject.VisualRectangle
            };

            if (objectChange.ChangeType == WorldObjectChangeType.Addition)
            {
                newChange = new WorldObjectChange(objectChange.OriginalObject, objectChange.OriginalObject.X, objectChange.OriginalObject.Y, objectChange.OriginalObject.GameObjectId, WorldObjectChangeType.Deletion);
                _world.ObjectData.Remove(objectChange.OriginalObject);
                _selectedObject = null;
                ClearSelectionRectangle();
            }
            else if (objectChange.ChangeType == WorldObjectChangeType.Deletion)
            {
                newChange = new WorldObjectChange(objectChange.OriginalObject, objectChange.OriginalObject.X, objectChange.OriginalObject.Y, objectChange.OriginalObject.GameObjectId, WorldObjectChangeType.Addition);
                _world.ObjectData.Add(objectChange.OriginalObject);
                _selectedObject = objectChange.OriginalObject;
                SetSelectionRectangle(_selectedObject.CalcBoundBox());
            }
            else if (objectChange.ChangeType == WorldObjectChangeType.Update)
            {
                newChange = new WorldObjectChange(objectChange.OriginalObject, objectChange.OriginalObject.X, objectChange.OriginalObject.Y, objectChange.OriginalObject.GameObjectId, WorldObjectChangeType.Update);
                objectChange.OriginalObject.X            = objectChange.X;
                objectChange.OriginalObject.Y            = objectChange.Y;
                objectChange.OriginalObject.GameObjectId = objectChange.GameId;
                objectChange.OriginalObject.GameObject   = _gameObjectService.GetObject(objectChange.GameId);
                updateRects.Add(objectChange.OriginalObject.CalcVisualBox(true));
                _selectedObject = objectChange.OriginalObject;
                SetSelectionRectangle(_selectedObject.CalcBoundBox());
            }

            Update(updateRects);
            return(newChange);
        }