Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1.     public void BorderSwitcher ()
  2.     {
  3.         GameObject[] bords = FindGameObjectsByTags(new string[] { "armory", "building", "well", "ratusha", "house", "tower", "wtower", "blacksmith", "bath", "chapel", "priton", "tavern", "smeltery", "outpost", "farm", "dwarfshop", "dummy", "gates", "henhouse", "barracks", "bakery", "mill", "tavern", "pigfarm", "goblinshop", "hospital", "tree" });
  4.         bordo.Clear ();
  5.         foreach (GameObject bo in bords)
  6.         {
  7.             if (Vector2.Distance (new Vector2 (bo.transform.position.x, ratusha.transform.position.y), ratusha.transform.position) <= 80)
  8.             {
  9.                 bordo.Add (bo);
  10.             }
  11.         }
  12.         bordo = bordo.OrderBy (x => x.transform.position.x).ToList ();
  13.         borders = new Vector2[bordo.Count];
  14.         for (int b = 0; b < bordo.Count; b++)
  15.         {
  16.             if (b != 0 && b != bordo.Count-1)
  17.             {
  18.                 borders[b] = new Vector2 (bordo[b-1].GetComponent<BoxCollider2D>().bounds.max.x, bordo[b].GetComponent<BoxCollider2D>().bounds.min.x);
  19.             }
  20.             if (b == 0)
  21.                 borders[b] = new Vector2(ratusha.transform.position.x-80, bordo[b+1].GetComponent<BoxCollider2D>().bounds.min.x);
  22.             if (b == bordo.Count-1)
  23.                 borders[b] = new Vector2(bordo[b].GetComponent<BoxCollider2D>().bounds.max.x, ratusha.transform.position.x+80);
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement