public void SetBrakeCouplePuzzle(int y, int x, Puzzle[,] puzzles)
 {
     if (!puzzles[y, x].Changed)
     {
         Array values = Enum.GetValues(typeof(PuzzlesConfigurations.puzzleBrakeCoupleEnum));
         PuzzlesConfigurations.puzzleBrakeCoupleEnum puzzleChimera = (PuzzlesConfigurations.puzzleBrakeCoupleEnum)values.GetValue(random.Next(values.Length));
         switch (puzzleChimera)
         {
             case PuzzlesConfigurations.puzzleBrakeCoupleEnum.horizontalDivide:
                 HorizontalDivide(y, x, puzzles);
                 break;
             case PuzzlesConfigurations.puzzleBrakeCoupleEnum.untouchable:
                 Untouchable(y, x, puzzles);
                 break;
             case PuzzlesConfigurations.puzzleBrakeCoupleEnum.verticalCouple:
                 VerticalCouple(y, x, puzzles);
                 break;
             case PuzzlesConfigurations.puzzleBrakeCoupleEnum.horizontalCouple:
                 HorizontalCouple(y, x, puzzles);
                 break;
             case PuzzlesConfigurations.puzzleBrakeCoupleEnum.verticalDivide:
                 VerticalDivide(y, x, puzzles);
                 break;
             default:
                 break;
         }
     }
 }
        public List<Puzzle> Create(Puzzle[,] puzzles)
        {
            for (int y = 0; y < PuzzlesConfigurations.Vertical; y++)
               {
               for (int x = 0; x < PuzzlesConfigurations.Horizontal; x++)
               {
                   if (puzzles[y, x] != null)
                   {
                       if (puzzles[y, x].divededPuzzles[0] != null)
                       {
                           for (int i = 0; i < 2; i++)
                           {
                               puzzles[y, x].divededPuzzles[i].ImageOrder = ++order;
                               puzzlesList.Add(puzzles[y, x].divededPuzzles[i]);
                           }
                       }
                       else
                       {
                           puzzles[y, x].ImageOrder = ++order;
                           puzzlesList.Add(puzzles[y, x]);
                       }
                   }
               }
               }

               return puzzlesList;
        }
 private void HorizontalCouple(int y, int x, Puzzle[,] puzzles)
 {
     if (x != puzzles.GetLength(1) - 1 && puzzles[y, x + 1] != null)
     {
         puzzles[y, x].Changed = true;
         puzzles[y, x].Width *= 2;
         puzzles[y, x + 1] = null;
     }
 }
Ejemplo n.º 4
0
        public Puzzle CreatePuzzle(int bucketCapacity1, int bucketCapacity2, int desiredAmount)
        {
            Puzzle puzzle = new Puzzle(bucketCapacity1, bucketCapacity2, desiredAmount);

            using (var db = OdbFactory.Open(_dbName))
            {
                db.Store(puzzle);
            }

            return puzzle;
        }
 private void HorizontalDivide(int y, int x, Puzzle[,] puzzles)
 {
     puzzles[y, x].Changed = true;
     puzzles[y, x].divededPuzzles = new Puzzle[2] { new Puzzle(), new Puzzle() };
     for (int i = 0; i < 2; i++)
     {
         puzzles[y, x].divededPuzzles[i].Width = puzzles[y, x].Width;
         puzzles[y, x].divededPuzzles[i].Height = puzzles[y, x].Height / 2;
         puzzles[y, x].divededPuzzles[i].CoordinateX = puzzles[y, x].CoordinateX;
         if (i == 0)
         {
             puzzles[y, x].divededPuzzles[i].Changed = true;
             puzzles[y, x].divededPuzzles[i].CoordinateY = puzzles[y, x].CoordinateY;
         }
         else
         {
             puzzles[y, x].divededPuzzles[i].Changed = true;
             puzzles[y, x].divededPuzzles[i].CoordinateY = puzzles[y, x].CoordinateY + puzzles[y, x].Height / 2;
         }
     }
 }
 private void VerticalCouple(int y, int x, Puzzle[,] puzzles)
 {
     if (y != puzzles.GetLength(0) - 1)
     {
         puzzles[y, x].Changed = true;
         puzzles[y, x].Height *= 2;
         puzzles[y + 1, x] = null;
     }
 }
 private void Untouchable(int y, int x, Puzzle[,] puzzles)
 {
     puzzles[y, x].Changed = true;
 }