사운드 매니져 - 사운드 패키지별로 관리 가능 ( 폴더명이 패키지 키 값이다 ) , 사운드 폴더별로 관리 필요 - 오디오소스 버퍼는 5개만 이용 ( 다음 업글시에 캐싱기능 추가 할생각 ) - 오디오클립 관리가 현재 모든 패키지를 하나로 처리됨 ( 다음 업글시에 패키지별로 관리 하도록 기능 향상 시킬 생각 )
Inheritance: Singleton
    public void SetSound(AudioClip newSound, SOUND type)
    {
        switch (type)
        {
        case SOUND.FOOTSTEP:
            footstep = newSound;
            break;

        case SOUND.ATTACK:
            attack = newSound;
            break;

        case SOUND.DAMAGED:
            damaged = newSound;
            break;

        case SOUND.DEATH:
            death = newSound;
            break;

        case SOUND.ATTACKHIT:
            attackHit = newSound;
            break;

        case SOUND.AMBIENT:
            ambient.Add(newSound);
            break;

        case SOUND.BLOCKED:
            blocked = newSound;
            break;
        }
    }
示例#2
0
    public void PlayEffSound(SOUND idx, float volume = 1f, bool loop = false, bool overlap = true)
    {
        if (!overlap)
        {
            if (checkOverLap(idx))
            {
                return;
            }
        }

        for (int i = 0; i < effSource.Length; ++i)
        {
            if (loop == false)
            {
                if (!effSource[i].isPlaying)
                {
                    effSource[i].clip   = _soundDictionary[idx];
                    effSource[i].volume = volume;
                    effSource[i].Play();
                    return;
                }
            }
            else
            {
                if (!effSource[i].isPlaying && effSource[i].loop)
                {
                    effSource[i].clip   = _soundDictionary[idx];
                    effSource[i].volume = volume;
                    effSource[i].Play();
                    return;
                }
            }
        }
    }
示例#3
0
 public void PlayBGMSound(SOUND idx, float volume = 1f)
 {
     bgmSource.clip   = _soundDictionary[idx];
     bgmSource.volume = volume;
     bgmSource.loop   = true;
     bgmSource.Play();
 }
示例#4
0
    public void PlaySoundEffect(SOUND sound)
    {
        bool isPlay = true;

        switch(sound)
        {
            case SOUND.AHA:
                chosenAudio = aha;
                break;
            case SOUND.COMBO:
                chosenAudio = combo;
                break;
            case SOUND.WRONG:
                chosenAudio = wrong;
                break;
            case SOUND.CUBECLICK:
                chosenAudio = cubeClick;
                break;
            default:
                isPlay = false;
                break;

        }

        if(isPlay)
        {
            audioSource.PlayOneShot(chosenAudio, 1);
        }
    }
    ///////////////////////////////////
    ///// Collision Section       /////
    ///////////////////////////////////
    ///
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.GetComponent <StockSave>() != null)
        {
            basket.OnStockCollision(collision.gameObject.GetComponent <StockSave>(), _playerIndex);
        }
        if (collision.gameObject.name.Contains("apple") && !basket.IsFull() && !collision.gameObject.GetComponent <Projectile>())
        {
            basket.OnAppleCollision(collision.gameObject);
        }
        if (collision.gameObject.name.Contains("Tree") && _dashing)
        {
            collision.gameObject.GetComponent <TreeApplesGrow>().DropApples();
        }

        if (_dashing && collision.gameObject.tag == "Obstacle")
        {
            Bump(collision.contacts[0].point, true);
            SOUND.HitTree();
        }
        else if (_dashing && collision.gameObject.tag == "Player")
        {
            BumpOtherPlayer(collision.gameObject, collision.contacts[0].point);
            Bump(collision.contacts[0].point, false);
        }
    }
    private IEnumerator BumpByPlayerCoroutine(Vector3 direction)
    {
        float   startTime       = Time.time;
        float   currentTime     = 0f;
        Vector3 startPosition   = transform.position;
        Vector3 desiredPosition = startPosition + Vector3.Normalize(direction) * _bumpOnTargetForce;

        SwitchToHitSprite(_bumpDuration);
        while (currentTime < _stunOnTargetDuration)
        {
            if (currentTime < _bumpDuration)
            {
                float fracComplete = (Time.time - startTime) / _bumpDuration;
                _rigidbody.position = Vector3.Lerp(transform.position, desiredPosition, fracComplete);
            }
            else
            {
                _animator.enabled = true;
            }

            currentTime += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }
        _animator.enabled = true;
        _bumped           = false;
        SOUND.Stun();
    }
示例#7
0
 // Start is called before the first frame update
 void Start()
 {
     SOUND.StartAmbiance();
     _players = FindObjectsOfType <PlayerController>();
     _seconds = 0;
     InvokeRepeating("AddSecond", 1f, 1f);
     _nextMeteorite = delayMeteorite + Random.Range(-1 * varTimeMeteorite, varTimeMeteorite);
 }
示例#8
0
    public void AddApple(GameObject apple, int playerIndex)
    {
        SOUND.WinPoint();
        playerScore[playerIndex] += 1;

        GameObject.Find("P" + playerIndex).GetComponent <CharacterUI>().textScore.text = "x" + playerScore[playerIndex];
        Destroy(apple);
    }
示例#9
0
 public void PlayAudio_Sound(SOUND _clip)
 {
     AudioSource_Sound.clip = AudioClips_Sound[(int)_clip];
     if (AudioSource_Sound.clip != null && AudioSource_Sound.enabled == true)
     {
         AudioSource_Sound.Play();
     }
 }
示例#10
0
    public void AddApple(GameObject apple)
    {
        _apples.Push(apple);
        SOUND.Grab();

        apple.transform.position = _appleAnchors[_apples.Count - 1].transform.position;
        apple.transform.parent   = _appleAnchors[_apples.Count - 1].transform;
    }
示例#11
0
    //================================================================================================================//

    public void PlaySoundEffect(SOUND effect, float volumeScale = 1f)
    {
        var index = (int)effect;

        var pitchRange = _effectProfiles[index].pitchRange;

        masterMixer.SetFloat("EffectPitch", Random.Range(pitchRange.x, pitchRange.y));
        effectsSource.PlayOneShot(effects[index], volumeScale);
    }
    public void PlaySound(SOUND type)
    {
        switch (type)
        {
        case SOUND.FOOTSTEP:
            audioManager.instance.PlaySound(
                footstep,
                sourceID
                );
            break;

        case SOUND.ATTACK:
            audioManager.instance.PlaySound(
                attack,
                sourceID
                );
            break;

        case SOUND.DAMAGED:
            audioManager.instance.PlaySound(
                damaged,
                sourceID
                );
            break;

        case SOUND.DEATH:
            audioManager.instance.PlaySound(
                death,
                sourceID
                );
            break;

        case SOUND.ATTACKHIT:
            audioManager.instance.PlaySound(
                attackHit,
                sourceID
                );
            break;

        case SOUND.AMBIENT:
            audioManager.instance.PlaySound(
                ambient[Random.Range(0, ambient.Count - 1)],
                sourceID
                );
            break;

        case SOUND.BLOCKED:
            audioManager.instance.PlaySound(
                blocked,
                sourceID
                );
            break;
        }
    }
    public void SetSoundIntoSource(SOUND type)
    {
        switch (type)
        {
        case SOUND.FOOTSTEP:
            audioManager.instance.SetSoundIntoSource(
                footstep,
                SOUND.FOOTSTEP
                );
            break;

        case SOUND.ATTACK:
            audioManager.instance.SetSoundIntoSource(
                attack,
                SOUND.ATTACK
                );
            break;

        case SOUND.DAMAGED:
            audioManager.instance.SetSoundIntoSource(
                damaged,
                SOUND.DAMAGED
                );
            break;

        case SOUND.DEATH:
            audioManager.instance.SetSoundIntoSource(
                death,
                SOUND.DEATH
                );
            break;

        case SOUND.ATTACKHIT:
            audioManager.instance.SetSoundIntoSource(
                attackHit,
                SOUND.ATTACKHIT
                );
            break;

        case SOUND.BLOCKED:
            audioManager.instance.SetSoundIntoSource(
                blocked,
                SOUND.BLOCKED
                );
            break;

        case SOUND.AMBIENT:
            audioManager.instance.SetSoundIntoSource(
                ambient[Random.Range(0, ambient.Count - 1)],
                SOUND.AMBIENT
                );
            break;
        }
    }
示例#14
0
 public void PlayEffSound(SOUND idx)
 {
     for (int i = 0; i < effSource.Length; ++i)
     {
         if (!effSource[i].isPlaying)
         {
             effSource[i].clip = _soundDictionary[idx];
             effSource[i].Play();
         }
     }
 }
示例#15
0
 // Start is called before the first frame update
 void Start()
 {
     Debug.Log("PlayerManger");
     SOUND.StartMusic();
     for (int i = 0; i < 4; ++i)
     {
         playerIsSet.Add(i, false);
         playerIsReleaseStick.Add(i, true);
         playerIsReady.Add(i, false);
     }
 }
示例#16
0
 private bool checkOverLap(SOUND idx)
 {
     for (int i = 0; i < effSource.Length; ++i)
     {
         if (effSource[i].isPlaying && effSource[i].clip.Equals(_soundDictionary[idx]))
         {
             return(true);
         }
     }
     return(false);
 }
示例#17
0
 public void OffEffSound(SOUND idx)
 {
     for (int i = 0; i < effSource.Length; ++i)
     {
         if (effSource[i].isPlaying && effSource[i].clip == _soundDictionary[idx])
         {
             effSource[i].Stop();
             return;
         }
     }
 }
示例#18
0
    ///////////////////////////////////
    ///// Dash boost Section      /////
    ///////////////////////////////////
    public void Dash()
    {
        if (_dashing || _currentDashJauge < _dashCost)
        {
            return;
        }

        SOUND.Dash();
        _dashing           = true;
        _currentDashJauge -= _dashCost;
        Invoke("ResetDash", _dashDuration);
    }
示例#19
0
 public void Play(SOUND sound)
 {
     switch (sound)
     {
         case SOUND.Falling:
             SFXSource.clip = Falling[(int)Random.Range(0f, Falling.Length - 0.00001f)];
             SFXSource.Play();
             break;
         case SOUND.Pain:
             SFXSource.clip = Pain[(int)Random.Range(0f, Pain.Length - 0.00001f)];
             SFXSource.Play();
             break;
         case SOUND.Conga:
             SFXSource.clip = Conga;
             SFXSource.Play();
             break;
         case SOUND.Landing:
             SFXSource.clip = Landing[(int)Random.Range(0f, Landing.Length - 0.00001f)];
             SFXSource.Play();
             break;
         case SOUND.Meow:
             // Meow should only play occasionally
             if(Random.value<0.3)
             {
                 SFXSource.clip = Meow[(int)Random.Range(0f, Meow.Length - 0.00001f)];
                 SFXSource.Play();
             }
             break;
         case SOUND.Snarl:
             SFXSource.clip = Snarl;
             SFXSource.Play();
             break;
         case SOUND.Step:
             if (Random.value < 0.5)
             {
                 FootStepSource.clip = Step[(int)Random.Range(0f, Step.Length - 0.00001f)];
                 FootStepSource.Play();
             }
             break;
         case SOUND.Vine:
             SFXSource.clip = Vine[(int)Random.Range(0f, Vine.Length - 0.00001f)];
             SFXSource.Play();
             break;
         case SOUND.WoodClick:
             SFXSource.clip = WoodClick;
             SFXSource.Play();
             break;
         case SOUND.WoodToggle:
             SFXSource.clip = WoodToggle;
             SFXSource.Play();
             break;
     }
 }
示例#20
0
    public void playSound(SOUND sound)
    {
        switch (sound)
        {
        case SOUND.ERROR:
            source.PlayOneShot(errorClip, sfxVolume);
            break;

        case SOUND.TURN_READY:
            source.PlayOneShot(turnReadyClip, sfxVolume);
            break;
        }
    }
示例#21
0
    // AudioClipを取得する
    // soundKeyに対して複数のAudioClipが存在する場合、ランダムで1つ取得する
    private AudioClip getAudio(SOUND soundKey)
    {
        if (!audioClips.ContainsKey(soundKey))
        {
            return(null);
        }
        List <AudioClip> sounds = audioClips [soundKey];

        int selectedIndex = Mathf.FloorToInt(Random.Range(0, sounds.Count - 1));

        //Debug.Log ("soundKey : " + soundKey  + " / selectedIndex : " + selectedIndex +" / maxIndex : " + sounds.Count);
        return(sounds[selectedIndex]);
    }
示例#22
0
    // ループ無し再生(SE)
    public void play(SOUND soundName)
    {
        AudioClip audioClip = getAudio(soundName);

        if (audioClip == null)
        {
            return;
        }

        initializeAudioSource();

        m_SeAudioSource.PlayOneShot(audioClip);
    }
示例#23
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject);
    }
示例#24
0
    // ループあり再生(BGM)
    public void playBgm(SOUND soundName)
    {
        AudioClip audioClip = getAudio(soundName);

        if (audioClip == null)
        {
            return;
        }

        initializeAudioSource();

        m_BgmAudioSource.clip = audioClip;
        m_BgmAudioSource.Play();
    }
示例#25
0
 public void Shoot()
 {
     _shooting = false;
     if (_projectile != null)
     {
         Destroy(_sight);
         _projectile.GetComponent <Rigidbody>().isKinematic = false;
         _projectile.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
         _projectile.GetComponent <Rigidbody>().AddForce((Vector3.Normalize(transform.forward) + new Vector3(0, 0.1f, 0)) * 1000);
         _projectile.transform.parent = null;
         StartCoroutine(DisableProjectileTrigger(_projectile));
         _projectile = null;
         SOUND.ThrowApple();
     }
 }
示例#26
0
        public static ResponseBase CreateOrUpdate(SOUND soundObj)
        {
            var result = new ResponseBase();
            var flag   = true;

            try
            {
                var db = new PMSEntities();
                if (soundObj.Id == 0)
                {
                    db.SOUNDs.Add(soundObj);
                }
                else
                {
                    var sound = db.SOUNDs.FirstOrDefault(x => !x.IsDeleted && x.Id == soundObj.Id);
                    if (sound != null)
                    {
                        sound.Code        = soundObj.Code;
                        sound.Name        = soundObj.Name;
                        sound.IsActive    = soundObj.IsActive;
                        sound.Path        = soundObj.Path;
                        sound.Description = soundObj.Description;
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Messages.Add(new Message()
                        {
                            Title = "Thông Báo", msg = "Không tìm thấy thông tin tệp bạn đang thao tác."
                        });
                    }
                }
                if (flag)
                {
                    db.SaveChanges();
                    result.IsSuccess = true;
                    result.Messages.Add(new Message()
                    {
                        Title = "Thông Báo", msg = "Lưu thành công."
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
示例#27
0
    void playSound(SOUND sound)
    {
        Sound s = Array.Find <Sound>(sounds, (ss) => { return(ss.name == sound); });

        audioSource.clip = s.clip;
        audioSource.loop = s.oneShot ? false : true;

        audioSource.Play();

        if (s.name == SOUND.typing)
        {
            if (!(typing = !typing))
            {
                audioSource.Stop();
            }
        }
    }
示例#28
0
    public void PlayBGM(SOUND sound)
    {
        if (m_CurPlayBGM == sound)
        {
            return;
        }

        if (m_AudioSource.isPlaying)
        {
            m_AudioSource.Stop();
        }

        m_CurPlayBGM       = sound;
        m_AudioSource.clip = m_mAudio[sound];
        m_AudioSource.Play();
        m_AudioSource.loop = true;
    }
示例#29
0
    public static void PlaySound(SOUND currentSound)
    {
        if (currentSound == SOUND.ButtonClick)
        {
            instance.GetComponent <AudioSource>().PlayOneShot(instance.SoundDie);
        }

        if (currentSound == SOUND.die)
        {
            instance.GetComponent <AudioSource>().PlayOneShot(instance.SoundDie);
            instance.Invoke("PlaySoundDie", 0.8f);
        }
        if (currentSound == SOUND.Scored)
        {
            instance.GetComponent <AudioSource>().PlayOneShot(instance.SoundScored);
        }
    }
示例#30
0
 private SOUND GetSoundData()
 {
     try
     {
         var sound = new SOUND();
         sound.Id          = soundId;
         sound.Code        = txtCode.Text;
         sound.Name        = txtName.Text;
         sound.Description = txtDescription.Text;
         sound.Path        = txtPath.Text;
         sound.IsActive    = chkIsActive.Checked;
         return(sound);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#31
0
    // AudioClipsを追加する。重複判定しないので注意
    private void addAudio(SOUND soundKey, string filePath)
    {
        List <AudioClip> sounds;

        if (!audioClips.ContainsKey(soundKey))
        {
            sounds = new List <AudioClip> ();
            audioClips.Add(soundKey, sounds);
        }
        else
        {
            sounds = audioClips [soundKey];
        }

        //Debug.Log ("sounds : " + sounds.Count);
        sounds.Add((AudioClip)Resources.Load(filePath));

        //audioClips.Add (soundKey, (AudioClip)Resources.Load (filePath));
    }
示例#32
0
    protected override bool Init()
    {
        m_mAudio = new Dictionary <SOUND, AudioClip>();
        AudioClip[] arry = Resources.LoadAll <AudioClip>("03Sound");

        if (m_AudioSource == null)
        {
            m_AudioSource = gameObject.AddComponent <AudioSource>();
        }

        for (SOUND i = SOUND.BGM_MAIN; i <= (SOUND)arry.Length; i++)
        {
            m_mAudio.Add(i, arry[(int)i - 1]);
        }



        return(true);
    }