Advertisement
Deerenaros

inevergonnathisshouldwork

Oct 10th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.03 KB | None | 0 0
  1.     void DrawFootWay(Rect zoneA, Rect zoneB) {
  2.         Vector2 a = new Vector2((int)zoneA.xMax - 20, (int)Random.Range(zoneA.y + 20, zoneA.yMax - 20));
  3.         Vector2 b = a;
  4.         if (zoneA.y == zoneB.y) {
  5.             while (true) {
  6.                 a = new Vector2((int)zoneA.xMax - 20, (int)Random.Range(zoneA.y + 20, zoneA.yMax - 20));
  7.                 if (SearchRect(a).yMax - a.y < 20) {
  8.                     a.y = SearchRect(a).yMax - 20;
  9.                 }
  10.                 if (a.y - SearchRect(a).y < 20) {
  11.                     a.y = SearchRect(a).y + 20;
  12.                 }
  13.  
  14.                 b = new Vector2((int)a.x + 20, (int)a.y);
  15.                 if ( b.y - SearchRect(b).y  <= 20 || SearchRect(b).yMax - b.y < 20) {
  16.                     break;
  17.                 }
  18.             }
  19.  
  20.             for (int i = 0; i < 40; i++) {
  21.                 for (int j = 0; j < footwayWidth; j++) {
  22.                     tex.SetPixel((int)a.x + i, (int)a.y + j, footway);
  23.                 }
  24.             }
  25.         } else {
  26.             a = new Vector2((int)Random.Range(zoneA.x + 20 + fillJitter, zoneA.xMax - 20 - fillJitter), zoneA.yMax - 20);
  27.             b = new Vector2((int)a.x, (int)a.y + 20);
  28.  
  29.             while (true) {
  30.                 a = new Vector2((int)Random.Range(zoneA.x + 20, zoneA.xMax - 20), (int)zoneA.yMax - 20);
  31.                 if (SearchRect(a).xMax - a.x < 20) {
  32.                     a.x = SearchRect(a).xMax - 20;
  33.                 }
  34.                 if (a.x - SearchRect(a).x < 20) {
  35.                     a.x = SearchRect(a).x + 20;
  36.                 }
  37.  
  38.                 b = new Vector2((int)a.x, (int)a.y + 20);
  39.                 if ( b.x - SearchRect(b).x  <= 20 || SearchRect(b).xMax - b.x < 20) {
  40.                     break;
  41.                 }
  42.             }
  43.  
  44.             for (int i = 0; i < 40; i++) {
  45.                 for (int j = 0; j < footwayWidth; j++) {
  46.                     tex.SetPixel((int)a.x + j, (int)a.y + i, footway);
  47.                 }
  48.             }
  49.         }
  50.         tex.Apply();
  51.     }
  52.  
  53.     Rect SearchRect(Vector2 point) {
  54.         return zones.Where((room) => point.x >= room.x && point.x < room.x + room.width && point.y >= room.y && point.y < room.y + room.height).ElementAt(0);
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement