Exemplo n.º 1
0
            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;
                }
            }
Exemplo n.º 2
0
            public Box()
            {
                show = false;
                found = 0;
                Box.cursor = new Baffle(0, 0);

                return;
            }
Exemplo n.º 3
0
 private bool SpaceOccupied(Baffle baffle, int size)
 {
     for (int b = 0; b < size; b++)
     {
         if (Box.baffles[b].Equals(baffle))
         {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
            private int GetBaffle(Baffle baffle)
            {
                for (int b = 0; b < count; b++)
                {
                    if (Match(baffle, b))
                    {
                        return b;
                    }

                }
                return -1;
            }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 private bool Correct(Baffle baffle)
 {
     if (GetBaffle(baffle) >= 0)
     {
         return true;
     }
     return false;
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 public bool Equals(Baffle other)
 {
     if (this.x != other.x) return false;
     if (this.y != other.y) return false;
     return true;
 }