public async Task <bool> ValidateRotationAsync(GameGrid area, Figure figure) { await Task.Yield(); return((await figure.GetPositionWithOffsetAsync()).AsParallel().All(point => point.X >= 0 && point.X < area.Width && point.Y >= 0 && point.Y < area.Height && !area[point].IsOccupiedWithNotFigure)); }
public Task <MovingValidationResult> ValidateMoveAsync(GameGrid area, Figure figure, Point offset) { switch (offset) { case Point p when p.X == 1: return(CanMoveRightAsync(area, figure)); case Point p when p.X == -1: return(CanMoveLeftAsync(area, figure)); case Point p when p.Y == 1: return(CanMoveDownAsync(area, figure)); default: return(Task.FromResult(new MovingValidationResult { Allow = true })); } }
public async Task RestartAsync(int width, int height) { await Task.Yield(); Grid = new GameGrid(width, height); }