Exemple #1
0
 public void UpdateConfidence()
 {
     if (OtherModes.TimeModeOn)
     {
         float timedMultiplier = OtherModes.GetAdjustedMultiplier();
         ConfidencePrefab.color = Color.yellow;
         string conf = "x" + $"{timedMultiplier:0.0}";
         string pts  = "+" + $"{TwitchPlaySettings.GetRewardBonus():0}";
         ConfidencePrefab.text = pts;
         StrikesPrefab.color   = Color.yellow;
         StrikesPrefab.text    = conf;
     }
     else if (OtherModes.ZenModeOn)
     {
         ConfidencePrefab.color = Color.yellow;
         string pts = "+" + $"{TwitchPlaySettings.GetRewardBonus():0}";
         ConfidencePrefab.text = pts;
         StrikesPrefab.color   = Color.red;
         if (_currentBomb != null)
         {
             StrikesPrefab.text = _currentBomb.StrikeCount.ToString();
         }
     }
     else if (OtherModes.VSModeOn)
     {
         int bossHealth = OtherModes.GetEvilHealth();
         int teamHealth = OtherModes.GetGoodHealth();
         StrikesPrefab.color    = Color.cyan;
         ConfidencePrefab.color = Color.red;
         StrikesPrefab.text     = $"{teamHealth} HP";
         ConfidencePrefab.text  = $"{bossHealth} HP";
     }
     else
     {
         ConfidencePrefab.color = Color.yellow;
         string pts = $"+{TwitchPlaySettings.GetRewardBonus():0}";
         ConfidencePrefab.text = pts;
     }
 }
    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);
    }