Ejemplo n.º 1
0
 static void ReceiveSoundEvent(string serializedSoundEvent)
 {
     try
     {
         SoundEventModel SoundEvent = Helpers.MsgPack.Deserialize <SoundEventModel>(serializedSoundEvent);
         if (SoundEvent.SoundName == "STOP" && SirenSoundIds.ContainsKey(SoundEvent.SourceServerId) && SirenSoundIds[SoundEvent.SourceServerId] != -1)
         {
             Function.Call(Hash.STOP_SOUND, SirenSoundIds[SoundEvent.SourceServerId]);
             Function.Call(Hash.RELEASE_SOUND_ID, SirenSoundIds[SoundEvent.SourceServerId]);
             SirenSoundIds[SoundEvent.SourceServerId] = -1;
         }
         else
         {
             if (SirenSoundIds.ContainsKey(SoundEvent.SourceServerId) && SirenSoundIds[SoundEvent.SourceServerId] != -1)
             {
                 Function.Call(Hash.STOP_SOUND, SirenSoundIds[SoundEvent.SourceServerId]);
                 Function.Call(Hash.RELEASE_SOUND_ID, SirenSoundIds[SoundEvent.SourceServerId]);
             }
             SirenSoundIds[SoundEvent.SourceServerId] = Function.Call <int>(Hash.GET_SOUND_ID);
             Function.Call(Hash.PLAY_SOUND_FROM_ENTITY, SirenSoundIds[SoundEvent.SourceServerId], SoundEvent.SoundName, new PlayerList()[SoundEvent.SourceServerId].Character.CurrentVehicle.Handle, 0, 0, 0);
         }
     }
     catch (Exception ex)
     {
         Log.Error($"Siren event error: {ex.Message}");
     }
 }
Ejemplo n.º 2
0
        override public void Launch(OnFinishEvent callBack, DataManager dataManager, EventModel eventManagerModel, GameManager gameManager)
        {
            base.Launch(callBack, dataManager, eventManagerModel, gameManager);
            SoundEventModel SoundEventModel = this.dataManager.soundEventModel.getModelById(eventManagerModel.eventChildId);

            this.Sound(SoundEventModel);
            this.callBack();
        }
Ejemplo n.º 3
0
 // 全BGM停止
 public void StopAllBGM(SoundEventModel soundEventModel)
 {
     foreach (KeyValuePair <int, SoundObject> pair in this.soundObject)
     {
         if (SoundType.BGM == this.GetSoundType(pair.Key))
         {
             pair.Value.Stop(soundEventModel);
         }
     }
 }
Ejemplo n.º 4
0
        public void Play(SoundEventModel soundEventModel)
        {
            this.audioSource.loop = soundEventModel.isLoop;

            // FadeTimeが設定されていない場合すぐに再生
            if (soundEventModel.fadeTime == 0)
            {
                this.audioSource.Play();
                return;
            }

            StartCoroutine("Fadein", soundEventModel);
        }
Ejemplo n.º 5
0
        public void Stop(SoundEventModel soundEventModel)
        {
            if (!this.IsPlaying())
            {
                return;
            }

            // FadeTimeが設定されていない場合すぐに停止
            if (soundEventModel.fadeTime == 0)
            {
                this.audioSource.Stop();
                return;
            }

            StartCoroutine("Fadeout", soundEventModel);
        }
Ejemplo n.º 6
0
        // フェードイン
        IEnumerator Fadein(SoundEventModel soundEventModel)
        {
            float currentTime = 0.0f;
            float waitTime    = DETECTION_TIME;
            float originalVol = audioSource.volume;

            // msecに修正
            float duration = (float)(soundEventModel.fadeTime / 1000.0f);

            audioSource.volume = 0.0f;
            audioSource.Play();

            while (duration > currentTime)
            {
                currentTime       += Time.deltaTime;
                audioSource.volume = Mathf.Clamp01(originalVol * currentTime / duration);
                yield return(new WaitForSeconds(waitTime));
            }
        }
Ejemplo n.º 7
0
        // イベントによる操作
        private void Sound(SoundEventModel soundEventModel)
        {
            switch (soundEventModel.operationType)
            {
            case (int)OperationType.PLAY:
                this.soundManager.Play(soundEventModel);
                break;

            case (int)OperationType.STOP:
                this.soundManager.Stop(soundEventModel);
                break;

            case (int)OperationType.PAUSE:
                this.soundManager.Pause(soundEventModel);
                break;

            case (int)OperationType.STOP_ALLBGM:
                this.soundManager.StopAllBGM(soundEventModel);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 8
0
 // 停止
 public void Stop(SoundEventModel soundEventModel)
 {
     this.soundObject[soundEventModel.soundId].Stop(soundEventModel);
 }
Ejemplo n.º 9
0
 // 再生(なんでも)
 public void Play(SoundEventModel soundEventModel)
 {
     this.soundObject[soundEventModel.soundId].Play(soundEventModel);
 }
Ejemplo n.º 10
0
 // 一時停止
 public void Pause(SoundEventModel soundEventModel)
 {
     this.soundObject[soundEventModel.soundId].Pause(soundEventModel);
 }
Ejemplo n.º 11
0
 public void Pause(SoundEventModel soundEventModel)
 {
     this.audioSource.Pause();
 }