using UnityEngine;
using System.Collections;

public class WallController : MonoBehaviour {

    public Transform tracerReferencePoint;
    public WallSegment wallPrefab;

    private WallSegment currentWall = null;

    public void TracerTurned() {

        if (currentWall != null) {
            currentWall.StopGrowing();
            Physics.IgnoreCollision(GetComponent<Collider>(),
                        currentWall.wallCollider,
                        false);
        }

        currentWall = (WallSegment)Instantiate(
                              wallPrefab,
                              tracerReferencePoint.position,
                              tracerReferencePoint.rotation);

        Physics.IgnoreCollision(GetComponent<Collider>(),
                                currentWall.wallCollider);

        currentWall.TracerReferencePoint = tracerReferencePoint;
    }

}
