コード例 #1
0
    private void UpdateCleaningProgressionUI(int teamID)
    {
        const string BOUNCE_TRIGGER_STRING = "Bounce";

        if (NetworkManager.localPlayerInformation.team == teamID)
        {
            fill_CleanAmount.fillAmount = HouseManager.CleanPercentage;
            fill_CleanAmount.color      = Mathf.Approximately(fill_CleanAmount.fillAmount, 1) ? Color.green : fill_StartColor;
            anim_OurProgressBar.SetTrigger(BOUNCE_TRIGGER_STRING);
            return;
        }

        fill_CleanAmount_OtherTeam.fillAmount = HouseManager.Get_OtherTeamCleaningPercentage();
        fill_CleanAmount_OtherTeam.color      = Mathf.Approximately(fill_CleanAmount_OtherTeam.fillAmount, 1) ? Color.green : fill_StartColor;
        anim_OpponentProgressBar.SetTrigger(BOUNCE_TRIGGER_STRING);
    }
コード例 #2
0
    private IEnumerator StartUILoop()
    {
        const string TRIGGER_STRING = "BounceIn";

        Color screenColor = Color.white;

        screenColor.a = whitescreen.color.a;

        while (screenColor.a < 1)
        {
            screenColor.a    += Time.deltaTime / 2;
            whitescreen.color = screenColor;
            yield return(new WaitForEndOfFrame());
        }

        yield return(new WaitForSeconds(1.3f));

        winscreenAnimator.enabled = true;
        winscreenAnimator.SetTrigger(TRIGGER_STRING);

        yield return(new WaitForSeconds(1.5f));

        statisticsObject.SetActive(true);
        audioSource.PlayOneShot(clips[0]);

        yield return(new WaitForSeconds(2.5f));

        float finalCleaningprogressionOpponent = HouseManager.Get_OtherTeamCleaningPercentage();
        float finalCleaningprogressionYours    = HouseManager.Get_CleanPercentage();

        Debug.Log(finalCleaningprogressionOpponent + " is other team.");
        Debug.Log(finalCleaningprogressionYours + "is our team.");

        audioSource.PlayOneShot(clips[1]);
        audioSource.Play();

        while (finalCleaningprogressionYours > fillbarYourTeam.fillAmount || finalCleaningprogressionOpponent > fillbarOpponentTeam.fillAmount)
        {
            fillbarYourTeam.fillAmount     += Time.deltaTime / 8;
            fillbarOpponentTeam.fillAmount += Time.deltaTime / 8;

            fillbarYourTeam.fillAmount     = Mathf.Clamp(fillbarYourTeam.fillAmount, 0, finalCleaningprogressionYours);
            fillbarOpponentTeam.fillAmount = Mathf.Clamp(fillbarOpponentTeam.fillAmount, 0, finalCleaningprogressionOpponent);

            float highestValue = fillbarYourTeam.fillAmount > fillbarOpponentTeam.fillAmount ? fillbarYourTeam.fillAmount : fillbarOpponentTeam.fillAmount;
            float lowestValue  = fillbarYourTeam.fillAmount < fillbarOpponentTeam.fillAmount ? fillbarYourTeam.fillAmount : fillbarOpponentTeam.fillAmount;

            percentageDifference.text = Mathf.RoundToInt((highestValue - lowestValue) * 100).ToString() + '%';

            Debug.Log("Filling the fillamount");

            percentageYourTeam.text     = Mathf.RoundToInt(fillbarYourTeam.fillAmount * 100f).ToString() + '%';
            percentageOpponentTeam.text = Mathf.RoundToInt(fillbarOpponentTeam.fillAmount * 100f).ToString() + '%';

            yield return(new WaitForEndOfFrame());
        }

        yield return(new WaitForSeconds(clips[1].length + 1));

        const string winMessage  = "Congratulations, your team has won!";
        const string loseMessage = "Better luck next time.";
        const string tiedMessage = "How'd you even ti.. i mean good job!";

        result.gameObject.SetActive(true);
        result.text = finalCleaningprogressionOpponent < finalCleaningprogressionYours ? winMessage : finalCleaningprogressionYours == finalCleaningprogressionOpponent ? tiedMessage : loseMessage;

        AudioClip toPlay = finalCleaningprogressionOpponent < finalCleaningprogressionYours ? clips[2] : finalCleaningprogressionOpponent == finalCleaningprogressionYours ? clips[2] : clips[3];

        if (toPlay == clips[2])
        {
            audioSource.PlayOneShot(clips[5]);
        }

        audioSource.PlayOneShot(toPlay);


        yield return(new WaitForSeconds(4));

        menuButton.SetActive(true);
    }