コード例 #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}");
     }
 }
コード例 #2
0
ファイル: SoundEvent.cs プロジェクト: taku689/TimeTraveler
        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();
        }
コード例 #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);
         }
     }
 }
コード例 #4
0
ファイル: SoundObject.cs プロジェクト: taku689/TimeTraveler
        public void Play(SoundEventModel soundEventModel)
        {
            this.audioSource.loop = soundEventModel.isLoop;

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

            StartCoroutine("Fadein", soundEventModel);
        }
コード例 #5
0
ファイル: SoundObject.cs プロジェクト: taku689/TimeTraveler
        public void Stop(SoundEventModel soundEventModel)
        {
            if (!this.IsPlaying())
            {
                return;
            }

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

            StartCoroutine("Fadeout", soundEventModel);
        }
コード例 #6
0
ファイル: SoundObject.cs プロジェクト: taku689/TimeTraveler
        // フェードイン
        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));
            }
        }
コード例 #7
0
ファイル: SoundEvent.cs プロジェクト: taku689/TimeTraveler
        // イベントによる操作
        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;
            }
        }
コード例 #8
0
 // 停止
 public void Stop(SoundEventModel soundEventModel)
 {
     this.soundObject[soundEventModel.soundId].Stop(soundEventModel);
 }
コード例 #9
0
 // 再生(なんでも)
 public void Play(SoundEventModel soundEventModel)
 {
     this.soundObject[soundEventModel.soundId].Play(soundEventModel);
 }
コード例 #10
0
 // 一時停止
 public void Pause(SoundEventModel soundEventModel)
 {
     this.soundObject[soundEventModel.soundId].Pause(soundEventModel);
 }
コード例 #11
0
ファイル: SoundObject.cs プロジェクト: taku689/TimeTraveler
 public void Pause(SoundEventModel soundEventModel)
 {
     this.audioSource.Pause();
 }