void SpawnCutArea(int numberOfPoint) { terrainPrefab = Instantiate(TerrainPre, transform.position, Quaternion.identity); edgePre = Instantiate(edgePrefab, transform.position, Quaternion.identity); currentEdge = edgePre.GetComponent <EdgeCol>(); List <Vector2> listNewPoints = new List <Vector2>(); if (numberOfPoint != 0) { listNewPoints.Add(terrain.PathData.Get(numberOfPoint - 1)); } else { listNewPoints.Add(terrain.PathData.Get(terrain.PathData.GetPoints(1).Count - 1)); } listNewPoints.Add(terrain.PathData.Get(numberOfPoint)); if (numberOfPoint < terrain.PathData.GetControls().Count - 1) { listNewPoints.Add(terrain.PathData.Get(numberOfPoint + 1)); } else { listNewPoints.Add(terrain.PathData.Get(0)); } var t = terrainPrefab.GetComponent <Ferr2DT_PathTerrain>(); var m = t.PathData.GetPoints(1); for (var i = m.Count - 1; i >= 0; i--) { t.PathData.RemoveAt(i); } for (int i = 0; i < listNewPoints.Count; i++) { t.PathData.Add(listNewPoints[i]); if (i == 1) { t.PathData.GetControls(i).type = terrain.PathData.GetControls(numberOfPoint).type; t.PathData.GetControls(i).controlPrev = terrain.PathData.GetControls(numberOfPoint).controlPrev; t.PathData.GetControls(i).controlNext = terrain.PathData.GetControls(numberOfPoint).controlNext; } else { t.PathData.GetControls(i).type = Ferr.PointType.Sharp; } } currentLine = listNewPoints[0] - listNewPoints[2]; listNewPoints.Add(listNewPoints[0]); currentEdge.gameObject.Hide(); currentEdge.edge.points = listNewPoints.ToArray(); currentTerrain = t; }
public void EnableDetector(EdgeCol e = null) { bladeDetector.enabled = true; if (e) // 是注册新的 edgeCol { bladeDetector.OnEnableDetector(e); } }
private void OnCollisionEnter(Collision other) { if (coled) { return; } Vector3 speedOnEdge = Vector3.Project(velBeforeHit, transform.right); float dotResult = Vector3.Dot(speedOnEdge, transform.right); if (dotResult >= 20.0f) { edgeCol = propHandler.currentProp.transform.GetComponentInChildren <EdgeCol>(); propHandler.DropImmediate(); //UnityEditor.EditorApplication.isPaused = true; StopCoroutine("GetIn"); StartCoroutine("GetIn", other); coled = false; } }
public void OnEnableDetector(EdgeCol e) { edgeCol = e; coled = false; }
public void OnPickUp(EdgeCol e) { width = e.width; b = e.b; }