Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawFootWay(Rect zoneA, Rect zoneB) {
- Vector2 a = new Vector2((int)zoneA.xMax - 20, (int)Random.Range(zoneA.y + 20, zoneA.yMax - 20));
- Vector2 b = a;
- if (zoneA.y == zoneB.y) {
- while (true) {
- a = new Vector2((int)zoneA.xMax - 20, (int)Random.Range(zoneA.y + 20, zoneA.yMax - 20));
- if (SearchRect(a).yMax - a.y < 20) {
- a.y = SearchRect(a).yMax - 20;
- }
- if (a.y - SearchRect(a).y < 20) {
- a.y = SearchRect(a).y + 20;
- }
- b = new Vector2((int)a.x + 20, (int)a.y);
- if ( b.y - SearchRect(b).y <= 20 || SearchRect(b).yMax - b.y < 20) {
- break;
- }
- }
- for (int i = 0; i < 40; i++) {
- for (int j = 0; j < footwayWidth; j++) {
- tex.SetPixel((int)a.x + i, (int)a.y + j, footway);
- }
- }
- } else {
- a = new Vector2((int)Random.Range(zoneA.x + 20 + fillJitter, zoneA.xMax - 20 - fillJitter), zoneA.yMax - 20);
- b = new Vector2((int)a.x, (int)a.y + 20);
- while (true) {
- a = new Vector2((int)Random.Range(zoneA.x + 20, zoneA.xMax - 20), (int)zoneA.yMax - 20);
- if (SearchRect(a).xMax - a.x < 20) {
- a.x = SearchRect(a).xMax - 20;
- }
- if (a.x - SearchRect(a).x < 20) {
- a.x = SearchRect(a).x + 20;
- }
- b = new Vector2((int)a.x, (int)a.y + 20);
- if ( b.x - SearchRect(b).x <= 20 || SearchRect(b).xMax - b.x < 20) {
- break;
- }
- }
- for (int i = 0; i < 40; i++) {
- for (int j = 0; j < footwayWidth; j++) {
- tex.SetPixel((int)a.x + j, (int)a.y + i, footway);
- }
- }
- }
- tex.Apply();
- }
- Rect SearchRect(Vector2 point) {
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement