Пример #1
0
    // Spawn a new Agent to this agent's "Left". Update the chain of leftNeighbor
    // and rightNeighbor
    private RippleAgent SpawnLeft(Vector3 position, RippleOrigin newOrigin)
    {
        var oldLeftNeighbor = leftNeighbor;

        var newLeftNeighbor = Instantiate(this, position, this.transform.rotation, this.transform.parent);

        newLeftNeighbor.SetOrigin(newOrigin);

        oldLeftNeighbor.rightNeighbor = newLeftNeighbor;
        this.leftNeighbor             = newLeftNeighbor;

        newLeftNeighbor.leftNeighbor  = oldLeftNeighbor;
        newLeftNeighbor.rightNeighbor = this;

        return(newLeftNeighbor);
    }
Пример #2
0
    void Update()
    {
        RippleAgent origin    = this.GetComponentInChildren <RippleAgent>();
        RippleAgent traversal = origin;
        int         count     = 0;
        int         total     = this.GetComponentsInChildren <RippleAgent>().Length + 1; //.transform.childCount + 1;

        lineRenderer.positionCount = total;

        do
        {
            lineRenderer.SetPosition(count++, traversal.transform.position);
            traversal = traversal.leftNeighbor;
        }while (traversal != origin);

        // close the loop
        lineRenderer.SetPosition(count, origin.transform.position);
    }