예제 #1
0
 private void OnDestroy()
 {
     if (OnBlockDestroyed != null)
     {
         OnBlockDestroyed.Invoke(this.gameObject);
     }
 }
예제 #2
0
파일: Level.cs 프로젝트: damrem/ld48
    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);
        }
    }
예제 #3
0
        protected virtual IEnumerator Destroy()
        {
            yield return(null);

            Destroy(gameObject);

            OnBlockDestroyed.Raise(this);

            if (IsStable)
            {
                AlertNeighbors();
            }
        }
예제 #4
0
 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);
 }
예제 #5
0
        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);
        }