IEnumerator Escape(Collision2D collision) { yield return(new WaitForSeconds(1.2f)); if (Math.Abs(gameObject.transform.position.x - collision.transform.position.x) <= 0.55f && _col && Math.Abs(gameObject.transform.position.y - collision.transform.position.y) <= 0.55f) { FieldGenerator.ChEnemy("Enemies: " + (GameObject.FindGameObjectsWithTag("Enemy").Length - 1)); Destroy(gameObject); } }
IEnumerator CheckEmeny(GameObject enemy) { yield return(new WaitForSeconds(2.5f)); foreach (GameObject item in GameObject.FindGameObjectsWithTag("Enemy")) { if (item == enemy) { Destroy(enemy); } } FieldGenerator.ChEnemy("Enemies: " + (GameObject.FindGameObjectsWithTag("Enemy").Length)); }
IEnumerator KillEnemy(GameObject col) { if (col.GetComponent <Rigidbody2D>() != null) { Destroy(col.GetComponent <Rigidbody2D>()); } if (col.GetComponent <BoxCollider2D>() != null) { Destroy(col.GetComponent <BoxCollider2D>()); } FieldGenerator.ChEnemy("Enemies: " + (GameObject.FindGameObjectsWithTag("Enemy").Length - 1)); FieldGenerator.ChScore(100); col.gameObject.GetComponent <Animator>().SetBool("IsDead", true); yield return(new WaitForSeconds(0.1f)); Destroy(col); }