private void OnDestroy() { if (OnBlockDestroyed != null) { OnBlockDestroyed.Invoke(this.gameObject); } }
void DestroyBlock(Cell cell, bool animate = true) { var block = GetBlock(cell); if (!block) { return; } if (block.IsUnbreakable) { return; } Blocks[cell.X, cell.Y] = null; void onEnd(Block block) { Destroy(block.gameObject); OnBlockDestroyed?.Invoke(); }; if (animate) { block.AnimateDestroy(onEnd); } else { onEnd(block); } }
private void OnCollisionEnter2D(Collision2D collision) { if (Stage == blocksByStages.Length - 1) { levelManager.BlockDestroyed(); gameObject.SetActive(false); OnBlockDestroyed?.Invoke(gameObject, score.Score); return; } blocksByStages[Stage].SetActive(false); Stage++; blocksByStages[Stage].SetActive(true); }
private void OnCollisionEnter2D(Collision2D other) { Bomb b = other.gameObject.GetComponent <Bomb>(); if (b == null) { return; } if (!this._wall.IsDestroyedByColor(b.CurrentColor)) { return; } OnBlockDestroyed?.Invoke(this, null); Destroy(this.gameObject); }