public void CmdEndGame() { List <CaptainsMessPlayer> players = GetPlayers(); NetworkedPlayerScript bonusPlayer = null; float longestMatchTime = -1; List <int> scoringSongs = new List <int>(); foreach (CaptainsMessPlayer player in players) { NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>(); int sid = nps.GetSongID(); if (nps.scored_GuessedCorrect) { float currentMatchTime = nps.matchTime; nps.RpcAddScore(5 * Mathf.FloorToInt(currentMatchTime), (int)Score.Time); if (currentMatchTime > longestMatchTime) { longestMatchTime = currentMatchTime; bonusPlayer = nps; } scoringSongs.Add(sid); //Hacky bullshit for finding which kind of game we're in? GameManagerScript gameManager = FindObjectOfType <GameManagerScript>(); Assert.IsNotNull <GameManagerScript>(gameManager); int songSet = gameManager.GetSongSet(); Analytics.CustomEvent("guessedCorrect", new Dictionary <string, object> { { "matchTime", currentMatchTime }, { "songSet", songSet }, { "songID", sid } }); } else { for (int i = 0; i < players.Count; i++) { NetworkedPlayerScript other_nps = players[i].GetComponent <NetworkedPlayerScript>(); if (sid == other_nps.GetSongID()) { if (nps.color != other_nps.color) { nps.match_color = other_nps.color; break; } } } } } //Bonus for player who guessed first. if (bonusPlayer != null) //If this is null, nobody guessed anything. Lame! { bonusPlayer.RpcAddScore(100, (int)Score.First); } foreach (CaptainsMessPlayer player in players) { NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>(); if (nps.scored_GuessedCorrect) { nps.RpcAddScore(250, (int)Score.Correct); } if (scoringSongs.Contains(nps.songID)) { nps.RpcAddScore(500, (int)Score.WasGuessed); } nps.RpcEndGame(); } mess.FinishGame(); }
void Update() { GameManagerScript gameManager = FindObjectOfType <GameManagerScript>(); Assert.IsNotNull <GameManagerScript>(gameManager); if (gameManager.IsInPostGame()) { sliderText.text = ""; infoText.enabled = false; countdownText.enabled = false; string details = ""; if (networkedPScript.GetFirstBonus()) { details = "(First to guess: +100)\n"; } int song = networkedPScript.GetSongID(); int match = networkedPScript.GetMatchSongID(); int songTypeIndex = gameManager.GetSongSet(); if (match != -1) { answerParent.SetActive(true); playerPickedBtn.GetComponent <Image>().color = ColorScript.GetColor(networkedPScript.picked_color); playerPickedBtn.GetComponentInChildren <Text>().text = networkedPScript.picked_color.ToString(); noGuessText.enabled = false; if (song == match) { lookingForParent.SetActive(false); answerText.text = "Correct!"; details += "(Found Dance Partner: +250)\n(Time Bonus: +" + networkedPScript.GetTimeBonus() + ")\n"; listeningToText.text = "You were dancing to:\n" + AudioManagerScript.GetSongName(songTypeIndex, song); } else { lookingForParent.SetActive(true); lookingForBtn.GetComponent <Image>().color = ColorScript.GetColor(networkedPScript.match_color); lookingForBtn.GetComponentInChildren <Text>().text = networkedPScript.match_color.ToString(); answerText.text = "Wrong!"; listeningToText.text = "You heard: " + AudioManagerScript.GetSongName(songTypeIndex, song) + "\nThey heard: " + AudioManagerScript.GetSongName(songTypeIndex, match); } } else { lookingForParent.SetActive(false); answerParent.SetActive(false); noGuessText.enabled = true; listeningToText.text = "You were dancing to:\n" + AudioManagerScript.GetSongName(songTypeIndex, song); } finalScoreText.text = "Score: +" + networkedPScript.GetScoredThisRound().ToString(); if (networkedPScript.GetWasGuessed()) { details += "(Partner found you: +500)"; } if (details != "") { details = "Score breakdown:\n" + details; } detailsText.text = details; continuingInText.text = "Automatically continuing in " + Mathf.CeilToInt(gameManager.endgameCountDown); } else { float countDown = gameManager.countDown; float captainsCountdown = networkedPScript.captainsCountdown; if (captainsCountdown > 0) { sliderText.text = ""; infoText.enabled = true; if (captainsCountdown < 1) { infoText.text = "DANCE!"; } else if (captainsCountdown >= (4f)) //Plus one second for the "Dance" end { infoText.text = "Ready?"; } else { infoText.text = "" + Mathf.Floor(captainsCountdown); } } else if (countDown > 0) { bool chosen = (networkedPScript.GetMatchSongID() == -1); if (chosen) { sliderText.text = "Chose your dance partner:"; } else { sliderText.text = "Press back to undo current choice"; } infoText.enabled = false; countdownText.enabled = true; countdownText.text = "" + Mathf.Ceil(countDown); if (reminded == false) { if (countDown < 30 && chosen) { Debug.Log("Reminder to pick!"); AudioManagerScript.instance.PlayFind(); reminded = true; } } } else { sliderText.text = "Other players:"; infoText.enabled = false; } } }