Пример #1
0
 // true  - clockwise right
 // false - clockwise left
 // simple spin
 public bool Rotate(Part part, bool orientation)
 {
     bool factor;
      int side;
      part.Rotate(orientation);
     if(!isValid(part, out factor, out side))
     {
         part.Rotate(!orientation);
         if(factor)
         {
             if(side == 1)
             {
                 if (MoveLeft(part))
                 {
                     return Rotate(part, orientation);
                 }
             }
             else
             {
                 if(MoveRight(part))
                 {
                     return Rotate(part, orientation);
                 }
             }
         }
         return false;
     }
         return true;
 }
Пример #2
0
 public bool MoveRight(Part part)
 {
     part.MoveRight();
      if(!isValid(part))
      {
          part.MoveLeft();
          return false;
      }
      return true;
 }
Пример #3
0
 public bool MoveDown(Part part)
 {
     part.MoveDown();
      if(!isValid(part))
      {
          part.MoveUp();
          fillBoard(part, true);
          return false;
      }
      return true;
 }
Пример #4
0
 private bool isValid(Part part)
 {
     bool foo;
     int foo1;
     return isValid(part, out foo, out foo1);
 }
Пример #5
0
        // true - right 1 false - (-1) no err 0
        private bool isValid(Part part, out bool isOutOfBoard, out int side)
        {
            isOutOfBoard = false;
            side = 0;
            foreach (SimpleCube sc in part.GetCubes)
            {
                try
                {
                    if(sc.getPosX>width-1)
                    {
                        side = 1;
                    }
                    else if (sc.getPosX<0)
                    {
                        side = -1;
                    }

                    if (GameBoard[sc.getPosX, sc.getPosY] !=null)
                    {
                        return false;
                    }
                }
                catch (IndexOutOfRangeException e)
                {
                    isOutOfBoard = true;
                    return false;
                }

            }
            return true;
        }
Пример #6
0
 private void fillBoard(Part part, bool value)
 {
     foreach (SimpleCube sc in part.GetCubes)
     {
         GameBoard[sc.getPosX, sc.getPosY] = sc;
     }
 }
Пример #7
0
 // return true if player scored a line
 protected bool loseCondition(Part part)
 {
     return !isValid(part);
 }