private void borderToolStripMenuItem_Click(object sender, EventArgs e) { ICommand command = new border(m_PageLayControl); command.OnCreate(m_mapControl.Object); command.OnClick(); }
// Start is called before the first frame update void Start() { makeAreas(); makeLocations(); makeBorders(); northBorder = new border(new location(90, 0), new location(90, 0)); southBorder = new border(new location(-90, 0), new location(90, 0)); }
void Start() { gameObject.AddComponent <BoxCollider>().enabled = true; if (GetComponents <MeshCollider>().Length > 0) { Destroy(GetComponent <MeshCollider>()); } GBorder = FindObjectOfType <border>(); }
private void Awake() { gameObject.layer = LayerMask.NameToLayer("Player"); tag = "Player"; GameBorder = FindObjectOfType <border>(); if (GetComponents <MeshCollider>().Length > 0) { Component.Destroy(gameObject.GetComponent <MeshCollider>()); } }
public borders(css_borders val) { left = new border(val.left); right = new border(val.right); top = new border(val.top); bottom = new border(val.bottom); front = new border(val.front); //:h3ml back = new border(val.back); //:h3ml radius = default(border_radiuses); }
public borders(borders val) { left = val.left; right = val.right; top = val.top; bottom = val.bottom; front = val.front; //:h3ml back = val.back; //:h3ml radius = val.radius; }
void Start() { defPos = transform.position; defPosX = defPos.x; if (IsRightSide) { sign *= sign; } GBorder = FindObjectOfType <border>(); StartCoroutine(RespawnDelay()); }
void Start() { if (gameObject.GetComponents <BoxCollider>().Length == 0) { gameObject.AddComponent <BoxCollider>().enabled = true; } if (gameObject.GetComponents <MeshCollider>().Length > 0) { Destroy(GetComponent <MeshCollider>()); } rig = GetComponent <Rigidbody>(); rig.useGravity = true; GBorder = FindObjectOfType <border>(); }
// Update is called once per frame void Update() { double lngStart, latStart, lngEnd, latEnd, latitudeOnBorder, difference; //現在位置をとってくる //test lat-long 35.625665,139.884419 currentLocation = new location(35.625665, 139.884419); for (int i = 0; i < borders.Length; i++) { // get location data of start and end point of checked border lngStart = borders[i].getstartPoint().getlongitude(); latStart = borders[i].getstartPoint().getlatiude(); lngEnd = borders[i].getendPoint().getlongitude(); latEnd = borders[i].getendPoint().getlatitude(); // check if (lngStart < currentLocation.getlongitude() && currentLocation.getlongitude() < lngEnd) { // calculate target latitude on checked border latitudeOnBorder = (latEnd - latStart)(lngStart - lngStart) / (lngEnd - lngStart) + latEnd; // calculate difference of latitude between currentLocation and checked border difference = latitudeOnBorder - currentLocation.getlatitude(); // compare dif with north border if (difference > 0 && difference < (northBorder.getlatitude() - currentLocation.getlatitude())) { northBorder = borders[i]; } // compare dif with south border else if (difference < 0 && difference > (southBorder.getlatitude() - currentLocation.getlatitude())) { southBorder = borders[i]; } } } // judge area by south and north norder //割り出したエリアをテキストボックスに表示させる }
void Start() { if (gameObject.GetComponents <BoxCollider>().Length == 0) { gameObject.AddComponent <BoxCollider>().enabled = true; } if (gameObject.GetComponents <MeshCollider>().Length > 0) { Destroy(GetComponent <MeshCollider>()); } rig = GetComponent <Rigidbody>(); rig.useGravity = true; GBorder = FindObjectOfType <border>(); DefaultSpeed = Zspeed; lights = transform.Find("Lights").GetComponent <LightManager>(); defRot = transform.rotation; if (Inverse) { defRot = Quaternion.LookRotation(GBorder.transform.position); } }
Pen DefineColor(Point p1, Point p2) { Pen pen = new Pen(Color.Blue); int avarageX = (p2.X - p1.X) / 2 + p1.X; int avarageY = (p2.Y - p1.Y) / 2 + p1.Y; //Это средние точки прямой double dist = Math.Sqrt(Math.Pow(avarageX - CursorX, 2) + Math.Pow((avarageY - CursorY), 2)); //Расстояние от точки клика до центра прямой if (Clicked == true) //Если перерисовывается из-за нажатия { int index = FindCell(Zentrum(p1, p2, true)); int index2 = FindCell(Zentrum(p1, p2, false)); //индексы клеток в списке, которым принадлежит сторона if (dist < 5 * Math.Sqrt(2)) //если расстояние от точки клика до средней точки меньше вычисленного радиуса { /* if (/*FindCell(Zentrum(p1, p2, true)) == -1 || FindCell(Zentrum(p1, p2, false)) == -1 || /*AllCells[FindCell(Zentrum(p1, p2, true))].borderL.side == true || AllCells[FindCell(Zentrum(p1, p2, true))].borderR.side == true || AllCells[FindCell(Zentrum(p1, p2, true))].borderU.side == true || AllCells[FindCell(Zentrum(p1, p2, true))].borderD.side == true*/ // p1.Y == p2.Y) //Если с одной из сторон от линии клетки нет, значит она боковая // { if (FindCell(Zentrum(p1, p2, true)) == -1 || FindCell(Zentrum(p1, p2, false)) == -1) { Clicked = false; if (igrok1 == true) { igrok1 = false; } else { igrok1 = true; } ActivePlayer(); return(pen);//выходим из функции } else if ((AllCells[FindCell(Zentrum(p1, p2, true))].borderD.side == true && AllCells[FindCell(Zentrum(p1, p2, false))].borderU.side == true) || (AllCells[FindCell(Zentrum(p1, p2, true))].borderR.side == true && AllCells[FindCell(Zentrum(p1, p2, false))].borderL.side == true)) { Clicked = false; if (igrok1 == true) { igrok1 = false; } else { igrok1 = true; } ActivePlayer(); return(pen);//выходим из функции } //} //if (p1.Y == p2.Y && AllCells[FindCell(Zentrum(p1, p2, true))].borderD.coloured == false || p1.X == p2.X && AllCells[FindCell(Zentrum(p1, p2, true))].borderR.coloured == false) //{ else { if (igrok1 == true) //Если все клетки существуют, то цвет выбирается исходя из игрока { pen = new Pen(Color.DarkGreen, 1.5f); //ActivePlayer(); } else { pen = new Pen(Color.Red, 1.5f); //ActivePlayer(); } Clicked = false; //отключаем режим клика if (p1.Y == p2.Y) //добавляем информацию о прямой в список клеток. Если линия горизонтальная { Point сent1 = new Point(avarageX, avarageY - 10); Point сent2 = new Point(avarageX, avarageY + 10); border b1 = new border() { coloured = false, side = false, Red = false }; { if (pen.Color == Color.Blue) { b1.coloured = false; } else { b1.coloured = true; if (pen.Color == Color.Red) { b1.Red = true; } else { b1.Red = false; } } } int cellIndex = FindCell(сent1); Cell temp = AllCells[cellIndex]; temp.borderD = b1; AllCells[cellIndex] = temp; cellIndex = FindCell(сent2); temp = AllCells[cellIndex]; temp.borderU = b1; AllCells[cellIndex] = temp; } else //Если вертикальная { Point сent1 = new Point(avarageX - 10, avarageY); Point сent2 = new Point(avarageX + 10, avarageY); border b1 = new border() { coloured = false, side = false, Red = false }; if (pen.Color == Color.Blue) { b1.coloured = false; } else { b1.coloured = true; if (pen.Color == Color.Red) { b1.Red = true; } else { b1.Red = false; } } int cellIndex = FindCell(сent1); Cell temp = AllCells[cellIndex]; temp.borderR = b1; AllCells[cellIndex] = temp; cellIndex = FindCell(сent2); temp = AllCells[cellIndex]; temp.borderL = b1; AllCells[cellIndex] = temp; } } } else { pen = new Pen(Color.Blue, 1.5f); //Если расстояние меньше, просто отрисуем сторону } } //Если отрисовывается для показа возможных мест для постановки линии else { if (dist < 5 * Math.Sqrt(2)) //если расстояние меньше, покажем, что туда можно поставить { if (p1.Y == p1.Y) { int index = FindCell(Zentrum(p1, p2, true)); int index2 = FindCell(Zentrum(p1, p2, false)); if (index != -1 && index2 != -1) { if ((AllCells[FindCell(Zentrum(p1, p2, true))].borderD.side == false && AllCells[FindCell(Zentrum(p1, p2, false))].borderU.side == false) || (AllCells[FindCell(Zentrum(p1, p2, true))].borderR.side == false && AllCells[FindCell(Zentrum(p1, p2, false))].borderL.side == false)) { pen = new Pen(Color.Pink, 2f); } } else { pen = new Pen(Color.Blue, 1.5f); } } } else //иначе просто отрисуем сторону, а если она боковая, то внесём эти данные в список клеток { pen = new Pen(Color.Blue, 1.5f); int index = FindCell(Zentrum(p1, p2, true)); int index2 = FindCell(Zentrum(p1, p2, false)); Cell temp = new Cell(); if (index != -1 && index2 == -1) { temp = AllCells[index]; if (p1.Y == p2.Y) { temp.borderD.side = true; } else { temp.borderR.side = true; } AllCells[index] = temp; } else if ((index2 != -1 && index == -1)) { temp = AllCells[index2]; if (p1.Y == p2.Y) { temp.borderU.side = true; } else { temp.borderL.side = true; } AllCells[index2] = temp; } else { pen = new Pen(Color.Blue, 1.5f); } } } return(pen); }
public border(border val) { width = val.width; style = val.style; color = val.color; }
void makeBorders() { borders = new border[67]; borders[0] = new border(locations[0], locations[1], areas[8], areas[6]); borders[1] = new border(locations[0], locations[3], areas[6], areas[8]); borders[2] = new border(locations[1], locations[2], areas[7], areas[8]); borders[3] = new border(locations[1], locations[5], areas[7], areas[6]); borders[4] = new border(locations[2], locations[25], areas[8], areas[7]); borders[5] = new border(locations[3], locations[16], areas[6], areas[8]); borders[6] = new border(locations[4], locations[6], areas[4], areas[6]); borders[7] = new border(locations[4], locations[18], areas[6], areas[4]); borders[8] = new border(locations[5], locations[7], areas[7], areas[6]); borders[9] = new border(locations[6], locations[9], areas[4], areas[6]); borders[10] = new border(locations[7], locations[8], areas[7], areas[6]); borders[11] = new border(locations[8], locations[13], areas[5], areas[6]); borders[12] = new border(locations[8], locations[15], areas[7], areas[5]); borders[13] = new border(locations[9], locations[16], areas[5], areas[6]); borders[14] = new border(locations[10], locations[12], areas[5], areas[6]); borders[15] = new border(locations[10], locations[13], areas[6], areas[5]); borders[16] = new border(locations[11], locations[12], areas[6], areas[5]); borders[17] = new border(locations[11], locations[14], areas[5], areas[6]); borders[18] = new border(locations[14], locations[17], areas[5], areas[6]); borders[19] = new border(locations[15], locations[20], areas[7], areas[5]); borders[20] = new border(locations[16], locations[21], areas[4], areas[8]); borders[21] = new border(locations[17], locations[19], areas[5], areas[6]); borders[22] = new border(locations[20], locations[23], areas[7], areas[5]); borders[23] = new border(locations[21], locations[27], areas[4], areas[2]); borders[24] = new border(locations[21], locations[57], areas[2], areas[8]); borders[25] = new border(locations[22], locations[28], areas[5], areas[3]); borders[26] = new border(locations[22], locations[29], areas[3], areas[4]); borders[27] = new border(locations[23], locations[24], areas[7], areas[5]); borders[28] = new border(locations[24], locations[25], areas[7], areas[8]); borders[29] = new border(locations[24], locations[32], areas[8], areas[5]); borders[30] = new border(locations[26], locations[29], areas[4], areas[2]); borders[31] = new border(locations[27], locations[31], areas[4], areas[2]); borders[32] = new border(locations[28], locations[32], areas[5], areas[8]); borders[33] = new border(locations[28], locations[35], areas[8], areas[3]); borders[34] = new border(locations[29], locations[36], areas[3], areas[2]); borders[35] = new border(locations[30], locations[33], areas[2], areas[4]); borders[36] = new border(locations[31], locations[34], areas[4], areas[2]); borders[37] = new border(locations[33], locations[34], areas[2], areas[4]); borders[38] = new border(locations[35], locations[39], areas[8], areas[1]); borders[39] = new border(locations[35], locations[40], areas[1], areas[3]); borders[40] = new border(locations[37], locations[38], areas[8], areas[1]); borders[41] = new border(locations[37], locations[39], areas[1], areas[8]); borders[42] = new border(locations[38], locations[42], areas[8], areas[1]); borders[43] = new border(locations[40], locations[41], areas[1], areas[3]); borders[44] = new border(locations[41], locations[45], areas[1], areas[3]); borders[45] = new border(locations[42], locations[46], areas[8], areas[1]); borders[46] = new border(locations[43], locations[44], areas[1], areas[3]); borders[47] = new border(locations[43], locations[48], areas[3], areas[1]); borders[48] = new border(locations[44], locations[52], areas[1], areas[2]); borders[49] = new border(locations[45], locations[48], areas[2], areas[3]); borders[50] = new border(locations[46], locations[47], areas[8], areas[1]); borders[51] = new border(locations[47], locations[49], areas[8], areas[1]); borders[52] = new border(locations[49], locations[50], areas[8], areas[1]); borders[53] = new border(locations[50], locations[51], areas[8], areas[1]); borders[54] = new border(locations[51], locations[54], areas[8], areas[1]); borders[55] = new border(locations[52], locations[53], areas[1], areas[2]); borders[56] = new border(locations[53], locations[55], areas[1], areas[2]); borders[57] = new border(locations[54], locations[58], areas[8], areas[1]); borders[58] = new border(locations[55], locations[56], areas[1], areas[2]); borders[59] = new border(locations[56], locations[63], areas[1], areas[2]); borders[60] = new border(locations[57], locations[64], areas[1], areas[8]); borders[61] = new border(locations[58], locations[62], areas[8], areas[1]); borders[62] = new border(locations[59], locations[61], areas[8], areas[1]); borders[63] = new border(locations[59], locations[62], areas[1], areas[8]); borders[64] = new border(locations[60], locations[61], areas[1], areas[8]); borders[65] = new border(locations[60], locations[63], areas[8], areas[1]); borders[66] = new border(locations[63], locations[64], areas[8], areas[2]); }
Import(sourceFile, targetWriter, border, SixLabors.Primitives.Rectangle.Empty);
void CreateLevel() { timerScript.startTimer = Time.time; levelNumber += 1f; if (levelSpawn != null) { Destroy(levelSpawn); } else { Debug.Log("level is not spawned yet"); } findGOpanel.SetActive(false); heroSpawn.transform.position = spawnCords[7, 5]; Debug.Log(" vremya starta: " + timerScript.startTimer); float bordersCount = Mathf.Round(levelNumber / 1.99f); currentBorders = new GameObject[(int)bordersCount]; bordersSpawnNumber = 0; levelSpawn = Instantiate <GameObject>(levelZeroPrefab); float calculateNumber = Random.Range(0.1f + (levelNumber / 70), 1f + (levelNumber / 70)); Debug.Log(" " + calculateNumber); foreach (BorderDefinition brdr in borderDefs) { if (bordersSpawnNumber < bordersCount) { if (calculateNumber > brdr.spawnChance) { cordGenerate(); brdrSpawn = Instantiate <GameObject>(brdr.borderPrefab); brdrSpawn.transform.position = spawnCords[brdrSpawnX, brdrSpawnY]; brdrSpawn.transform.parent = levelSpawn.transform; bordersSpawnNumber += 1; border getBrdrScript = brdrSpawn.GetComponent <border>(); float rotDirection = Random.Range(-3f, 3f); getBrdrScript.rotSpeed *= rotDirection; for (int i = 0; i < bordersSpawnNumber; i++) { if (brdrSpawn != null) { currentBorders[i] = brdrSpawn; } } } } } float chooseGoalPos = Random.Range(0, bordersCount); GameObject goalSpawn = Instantiate <GameObject>(goalPrefab); goalSpawn.transform.position = brdrSpawn.transform.position; if (brdrSpawn.name == "borderLine(Clone)") { goalSpawn.transform.position = new Vector2(brdrSpawn.transform.position.x + 1f, brdrSpawn.transform.position.y); } goalSpawn.transform.parent = levelSpawn.transform; for (int i = 0; i < bordersCount; i++) { if (currentBorders[i] == null) { cordGenerate(); GameObject cubeSpawn = Instantiate <GameObject>(borderDict[BorderType.Cube].borderPrefab); cubeSpawn.transform.position = spawnCords[brdrSpawnX, brdrSpawnY]; cubeSpawn.transform.parent = levelSpawn.transform; border getBrdrScript = cubeSpawn.GetComponent <border>(); float rotDirectChoose = Random.Range(-1f, 1f); getBrdrScript.rotSpeed += levelNumber * rotDirectChoose; Vector2 toGoalVector = cubeSpawn.transform.position - goalSpawn.transform.position; float goalDistnce = toGoalVector.magnitude; if (goalDistnce <= 2f) { Destroy(cubeSpawn); } } } }
static DefaultValues() { borders = new border(Camera.main); Diameter = borders.Size.x / Ballons_per_Row; }
public List <int> MakeEdgeCollider() { //Call "get entries" of all walls and combine into dictionary GameObject[] wallsInScene = GameObject.FindGameObjectsWithTag("Wall"); //Dictionary<Vector2, Vector2> paths = new Dictionary<Vector2, Vector2>(); List <Vector3> paths = new List <Vector3>(); foreach (GameObject wall in wallsInScene) { wall.GetComponent <WallScript>().GetEntries(ref paths); } //Combine //Start with top left of this wall and set point=start Vector2 start = new Vector2(myRenderer.bounds.min.x, myRenderer.bounds.max.y); Vector2 point = start; int curRank = wallRank; List <Vector2> edgePoints = new List <Vector2>(); List <Vector3> closePoints; List <int> pointRanks = new List <int>(); edgePoints.Add(point); pointRanks.Add(curRank); //Until we get back to start Debug.Log("STARTINGSTARTINGSTARTINGSTARTINGSTARTINGSTARTINGSTARTINGSTARTINGSTARTING"); do { //Get all possible points closePoints = findPoints(point, paths); List <Vector3> blackListPoints = new List <Vector3>(); for (int i = closePoints.Count - 1; i >= 0; i--) { //if this point is the exact point we're on, get rid of it. if (closePoints[i].x == point.x && closePoints[i].y == point.y) { closePoints.RemoveAt(i); } } //Narrow down to all feasible points for (int i = closePoints.Count - 1; i >= 0; i--) { //If this point has already been used, get rid of it (unless we've looped around to the beginning) if (edgePoints.Contains(closePoints[i]) && (!((Vector2)closePoints[i]).Equals(start) || edgePoints.Count <= 2)) { Debug.Log("Already used point " + closePoints[i]); blackListPoints.Add(closePoints[i]); } //else { bool opposingStatus = false; //This variable will change when set according to point's place in comparison //It's just set to border.up so unity won't complain border reqDirection = border.up; if (closePoints[i].x > point.x) { reqDirection = border.left; } if (closePoints[i].x < point.x) { reqDirection = border.right; } if (closePoints[i].y > point.y) { reqDirection = border.down; } if (closePoints[i].y < point.y) { reqDirection = border.up; } foreach (Vector3 checkedPoint in closePoints) { if (!checkedPoint.Equals(closePoints[i])) { if (checkedPoint.z == closePoints[i].z && (int)checkedPoint.z == curRank) { opposingStatus = true; } //Check if a box is on the left AND right sides, making it absolutely confirmed that these boxes are touching else if (checkedPoint.z == closePoints[i].z) { if (reqDirection == border.down && checkedPoint.y <= point.y) { opposingStatus = true; Vector3 foundPoint = FindLocalPoint(point.x, -1, curRank, point, paths); //Find if this box intersects with current box and cut off the direction in which the two are intersecting if (foundPoint.y > point.y) { Debug.Log("Removing " + closePoints[i] + "at " + reqDirection); blackListPoints.Add(closePoints[i]); } else if (foundPoint.y < point.y) { Debug.Log("Removing " + checkedPoint + "at " + reqDirection); blackListPoints.Add(checkedPoint); } } if (reqDirection == border.up && checkedPoint.y >= point.y) { opposingStatus = true; Vector3 foundPoint = FindLocalPoint(point.x, -1, curRank, point, paths); //Find if this box intersects with current box and cut off the direction in which the two are intersecting if (foundPoint.y < point.y) { Debug.Log("Removing " + closePoints[i] + "at " + reqDirection); blackListPoints.Add(closePoints[i]); } else if (foundPoint.y > point.y) { Debug.Log("Removing " + checkedPoint + "at " + reqDirection); blackListPoints.Add(checkedPoint); } } if (reqDirection == border.left && checkedPoint.x <= point.x) { opposingStatus = true; Vector3 foundPoint = FindLocalPoint(-1, point.y, curRank, point, paths); //Find if this box intersects with current box and cut off the direction in which the two are intersecting if (foundPoint.x > point.x) { Debug.Log("Removing " + closePoints[i] + "at " + reqDirection); blackListPoints.Add(closePoints[i]); } else if (foundPoint.x < point.x) { Debug.Log("Removing " + checkedPoint + "at " + reqDirection); blackListPoints.Add(checkedPoint); } } if (reqDirection == border.right && checkedPoint.x >= point.x) { opposingStatus = true; Vector3 foundPoint = FindLocalPoint(-1, point.y, curRank, point, paths); //Find if this box intersects with current box and cut off the direction in which the two are intersecting if (foundPoint.x < point.x) { Debug.Log("Removing " + closePoints[i] + "at " + reqDirection); blackListPoints.Add(closePoints[i]); } else if (foundPoint.x > point.x) { Debug.Log("Removing " + checkedPoint + "at " + reqDirection); blackListPoints.Add(checkedPoint); } } } //Check if THIS box encompasses the other box's width else if ((int)checkedPoint.z == curRank) { if (reqDirection == border.down && checkedPoint.y >= closePoints[i].y) { opposingStatus = true; blackListPoints.Add(checkedPoint); /* * Vector3 foundPoint = FindLocalPoint(closePoints[i].x, -1, (int) closePoints[i].z, (Vector2) closePoints[i], paths); * Debug.Log("Cutting point " + closePoints[i] + " with local point " + foundPoint); * //Find if this box intersects with current box and cut off the direction in which the two are intersecting * if(foundPoint.y < closePoints[i].y) { * blackListPoints.Add(closePoints[i]); * } else if(foundPoint.y > closePoints[i].y) { * blackListPoints.Add(foundPoint); * }*/ } if (reqDirection == border.up && checkedPoint.y <= closePoints[i].y) { opposingStatus = true; blackListPoints.Add(checkedPoint); /* * Vector3 foundPoint = FindLocalPoint(closePoints[i].x, -1, (int) closePoints[i].z, (Vector2) closePoints[i], paths); * Debug.Log("Cutting point " + closePoints[i] + " with local point " + foundPoint); * //Find if this box intersects with current box and cut off the direction in which the two are intersecting * if(foundPoint.y > closePoints[i].y) { * blackListPoints.Add(closePoints[i]); * } else if(foundPoint.y < closePoints[i].y) { * blackListPoints.Add(foundPoint); * }*/ } if (reqDirection == border.left && checkedPoint.x >= closePoints[i].x) { opposingStatus = true; blackListPoints.Add(checkedPoint); /* * Vector3 foundPoint = FindLocalPoint(-1, closePoints[i].y, (int) closePoints[i].z, (Vector2) closePoints[i], paths); * Debug.Log("Cutting point " + closePoints[i] + " with local point " + foundPoint); * //Find if this box intersects with current box and cut off the direction in which the two are intersecting * if(foundPoint.x < closePoints[i].x) { * blackListPoints.Add(closePoints[i]); * } else if(foundPoint.x > closePoints[i].x) { * blackListPoints.Add(foundPoint); * }*/ } if (reqDirection == border.right && checkedPoint.x <= closePoints[i].x) { opposingStatus = true; blackListPoints.Add(checkedPoint); /* * Vector3 foundPoint = FindLocalPoint(-1, closePoints[i].y, (int) closePoints[i].z, (Vector2) closePoints[i], paths); * Debug.Log("Cutting point " + closePoints[i] + " with local point " + foundPoint); * //Find if this box intersects with current box and cut off the direction in which the two are intersecting * if(foundPoint.x > closePoints[i].x) { * blackListPoints.Add(closePoints[i]); * } else if(foundPoint.x < closePoints[i].x) { * blackListPoints.Add(foundPoint); * }*/ } } //Check for an intermediary //Intermediary across the x axis if (closePoints[i].x == point.x && checkedPoint.x == point.x && closePoints[i].z != curRank) { Vector3 foundPoint = FindLocalPoint(checkedPoint.x, -1, (int)checkedPoint.z, (Vector2)checkedPoint, paths); //Check if checkedPoint is below or above both point and closePoints and sees if its localPoint spans the gap if (checkedPoint.y <= point.y && checkedPoint.y <= closePoints[i].y) { if (foundPoint.y >= point.y && foundPoint.y >= closePoints[i].y) { opposingStatus = true; } } else if (checkedPoint.y >= point.y && checkedPoint.y >= closePoints[i].y) { if (foundPoint.y <= point.y && foundPoint.y <= closePoints[i].y) { opposingStatus = true; } } } if (closePoints[i].y == point.y && checkedPoint.y == point.y && closePoints[i].z != curRank) { Vector3 foundPoint = FindLocalPoint(-1, checkedPoint.y, (int)checkedPoint.z, (Vector2)checkedPoint, paths); //Check if checkedPoint is below or above both point and closePoints and sees if its localPoint spans the gap if (checkedPoint.x <= point.x && checkedPoint.x <= closePoints[i].x) { if (foundPoint.x >= point.x && foundPoint.x >= closePoints[i].x) { opposingStatus = true; } } else if (checkedPoint.x >= point.x && checkedPoint.x >= closePoints[i].x) { if (foundPoint.x <= point.x && foundPoint.x <= closePoints[i].x) { opposingStatus = true; } } } } } //If we went through every point and COULDN'T find an opposing entry, scrap this point if (opposingStatus == false) { Debug.Log("Removing " + closePoints[i] + " for not having an equalizer"); blackListPoints.Add(closePoints[i]); } else { //Bool value that will let us know we found a "tween" point once for loop is done bool betweenStatus = true; //Check if there any points between this one and the current one for (int j = closePoints.Count - 1; j >= 0; j--) { //If point j is betweeen point i and point k if (isBetween(closePoints[j], closePoints[i], point) && j != i) { //Set it to be DESTROYED at the end of this loop (removing objects mid-loop is dangerous)! betweenStatus = false; Debug.Log("curRank is " + curRank + " current point found between is " + closePoints[j] + " so " + closePoints[i] + " is out of the running"); //Check if closePoints[j] is in the current point's rank. If so, DON'T GO TO THAT POINT if ((int)closePoints[j].z == curRank) { blackListPoints.Add(closePoints[j]); } } } if (betweenStatus == false) { //Scrap point i blackListPoints.Add(closePoints[i]); } } //} } foreach (Vector3 toRemove in blackListPoints) { Debug.Log("Removing " + toRemove); //Make sure I didn't make a mistake and add the same value twice to be removed if (closePoints.Contains(toRemove)) { closePoints.Remove(toRemove); } } foreach (Vector3 aPoint in closePoints) { Debug.Log("Point " + point + " could go to: " + aPoint); } //Check that there are points left. If not, raise an error if (closePoints.Count == 0) { //Leave this while loop and place current edgePoints into the collider break; } else { //If there's a point not in this object's rank, do that one. bool foundPoint = false; foreach (Vector3 curPoint in closePoints) { if (((int)curPoint.z) != curRank) { point = (Vector2)curPoint; curRank = (int)curPoint.z; foundPoint = true; break; } } //If foundPoint is false, that means we never found a point not in this point's rank if (foundPoint == false) { //Just use the first one point = (Vector2)closePoints[0]; curRank = (int)closePoints[0].z; } } //Place new point in array edgePoints.Add(point); pointRanks.Add(curRank); //Keep going until we go full circle } while(!point.Equals(start)); //This may have just gone around the outside of all the walls, so check if this wall's //inside point (bottom-left) has been used. If not, start over with bottom-left as start! for (int i = 0; i < edgePoints.Count; i++) { edgePoints[i] = edgePoints[i] - (Vector2)transform.position; } //Create mainWall by making component mainWall = gameObject.AddComponent(typeof(EdgeCollider2D)) as EdgeCollider2D; //Make this full array the points for mainWall mainWall.points = edgePoints.ToArray(); sortedByX = edgePoints.OrderBy(v => v.x).ToArray <Vector2>(); sortedByY = edgePoints.OrderBy(v => v.y).ToArray <Vector2>(); return(pointRanks); }