public Back(Status[,] status, int x, int y) { this.State = status[x, y]; Point point; if (this.State == Status.Blank) { point = new Point(0, 0); } else { if (x == 0 && y == 0) { point = new Point(2, 8); } else if (x == status.GetLength(0) - 1 && y == 0) { point = new Point(3, 8); } else if (x == status.GetLength(0) - 1 && y == status.GetLength(1) - 1) { point = new Point(0, 8); } else if (x == 0 && y == status.GetLength(1) - 1) { point = new Point(1, 8); } else if (x == 0) { if (status[x + 1, y] == Status.Wall) point = new Point(2, 9); else point = new Point(2, 10); } else if (y == 0) { if (status[x, y + 1] == Status.Wall) point = new Point(3, 9); else point = new Point(3, 10); } else if (x == status.GetLength(0) - 1) { if (status[x - 1, y] == Status.Wall) point = new Point(0, 9); else point = new Point(0, 10); } else if (y == status.GetLength(1) - 1) { if (status[x, y - 1] == Status.Wall) point = new Point(1, 9); else point = new Point(1, 10); } else { int walls = 0; if (status[x - 1, y] == Status.Wall) walls++; if (status[x, y - 1] == Status.Wall) walls++; if (status[x + 1, y] == Status.Wall) walls++; if (status[x, y + 1] == Status.Wall) walls++; switch (walls) { case 4: point = new Point(0, 1); break; case 3: if (status[x - 1, y] == Status.Blank) point = new Point(0, 2); else if (status[x, y - 1] == Status.Blank) point = new Point(1, 2); else if (status[x + 1, y] == Status.Blank) point = new Point(2, 2); else point = new Point(3, 2); break; case 2: if (status[x + 1, y] == Status.Wall && status[x, y + 1] == Status.Wall) point = new Point(0, 3); else if (status[x, y + 1] == Status.Wall && status[x - 1, y] == Status.Wall) point = new Point(1, 3); else if (status[x - 1, y] == Status.Wall && status[x, y - 1] == Status.Wall) point = new Point(2, 3); else if (status[x, y - 1] == Status.Wall && status[x + 1, y] == Status.Wall) point = new Point(3, 3); else if (status[x - 1, y] == Status.Wall && status[x + 1, y] == Status.Wall) point = new Point(0, 4); else point = new Point(1, 4); break; case 1: if (status[x + 1, y] == Status.Wall) point = new Point(0, 5); else if (status[x, y + 1] == Status.Wall) point = new Point(1, 5); else if (status[x - 1, y] == Status.Wall) point = new Point(2, 5); else point = new Point(3, 5); break; default: point = new Point(0, 6); break; } } } this.ImageChip = new ImageChip(@"Images\back", point.X, point.Y); }