Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ColorTilesInitialize()
- {
- ColorTile(1, 2, Color.Green);
- ColorTile(3, 6, Color.Red);
- }
- public void ColorTile(int x, int y, Color color)
- {
- // Create compare list
- List<int> compareList = new List<int>();
- compareList.Add(x);
- compareList.Add(y);
- // Get the right tile and color it.
- foreach (GameObject tile in tiles)
- {
- if(ParseTile(tile.GameObject.Name).Equals(compareList))
- {
- // Color the tile
- }
- }
- }
- public static List<int> ParseTile(string tileString)
- {
- // Initialize a new list of integers
- List<int> tempList = new List<int>();
- // Split the two parts of the string
- string[] tempString = tileString.Trim(' ').Split(',');
- foreach (string splittedString in tempString)
- {
- // Remove all numberic from the string
- string splittedStringNew = new string(splittedString.Where(char.IsDigit).ToArray());
- // Try parsing the int ouf the string, if sucessfull: Add to list.
- int tempInt;
- if (int.TryParse(splittedStringNew, out tempInt))
- {
- tempList.Add(tempInt);
- }
- }
- return tempList;
- }
Add Comment
Please, Sign In to add comment