private void OnDisable() { BombActive = false; EnableDisableInput(); TwitchComponentHandle.ClaimedList.Clear(); TwitchComponentHandle.ClearUnsupportedModules(); StopAllCoroutines(); leaderboard.BombsAttempted++; string bombMessage = null; bool HasDetonated = false; bool HasBeenSolved = true; var timeStarting = float.MaxValue; var timeRemaining = float.MaxValue; var timeRemainingFormatted = ""; TwitchPlaysService.logUploader.Post(); foreach (var commander in _bombCommanders) { HasDetonated |= commander.Bomb.HasDetonated; HasBeenSolved &= commander.IsSolved; if (timeRemaining > commander.CurrentTimer) { timeStarting = commander.bombStartingTimer; timeRemaining = commander.CurrentTimer; } if (!string.IsNullOrEmpty(timeRemainingFormatted)) { timeRemainingFormatted += ", " + commander.GetFullFormattedTime; } else { timeRemainingFormatted = commander.GetFullFormattedTime; } } if (HasDetonated) { bombMessage = string.Format(TwitchPlaySettings.data.BombExplodedMessage, timeRemainingFormatted); leaderboard.BombsExploded += _bombCommanders.Count; leaderboard.Success = false; TwitchPlaySettings.ClearPlayerLog(); } else if (HasBeenSolved) { bombMessage = string.Format(TwitchPlaySettings.data.BombDefusedMessage, timeRemainingFormatted); bombMessage += TwitchPlaySettings.GiveBonusPoints(leaderboard); leaderboard.BombsCleared += _bombCommanders.Count; leaderboard.Success = true; if (leaderboard.CurrentSolvers.Count == 1) { float previousRecord = 0.0f; float elapsedTime = timeStarting - timeRemaining; string userName = ""; foreach (string uName in leaderboard.CurrentSolvers.Keys) { userName = uName; break; } if (leaderboard.CurrentSolvers[userName] == (Leaderboard.RequiredSoloSolves * _bombCommanders.Count)) { leaderboard.AddSoloClear(userName, elapsedTime, out previousRecord); if (TwitchPlaySettings.data.EnableSoloPlayMode) { //Still record solo information, should the defuser be the only one to actually defuse a 11 * bomb-count bomb, but display normal leaderboards instead if //solo play is disabled. TimeSpan elapsedTimeSpan = TimeSpan.FromSeconds(elapsedTime); string soloMessage = string.Format(TwitchPlaySettings.data.BombSoloDefusalMessage, leaderboard.SoloSolver.UserName, (int)elapsedTimeSpan.TotalMinutes, elapsedTimeSpan.Seconds); if (elapsedTime < previousRecord) { TimeSpan previousTimeSpan = TimeSpan.FromSeconds(previousRecord); soloMessage += string.Format(TwitchPlaySettings.data.BombSoloDefusalNewRecordMessage, (int)previousTimeSpan.TotalMinutes, previousTimeSpan.Seconds); } soloMessage += TwitchPlaySettings.data.BombSoloDefusalFooter; parentService.StartCoroutine(SendDelayedMessage(1.0f, soloMessage)); } else { leaderboard.ClearSolo(); } } else { leaderboard.ClearSolo(); } } } else { bombMessage = string.Format(TwitchPlaySettings.data.BombAbortedMessage, timeRemainingFormatted); leaderboard.Success = false; TwitchPlaySettings.ClearPlayerLog(); } parentService.StartCoroutine(SendDelayedMessage(1.0f, bombMessage, SendAnalysisLink)); moduleCameras?.gameObject.SetActive(false); foreach (TwitchBombHandle handle in _bombHandles) { if (handle != null) { Destroy(handle.gameObject, 2.0f); } } _bombHandles.Clear(); _bombCommanders.Clear(); if (_componentHandles != null) { foreach (TwitchComponentHandle handle in _componentHandles) { Destroy(handle.gameObject, 2.0f); } _componentHandles.Clear(); } MusicPlayer.StopAllMusic(); }
public string GetBombResult(bool lastBomb = true) { bool hasDetonated = false; bool hasBeenSolved = true; float timeStarting = float.MaxValue; float timeRemaining = float.MaxValue; string timeRemainingFormatted = ""; foreach (TwitchBomb bomb in Bombs) { if (bomb == null) { continue; } hasDetonated |= bomb.Bomb.HasDetonated; hasBeenSolved &= bomb.IsSolved; if (timeRemaining > bomb.CurrentTimer) { timeStarting = bomb.BombStartingTimer; timeRemaining = bomb.CurrentTimer; } if (!string.IsNullOrEmpty(timeRemainingFormatted)) { timeRemainingFormatted += ", " + bomb.GetFullFormattedTime; } else { timeRemainingFormatted = bomb.GetFullFormattedTime; } } string bombMessage = ""; if (OtherModes.VSModeOn && (hasDetonated || hasBeenSolved)) { OtherModes.Team winner = OtherModes.Team.Good; if (OtherModes.GetGoodHealth() == 0) { winner = OtherModes.Team.Evil; bombMessage = TwitchPlaySettings.data.VersusEvilHeader; } else if (OtherModes.GetEvilHealth() == 0) { winner = OtherModes.Team.Good; bombMessage = TwitchPlaySettings.data.VersusGoodHeader; } bombMessage += string.Format(TwitchPlaySettings.data.VersusEndMessage, winner == OtherModes.Team.Good ? "good" : "evil", timeRemainingFormatted); bombMessage += TwitchPlaySettings.GiveBonusPoints(); if (winner == OtherModes.Team.Good) { bombMessage += TwitchPlaySettings.data.VersusGoodFooter; } else if (winner == OtherModes.Team.Evil) { bombMessage += TwitchPlaySettings.data.VersusEvilFooter; } if (lastBomb && hasBeenSolved) { Leaderboard.Instance.Success = true; } } else if (hasDetonated) { bombMessage = string.Format(TwitchPlaySettings.data.BombExplodedMessage, timeRemainingFormatted); Leaderboard.Instance.BombsExploded += Bombs.Count; if (!lastBomb) { return(bombMessage); } Leaderboard.Instance.Success = false; TwitchPlaySettings.ClearPlayerLog(); } else if (hasBeenSolved) { bombMessage = string.Format(TwitchPlaySettings.data.BombDefusedMessage, timeRemainingFormatted); Leaderboard.Instance.BombsCleared += Bombs.Count; bombMessage += TwitchPlaySettings.GiveBonusPoints(); if (lastBomb) { Leaderboard.Instance.Success = true; } if (Leaderboard.Instance.CurrentSolvers.Count != 1) { return(bombMessage); } float elapsedTime = timeStarting - timeRemaining; string userName = ""; foreach (string uName in Leaderboard.Instance.CurrentSolvers.Keys) { userName = uName; break; } if (Leaderboard.Instance.CurrentSolvers[userName] == Leaderboard.RequiredSoloSolves * Bombs.Count && OtherModes.currentMode == TwitchPlaysMode.Normal) { Leaderboard.Instance.AddSoloClear(userName, elapsedTime, out float previousRecord); if (TwitchPlaySettings.data.EnableSoloPlayMode) { //Still record solo information, should the defuser be the only one to actually defuse a 11 * bomb-count bomb, but display normal leaderboards instead if //solo play is disabled. TimeSpan elapsedTimeSpan = TimeSpan.FromSeconds(elapsedTime); string soloMessage = string.Format(TwitchPlaySettings.data.BombSoloDefusalMessage, Leaderboard.Instance.SoloSolver.UserName, (int)elapsedTimeSpan.TotalMinutes, elapsedTimeSpan.Seconds); if (elapsedTime < previousRecord) { TimeSpan previousTimeSpan = TimeSpan.FromSeconds(previousRecord); soloMessage += string.Format(TwitchPlaySettings.data.BombSoloDefusalNewRecordMessage, (int)previousTimeSpan.TotalMinutes, previousTimeSpan.Seconds); } soloMessage += TwitchPlaySettings.data.BombSoloDefusalFooter; ParentService.StartCoroutine(SendDelayedMessage(1.0f, soloMessage)); } else { Leaderboard.Instance.ClearSolo(); } } else { Leaderboard.Instance.ClearSolo(); } } else { bombMessage = string.Format(TwitchPlaySettings.data.BombAbortedMessage, timeRemainingFormatted); Leaderboard.Instance.Success = false; TwitchPlaySettings.ClearPlayerLog(); } return(bombMessage); }
public string GetBombResult(bool lastBomb = true) { bool HasDetonated = false; bool HasBeenSolved = true; var timeStarting = float.MaxValue; var timeRemaining = float.MaxValue; var timeRemainingFormatted = ""; foreach (var commander in BombCommanders) { HasDetonated |= commander.Bomb.HasDetonated; HasBeenSolved &= commander.IsSolved; if (timeRemaining > commander.CurrentTimer) { timeStarting = commander.bombStartingTimer; timeRemaining = commander.CurrentTimer; } if (!string.IsNullOrEmpty(timeRemainingFormatted)) { timeRemainingFormatted += ", " + commander.GetFullFormattedTime; } else { timeRemainingFormatted = commander.GetFullFormattedTime; } } string bombMessage; if (HasDetonated) { bombMessage = string.Format(TwitchPlaySettings.data.BombExplodedMessage, timeRemainingFormatted); Leaderboard.Instance.BombsExploded += BombCommanders.Count; if (lastBomb) { Leaderboard.Instance.Success = false; TwitchPlaySettings.ClearPlayerLog(); } } else if (HasBeenSolved) { bombMessage = string.Format(TwitchPlaySettings.data.BombDefusedMessage, timeRemainingFormatted); Leaderboard.Instance.BombsCleared += BombCommanders.Count; bombMessage += TwitchPlaySettings.GiveBonusPoints(); if (lastBomb) { Leaderboard.Instance.Success = true; } if (Leaderboard.Instance.CurrentSolvers.Count == 1) { float previousRecord = 0.0f; float elapsedTime = timeStarting - timeRemaining; string userName = ""; foreach (string uName in Leaderboard.Instance.CurrentSolvers.Keys) { userName = uName; break; } if (Leaderboard.Instance.CurrentSolvers[userName] == (Leaderboard.RequiredSoloSolves * BombCommanders.Count)) { Leaderboard.Instance.AddSoloClear(userName, elapsedTime, out previousRecord); if (TwitchPlaySettings.data.EnableSoloPlayMode) { //Still record solo information, should the defuser be the only one to actually defuse a 11 * bomb-count bomb, but display normal leaderboards instead if //solo play is disabled. TimeSpan elapsedTimeSpan = TimeSpan.FromSeconds(elapsedTime); string soloMessage = string.Format(TwitchPlaySettings.data.BombSoloDefusalMessage, Leaderboard.Instance.SoloSolver.UserName, (int)elapsedTimeSpan.TotalMinutes, elapsedTimeSpan.Seconds); if (elapsedTime < previousRecord) { TimeSpan previousTimeSpan = TimeSpan.FromSeconds(previousRecord); soloMessage += string.Format(TwitchPlaySettings.data.BombSoloDefusalNewRecordMessage, (int)previousTimeSpan.TotalMinutes, previousTimeSpan.Seconds); } soloMessage += TwitchPlaySettings.data.BombSoloDefusalFooter; parentService.StartCoroutine(SendDelayedMessage(1.0f, soloMessage)); } else { Leaderboard.Instance.ClearSolo(); } } else { Leaderboard.Instance.ClearSolo(); } } } else { bombMessage = string.Format(TwitchPlaySettings.data.BombAbortedMessage, timeRemainingFormatted); Leaderboard.Instance.Success = false; TwitchPlaySettings.ClearPlayerLog(); } return(bombMessage); }