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(); * }*/ }
//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); }
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); } } }