private void drawlinerenderer() { GameObject newline = Instantiate(Line); activeLine = newline.GetComponent <drawLine>(); // activeLine.DrawOutline(grid, zPos); // DrawOutline(); StartCoroutine(SortVertices()); // SortVertices(); // StartCoroutine(activeLine.DrawLineOutline(finalVertices)); }
private void createLine(int division) { GameObject newline = Instantiate(Line); activeLine = newline.GetComponent <drawLine>(); foreach (var item in SortedVertices[division]) { activeLine.extendLine(item); } activeLine.extendLine(SortedVertices[division][0]); }
void Start() { if (polygon) { GameObject newline = Instantiate(Line); activeLine = newline.GetComponent <drawLine>(); activeLine.DrawPolygon(vertexNumber, radius, centerPos, startWidth, endWidth, Mesh1); } else { // activeLine.DrawGridShape(vertexNumber, radius, centerPos, startWidth, endWidth, Mesh1); } }
//ready set go void Start() { //define settings for the background worker bw.WorkerReportsProgress = true; bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); //fetch external scripts xTanScript = (drawLine)xTangentLine.GetComponent(typeof(drawLine)); yTanScript = (drawLine)yTangentLine.GetComponent(typeof(drawLine)); integralScript = (integralRender)integralRenderer.GetComponent(typeof(integralRender)); line = GetComponent <LineRenderer>(); }
public void Start() { cam = Camera.main; dl = GetComponent <drawLine>(); LoadData(); spriteRenderer = rb.gameObject.GetComponent <SpriteRenderer>(); if (sk == 1) { spriteRenderer.sprite = newSprite; } rb.transform.position = new Vector3(p1, p2, p3); rb.velocity = new Vector2(v1, v2); dl.endLine(); prePos = rb.position; startPos = rb.position; endPos = rb.position; }
// Start is called before the first frame update void Start() { lineScript = lineObj.GetComponent <drawLine>(); }
private void Awake() { instantiate = this; }
private IEnumerator SortVerticesAndCreateLine() { // foreach (var item in verticesofGrid) // { // if (!item.getUsed()) // { // finalVertices.Add(item.vertice); // Debug.Log(item.vertice + " " + item.getUsed()); // } // } // finalVertices.Sort(); // for (int x = 1; x < temp.Count; x++) // { // for (int y = x; y < temp.Count; y++) // { // if (temp[x].x == 1) // } // } for (int division = 0; division <= divisionCount; division++) { if (grid.checkDivision(division) && divisionType[division] == DivisionType.Fill) { Debug.Log(division); List <Vector3> temp = new List <Vector3>(); GameObject newline = Instantiate(Line); activeLine = newline.GetComponent <drawLine>(); int x = 0, y = 0; // for (int i = 0; i < finalVertices[division].Count; i++) // { // // Debug.LogError(finalVertices[division][i]); // } // activeLine.extendLine(new Vector3(v.x, v.y + 0.05f)); float offset = cellSize / 2; Vector3 v = finalVertices[division][0]; Vector3 prev = v; Vector3 first = v; temp.Add(v); activeLine.extendLine(v); UnSorted = true; while (UnSorted) { // Debug.Log(temp.Exists(e => e.x == v.x && e.y == v.y)); if (!grid.CheckIfIndexPossible(new Vector3(v.x - offset, v.y + offset), false, division) && grid.CheckIfIndexPossible(new Vector3(v.x + offset, v.y + offset), true, division) && !temp.Exists(e => e.y == v.y + 1 && e.x == v.x) && finalVertices[division].Exists(e => e.y == v.y + 1 && e.x == v.x)) { /* Debug.Log("prev " + prev.x + " " + prev.y);*/ /*up = true;*/ // resetBool(1); prev = v; v = finalVertices[division].Find(e => e.y == v.y + 1 && e.x == v.x); if (temp.Contains(v)) { Debug.Log("unsorted false"); UnSorted = false; } // CheckAndGetIndex(new Vector3((v.x) + cellSize / 2, v.y + (cellSize / 2)), out x, out y); // grid.getXYPosition(new Vector3((v.x) + cellSize / 2, v.y - (cellSize / 2)), out x, out y); /*Debug.Log(v.x + " " + v.y);*/ temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { UnSorted = false; } } else if ((!grid.CheckIfIndexPossible(new Vector3(v.x - offset, v.y + offset), false, division) || !grid.CheckIfIndexPossible(new Vector3(v.x + offset, v.y + offset), false, division)) && grid.CheckIfIndexPossible(new Vector3(v.x + offset, v.y - offset), true, division) && !temp.Exists(e => e.x == v.x + 1 && e.y == v.y) && finalVertices[division].Exists(e => e.x == v.x + 1 && e.y == v.y)) { // ((x < width && y < height) ? grid.getCreated(x, y) : true) // right = true; // resetBool(); Debug.Log("prev " + prev.x + " " + prev.y); prev = v; v = finalVertices[division].Find(e => e.x == v.x + 1 && e.y == v.y); // CheckAndGetIndex(new Vector3((v.x + cellSize) + cellSize / 2, (v.y) - (cellSize / 2)), out x, out y); // grid.getXYPosition(new Vector3((v.x) + cellSize / 2, v.y - (cellSize / 2)), out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { Debug.Log("unsorted false"); UnSorted = false; } } else if (grid.CheckIfIndexPossible(new Vector3(v.x - offset, v.y - offset), true, division) && !grid.CheckIfIndexPossible(new Vector3(v.x + offset, v.y - offset), false, division) && !temp.Exists(e => e.y == v.y - 1 && e.x == v.x) && finalVertices[division].Exists(e => e.y == v.y - 1 && e.x == v.x)) { // ((x < width && y < height) ? !grid.getCreated(x, y) : true) // down = true; // resetBool(); Debug.Log("prev " + prev.x + " " + prev.y); prev = v; v = finalVertices[division].Find(e => e.y == v.y - 1 && e.x == v.x); if (temp.Contains(v)) { Debug.Log("unsorted false"); UnSorted = false; } // CheckAndGetIndex(v, out x, out y); grid.getXYPosition(new Vector3((v.x) + cellSize / 2, v.y - (cellSize / 2)), out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { Debug.Log("unsorted false"); UnSorted = false; } } else if (!grid.CheckIfIndexPossible(new Vector3(v.x - offset, v.y - offset), false, division) && (!temp.Exists(e => e.x == v.x - 1 && e.y == v.y)) && finalVertices[division].Exists(e => e.x == v.x - 1 && e.y == v.y)) { // ((x < width && y < height) ? grid.getCreated(x, y) : true) // left = true; // resetBool(); Debug.Log("prev " + prev.x + " " + prev.y); prev = v; v = finalVertices[division].Find(e => e.x == v.x - 1 && e.y == v.y); // temp.Contains(new Vector3(v.x - 1, v.y, 0)) if (new Vector3(v.x - 1, v.y, 0) == first) { Debug.Log("unsorted false"); UnSorted = false; } // CheckAndGetIndex(v, out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { Debug.Log("unsorted false"); UnSorted = false; } } yield return(new WaitForSeconds(0.01f)); // activeLine.extendLine(new Vector3(first.x, first.y + 0.05f)); // finalVertices.Sort(delegate (Vector3 x, Vector3 y) // { // if ((x.y - y.y == 1 && x.x == y.x) || (x.x - y.x == 1 && x.y == y.y)) return 1; // else if ((Mathf.Abs(x.x - y.x) + Mathf.Abs(x.y - y.y)) == 1) // return 0; // else // return 0; // // return x.x.CompareTo(y.x); // }); ; } activeLine.extendLine(first); } else if (divisionType[division] == DivisionType.Empty) { Debug.Log("Empty"); for (int i = 0; i < finalVertices[division].Count; i++) { Debug.Log(finalVertices[division][i]); } List <Vector3> temp = new List <Vector3>(); GameObject newline = Instantiate(Line); activeLine = newline.GetComponent <drawLine>(); int x = 0, y = 0; // activeLine.extendLine(new Vector3(v.x, v.y + 0.05f)); float offset = cellSize / 2; Debug.Log(division); Debug.Log(finalVertices[division].Count); Vector3 v = finalVertices[division][0]; Vector3 prev = v; Vector3 first = v; temp.Add(v); activeLine.extendLine(v); UnSorted = true; while (UnSorted) { // Debug.Log(temp.Exists(e => e.x == v.x && e.y == v.y)); if (!temp.Exists(e => e.y == v.y + 1 && e.x == v.x) && finalVertices[division].Exists(e => e.y == v.y + 1 && e.x == v.x)) { /* Debug.Log("prev " + prev.x + " " + prev.y);*/ /*up = true;*/ // resetBool(1); prev = v; v = finalVertices[division].Find(e => e.y == v.y + 1 && e.x == v.x); // CheckAndGetIndex(new Vector3((v.x) + cellSize / 2, v.y + (cellSize / 2)), out x, out y); // grid.getXYPosition(new Vector3((v.x) + cellSize / 2, v.y - (cellSize / 2)), out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { UnSorted = false; } } else if (!temp.Exists(e => e.x == v.x + 1 && e.y == v.y) && finalVertices[division].Exists(e => e.x == v.x + 1 && e.y == v.y)) { // ((x < width && y < height) ? grid.getCreated(x, y) : true) // right = true; // resetBool(); Debug.Log("prev " + prev.x + " " + prev.y); prev = v; v = finalVertices[division].Find(e => e.x == v.x + 1 && e.y == v.y); // CheckAndGetIndex(new Vector3((v.x + cellSize) + cellSize / 2, (v.y) - (cellSize / 2)), out x, out y); // grid.getXYPosition(new Vector3((v.x) + cellSize / 2, v.y - (cellSize / 2)), out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { Debug.Log("unsorted false"); UnSorted = false; } } else if (!temp.Exists(e => e.y == v.y - 1 && e.x == v.x) && finalVertices[division].Exists(e => e.y == v.y - 1 && e.x == v.x)) { // ((x < width && y < height) ? !grid.getCreated(x, y) : true) // down = true; // resetBool(); Debug.Log("prev " + prev.x + " " + prev.y); prev = v; v = finalVertices[division].Find(e => e.y == v.y - 1 && e.x == v.x); // CheckAndGetIndex(v, out x, out y); grid.getXYPosition(new Vector3((v.x) + cellSize / 2, v.y - (cellSize / 2)), out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { Debug.Log("unsorted false"); UnSorted = false; } } else if ((!temp.Exists(e => e.x == v.x - 1 && e.y == v.y)) && finalVertices[division].Exists(e => e.x == v.x - 1 && e.y == v.y)) { // ((x < width && y < height) ? grid.getCreated(x, y) : true) // left = true; // resetBool(); Debug.Log("prev " + prev.x + " " + prev.y); prev = v; v = finalVertices[division].Find(e => e.x == v.x - 1 && e.y == v.y); // temp.Contains(new Vector3(v.x - 1, v.y, 0)) // CheckAndGetIndex(v, out x, out y); Debug.Log(v.x + " " + v.y); temp.Add(v); activeLine.extendLine(v); if (temp.Count == finalVertices[division].Count) { Debug.Log("unsorted false"); UnSorted = false; } } yield return(new WaitForSeconds(0.01f)); } activeLine.extendLine(first); } } yield return(null); }