How to Make Text Count Objects in a Grid?
I have a game in which a player can add or take white tiles from a grid in order to fill in required spaces - stopping at the first tile in which it hits (gray tiles are stationary). I'd like it to also lower a counter whenever a tile is added, and not allow any tiles to be added when the counter is at 0. Inversely, I'd like it to add to the counter whenever a tile is taken.
I'm just not sure how to go about this. This needs to be a method that can be duplicated across multiple levels as well. My best idea would be to count the number of objects in the grid with the tag "Correct Tile" or "Incorrect Tile", as each cell of the grid is its own object as a child of "Board". The cells are arranged from the top left cell being "Cell A (1)" to the bottom right being "Cell S (19)".
The numbers at the bottom left are the tile counters. The number on the white tile ("TileCounterCurrent") is the current number of usable tiles left, while the number on the gray tile ("TileCounterMax") is the maximum tiles for this level.
Your answer
Follow this Question
Related Questions
Please help me to solve this in unity C# scripts (TriggerCounter and OnTriggerEnter) 0 Answers
Need help with how my script needs to be attached 2 Answers
Notify a script that a transform has changed its parent 1 Answer
C# GameObject disabled scripts of its children after SetActive(false) 1 Answer
[Unity 2D]Grid Based Character Movement Issues with Vector3D.movetowards 0 Answers