Esempio n. 1
0
        /// <summary>Spawns the specified piece.</summary>
        /// <param name="_piece">The piece to be created.</param>
        private void Spawn(Tetremino _piece)
        {
            position = new Point(0, 0);
            type     = _piece;

            switch (_piece)
            {
            case Tetremino.PURPLE_T:
                image = PURPLE_TILE;
                shape = Initialize(Tetremino.PURPLE_T);
                break;

            case Tetremino.BLUE_I:
                image = LIGHT_BLUE_TILE;
                shape = Initialize(Tetremino.BLUE_I);
                break;

            case Tetremino.BLUE_L:
                image = BLUE_TILE;
                shape = Initialize(Tetremino.BLUE_L);
                break;

            case Tetremino.GREEN_Z:
                image = GREEN_TILE;
                shape = Initialize(Tetremino.GREEN_Z);
                break;

            case Tetremino.ORANGE_J:
                image = ORANGE_TILE;
                shape = Initialize(Tetremino.ORANGE_J);
                break;

            case Tetremino.RED_S:
                image = RED_TILE;
                shape = Initialize(Tetremino.RED_S);
                break;

            case Tetremino.YELLOW_O:
                image = YELLOW_TILE;
                shape = Initialize(Tetremino.YELLOW_O);
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        /// <summary>Initializes a new instance of the <see cref="TetreminoModel" /> class.</summary>
        /// <param name="piece">The piece.</param>
        public TetreminoModel(Tetremino piece)
        {
            image = new ImageBrush();

            Spawn(piece);
        }
Esempio n. 3
0
        /// <summary>Initializes the specified piece with a Point array.</summary>
        /// <param name="_piece">The piece to initialize.</param>
        /// <returns></returns>
        private Point[] Initialize(Tetremino _piece)
        {
            Point[] temp = new Point[4];

            switch (_piece)
            {
            case Tetremino.PURPLE_T:
                temp[0] = new Point(5, 2);
                temp[1] = new Point(4, 1);
                temp[2] = new Point(5, 1);
                temp[3] = new Point(6, 1);

                return(temp);

            case Tetremino.BLUE_I:
                temp[0] = new Point(4, 1);
                temp[1] = new Point(5, 1);
                temp[2] = new Point(6, 1);
                temp[3] = new Point(7, 1);

                return(temp);

            case Tetremino.BLUE_L:
                temp[0] = new Point(4, 1);
                temp[1] = new Point(4, 2);
                temp[2] = new Point(5, 2);
                temp[3] = new Point(6, 2);

                return(temp);

            case Tetremino.GREEN_Z:
                temp[0] = new Point(5, 1);
                temp[1] = new Point(4, 2);
                temp[2] = new Point(5, 2);
                temp[3] = new Point(6, 1);

                return(temp);

            case Tetremino.ORANGE_J:
                temp[0] = new Point(6, 2);
                temp[1] = new Point(4, 2);
                temp[2] = new Point(5, 2);
                temp[3] = new Point(6, 1);

                return(temp);

            case Tetremino.RED_S:
                temp[0] = new Point(5, 1);
                temp[1] = new Point(4, 1);
                temp[2] = new Point(5, 2);
                temp[3] = new Point(6, 2);

                return(temp);

            case Tetremino.YELLOW_O:
                temp[0] = new Point(6, 1);
                temp[1] = new Point(5, 1);
                temp[2] = new Point(6, 2);
                temp[3] = new Point(5, 2);

                return(temp);

            default:
                return(null);
            }
        }