Okey. So I'm making this simple script that spawns blocks from an Array, almost like a tilebased 2d game. But it is not preforming as I want it to, I know why, but I have'nt found any solution. Please help me out if you can :)
So here I run the StreamReader with a space as a delimiter:
StreamReader reader = new StreamReader (@"blablabla\path\levelOneMap.txt");
string s = reader.ReadToEnd();
while(s != null)
{
char[] delimiter = {' '};
// Level holder is a string array, wish hold x, s or h.
levelHolder = s.Split(delimiter, System.StringSplitOptions.RemoveEmptyEntries);
s = reader.ReadLine();
}
The file he's reading looks something like this:
x x x
x s x
x h x
And so on, so were the x'es are, it will spawn a block. s is a starting block, and h is just a hole in the ground.
I did a bunch of debug.logs and changed the x, s and h to 1 2 3 4... to see what was going on. Turn out the first 1 2 is fine, but the levelHolder[2] contains both 3 and 4. How can I make this script understand that it should skip both ' ' and '\n' ?