Need some sort of foreach method
Hello all,
Here's what I'm trying to accomplish. In this game the user will have a number of units arranged in a grid formation
(pre gameplay. Pretty much like the game mini warriors does here https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQ56OLfbWUwQm8e7aAJmYfm4uU2eKzNYhbvPUIVmTWiHmAv4VDI )
Each unit has unique values and the position in the grid determines where they are placed in the scene for each level. The way you place your units in the grid can be modified before gameplay, but is saved and loaded as you last saved it
Anyway. For each level, the enemy will have a grid as well that might not always be the same. I've been trying to figure out how to accomplish the task of loading actors to a level and saving a players current grid formation using tables. For instance, the table for enemies in level one might be something like
UnitType | GridRow | GridColumn |
Warrior | 1 | 4 |
Mage | 2 | 3 |
Having two enemies, level 2 might have four enemies, etc. Basically the number of rows with values will be different.
In short, what I want to do for each level is to say something like
foreach (row in levelTable )
if value isnt null
add unit to my grid.GridRow grid.GridColumn
Also, is there a way for me to call a table if I keep the naming scheme the same. Say my tables are all named Level1ArmyGrid, Level2ArmyGrid, etc
Can I call something like "Level"+game.level"+"ArmyGrid" ?
Sorry if this was confusing, thanks!