public CoordinateStepping() { Stepping[0] = new CoordinateStep(Constants.Step, 0); Stepping[1] = new CoordinateStep(-Constants.Step, 0); Stepping[2] = new CoordinateStep(0, Constants.Step); Stepping[3] = new CoordinateStep(0, -Constants.Step); }
private bool CanGoOut(Block block, List <Block> blocks) { Block neighbour = new Block(); CoordinateStepping stepping = new CoordinateStepping(); CoordinateStep directionNeigh = new CoordinateStep(0, 0); foreach (var item in blocks) { if (AreNeighbours(item, block)) { neighbour = item; break; } } for (int i = 0; i < stepping.Stepping.Length; i++) { if (((block.Left - neighbour.Left) == stepping.Stepping[i].Left) && ((block.Top - neighbour.Top) == stepping.Stepping[i].Top)) { directionNeigh = stepping.Stepping[i]; break; } } var dirTop = new CoordinateStep(2 * directionNeigh.Top, 2 * directionNeigh.Left); var dirTopDown = new CoordinateStep(-2 * directionNeigh.Top, -2 * directionNeigh.Left); foreach (Block item in blocks) { if ((item.Left == block.Left + dirTop.Left) && (item.Top == block.Top + dirTop.Top)) { return(false); } if ((item.Left == block.Left + dirTopDown.Left) && (item.Top == block.Top + dirTopDown.Top)) { return(false); } } return(true); }