Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 0; i < 10; ++i)
        {
            pieces[i] = new PieceTest[10];
            for (int j = 0; j < 10; ++j)
            {
                if (i < 3)
                {
                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        pieces[i][j] = new PieceTest(Color.White, new Vector3(j, 0.65f, i));
                    }
                    else if (i % 2 == 1 && j % 2 == 1)
                    {
                        pieces[i][j] = new PieceTest(Color.White, new Vector3(j, 0.65f, i));
                    }
                }

                if (i > 6)
                {
                    if (i % 2 == 0 && j % 2 == 0)
                    {
                        pieces[i][j] = new PieceTest(Color.Black, new Vector3(j, 0.65f, i));
                    }
                    else if (i % 2 == 1 && j % 2 == 1)
                    {
                        pieces[i][j] = new PieceTest(Color.Black, new Vector3(j, 0.65f, i));
                    }
                }
            }
        }
        displayPieces();
    }
Example #2
0
 private void displayPieces()
 {
     for (int i = 0; i < 10; ++i)
     {
         for (int j = 0; j < 10; ++j)
         {
             if (pieces[i][j] != null)
             {
                 PieceTest piece = pieces[i][j];
                 Instantiate(piecesPrefabs[(int)piece.color], piece.position, Quaternion.identity);
             }
         }
     }
 }