예제 #1
0
        public void Undo()
        {
            if (CanUndo())
            {
                CreateAnimation($"Command Undone: {GetUndoHint()}");

                var command = _commands.Pop();
                command.Undo();
                CommandStackChanged?.Invoke();
            }
        }
예제 #2
0
        public void Dispose()
        {
            _spriteBatch.Dispose();
            _spriteBatch = null;

            if (CommandStackChanged != null)
            {
                foreach (var d in CommandStackChanged.GetInvocationList())
                {
                    CommandStackChanged -= (d as CommandStackChangedDelegate);
                }
            }
        }
예제 #3
0
        public void ExecuteCommand(ICommand command, bool isUndoable = true)
        {
            if (command == null)
            {
                throw new ArgumentNullException("Command is null");
            }
            if (isUndoable)
            {
                _commands.Push(command);
            }
            command.Initialize(Game);
            command.Execute();

            CreateAnimation($"Command added: {command.GetHintText()}");
            if (isUndoable)
            {
                CommandStackChanged?.Invoke();
            }
        }