// Start is called before the first frame update void Start() { op = GetComponent <OriginPoint>(); lr = GetComponent <LineRenderer>(); sr = GetComponent <SpriteRenderer>(); lr.positionCount = 2; }
public override int GetHashCode() { unchecked { return((OriginPoint.GetHashCode() * 397) ^ DirectionVector.GetHashCode()); } }
public OriginPoint SpawnOriginPoint(float angle) { OriginPoint originPoint = Instantiate(originPointPrefab).GetComponent <OriginPoint>(); originPoint.parentCell = this; originPoint.transform.SetParent(transform); originPoint.InitLifeTime(); originPoint.p = center + new Vector3(Mathf.Cos(angle), Mathf.Sin(angle)) * r; originPoint.transform.position = originPoint.p; originPoints.Add(originPoint); return(originPoint); }
public void AddCell(Vector3 p) { int numberOfOriginPoints = Mathf.RoundToInt(OriginPoint.initialLifeTime / (Cell.originPointSpawnTimeMax + Cell.originPointSpawnTimeMin) * 2.0f); Cell cell = Instantiate(cellPrefab, p, Quaternion.identity).GetComponent <Cell>(); cell.id = ++Cell.idGen; cell.transform.position = p; cell.center = p; for (int i = 0; i < numberOfOriginPoints; ++i) { OriginPoint op = cell.SpawnOriginPoint(Mathf.PI * 2 / numberOfOriginPoints * i); op.lifeTime *= Random.Range(0f, 1f); } cell.originPointSpawnTimer += Random.Range(Cell.originPointSpawnTimeMin, Cell.originPointSpawnTimeMax); cell.SimulationUpdate(0.001f); cells.Add(cell); }
public void ConnectOriginPointToCell(OriginPoint op, Cell c) { OriginPoint originPoint = c.SpawnOriginPoint(); originPoint.lifeTime = op.lifeTime * 2;//originPoint will be deleted anyways when the connector is deleted op.lifeTime *= OriginPoint.lifeTimeConnected / OriginPoint.initialLifeTime; originPoint.p = op.p; originPoint.connected = op; op.connected = originPoint; foreach (GripPoint gp in op.gripPoints) { gp.lifeTime *= GripPoint.lifeTimeConnected / GripPoint.initialLifeTime; } foreach (GripPoint gp in originPoint.gripPoints) { gp.lifeTime *= GripPoint.lifeTimeConnected / GripPoint.initialLifeTime; } }
public bool Equals(Ray other) { return(OriginPoint.Equals(other.OriginPoint) && DirectionVector.Equals(other.DirectionVector)); }