コード例 #1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy" || col.gameObject.tag == "Spell")
        {
            LivesText.livesRemaining -= 1;
            transform.position        = startPosition;
            sm.PlaySoundEffect("Death");
            StartCoroutine(FlashSprites(sprRend, 10, 0.1f));
            Destroy(col.gameObject);
            if (LivesText.livesRemaining == 0)
            {
                EGManager.TriggerEndGame(Score.score);
                LivesText.livesRemaining = 3;
            }
        }

        else if (col.gameObject.tag.Equals("Lava"))
        {
            LivesText.livesRemaining -= 1;
            transform.position        = startPosition;
            sm.PlaySoundEffect("Death");
            StartCoroutine(FlashSprites(sprRend, 10, 0.1f));
            if (LivesText.livesRemaining == 0)
            {
                EGManager.TriggerEndGame(Score.score);
                LivesText.livesRemaining = 3;
            }
        }

        /* else if(col.gameObject.tag == "EndGame")
         * {
         *   transform.position = startPosition;
         *   EndGame.TriggerEndGame();
         * }*/
    }
コード例 #2
0
    //temporary sub routine. Could be replaces with one that takes time as argument
    IEnumerator DestroyAfterDeathAnimation()
    {
        yield return(new WaitForSeconds(3.25f));

        Destroy(gameObject);
        EGManager.TriggerEndGame(Score.score);
    }
コード例 #3
0
 void OnCollisionEnter2D(Collision2D col)
 {
     Debug.Log("Hit by: " + col.gameObject.name);
     if (col.gameObject.tag == "Enemy" || col.gameObject.tag == "Spell")
     {
         LivesText.livesRemaining -= 1;
         transform.position        = startPosition;
         sm.PlaySoundEffect("Death");
         StartCoroutine(FlashSprites(sprRend, 10, 0.1f));
         if (LivesText.livesRemaining == 0)
         {
             EGManager.TriggerEndGame(Score.score);
         }
     }
 }