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

                var command = _commands.Pop();
                command.Undo();
                CommandStackChanged?.Invoke();
            }
        }
예제 #2
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();
            }
        }