public void Finished() { PauseGame(); int saved = 0, trapped = 0, sacrificed = 0, found = 0; foreach (Critter critter in critters) { switch (critter.GetCurrentState()) { case Critter.State.TRAPPED: trapped++; break; case Critter.State.FOLLOWING: case Critter.State.HELD: saved++; break; case Critter.State.DEAD: sacrificed++; break; } if (critter.IsFound()) { found++; } } SaveLoad.LevelData data = new SaveLoad.LevelData(); data.levelNumber = SceneManager.GetActiveScene().buildIndex; data.completed = true; data.totalCritters = critters.Count; data.foundCritters = found; data.savedCritters = saved; SaveLoad.SaveLevel(data); endScreen.SetStats(critters.Count, saved, trapped, sacrificed, found); endScreen.gameObject.SetActive(true); }