// Use this for initialization public void Awake() { zeroPoint = new Vector3(0,0,0); lineTopSetup = GameObject.Find("LineSetupTop").GetComponent<LineSetupTop>(); controller = GameObject.Find("GameController").GetComponent<GameController>(); handler = GameObject.Find("OnClickEvents").GetComponent<GuiHandler>(); x = -12; y = Random.Range(-5, 0); lastY = y; GameObject linePart = Instantiate(curvesBotPrefab, zeroPoint, Quaternion.identity); lineRendererS = lineRendererSetup(linePart); colliderS = linePart.GetComponent<EdgeCollider2D>(); curveDrawer = linePart.GetComponent<BezierCurve2D>(); curveDrawer.drawQuadraticCurve(lineRendererS, 50, new Vector3(-17, 0, 0), new Vector3(-16, 0, 0), new Vector3(-15, 0, 0)); curveCollider = linePart.GetComponent<BezierCurve2DCollider>(); curveCollider.CreateColliderQuadraticCurve2D(colliderS, 50, new Vector3(-17, 0, 0), new Vector3(-16, 0, 0), new Vector3(-15, 0, 0)); colliderS.edgeRadius = 0.1f; }
public void lineSetupBot() { startPoint = new Vector3(x, lastY, -5); x = x + lineTopSetup.randomX; y = Random.Range(-4f, -2f); lastY = y; endPoint = new Vector3(x, y, -5); y = Random.Range(-4f, -2f); edgePoint = new Vector3(x - 1, y, -5); GameObject linePart = Instantiate(curvesBotPrefab, zeroPoint, Quaternion.identity); lineRendererS = lineRendererSetup(linePart); colliderS = linePart.GetComponent<EdgeCollider2D>(); curveDrawer = linePart.GetComponent<BezierCurve2D>(); //linePart.transform.position = (startPoint + endPoint) / 2; curveDrawer.drawQuadraticCurve(lineRendererS, 50, startPoint - new Vector3(0.0f, 0, 0), edgePoint, endPoint); curveCollider = linePart.GetComponent<BezierCurve2DCollider>(); curveCollider.CreateColliderQuadraticCurve2D(colliderS, 50, startPoint, edgePoint, endPoint); Line forVariables = linePart.GetComponent<Line>(); forVariables.startPoint = startPoint; forVariables.edgePoint = edgePoint; forVariables.endPoint = endPoint; colliderS.edgeRadius = 0.08f; if (Random.value < 0.3f) { //colliderS.isTrigger = true; lineRendererS.material = redColor; } if (Random.value < 0.1f) { lineRendererS.GetComponent<Renderer>().enabled = false; linePart.layer = 9;//unvisible terrain } lineArray.Add(linePart); }
public void lineSetupperTop() { startPoint = new Vector3(x, lastY, -5); randomX = Random.Range(8f, 10f); x = x + randomX; y = Random.Range(4f, 2f); lastY = y; endPoint = new Vector3(x, y, -5); y = Random.Range(4f, 2f); edgePoint = new Vector3(x - 1, y, -5); GameObject linePart = Instantiate(curvesTopPrefab, zeroPoint, Quaternion.identity); lineRendererS = lineRendererSetup(linePart); colliderS = linePart.GetComponent <EdgeCollider2D>(); curveDrawer = linePart.GetComponent <BezierCurve2D>(); curveDrawer.drawQuadraticCurve(lineRendererS, 50, startPoint, edgePoint, endPoint); curveCollider = linePart.GetComponent <BezierCurve2DCollider>(); curveCollider.CreateColliderQuadraticCurve2D(colliderS, 50, startPoint, edgePoint, endPoint); colliderS.edgeRadius = 0.08f; //0.08di Line forVariables = linePart.GetComponent <Line>(); forVariables.startPoint = startPoint; forVariables.endPoint = endPoint; if (Random.value < 0.3f) { lineRendererS.material = redColor; } else if (Random.value > 0.3f && Random.value < 0.5) { lineRendererS.GetComponent <Renderer>().enabled = false; linePart.layer = 9; } lineArray.Add(linePart); }