示例#1
0
        public bool CheckLeft()
        {
            int summand = 1;

            for (int x = 0; x < TetroField.GetUpperBound(1); x++)
            {
                for (int y = 0; y < TetroField.GetUpperBound(0); y++)
                {
                    if (x + this.X <= 0)
                    {
                        if (tetroField[y, x] != -1)
                        {
                            return(false);
                        }
                    }

                    if (tetroField[y, x] != -1)
                    {
                        if (x == 0)
                        {
                            summand = 0;
                        }
                        if (gameField[this.Y + y, this.X + x - 1] != -1 && (summand == 0 || tetroField[y, x - summand] == -1))
                        {
                            return(false);
                        }
                    }
                    summand = 1;
                }
            }

            return(true);
        }
示例#2
0
        public bool CheckRight()
        {
            int summand = 1;

            for (int x = 0; x < TetroField.GetUpperBound(1) + 1; x++)
            {
                for (int y = 0; y < TetroField.GetUpperBound(0) + 1; y++)
                {
                    if (x + this.X >= gameField.GetUpperBound(1))
                    {
                        if (tetroField[y, x] != -1)
                        {
                            return(false);
                        }
                    }

                    if (tetroField[y, x] != -1)
                    {
                        if (x == TetroField.GetUpperBound(0))
                        {
                            summand = 0;
                        }
                        if (gameField[this.Y + y, this.X + x + 1] != -1 && (summand == 0 || tetroField[y, x + summand] == -1))
                        {
                            return(false);
                        }
                    }
                    summand = 1;
                }
            }

            return(true);
        }
示例#3
0
        public bool KickDown()
        {
            int summand = 1;

            Clear();
            do
            {
                for (int y = 0; y < TetroField.GetUpperBound(1) + 1; y++)
                {
                    for (int x = 0; x < TetroField.GetUpperBound(0) + 1; x++)
                    {
                        if (tetroField[y, x] != -1)
                        {
                            if (y == TetroField.GetUpperBound(1))
                            {
                                summand = 0;
                            }
                            if (gameField[this.Y + y + 1, this.X + x] != -1 && (summand == 0 || tetroField[y + summand, x] == -1))
                            {
                                Fill();
                                return(false);
                            }
                        }
                    }
                }

                this.Y++;
            }while (true);
        }
示例#4
0
 private void Clear()
 {
     for (int y = 0; y < TetroField.GetUpperBound(0) + 1; y++)
     {
         for (int x = 0; x < TetroField.GetUpperBound(1) + 1; x++)
         {
             if (this.tetroField[y, x] != -1)
             {
                 gameField[Math.Abs(y + this.Y), Math.Abs(x + this.X)] = -1;
             }
         }
     }
 }
示例#5
0
        public void Rotate()
        {
            if (this.Type != TetroType.O)
            {
                int center = 2;
                if (this.type == TetroType.I)
                {
                    center = 3;
                }


                sbyte[,] temp = new sbyte[TetroField.GetUpperBound(0) + 1, TetroField.GetUpperBound(0) + 1];

                for (int y = 0; y < TetroField.GetUpperBound(0) + 1; y++)
                {
                    for (int x = 0; x < TetroField.GetUpperBound(1) + 1; x++)
                    {
                        if (-y + center >= 0)
                        {
                            temp[-y + center, x] = TetroField[x, y];
                        }
                    }
                }
                for (int y = 0; y < TetroField.GetUpperBound(0) + 1; y++)
                {
                    for (int x = 0; x < TetroField.GetUpperBound(1) + 1; x++)
                    {
                        if (temp[y, x] != -1)
                        {
                            if (this.X < 0)
                            {
                                if (CheckRight())
                                {
                                    MoveRight();
                                }
                                else
                                {
                                    return;
                                }
                            }
                            else if (this.X + this.tetroField.GetUpperBound(1) + 1 > gameField.GetUpperBound(1) + 1)
                            {
                                if (CheckLeft())
                                {
                                    MoveLeft();
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                    }
                }

                Clear();

                TetroField = temp;

                Fill();
            }
        }