Exemple #1
0
        public override void setBlocksPos(int x, int y)
        {
            SingleBlock b1 = (SingleBlock)blocks[0];
            SingleBlock b2 = (SingleBlock)blocks[1];
            SingleBlock b3 = (SingleBlock)blocks[2];
            SingleBlock b4 = (SingleBlock)blocks[3];

            setX(x);
            setY(y);
            switch (this.rot)
            {
            case 1:
                b1.setBlocksPos(x, y);
                b2.setBlocksPos(x + 1, y);
                b3.setBlocksPos(x - 1, y);
                b4.setBlocksPos(x + 2, y);
                break;

            case 2:
                b1.setBlocksPos(x, y);
                b2.setBlocksPos(x, y - 1);
                b3.setBlocksPos(x, y + 1);
                b4.setBlocksPos(x, y + 2);
                break;

            case 3:
                b1.setBlocksPos(x, y + 1);
                b2.setBlocksPos(x + 1, y + 1);
                b3.setBlocksPos(x - 1, y + 1);
                b4.setBlocksPos(x + 2, y + 1);
                break;

            case 4:
                b1.setBlocksPos(x - 1, y);
                b2.setBlocksPos(x - 1, y - 1);
                b3.setBlocksPos(x - 1, y + 1);
                b4.setBlocksPos(x - 1, y + 2);
                break;
            }
            blocks[0] = b1;
            blocks[1] = b2;
            blocks[2] = b3;
            blocks[3] = b4;
        }
        public override List <KeyValuePair <int, int> > getPos()
        {
            List <KeyValuePair <int, int> > poses = new List <KeyValuePair <int, int> >();

            for (int i = 0; i < blocks.Count; i++)
            {
                DoubleBlock db = blocks[i] as DoubleBlock;
                SingleBlock sb = blocks[i] as SingleBlock;
                if (db != null)
                {
                    // double block
                    List <KeyValuePair <int, int> > dbpos = db.getPos();
                    poses.AddRange(dbpos);
                }
                else if (sb != null)
                {
                    // is singleblock
                    List <KeyValuePair <int, int> > sbpos = sb.getPos();
                    poses.AddRange(sbpos);
                }
            }
            return(poses);
        }
Exemple #3
0
 public DoubleBlock()
 {
     blocks[0] = new SingleBlock();
     blocks[1] = new SingleBlock();
 }