I'm trying to replicate Minesweeper.
I have this code that spawns a bunch of squares in a grid formation, to make the game board; this leaves me with 100 GameObjectsgame objects all named "square(clone)"
//10x10 grid
yPos = yStart;
for (row = 0; row < 10; row++)
{ xPos = xStart;
for (column = 0; column < 10; column++)
{
newPos = new Vector2(xPos, yPos);
Instantiate(coolsquare, newPos, Quaternion.identity);
xPos = xPos + 1f;
}
yPos = yPos - 1f;
}
//10x10 grid
yPos = yStart;
for (row = 0; row < 10; row++)
{
xPos = xStart;
for (column = 0; column < 10; column++)
{
newPos = new Vector2(xPos, yPos);
Instantiate(coolsquare, newPos, Quaternion.identity);
xPos = xPos + 1f;
}
yPos = yPos - 1f;
}
theThe squares have this script with a few working idsIDs that tellstell me theytheir row and collumncolumn, and also a status bool
public bool marked = false;
public int rowid, columnid;
filacolum = GameObject.FindGameObjectWithTag("tablerofacil").GetComponent<tablerofacil>();
rowid = filacolum.row;
columnid = filacolum.column;
public bool marked = false;
public int rowid, columnid;
filacolum = GameObject.FindGameObjectWithTag("tablerofacil").GetComponent<tablerofacil>();
rowid = filacolum.row;
columnid = filacolum.column;
So, I want to be able to select a random set of thisthese squares and change their status to "marked = true",.
I tried a few things like tags with "GameObject.FindGameObjectWithTag("square").GetComponent();GameObject.FindGameObjectWithTag("square").GetComponent<squarecode>(); but I can't find a way to access to the variables of multiple clones,. in fact, I can't find a way to change the variables value of any other clone other than the first.
I'm pretty new in this gamedev thing so maybe im overcomplicating things from the start so any help is welcomed
I'm triying to replicate minesweeper if it helps lol