public void Reset(int count, int seed) { Random rand = new Random(seed); Box.count = count; Box.found = 0; Box.cursor.x = 0; Box.cursor.y = 0; Box.cursor.type = BaffleType.SLASH; Box.baffles = new Baffle[count]; Baffle.Initialize(Box.display); Baffle.LoadBaffle(this.baffle); for (int b = 0; b < Box.count; b++) { Baffle tbaffle = new Baffle(Box.posx, Box.posy); do { tbaffle.x = rand.Next(0, 8); tbaffle.y = rand.Next(0, 8); } while (SpaceOccupied(tbaffle, b)); tbaffle.type = ((rand.Next(0, 2) > 0) ? BaffleType.SLASH : BaffleType.BACKSLASH); tbaffle.hidden = true; Box.baffles[b] = tbaffle; } }
public Box() { show = false; found = 0; Box.cursor = new Baffle(0, 0); return; }
private bool SpaceOccupied(Baffle baffle, int size) { for (int b = 0; b < size; b++) { if (Box.baffles[b].Equals(baffle)) { return true; } } return false; }
private int GetBaffle(Baffle baffle) { for (int b = 0; b < count; b++) { if (Match(baffle, b)) { return b; } } return -1; }
private bool Match(Baffle baffle, int index) { if ((baffle.x == baffles[index].x) && (baffle.y == baffles[index].y) && (baffle.type == baffles[index].type)) { return true; } return false; }
private bool Correct(Baffle baffle) { if (GetBaffle(baffle) >= 0) { return true; } return false; }
private bool SpaceOccupied(Baffle baffle, bool hidden) { for (int b = 0; b < count; b++) { if (Box.baffles[b].Equals(baffle)) { if (Box.baffles[b].hidden == hidden) return true; } } return false; }
public bool Equals(Baffle other) { if (this.x != other.x) return false; if (this.y != other.y) return false; return true; }