protected virtual void UpdateCoords() { coords.Clear(); holeCoords.Clear(); BoundaryPointsHandler bph = gameObject.GetComponent <BoundaryPointsHandler> (); foreach (GameObject o in bph.boundaryPoints) { var t = o.transform.localPosition; coords.Add(new Vector2(t.x, t.y)); } Vector2 clothPosition = transform.position; foreach (GameObject d in bph.darts) { Vector2 dartPosition = d.transform.position; List <Vector2> temp = new List <Vector2> (); foreach (Vector2 v in d.GetComponent <BoundaryPointsHandler> ().GetPointPositions()) { temp.Add(v - clothPosition + dartPosition); } holeCoords.Add(temp); } }
public GameObject CreateDart(Vector3 start, Vector3 end, SimpleLineBehaviour simpleLine) { Vector2 position = end; GameObject o = new GameObject(); o.transform.parent = simpleLine.transform; o.transform.localPosition = Vector3.zero; GameObject d = Instantiate(dartPrefab, o.transform) as GameObject; d.transform.Translate(position); var positions = InitPositions(position); BoundaryPointsHandler bph = d.GetComponent <BoundaryPointsHandler> (); InitBoundaryPointsHandler(bph, positions); bph.DeactivateBoundaryPoint(bph.boundaryPoints[2]); Destroy(d.GetComponent <Movable>()); var movable = d.AddComponent <Movable1D> (); movable.Init(simpleLine.first, simpleLine.second); return(d); }
void InitBoundaryPointsHandler(BoundaryPointsHandler bph, Vector2[] positions) { bph.boundaryPointPrefab = dartPointPrefab; bph.boundaryLinePrefab = simpleLinePrefab; bph.InitQuad(); bph.boundaryPoints [0].transform.position = positions[0]; bph.boundaryPoints [1].transform.position = positions[2]; bph.boundaryPoints [2].transform.position = positions[1]; bph.boundaryPoints [3].transform.position = positions[3]; bph.boundaryPoints [0].GetComponent <Movable1D> ().Init(bph.boundaryPoints [2].transform, bph.boundaryPoints [0].transform); bph.boundaryPoints [1].GetComponent <Movable1D> ().Init(bph.boundaryPoints [3].transform, bph.boundaryPoints [1].transform); bph.boundaryPoints [2].GetComponent <Movable1D> ().Init(bph.boundaryPoints [0].transform, bph.boundaryPoints [2].transform); bph.boundaryPoints [3].GetComponent <Movable1D> ().Init(bph.boundaryPoints [1].transform, bph.boundaryPoints [3].transform); }
public GameObject CreateDart(Vector3 start, Vector3 end) { Vector2 position = start + (end - start) / 2; GameObject d = Instantiate(dartPrefab, cloth.transform) as GameObject; d.transform.Translate(position); var positions = InitPositions(position); BoundaryPointsHandler bph = d.GetComponent <BoundaryPointsHandler> (); InitBoundaryPointsHandler(bph, positions); return(d); }
public RemovePointAction(BoundaryPointsHandler handler, GameObject point) { Debug.Log("Creating RemovePointAction"); boundaryPoint = point; boundaryPointsHandler = handler; }
public AddPointAction(BoundaryPointsHandler handler, GameObject line, Vector3 pos) { boundaryLine = line; position = pos; boundaryPointsHandler = handler; }