public static IEnumerator PlayIntroMusic() { yield return(new WaitForFixedUpdate()); NumberSpeech.PlayAudio("welcomemus"); NumberSpeech.PlayAudio("welcome"); }
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; }
/// <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)); } }
private void Start() { if (JoyconManager.Instance == null) { SceneManager.LoadSceneAsync("GlobalInit", LoadSceneMode.Single); return; } GameUtils.playState = GameUtils.GamePlayState.ExpMode; GameUtils.ballSpeedPointsEnabled = false; _currBallNumber = -1; CreateBallPosition(); ShuffleArray(); saveExpButton.onClick.AddListener(FinishExp); startExpButton.onClick.AddListener(StartExp); numberSpeech = globalSpeechGameObject.GetComponent <NumberSpeech>(); _audioSources = GetComponents <AudioSource>(); levelUpAudio = _audioSources[14]; BallScript.GameInit = false; playerReady = false; batSound = batObj.GetComponents <AudioSource>()[0]; batSound.mute = true; StartCoroutine(GameUtils.PlayIntroMusic()); newBallOk = true; canPressButton = true; clockTimer = new Timer(100); clockTimer.Elapsed += ClockTimer_Elapsed; globalTimer = new Timer(100); globalTimer.Elapsed += GlobalTimer_Elapsed; globalTimer.Start(); ExperimentLog.Log("Program Started", time: DateTime.Now.ToLongTimeString()); gamePoints = 0; canPressStartButton = true; expState = ExpState.menus; playerLevel = 0; past6Min = false; prevHits = new int[6] { 0, 0, 0, 0, 0, 0 }; SetupChildAudio(); }
/// <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; }
/// <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)); }
/// <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)); } }