Ejemplo n.º 1
0
        public static Piece GetPiece(PieceType type, byte rotation, int boardWidth, int x = -1, int y = -1)
        {
            Piece returnPiece = null;

            switch (type)
            {
            case PieceType.Indigo:
                returnPiece = new IndigoPiece();
                break;

            case PieceType.Oscar:
                returnPiece = new OscarPiece();
                break;

            case PieceType.Tango:
                returnPiece = new TangoPiece();
                break;

            case PieceType.Sierra:
                returnPiece = new SierraPiece();
                break;

            case PieceType.Zulu:
                returnPiece = new ZuluPiece();
                break;

            case PieceType.Juliet:
                returnPiece = new JulietPiece();
                break;

            case PieceType.Lima:
                returnPiece = new LimaPiece();
                break;
            }

            returnPiece.Rotation = rotation;

            // If x or y are -1, this is the initial position.
            if (x == -1)
            {
                var initialPos = returnPiece.GetInitialPosition();
                returnPiece.PosX = (boardWidth / 2) + initialPos.X;
            }
            else
            {
                returnPiece.PosX = x;
            }

            if (y == -1)
            {
                var initialPos = returnPiece.GetInitialPosition();
                returnPiece.PosY = initialPos.Y;
            }
            else
            {
                returnPiece.PosY = y;
            }

            return(returnPiece);
        }
Ejemplo n.º 2
0
        public static Piece GetPiece(PieceType type, PieceRotation rotation, bool isNextPiece = true)
        {
            Piece returnPiece = null;

            switch (type)
            {
            case PieceType.Indigo:
                returnPiece = new IndigoPiece();
                break;

            case PieceType.Oscar:
                returnPiece = new OscarPiece();
                break;

            case PieceType.Tango:
                returnPiece = new TangoPiece();
                break;

            case PieceType.Sierra:
                returnPiece = new SierraPiece();
                break;

            case PieceType.Zulu:
                returnPiece = new ZuluPiece();
                break;

            case PieceType.Juliet:
                returnPiece = new JulietPiece();
                break;

            case PieceType.Lima:
                returnPiece = new LimaPiece();
                break;
            }

            returnPiece.Rotation    = rotation;
            returnPiece.IsNextPiece = isNextPiece;

            return(returnPiece);
        }