Beispiel #1
0
        public static bool CanBeRotated(Figure figure, int[,] field, int currX, int currY)
        {
            var CheckingFigure = GenerateFigure.getFigure(Indexes.currIndex);

            for (int i = 0; i < CheckingFigure.size; i++)
            {
                for (int j = 0; j < CheckingFigure.size; j++)
                {
                    CheckingFigure.matrix[i, j] = figure.matrix[i, j];
                }
            }
            CheckingFigure.rotate();
            if (Validator.IsInRange(CheckingFigure, field, Indexes.currX, Indexes.currY))
            {
                for (int i = 0; i < CheckingFigure.size; i++)
                {
                    for (int j = 0; j < CheckingFigure.size; j++)
                    {
                        if (CheckingFigure.matrix[i, j] != 0 && field[i + Indexes.currX, j + Indexes.currY] != 0)
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 public static void MoveToNextRow(object source, ElapsedEventArgs e)
 {
     if (!Moves.canBeMoved("down", FigureHolder.myFigure, Field.field, Indexes.currX, Indexes.currY))
     {
         if (Indexes.currX == 0)
         {
             Console.WriteLine("GameOver");
             ImportantGameVariables.gameOver = true;
             return;
         }
         else
         {
             FieldSaver.saveField(FigureHolder.myFigure, Field.field, Indexes.currX, Indexes.currY);
             LaneRemover.RemoveLane(Field.field, Indexes.currX, Indexes.currY);
             FigureHolder.myFigure = GenerateFigure.Generate();
             Indexes.currX         = 0;
             Indexes.currY         = 0;
             if (!Validator.IsInRange(FigureHolder.myFigure, Field.field, Indexes.currX, Indexes.currY))
             {
                 ImportantGameVariables.gameOver = true;
                 return;
             }
         }
     }
     else
     {
         Indexes.currX++;
     }
     Printer.Print(FigureHolder.myFigure, Field.field, Indexes.currX, Indexes.currY);
 }