private void Rotate(bool anticlockwise = false) { IRotateStrategy strategy = RotateStrategies.Where(x => x.Direction == CurrentPosition.Direction).FirstOrDefault(); if (strategy != null) { strategy.Execute(this, anticlockwise); } }
//Set proper Rotation algorithm based on the chosen configuration private void SetRotation() { switch (boardConfig.rotationType) { case RotateType.Matrix: rotateStrategy = new MatrixRotate(); break; case RotateType.Nintendo: rotateStrategy = new NESRotate(); break; default: rotateStrategy = new MatrixRotate(); break; } }
public static IRotateStrategy CreateRotateStrategy(Direction direction) { IRotateStrategy strategy = GetRotateStrategies().FirstOrDefault(x => x.Direction.Equals(direction)); return(strategy); }