Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. public void Generate(int goalX, int goalY)
  2. {
  3. this.solvedMap[goalX, goalY] = 0;
  4. this.orderedTilesToGenerate.Add(new Vector2(goalX, goalY));
  5. while (this.orderedTilesToGenerate.Count > 0)
  6. {
  7. Vector2 toExpand = this.orderedTilesToGenerate[0];
  8. int x = (int)toExpand.X;
  9. int y = (int)toExpand.Y;
  10. int currentVal = this.solvedMap[x, y];
  11. int nextVal = currentVal + 1;
  12. if (x != 0)
  13. {
  14. if (this.solvedMap[x - 1, y] == -2)
  15. {
  16. this.solvedMap[x - 1, y] = currentVal + 1;
  17. this.orderedTilesToGenerate.Add(new Vector2(x - 1, y));
  18. }
  19. }
  20. if (x != this.width - 1)
  21. {
  22. if (this.solvedMap[x + 1, y] == -2)
  23. {
  24. this.solvedMap[x + 1, y] = currentVal + 1;
  25. this.orderedTilesToGenerate.Add(new Vector2(x + 1, y));
  26. }
  27. }
  28. if (y != 0)
  29. {
  30. if (this.solvedMap[x, y - 1] == -2)
  31. {
  32. this.solvedMap[x, y - 1] = currentVal + 1;
  33. this.orderedTilesToGenerate.Add(new Vector2(x, y - 1));
  34. }
  35. }
  36. if (y != this.height - 1)
  37. {
  38. if (this.solvedMap[x, y + 1] == -2)
  39. {
  40. this.solvedMap[x, y + 1] = currentVal + 1;
  41. this.orderedTilesToGenerate.Add(new Vector2(x, y + 1));
  42. }
  43. }
  44. this.orderedTilesToGenerate.Remove(toExpand);
  45. this.totalcalls++;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement