private void DestroyBlock() { AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position); TriggerSparklesVFX(); Destroy(gameObject); lvl.BlockDestroyed(); FindObjectOfType <GameStatus>().AddToScore(); }
private void OnCollisionEnter2D(Collision2D collision) { if (gameObject.tag == "Breakable") { timesHit++; int maxHits = hitSprites.Length + 1; if (timesHit >= maxHits) { AudioSource.PlayClipAtPoint(breakSound, Camera.main.transform.position); gameStatus.AddToScore(); lvl.BlockDestroyed(); TriggerSparklesVFX(); Destroy(gameObject); } else { GetComponent <SpriteRenderer>().sprite = hitSprites[timesHit - 1]; } } }