public void Undo() { if (CanUndo()) { CreateAnimation($"Command Undone: {GetUndoHint()}"); var command = _commands.Pop(); command.Undo(); CommandStackChanged?.Invoke(); } }
public void Dispose() { _spriteBatch.Dispose(); _spriteBatch = null; if (CommandStackChanged != null) { foreach (var d in CommandStackChanged.GetInvocationList()) { CommandStackChanged -= (d as CommandStackChangedDelegate); } } }
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(); } }