Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void BorderSwitcher ()
- {
- 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" });
- bordo.Clear ();
- foreach (GameObject bo in bords)
- {
- if (Vector2.Distance (new Vector2 (bo.transform.position.x, ratusha.transform.position.y), ratusha.transform.position) <= 80)
- {
- bordo.Add (bo);
- }
- }
- bordo = bordo.OrderBy (x => x.transform.position.x).ToList ();
- borders = new Vector2[bordo.Count];
- for (int b = 0; b < bordo.Count; b++)
- {
- if (b != 0 && b != bordo.Count-1)
- {
- borders[b] = new Vector2 (bordo[b-1].GetComponent<BoxCollider2D>().bounds.max.x, bordo[b].GetComponent<BoxCollider2D>().bounds.min.x);
- }
- if (b == 0)
- borders[b] = new Vector2(ratusha.transform.position.x-80, bordo[b+1].GetComponent<BoxCollider2D>().bounds.min.x);
- if (b == bordo.Count-1)
- borders[b] = new Vector2(bordo[b].GetComponent<BoxCollider2D>().bounds.max.x, ratusha.transform.position.x+80);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement