Guest User

Untitled

a guest
May 21st, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. public void ColorTilesInitialize()
  2.         {
  3.             ColorTile(1, 2, Color.Green);
  4.             ColorTile(3, 6, Color.Red);
  5.         }
  6.  
  7.         public void ColorTile(int x, int y, Color color)
  8.         {
  9.             // Create compare list
  10.             List<int> compareList = new List<int>();
  11.             compareList.Add(x);
  12.             compareList.Add(y);
  13.  
  14.             // Get the right tile and color it.
  15.             foreach (GameObject tile in tiles)
  16.             {
  17.                 if(ParseTile(tile.GameObject.Name).Equals(compareList))
  18.                 {
  19.                     // Color the tile
  20.                 }
  21.             }
  22.         }
  23.  
  24.         public static List<int> ParseTile(string tileString)
  25.         {
  26.             // Initialize a new list of integers
  27.             List<int> tempList = new List<int>();
  28.  
  29.             // Split the two parts of the string
  30.             string[] tempString = tileString.Trim(' ').Split(',');
  31.  
  32.  
  33.             foreach (string splittedString in tempString)
  34.             {
  35.                 // Remove all numberic from the string
  36.                 string splittedStringNew = new string(splittedString.Where(char.IsDigit).ToArray());
  37.  
  38.                 // Try parsing the int ouf the string, if sucessfull: Add to list.
  39.                 int tempInt;
  40.                 if (int.TryParse(splittedStringNew, out tempInt))
  41.                 {
  42.                     tempList.Add(tempInt);
  43.                 }
  44.             }
  45.  
  46.             return tempList;
  47.         }
Add Comment
Please, Sign In to add comment