private static int SetPieces(string[] pieceFile, int index, PieceColor[,] colors, Quaternion[,] rotations, ref IPiece[,] pieces)
    {
        int a = 0;

        for (int i = index; i < pieceFile.Length; i++)
        {
            if (pieceFile[i].Trim() == "~")
            {
                return(Mathf.Clamp(i + 1, 0, pieceFile.Length - 1));
            }

            for (int j = 0; j < pieceFile[i].Length; j++)
            {
                char   c = pieceFile[i][j];
                IPiece gp;

                switch (c)
                {
                case 'I':
                    gp = new Pharaoh(new Point(a, j), rotations[a, j], colors[a, j], null);
                    break;

                case 'S':
                    gp = new Sphynx(new Point(a, j), rotations[a, j], colors[a, j], null);
                    break;

                case 'C':
                    gp = new Scarab(new Point(a, j), rotations[a, j], colors[a, j], null);
                    break;

                case 'A':
                    gp = new Anubis(new Point(a, j), rotations[a, j], colors[a, j], null);
                    break;

                case 'P':
                    gp = new Pyramid(new Point(a, j), rotations[a, j], colors[a, j], null);
                    break;

                default:
                    gp = new EmptyPoint(null, new Point(a, j));
                    break;
                }

                pieces[a, j] = gp;
            }

            a++;
        }

        return(Mathf.Clamp(index + 1, 0, pieceFile.Length - 1));
    }
示例#2
0
    public Board(int width, int height)
    {
        this.width  = width;
        this.height = height;
        pieces      = new IPiece[width, height];
        underlines  = new Underline[width, height];

        for (int i = 0; i < pieces.GetLength(0); i++)
        {
            for (int j = 0; j < pieces.GetLength(1); j++)
            {
                pieces[i, j]     = new EmptyPoint(this, i, j);
                underlines[i, j] = Underline.Blank;
            }
        }
    }