Esempio n. 1
0
    public static IEnumerator PlayIntroMusic()
    {
        yield return(new WaitForFixedUpdate());

        NumberSpeech.PlayAudio("welcomemus");
        NumberSpeech.PlayAudio("welcome");
    }
Esempio n. 2
0
    private IEnumerator PauseForBallSetAudio(Vector3 ballPos)
    {
        rb.velocity = new Vector3(0, 0, 0);
        rb.position = ballPos;
        AudioSource setAudioSource = NumberSpeech.PlayAudio("readygo");

        yield return(new WaitForSeconds(setAudioSource.clip.length - 0.5f)); //Give 1 second to move the bat way bc of jitters

        GameUtils.playState = GameUtils.GamePlayState.InPlay;                //Maybe remove this
        aiSettingBall       = false;
        rb.isKinematic      = false;
    }
Esempio n. 3
0
 /// <summary>
 /// Reads out whose serve it is
 /// </summary>
 /// <returns></returns>
 private static IEnumerator PlayServeSound()
 {
     if (GameUtils.PlayerServe)
     {
         AudioSource t = NumberSpeech.PlayAudio("yourserve");
         yield return(new WaitForSeconds(t.clip.length - 0.7f));
     }
     else
     {
         AudioSource t = NumberSpeech.PlayAudio("oppserve");
         yield return(new WaitForSeconds(t.clip.length - 0.7f));
     }
 }
Esempio n. 4
0
    /// <summary>
    /// Audio for next ball and calls spawnBall to start a new ball
    /// </summary>
    /// <returns></returns>
    private IEnumerator NextBallComing()
    {
        if ((UnityEngine.Random.Range(0, 3) == 0 && _currBallNumber != -1 && gamePoints != 1) ||
            _currBallNumber == 29)        //Randomly 1/3 of the time say how many points
        {
            ExperimentLog.Log("Read the Score");
            StartCoroutine(numberSpeech.PlayExpPointsAudio(gamePoints));
            yield return(new WaitForSeconds(4.5f)); //Wait 4.5 seconds for points audio to finish
        }
        else if (!IsAnnounceBall)
        {
            AudioSource aud = NumberSpeech.PlayAudio("nextball");
            yield return(new WaitForSeconds(aud.clip.length + 0.2f));
        }

        yield return(SpawnBall());

        timerStarted = true;
        oldTime      = Time.time;
        newBallOk    = true;
    }
Esempio n. 5
0
    /// <summary>
    /// Reads the first serve of the game
    /// </summary>
    /// <returns></returns>
    private IEnumerator ReadInitServe()
    {
        AudioSource serveAudio = NumberSpeech.PlayAudio(GameUtils.PlayerServe ? "yourserve" : "oppserve");

        yield return(new WaitForSeconds(serveAudio.clip.length));
    }
Esempio n. 6
0
    /// <summary>
    /// Static method that reads the score of the current game. Note it is ugly because you can't
    /// static Coroutines in static methods.
    /// </summary>
    /// <returns></returns>
    public static IEnumerator ReadScore()
    {
        var ball = GameObject.FindGameObjectWithTag("Ball");

        ball.transform.position = new Vector3(0, 5, 0);
        ball.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);

        if (PlayerScore <= 12 && OpponentScore <= 12)
        {
            //Read the score normal
            theScoreIsAudio.Play();
            yield return(new WaitForSeconds(theScoreIsAudio.clip.length));

            AudioSource audioScore = null;
            if (PlayerScore <= 12)
            {
                audioScore = NumberSpeech.PlayAudio(PlayerScore.ToString());
            }
            yield return(new WaitForSeconds(audioScore.clip.length));

            toScoreAudio.Play();
            yield return(new WaitForSeconds(toScoreAudio.clip.length));

            AudioSource oppoScore = null;
            if (OpponentScore <= 12)
            {
                oppoScore = NumberSpeech.PlayAudio(OpponentScore.ToString());
            }
            yield return(new WaitForSeconds(oppoScore.clip.length));
        }
        else if (PlayerScore >= 10 && OpponentScore >= 10)
        {
            //Must win by two
            if (PlayerScore == OpponentScore)
            {
                //Tied
                tiedAudio.Play();
                yield return(new WaitForSeconds(tiedAudio.clip.length));
            }
            else if (PlayerScore > OpponentScore)
            {
                //Player Up1
                playerUpAudio.Play();
                yield return(new WaitForSeconds(playerUpAudio.clip.length));
            }
            else if (OpponentScore > PlayerScore)
            {
                opponentUpAudio.Play();
                yield return(new WaitForSeconds(opponentUpAudio.clip.length));
            }
        }
        if ((PlayerScore >= 11 && OpponentScore < 10) ||
            ((PlayerScore >= 10 && OpponentScore >= 10) && (PlayerScore > OpponentScore + 1)))
        {
            gameOver = true;
            playerWins.Play();
            yield return(new WaitForSeconds(playerWins.clip.length));

            Instance.ResetGame();
            yield break;
        }
        else if ((OpponentScore >= 11 && PlayerScore < 10) ||
                 ((OpponentScore >= 10 && PlayerScore >= 10) && (OpponentScore > PlayerScore + 1)))
        {
            gameOver = true;
            opponentWins.Play();
            yield return(new WaitForSeconds(opponentWins.clip.length));

            Instance.ResetGame();
            yield break;
        }
        if (GameUtils.PlayerServe)
        {
            AudioSource t = NumberSpeech.PlayAudio("yourserve");
            yield return(new WaitForSeconds(t.clip.length - 0.7f));
        }
        else
        {
            AudioSource t = NumberSpeech.PlayAudio("oppserve");
            yield return(new WaitForSeconds(t.clip.length - 0.7f));
        }
    }