AudioPlay currentAudioPlay; // Current AudioPlay public void Start() { currentAudioPlay = FindObjectOfType <AudioPlay> (); // Gets the current AudioPlay bool nothingsPlaying = true; // Nothing is playing intially, so nothingsPlaying is true. currentAudio = currentAudioPlay.getAudio(); // Gets the current AudioSource from the current AudioPlay if (levelToLoad == "Level1") // When in the mainMenu... (where the next scene is level 1) { if (currentAudio.isPlaying) // If the audio is playing, set nothingsPlaying to false. { nothingsPlaying = false; } if (currentAudio.clip.name != "L1 Theme") // If the audio playing isn't the level 1 theme, play the level 1 theme. { currentAudio.clip = currentAudioPlay.level1; currentAudio.Play(); } if (nothingsPlaying) // If no audio is playing, play the audio { currentAudio.Play(); } } }
protected async override void OnNavigatedFrom(NavigationEventArgs e) { if (IsRecognizing) { Cancellation?.Cancel(); await SpeechRec?.StopRecognitionAsync(); } else { Cancellation?.Dispose(); Cancellation = null; } AudioPlay.Stop(); AudioPlay.Source = null; SpeechRec?.Dispose(); SpeechRec = null; SpeechSynth?.Dispose(); SpeechSynth = null; LoadTask = null; StatusText.Visibility = Visibility.Collapsed; ListeningDisplay.Visibility = Visibility.Collapsed; }
private void OnMouseDown() { BGM = GameObject.Find("BGM"); count++; if (count % 2 == 1) { isPlayingMusic = true; GetComponent <SpriteRenderer>().sprite = pause; if (BGM.GetComponent <AudioSource>().clip == null) { AudioPlay.playMusic(0); } else { BGM.GetComponent <AudioSource>().UnPause(); } } else { GetComponent <SpriteRenderer>().sprite = play; BGM.GetComponent <AudioSource>().Pause(); isPlayingMusic = false; } }
public void Initialize(float startTime) { this.startTime = startTime; SetSpeed(); AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["birdFly"]); Destroy(gameObject, persistTime); }
public void BirdGG() { if (!rigid) { rigid = gameObject.AddComponent <Rigidbody2D> (); } birdCol.isTrigger = false; anim.SetTrigger("gg"); cadanCol.enabled = false; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["birdCadan"]); }
AudioSource currentAudio; // The current audio souce. Used the change the current clip. // Use this for initialization void Start() { playerInZone = false; // player begins out of trigger-zone currentAudioPlay = FindObjectOfType <AudioPlay> (); // Find the instance of AudioPlay to use later. // Plays the level 1 music when switching from the win screen to the main menu. This is to allow the music to be in a loop. if (levelToLoad == "Level1") { currentAudio = currentAudioPlay.getAudio(); if (currentAudio.clip.name == "Won") { currentAudio.clip = currentAudioPlay.level1; currentAudio.Play(); } } // Plays the level 2 music when switching from level 1 to level 2. else if (levelToLoad == "Level 2") { currentAudio = currentAudioPlay.audio; if (currentAudio.clip.name == "L1 Theme") { currentAudio.clip = currentAudioPlay.level2; currentAudio.Play(); } } // Plays the level 3 music when switching from level 2 to level 3. else if (levelToLoad == "Level3") { currentAudio = currentAudioPlay.audio; if (currentAudio.clip.name == "ThemeMusicL2" && currentAudio.isPlaying) { currentAudio.clip = currentAudioPlay.level3; currentAudio.Play(); } } // Loads the win music when switching from level 3 to the win screen. else if (levelToLoad == "MainMenu") { currentAudio = currentAudioPlay.audio; if ((currentAudio.clip.name == "ThemeMusicL3" || currentAudio.clip.name == "L3 Boss") && currentAudio.isPlaying) { currentAudio.clip = currentAudioPlay.win; currentAudio.Play(); } else if (currentAudio.clip.name == "L1 Theme" && !currentAudio.isPlaying) { currentAudio.clip = currentAudioPlay.win; currentAudio.Play(); } } }
private void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
public void ResumeGame() { if (isPaused) { score.enabled = false; isPaused = false; pauseUI.SetActive(false); isResuming = true; startResumeRealTime = Time.unscaledTime; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["bigButtonPress"]); } }
// Start is called before the first frame update void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(instance); } else { Destroy(gameObject); } }
void Start() { magicCircle = GetComponent<Transform>(); stock = altarState.altarCount; count = 0; fireStoc = 3; max = 3; fileState = 1; filestateTemp = fileState; se2 = GameObject.Find("SEObject").GetComponent<AudioPlay>(); }
private void OnTriggerEnter2D(Collider2D collision) { if (!isInvinciblePM && collision.CompareTag("Obstacle")) { isDamaged = true; currentHealth -= damage; AudioPlay.PlaySound(GetComponent <AudioSource>(), SoundLibrary.clipDictionary["comboBreak"]); //Debug.Log("Collide with house, cause damage"); //Debug.Log(currentHealth); StartCoroutine(BackFromInvincible(invincibleT)); } }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <mainCharacter>(); audioPlay = GameObject.FindGameObjectWithTag("AudioPlay").GetComponent <AudioPlay>(); text = GameObject.FindGameObjectWithTag("PairUI").GetComponent <Text>(); gameOverUI = GameObject.FindGameObjectWithTag("GameOver"); inGameUI = GameObject.FindGameObjectWithTag("InGame"); Debug.Log(GameObject.FindGameObjectWithTag("FinalText")); finalText = GameObject.FindGameObjectWithTag("FinalText").GetComponent <Text>(); finalText.gameObject.SetActive(false); text.text = textPrefix + numOfPairs; }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
public void PreviousPage() { if (!tutorialActivated) { Debug.Log("Tutorial not opened!"); } if (tutorialActivated) { tutorialPages[currentPageNum - 1].GetComponent <Animator>().SetTrigger("PreviousPage"); currentPageNum--; currentPage = tutorialPages[currentPageNum]; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["nextPagePress"]); } }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { audioSource = this.gameObject.AddComponent <AudioSource>(); main = this; /* * if(instance==null){ * instance = this; * DontDestroyOnLoad(this); * }else if(this!=instance){ * //防止重复创建 * Destroy(this.gameObject); * } */ }
public void PauseGame() { if (!isPaused) { pm.enabled = false; for (int i = 0; i < bg.Length; i++) { bg[i].enabled = false; } isPaused = true; pauseUI.SetActive(true); Time.timeScale = 0f; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["pauseButton"]); } }
// Use this for initialization void Start() { //Locate the player, camera, and health manager. player = FindObjectOfType <PlayerController> (); camera = FindObjectOfType <CameraController> (); healthManager = FindObjectOfType <HealthManager> (); // audio nextLevels = FindObjectOfType <AudioPlay> (); currentAudio = gameObject.GetComponent <AudioSource> (); hitChk4 = false; //Respawn crumble boxes at the beginning crumbleBoxes = GameObject.FindGameObjectsWithTag("CrumbleBox"); }
/// <summary> /// Call this method to increase the current combo by 1. /// </summary> public static void ComboUp() { if (reset) { reset = false; comboNum_Display = 0; } comboNum_Display += 1; currentComboNum += 1; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["comboUp"]); comboUI_static.text = comboNum_Display.ToString() + "\n<size=96>combo</size>"; comboUI_static.enabled = true; anim_UI.SetTrigger("Up"); //to do: play different clips based on current combo Num; }
void Awake() { // If there is no instance of the singleton AudioPlay, create it. if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); audio = FindObjectOfType <AudioSource>(); audio.clip = level1; audio.Play(); // If there is an instance, destroy gameObject. } else { DestroyImmediate(gameObject); } }
void Start() { tr = transform; rb = GetComponent <Rigidbody2D>(); spriteTr = tr.Find("sprite"); sprite = spriteTr.GetComponent <SpriteRenderer>(); hitbox = tr.Find("hitbox").GetComponent <BoxCollider2D>(); anim = spriteTr.GetComponent <Animator>(); arrowTr = tr.Find("arrow"); arrow = arrowTr.GetComponent <SpriteRenderer>(); aud = spriteTr.GetComponent <AudioPlay>(); sprite.enabled = false; dead = false; arrow.enabled = false; UpdateHighness(); }
public void NextPage() { if (!tutorialActivated) { Debug.Log("Tutorial not opened!"); } if (tutorialActivated) { currentPage.GetComponent <Animator>().SetTrigger("NextPage"); //currentPage.SetActive(false); currentPageNum++; tutorialPages[currentPageNum].SetActive(true); currentPage = tutorialPages[currentPageNum]; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["nextPagePress"]); } }
private async void Ellipse_PointerPressed(object sender, PointerRoutedEventArgs e) { lock (SyncRootProvider.SyncRoot) { if (IsRecognizing) { return; } IsRecognizing = true; } AudioPlay.Stop(); StatusText.Visibility = Visibility.Collapsed; ListeningDisplay.Visibility = Visibility.Visible; string RecResult = await WindowsLocalRecognizeAsync(); if (RecResult == null) { IsRecognizing = false; return; } if (RecResult == "Failure") { ListeningDisplay.Visibility = Visibility.Collapsed; StatusText.Visibility = Visibility.Visible; StatusText.Text = "麦克风未检测到声音输入"; } else { ListeningDisplay.Visibility = Visibility.Collapsed; StatusText.Visibility = Visibility.Visible; StatusText.Text = RecResult; } SpeechSynthesisStream stream = await SpeechSynth.SynthesizeTextToStreamAsync(StatusText.Text); AudioPlay.SetSource(stream, stream.ContentType); AudioPlay.Play(); IsRecognizing = false; }
/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { audioSource = this.gameObject.AddComponent <AudioSource>(); AudioPlay.main = this; /* * if(instance==null){ * instance = this; * DontDestroyOnLoad(this); * }else if(this!=instance){ * //防止重复创建 * Destroy(this.gameObject); * } */ // uAudioUI = AppSceneBase.main.objuAudio.GetComponent<uAudioStreamer_UI>(); // uAudioNet = this.gameObject.AddComponent<uAudioStreamer>(); // uAudioNet.sendPlaybackState += new System.Action<uAudio.uAudio_backend.PlayBackState>(uAudioPlayStatus); }
public void CloseTutorial() { tutorialPanel.SetActive(false); tutorialActivated = false; AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["closeButton"]); }
public static void PlaySound(AudioClip clip, AudioPlay prefab) { AudioPlay o = Instantiate(prefab); o.GetComponent<AudioSource>().PlayOneShot(clip); }
//public float waitBetweenLevels; // time waiting at between levels scene // Use this for initialization void Start() { playerInZone = false; // player begins out of trigger-zone //AudioBegin = PlayerPrefs.GetInt("AudioBegin", 0); currentAudioPlay = FindObjectOfType <AudioPlay> (); /*nextLevels = FindObjectsOfType<AudioPlay> (); * * for (var i = 0; i < nextLevels.Length; i++) { * audioList.Add (nextLevels [i]); * } * * Debug.Log ("The next level is: " + levelToLoad); * for (var i = 0; i < audioList.Count; i++) { * try { * Debug.Log (i + " " + audioList [i] + " name of clip: " + audioList [i].audio.clip.name + " is playing: " + audioList [i].audio.isPlaying); * } * catch { * } * }*/ if (levelToLoad == "Level1") { currentAudio = currentAudioPlay.getAudio(); // Debug.Log (currentAudio.name + " " + currentAudio.clip.name + " " + currentAudio.isPlaying); if (currentAudio.clip.name == "Won") { // Debug.Log ("The current audio is: " + currentAudio.clip.name); currentAudio.clip = currentAudioPlay.level1; currentAudio.Play(); } } else if (levelToLoad == "Level 2") { currentAudio = currentAudioPlay.audio; if (currentAudio.clip.name == "L1 Theme") { // Debug.Log ("The current audio is: " + currentAudio.clip.name); currentAudio.clip = currentAudioPlay.level2; currentAudio.Play(); } } else if (levelToLoad == "Level3") { currentAudio = currentAudioPlay.audio; if (currentAudio.clip.name == "ThemeMusicL2" && currentAudio.isPlaying) { // Debug.Log ("The current audio is: " + currentAudio.clip.name); currentAudio.clip = currentAudioPlay.level3; currentAudio.Play(); } } else if (levelToLoad == "MainMenu") { currentAudio = currentAudioPlay.audio; // Debug.Log (currentAudio.clip.name + " " + currentAudio.isPlaying); // Debug.Log ("Current audio name" + currentAudio.clip.name + " is it playing? " + currentAudio.isPlaying); if ((currentAudio.clip.name == "ThemeMusicL3" || currentAudio.clip.name == "L3 Boss") && currentAudio.isPlaying) { // Debug.Log ("The current audio is: " + currentAudio.clip.name); currentAudio.clip = currentAudioPlay.win; currentAudio.Play(); } else if (currentAudio.clip.name == "L1 Theme" && !currentAudio.isPlaying) { currentAudio.clip = currentAudioPlay.win; currentAudio.Play(); } } }
void Awake() { Instance = this; }
public void PlayGOSFX() { AudioPlay.PlaySound(audioSource, SoundLibrary.clipDictionary["countDownGo"]); }
void Start () { SE = GameObject.Find("AudioObject").GetComponent<AudioPlay>(); }
void Start() { SE = GameObject.Find("AudioObject").GetComponent<AudioPlay>(); fireNumStock = fireNum; }
public void ButtonUp() { Debug.Log("123"); anim.SetBool("ButtonDown", false); AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["bigButtonPress"]); }