Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
 // Set a new origin; update the rigidbody velocity
 private void SetOrigin(RippleOrigin newOrigin)
 {
     this.origin = newOrigin;
     this.GetComponent <Rigidbody2D>().velocity = getRelativeVec().normalized *speed;
 }