Пример #1
0
    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();
            }
        }
    }
Пример #2
0
        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;
        }
Пример #3
0
    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;
        }
    }
Пример #4
0
 public void Initialize(float startTime)
 {
     this.startTime = startTime;
     SetSpeed();
     AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["birdFly"]);
     Destroy(gameObject, persistTime);
 }
Пример #5
0
 public void BirdGG()
 {
     if (!rigid)
     {
         rigid = gameObject.AddComponent <Rigidbody2D> ();
     }
     birdCol.isTrigger = false;
     anim.SetTrigger("gg");
     cadanCol.enabled = false;
     AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["birdCadan"]);
 }
Пример #6
0
    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();
            }
        }
    }
Пример #7
0
 private void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Пример #8
0
 public void ResumeGame()
 {
     if (isPaused)
     {
         score.enabled = false;
         isPaused      = false;
         pauseUI.SetActive(false);
         isResuming          = true;
         startResumeRealTime = Time.unscaledTime;
         AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["bigButtonPress"]);
     }
 }
Пример #9
0
    // Start is called before the first frame update

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(instance);
        }
        else
        {
            Destroy(gameObject);
        }
    }
Пример #10
0
	void Start() {
		magicCircle = GetComponent<Transform>();
		stock = altarState.altarCount;
		count = 0;
		fireStoc = 3;
		max = 3;
		fileState = 1;
		filestateTemp = fileState;
   
        se2 = GameObject.Find("SEObject").GetComponent<AudioPlay>();

    }
Пример #11
0
 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));
     }
 }
Пример #12
0
    // 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;
    }
Пример #13
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Пример #14
0
    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"]);
        }
    }
Пример #15
0
    /// <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);
         *      }
         */
    }
Пример #16
0
 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"]);
     }
 }
Пример #17
0
    // 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");
    }
Пример #18
0
    /// <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;
    }
Пример #19
0
 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);
     }
 }
Пример #20
0
    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();
    }
Пример #21
0
    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"]);
        }
    }
Пример #22
0
        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;
        }
Пример #23
0
    /// <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);
    }
Пример #24
0
 public void CloseTutorial()
 {
     tutorialPanel.SetActive(false);
     tutorialActivated = false;
     AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["closeButton"]);
 }
Пример #25
0
 public static void PlaySound(AudioClip clip, AudioPlay prefab)
 {
     AudioPlay o = Instantiate(prefab);
     o.GetComponent<AudioSource>().PlayOneShot(clip);
 }
Пример #26
0
    //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();
            }
        }
    }
Пример #27
0
 void Awake()
 {
     Instance = this;
 }
Пример #28
0
 public void PlayGOSFX()
 {
     AudioPlay.PlaySound(audioSource, SoundLibrary.clipDictionary["countDownGo"]);
 }
Пример #29
0
	void Start () {
        SE = GameObject.Find("AudioObject").GetComponent<AudioPlay>();
    }
Пример #30
0
	void Start() {
        SE = GameObject.Find("AudioObject").GetComponent<AudioPlay>();
		fireNumStock = fireNum;
	}
Пример #31
0
 public void ButtonUp()
 {
     Debug.Log("123");
     anim.SetBool("ButtonDown", false);
     AudioPlay.PlaySound(aus, SoundLibrary.clipDictionary["bigButtonPress"]);
 }