private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.TryGetComponent <Wall>(out Wall wall)) { CollisionToDestroy--; if (CollisionToDestroy <= 0) { BallDestroyer.DestroyBall(gameObject); } } }
// Start is called before the first frame update void Start() { entitiesContainer = transform.Find("Entities").gameObject; propsContainer = transform.Find("Props").gameObject; avatar = entitiesContainer.transform.Find("Avatar").GetComponent <Avatar>(); lightSwitch = propsContainer.transform.Find("LightSwitch").GetComponent <LightSwitch>(); door.Add(propsContainer.transform.Find("Doors").Find("DoorLeft").GetComponent <Door>()); door.Add(propsContainer.transform.Find("Doors").Find("DoorRight").GetComponent <Door>()); ballSpawner = propsContainer.transform.Find("BallSpawner").GetComponent <BallSpawner>(); ballDestroyer = propsContainer.transform.Find("BallDestroyer").GetComponent <BallDestroyer>(); LeanTween.init(800); avatar.transform.position = Vector3.zero; }
private void OnCollisionEnter(Collision other) { BallDestroyer ballDestroyer = other.gameObject.GetComponent <BallDestroyer>(); if (ballDestroyer != null) { GameController.instance.EndGame(); } PlatformHit platformHit = other.gameObject.GetComponent <PlatformHit>(); if (platformHit != null) { GameController.instance.GetAudioController().Play(AudioControllerTrack.BallBump); } }
IEnumerator CheckLifeTime() { yield return(new WaitForSeconds(LifeTime)); BallDestroyer.DestroyBall(gameObject); }