// This function is to proceed to the next round. It will create a new list of auditions for the start of the round // from the list of auditions who survived the last one. In this way, a record is kept of who was eliminated in each round. private void NextRound() { currentRound++; if (Background != null && BackgroundSprites.Length > 0) { Background.sprite = BackgroundSprites[Mathf.Clamp(currentRound - 1, 0, BackgroundSprites.Length)]; } HideRecapScreen(); if (currentRound > numRounds) { OnLoseGame(); return; } else { // Ensure that the relevant lists are instantiated. if (auditionsLeftInRound == null) { auditionsLeftInRound = new List <GameObject>(); } // Shallow copy the survivors list to the new round's auditions list foreach (GameObject audition in selectedAuditionsList) { CastMember cm = audition.GetComponent <CastMember>(); if (!cm) { Debug.LogError("Selected audition prefab does not have the CastMember component!"); } else if (cm.GetEliminatedInRound() == 0) { auditionsLeftInRound.Add(audition); cm.OnNextRound(); } } if (auditionsLeftInRound.Count < 1) { OnWinGame(); } } timeSinceAuditionEnded = currentRound == 1 ? auditionInterval : 0.0f; // Will trigger NextAudition() when it reaches auditionInterval. }
// This function displays the recap scene at the end of the round, from which the player can then move on to the next round. private void ShowRecapScene() { showingRecap = true; recapMenu.SetActive(true); InsultManager.Instance.OnStopCountdown(); List <CastMember> cmlist = new List <CastMember>(); int survivors = 0; foreach (GameObject audition in selectedAuditionsList) { CastMember cm = audition.GetComponent <CastMember>(); cm.OnRelax(); if (cm.GetEliminatedInRound() == currentRound) // Actor was eliminated this round { cmlist.Add(cm); } else if (cm.GetEliminatedInRound() == 0) // Actor is still in the game { cmlist.Add(cm); survivors++; } } if (survivors < 1) { NextRoundButton.SetActive(false); AdmitDefeatButton.SetActive(false); celebrateVictoryButton.SetActive(true); } int auditionsInRound = cmlist.Count; float midpoint = (auditionsInRound - 1) / 2.0f; int i = 0; foreach (CastMember cm in cmlist) { cm.SetSilent(true); cm.OnFadeIn(1.0f); cm.gameObject.SetActive(true); float pc = recapScreenPercent / 100.0f; float offset = ((i - midpoint) / (auditionsInRound + 1)) * pc; Vector2 pos = Camera.current.ViewportToWorldPoint(new Vector3(0.5f + offset, 0.5f, 0.0f)); cm.gameObject.transform.position = pos; if (cm.GetEliminatedInRound() == currentRound) { SpriteRenderer sr = cm.GetSprite(); sr.material = greyscaleMaterial; Color c = sr.color; c.r *= darkenAmount; c.g *= darkenAmount; c.b *= darkenAmount; sr.color = c; } i++; } }