//!x is defeat, x is victory //the string should be "mother" or "bedtime" or "stress" based on what resulted in loss static public void end(bool x, string loseReason) { loadReferences(); timer.pause(); if (!x) { Debug.Log("Defeat"); if (!playedDefeat) { endscreen.losescreen(); playedDefeat = true; } if (loseReason.Equals("mother")) { reason.displayMotherLoss(); } else if (loseReason.Equals("bedtime")) { reason.displayBedtimeLoss(); } else if (loseReason.Equals("stress")) { reason.displayStressLoss(); } } else { //THIS SHOULD NEVER HAPPEN Debug.Log("This should not happen."); endscreen.winscreen(); reason.errorMethod(); } //turning off all the hitboxes GameObject[] clickables = GameObject.FindGameObjectsWithTag("Clickable"); for (int i = 0; i < clickables.Length; i++) { //tries to disable boxcolliders and if fails tries polygons and if fails does nothing try { clickables[i].GetComponent <BoxCollider2D>().enabled = !clickables[i].GetComponent <BoxCollider2D>().enabled; } catch { try { clickables[i].GetComponent <PolygonCollider2D>().enabled = !clickables[i].GetComponent <PolygonCollider2D>().enabled; } catch { } } } }