Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Generate(int goalX, int goalY)
- {
- this.solvedMap[goalX, goalY] = 0;
- this.orderedTilesToGenerate.Add(new Vector2(goalX, goalY));
- while (this.orderedTilesToGenerate.Count > 0)
- {
- Vector2 toExpand = this.orderedTilesToGenerate[0];
- int x = (int)toExpand.X;
- int y = (int)toExpand.Y;
- int currentVal = this.solvedMap[x, y];
- int nextVal = currentVal + 1;
- if (x != 0)
- {
- if (this.solvedMap[x - 1, y] == -2)
- {
- this.solvedMap[x - 1, y] = currentVal + 1;
- this.orderedTilesToGenerate.Add(new Vector2(x - 1, y));
- }
- }
- if (x != this.width - 1)
- {
- if (this.solvedMap[x + 1, y] == -2)
- {
- this.solvedMap[x + 1, y] = currentVal + 1;
- this.orderedTilesToGenerate.Add(new Vector2(x + 1, y));
- }
- }
- if (y != 0)
- {
- if (this.solvedMap[x, y - 1] == -2)
- {
- this.solvedMap[x, y - 1] = currentVal + 1;
- this.orderedTilesToGenerate.Add(new Vector2(x, y - 1));
- }
- }
- if (y != this.height - 1)
- {
- if (this.solvedMap[x, y + 1] == -2)
- {
- this.solvedMap[x, y + 1] = currentVal + 1;
- this.orderedTilesToGenerate.Add(new Vector2(x, y + 1));
- }
- }
- this.orderedTilesToGenerate.Remove(toExpand);
- this.totalcalls++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement