void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Ball") { OnBlockDestroyed.Invoke(this); gameObject.SetActive(false); } }
protected virtual void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.CompareTag("Ball")) { SoundManager.instance.AudSource.PlayOneShot(SoundManager.instance.StandardBlockHit); Destroy(this.gameObject); blockDestroyedEvent.Invoke(0); pointsAddedEvent.Invoke(standardPoints); } }
/// <summary> /// Sent when an incoming collider makes contact with this object's /// collider (2D physics only). /// </summary> /// <param name="other">The Collision2D data associated with this collision.</param> virtual protected void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Ball")) { pointsAddedEvent.Invoke(points); if (GameObject.FindGameObjectsWithTag("Block").Length == 1) { blockDestroyedEvent.Invoke(); AudioManager.Play(AudioClipName.YouWin); } Destroy(gameObject); } }
/// <summary> /// Destroys the block on collision with a ball /// </summary> /// <param name="coll">Coll.</param> virtual protected void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.CompareTag("Ball")) { // HUD.AddPoints(points); pointsAddedEvent.Invoke(points); GameObject[] blocks = GameObject.FindGameObjectsWithTag("Block"); if (blocks.Length == 1) { blockDestroyedEvent.Invoke(); } //AudioManager.Play(AudioClipName.BlockHit); Destroy(gameObject); } }
virtual protected void OnCollisionEnter2D() { if (gameObject.CompareTag("StandardBlock")) { pointsAddedEvent.Invoke((int)standardBlockPoints); AudioManager.Play(AudioClipName.Standard); } else if (gameObject.CompareTag("BonusBlock")) { AudioManager.Play(AudioClipName.Bonus); pointsAddedEvent.Invoke((int)bonusBlockPoints); } else if (gameObject.CompareTag("PickUpBlock")) { pointsAddedEvent.Invoke((int)pickUpBlockPoints); } Destroy(gameObject); blockDestroyEvent.Invoke(); }
protected virtual void Remove() { BlockDestroyedEvent?.Invoke(this); bonusGiver?.Activate(); Destroy(gameObject); }