Beispiel #1
0
 /// <summary>
 /// 按照某个Block对象生成一个一样的对象
 /// </summary>
 /// <param name="oldBlock">用于生成与其一样的某个Block对象</param>
 public Block(Block oldBlock)
 {
     this.gLocation   = oldBlock.gLocation;
     this.Location    = oldBlock.Location;
     this.BackColor   = oldBlock.BackColor;
     this.BorderStyle = oldBlock.BorderStyle;
     this.Size        = oldBlock.Size;
 }
Beispiel #2
0
 /// <summary>
 /// 生成以各Block对象,网格坐标(0,0) 背景色black,BorderStyle 为 BorderStyle.None
 /// </summary>
 public Block()
 {
     this.gLocation   = new GirdPoint(0, 0);
     this.Location    = new Point(0, 0);
     this.BackColor   = Color.Black;
     this.BorderStyle = BorderStyle.None;
     this.Size        = new Size(Globals.WidthOfGird, Globals.WidthOfGird);
 }
Beispiel #3
0
 /// <summary>
 /// 生成以各Block对象
 /// </summary>
 /// <param name="gX">使用网格坐标的横坐标</param>
 /// <param name="gY">使用网格坐标的纵坐标</param>
 /// <param name="backColor">背景色</param>
 /// <param name="style">BorderStyle样式</param>
 public Block(int gX, int gY, Color backColor, BorderStyle style)
 {
     this.gLocation   = new GirdPoint(gX, gY);
     this.Location    = new Point(Globals.ToPCoordinate(gX), Globals.ToPCoordinate(gY));
     this.BackColor   = backColor;
     this.BorderStyle = style;
     this.Size        = new Size(Globals.WidthOfGird, Globals.WidthOfGird);
 }
Beispiel #4
0
        private static bool CanMove(int indexOfShape, char arg)
        {
            try
            {
                GirdPoint tempBasePoint;

                switch (arg)
                {
                case 'L':
                    tempBasePoint = new GirdPoint(Globals.BasePoint.X - 1, Globals.BasePoint.Y);
                    break;

                case 'R':
                    tempBasePoint = new GirdPoint(Globals.BasePoint.X + 1, Globals.BasePoint.Y);
                    break;

                case 'D':
                    tempBasePoint = new GirdPoint(Globals.BasePoint.X, Globals.BasePoint.Y + 1);
                    break;

                case 'E':                        //不移动,用于判断能否旋转,与判断移动不同的是传入的indexOfShape,判断旋转用的是旋转后的形状的索引,而移动用的是当前的
                    tempBasePoint = Globals.BasePoint;
                    break;

                default:
                    MessageBox.Show("错误的参数" + arg + "\n应该为'L'或'R'或'D'");
                    return(false);
                }

                int gX0 = AllShapes.Shapes[indexOfShape].DCoordinates[0] + tempBasePoint.X;
                int gY0 = AllShapes.Shapes[indexOfShape].DCoordinates[1] + tempBasePoint.Y;
                int i   = Globals.GirdArray[gY0, gX0];

                int gX1 = AllShapes.Shapes[indexOfShape].DCoordinates[2] + tempBasePoint.X;
                int gY1 = AllShapes.Shapes[indexOfShape].DCoordinates[3] + tempBasePoint.Y;
                int j   = Globals.GirdArray[gY1, gX1];

                int gX2 = AllShapes.Shapes[indexOfShape].DCoordinates[4] + tempBasePoint.X;
                int gY2 = AllShapes.Shapes[indexOfShape].DCoordinates[5] + tempBasePoint.Y;
                int m   = Globals.GirdArray[gY2, gX2];

                int gX3 = AllShapes.Shapes[indexOfShape].DCoordinates[6] + tempBasePoint.X;
                int gY3 = AllShapes.Shapes[indexOfShape].DCoordinates[7] + tempBasePoint.Y;
                int n   = Globals.GirdArray[gY3, gX3];

                //i,j,m,n为其即将到达的新位置的网格值,若为1,说明该网格已被占据
                if (gX0 < 0 || gX0 >= Globals.CountOfTier || i == 1 ||
                    gX1 < 0 || gX1 >= Globals.CountOfTier || j == 1 ||
                    gX2 < 0 || gX2 >= Globals.CountOfTier || m == 1 ||
                    gX3 < 0 || gX3 >= Globals.CountOfTier || n == 1)
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }