Ejemplo n.º 1
0
        private bool CheckCrash(int rotate, int offsetX, int offsetY)
        {
            bool[,] newMap;

            if (FallingBlockSet == null)
            {
                return(false);
            }
            switch (rotate)
            {
            case 1:
                newMap = FallingBlockSet.BlockMap[FallingBlockSet.GetNextFace(Turn.Clockwise)];
                break;

            case -1:
                newMap = FallingBlockSet.BlockMap[FallingBlockSet.GetNextFace(Turn.CounterClockwise)];
                break;

            case 0:
            default:
                newMap = FallingBlockSet.BlockMap[FallingBlockSet.Face];
                break;
            }

            for (int y = 0; y < FallingBlockSet.Length; y++)
            {
                for (int x = 0; x < FallingBlockSet.Length; x++)
                {
                    if (newMap[y, x])
                    {
                        int TargetX = FallingBlockSet.OriginX + offsetX + x;
                        int TargetY = FallingBlockSet.OriginY + offsetY + y;

                        /* Edge checking */
                        if (TargetX < 0 || TargetX >= BlocksWidth)
                        {
                            return(true);
                        }
                        if (TargetY < 0 || TargetY >= BlocksHeight)
                        {
                            return(true);
                        }

                        /* Block checking */
                        if (!Blocks[TargetY, TargetX].Empty)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }