void OnTriggerEnter2D(Collider2D other) { if (other.tag == "HOLE") { WallsController controller = other.GetComponentInParent <WallsController>(); controller.ReverseDirection(); } }
void OnTriggerEnter2D(Collider2D collider) { WallsController wall = collider.GetComponent <WallsController>(); if (wall != null) { LevelController.addPointForWalls(); wall.Destroy(); } }
/* * ------------------------------------------------------------------------- * MARK: LIFECYCLE FUNCTIONS * ------------------------------------------------------------------------- */ void Awake() { wallsController = GameObject.FindGameObjectWithTag("Walls").GetComponent <WallsController>(); List <Transform> childTransforms = new List <Transform>(); for (int i = 0; i < transform.childCount; i++) { childTransforms.Add(transform.GetChild(i)); } wallSegmentControllers = childTransforms.ToArray() .Select((trans) => trans.gameObject.GetComponent <WallSegmentController>()) .Cast <WallSegmentController>() .ToArray(); }
public void Awake() { Instance = this; }