private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Ball") { LifePanel lifepanel = FindObjectOfType <LifePanel>(); lifepanel.DecraeseLife(); Destroy(collision.gameObject); //if (lifepanel.lifeIcons.Length >= 1) //{ // lifepanel.DecraeseLife(); // Destroy(collision.gameObject); // Restart(); // //TODO Restart() //} //if (lifepanel.lifeIcons.Length <1) //{ // FindObjectOfType<SceneLoader>().Invoke("LoadGameOverScene", 2); // //wait 2 seconds to load GameOver Scene // //TODO NOTE that this is referred by function name //} } else { Destroy(collision.gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Ball") { LifePanel lifepanel = FindObjectOfType <LifePanel>(); lifepanel.DecraeseLife(); //decrease life and restart. ChargeManager chargeManager = FindObjectOfType <ChargeManager>(); chargeManager.ResetCharge(); //set charge level to zero. Destroy(collision.gameObject); } else { Destroy(collision.gameObject); } }