lundi 1 mars 2021

arranging objects in random rows and columns

private void InitialSetup()
{
    AddPiece(whiteRook, white, 0, 0);
    AddPiece(whiteKnight, white,1,2);
    AddPiece(whiteBishop, white,2,0);
    AddPiece(whiteQueen, white, 3,4);
    AddPiece(whiteKing, white, 4, 6);
    AddPiece(whiteBishop, white,5,0);
    AddPiece(whiteKnight, white,6,3);
    AddPiece(whiteRook, white, 7, 6);
}

public void AddPiece(GameObject prefab, Player player, int col, int row)
{
    GameObject pieceObject = board.AddPiece(prefab, col, row);

    player.pieces.Add(pieceObject);
    pieces[col, row] = pieceObject;
}

8 columns 6 rows I have 48 game objects, I want them to be arranged in random rows and columns every time the game starts, but how can I do this with the addPiece method?




Aucun commentaire:

Enregistrer un commentaire