Example #1
0
 void Update()
 {
     if (isMutedAudio == 1)
     {
         musicControl.volume      = 0;
         AudioButton.image.sprite = AudioOff;
     }
     else
     {
         musicControl.volume      = 1;
         AudioButton.image.sprite = AudioOn;
     }
     if (isMutedSFX == 1)
     {
         SFXControl.volume      = 0;
         SFXButton.image.sprite = SFXOff;
     }
     else
     {
         SFXControl.volume      = 1;
         SFXButton.image.sprite = SFXOn;
     }
     if (!ballData.GetIsDead())
     {
         Time.timeScale = 1;
         scoreText.text = ballData.GetScore().ToString();
         if (Input.GetMouseButtonDown(0))
         {
             SFXControl.PlayOneShot(kick);
             Vector3 inputPos = Input.mousePosition;
             if (inputPos.x >= Screen.width / 2f)
             {
                 Throw(rbRight, -throwForce);
                 Throw(rbRightReflect, -throwForce);
             }
             if (inputPos.x < Screen.width / 2f)
             {
                 Throw(rbLeft, throwForce);
                 Throw(rbLeftReflect, throwForce);
             }
         }
         if (ballData.GetIsHooped())
         {
             hoopColl.enabled = false;
         }
         else
         {
             hoopColl.enabled = true;
         }
     }
     else
     {
         if (ballData.GetScore() > bestScore)
         {
             bestScore = ballData.GetScore();
             PlayerPrefs.SetInt("Best", bestScore);
         }
         scoreFinalText.text = "SCORE:" + ballData.GetScore();
         bestScoreText.text  = "BEST: " + bestScore;
         scoreText.enabled   = false;
         StaticButtons.SetActive(true);
         ball.SetActive(false);
         hoop.SetActive(false);
         Retry.SetActive(true);
         musicControl.volume = 0;
         Time.timeScale      = 0;
     }
 }