Esempio n. 1
0
    } //End Update()

    public void CheckForGameEnd()
    {
        if (!cellGrid.GetPlayer())
        {
            gameOverMenu.Open();
        }
    }
Esempio n. 2
0
    public IEnumerator TakeHit()
    {
        hp -= 1;
        damagedSpriteID++;
        if (damagedSpriteID > 1)
        {
            damagedSpriteID = 1;
        }

        spriteRenderer.sprite = flashSprite;
        yield return(new WaitForSeconds(0.0005f));

        spriteRenderer.sprite = damagedSprites[damagedSpriteID];

        if (hp <= 0)
        {
            GameSoundManager.instance.PlayBlockBreakSound();
            Vector3 position = transform.position;
            Destroy(gameObject);
            currentCell.block     = null;
            currentCell.shattered = true;
            cellGrid.GetPlayer().IncreaseScore();

            GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("Block");
            for (var i = 0; i < gameObjects.Length; i++)
            {
                if (gameObjects[i].transform.position == position)
                {
                    Destroy(gameObjects[i]);
                }
            }
        }
    }