Exemple #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        var laser = collider.gameObject.GetComponent <Projectile>();

        if (laser != null)
        {
            if (this.ImpactSound != null)
            {
                AudioClipHelper.PlayClipAt(this.ImpactSound, this.transform.position, this.ImpactSoundVolume);
            }
            laser.Hit();
            this.Health -= laser.GetDamage();
            if (this.Health <= 0)
            {
                var music = FindObjectOfType <Music>();
                if (music != null)
                {
                    music.Stop();
                }
                foreach (var system in FindObjectsOfType <ParticleSystem>())
                {
                    if (system.startSpeed > 1)
                    {
                        system.Stop();
                        system.Clear();
                    }
                }
                FindObjectOfType <EnemySpawner>().Stop();
                this.Invoke("Destroy", this.KillDelay);
            }
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D collider2D)
    {
        var laser = collider2D.gameObject.GetComponent <Projectile>();

        if (laser)
        {
            if (this.ImpactSound != null)
            {
                AudioClipHelper.PlayClipAt(this.ImpactSound, this.transform.position, this.ImpactSoundVolume);
            }
            laser.Hit();
            this.Health -= laser.GetDamage();
            if (this.Health <= 0)
            {
                var scoreKeeper = FindObjectOfType <ScoreKeeper>();
                if (scoreKeeper != null)
                {
                    scoreKeeper.IncrementScore(this.KillPoints);
                }
                if (this.KillSound != null)
                {
                    AudioClipHelper.PlayClipAt(this.KillSound, this.transform.position, this.KillSoundVolume);
                }
                Destroy(this.gameObject);
            }
        }
    }
Exemple #3
0
    void Destroy()
    {
        if (this.KillSound != null)
        {
            AudioClipHelper.PlayClipAt(this.KillSound, this.transform.position, this.KillSoundVolume);
        }
        var levelManager = FindObjectOfType <LevelManager>();

        levelManager.LoadLevel("Game Over", this.GameOverDelay);
        Destroy(this.gameObject);
    }
Exemple #4
0
    IEnumerator Timer()
    {
        while (true)
        {
            yield return(new WaitForSeconds(inteval));

            Microphone.End(null);
//            print(_clipRecord.length);
            updateClips();
            AudioClip currentClip = AudioClipHelper.Combine((AudioClip[])_audioClips.ToArray(typeof(AudioClip)));
//            AudioClip currentClip = AudioClipHelper.Combine(_audioClips);
//            AudioClip currentClip = (AudioClip) _audioClips[0];
            var data = Asr.ConvertAudioClipToPCM16(currentClip);
            StartCoroutine(_asr.Recognize(data, s =>
            {
                String text = s.result != null && s.result.Length > 0 ? s.result[0] : "未识别到声音";
                Debug.Log(DateTime.Now + ":" + text);
            }));
        }
    }
    static AudioManager()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        _sources = new List <AudioSource>();


        _audioMixer = Resources.Load("MasterMixer") as AudioMixer;

        _effectGroup    = _audioMixer.FindMatchingGroups("Effect")[0];
        _interfaceGroup = _audioMixer.FindMatchingGroups("Interface")[0];
        _musicGroup     = _audioMixer.FindMatchingGroups("Music")[0];
        _stingerGroup   = _audioMixer.FindMatchingGroups("Stinger")[0];

        _audioMixer.SetFloat("masterVolume", PlayerPrefs.GetFloat("masterVolume", 1));
        _audioMixer.SetFloat("musicVolume", PlayerPrefs.GetFloat("musicVolume", 0));
        _audioMixer.SetFloat("effectVolume", PlayerPrefs.GetFloat("effectsVolume", 0));
        _audioMixer.SetFloat("interfaceVolume", PlayerPrefs.GetFloat("interfaceVolume", 0));



        _audioPlayer = GameObject.Find("AudioPlayer");
        if (_audioPlayer == null)
        {
            _audioPlayer      = Object.Instantiate(Resources.Load("AudioPlayer") as GameObject);
            _audioPlayer.name = "AudioPlayer";
            Clips             = _audioPlayer.GetComponent <AudioClipHelper>();
            _audioPlayer.GetComponent <MusicManager>().OnSceneLoaded(SceneManager.GetActiveScene(), LoadSceneMode.Single);
        }
        else
        {
            Clips = _audioPlayer.GetComponent <AudioClipHelper>();
        }
    }