示例#1
0
        private void UpgradeButtonClick()
        {
            if (m_dynamicParameter.IsMaxLevel)
            {
                return;
            }

            if (IsAdUpgrade)
            {
                string parameterName = m_dynamicParameter.ParameterType.ToFriendlyName();

                BuyService buyService = new AdBuyService(string.Format(StringConstants.Formats.AdUpgradeParameterFormat, parameterName));
                buyService.TryToBuy(0, () =>
                {
                    m_upgradesCount = 0;
                    m_dynamicParameter.Upgrade();
                });
            }
            else
            {
                BuyService buyService = new RespectBuyService();
                buyService.TryToBuy((int)m_dynamicParameter.Price, () =>
                {
                    m_upgradesCount++;
                    m_dynamicParameter.Upgrade();
                });
            }

            AudioClipData audioClipData = ConfigManager.Instance.Get <AudioConfig>().UpgradeParameterAudioClipData;

            AudioManager.Instance.PlaySoundFx(audioClipData);
        }
示例#2
0
    public AudioChannelData PlayBGM(string _strName)
    {
        _strName = _strName.ToLower();
        //Debug.LogError ( _strName );

        AudioChannelData channelData = m_tAudioChannnelDataList [(int)AUDIO_TYPE.BGM] [0];

        //Debug.Log ("channelData:"+channelData);
        //Debug.Log ("channelData:"+channelData.m_strFilename);
        if (channelData.m_strFilename != null && channelData.m_strFilename.ToLower().Equals(_strName.ToLower()) == true)
        {
            return(channelData);
        }

        channelData.m_strFilename = _strName;
        channelData.m_bLoop       = true;
        AudioClipData playData = new AudioClipData();

        if (false == IsAudioClipData(_strName, AUDIO_TYPE.BGM, ref playData))
        {
            m_csSoundPlayerSupport.PlaySound(channelData);
            return(channelData);
        }
        PlaySound(channelData);
        return(channelData);
    }
示例#3
0
    // サウンドを鳴らす
    AudioChannelData playSound(AUDIO_TYPE _eAudioType, string _strName, bool _bLoop = false)
    {
        _strName = _strName.ToLower();

        bool             bHit = false;
        AudioChannelData data = new AudioChannelData();

        bHit = getEnableChannnel(_eAudioType, ref data);

        if (bHit == true)
        {
            data.m_strFilename = _strName;
            data.m_bLoop       = _bLoop;
            data.m_eStatus     = AudioChannelData.STATUS.REQUEST;
        }
        else
        {
            Debug.LogError("no hit");
            return(data);
        }

        AudioClipData audioClipData = new AudioClipData();

        if (false == IsAudioClipData(_strName, _eAudioType, ref audioClipData))
        {
            //Debug.LogError ( "audio_type=" +_eAudioType + " " + "playSound:" + _strName);
            return(m_csSoundPlayerSupport.PlaySound(data));
        }

        //Debug.Log ("audio_type:" + _eAudioType + " playSound:" + data.m_strFilename);

        data.Play(audioClipData);
        return(data);
    }
示例#4
0
    public static AudioClip CreateAudioClipFromData(AudioClipData clipData)
    {
        AudioClip audio = AudioClip.Create(clipData.name, clipData.lengthSamples, clipData.channels, clipData.frequency, clipData.stream);

        audio.SetData(clipData.data, clipData.offsetSamples);
        return(audio);
    }
示例#5
0
    /// <summary>
    /// 背景音乐渐入
    /// </summary>
    /// <param name="clipName"></param>
    /// <param name="fadeTime"></param>
    public void SetBgmFadeIn(AudioClipData data, float fadeTime)
    {
        if (data.AudioRes == CurrentBgm)
        {
            return;
        }

        if (data == null)
        {
            SetBgmFadeOut(fadeTime);
            return;
        }

        SetBgm(data);

        if (BgmSource.clip != null)
        {
            if (_volumeTween != null)
            {
                _volumeTween.Kill();
            }

            BgmSource.volume = 0;
            _volumeTween     = DOTween.To(() => BgmSource.volume, x => BgmSource.volume = x, _bgmVolume * data.Volume, fadeTime).OnComplete(() =>
            {
                _volumeTween = null;
            });
        }
    }
示例#6
0
        /// <summary>
        /// Compute the spectral flux data for beat analysis
        /// </summary>
        /// <param name="bmc">BeatmapContainer of the song to analyze</param>
        /// <param name="clipData">AudioClipData of the song to analyze</param>
        /// <returns>The SpectralFluxData of the analyzed song</returns>
        public static SpectralFluxData AnalyzeAudio(BeatmapContainer bmc, AudioClipData clipData)
        {
            if (!new DirectoryInfo(Application.streamingAssetsPath + "/SpectrumData/").Exists)
            {
                Directory.CreateDirectory(Application.streamingAssetsPath + "/SpectrumData/");
            }

            SpectralFluxData spectralFluxData;

            if (new FileInfo(Application.streamingAssetsPath + "/SpectrumData/" + bmc.sourceFile + ".json").Exists)
            {
                StreamReader reader = new StreamReader(Application.streamingAssetsPath + "/SpectrumData/" + bmc.sourceFile + ".json");
                spectralFluxData = JsonConvert.DeserializeObject <SpectralFluxData>(reader.ReadToEnd());
                reader.Close();
            }
            else
            {
                BeatAnalyzer analyzer = new BeatAnalyzer(clipData);
                spectralFluxData = analyzer.GetFullSpectrum();
                analyzer         = null;

                StreamWriter writer = new StreamWriter(Application.streamingAssetsPath + "/SpectrumData/" + bmc.sourceFile + ".json");
                writer.Write(JsonConvert.SerializeObject(spectralFluxData));
                writer.Close();
            }

            return(spectralFluxData);
        }
示例#7
0
        public void PlayBackgroundAudio(AudioClipData audioClipData)
        {
            m_backgroundAudioSource.clip   = audioClipData.Clip;
            m_backgroundAudioSource.volume = audioClipData.Volume;

            m_backgroundAudioSource.Play();
        }
示例#8
0
        private void OnBackButtonClick()
        {
            if (DynamicParametersManager.Instance.Get(DynamicParameterType.ArtistsCount).Level <= 1)
            {
                return;
            }

            SetBackButtonActive(false);

            AudioClipData audioClipData = ConfigManager.Instance.Get <AudioConfig>().OpenPopupAudioClipData;

            AudioManager.Instance.PlaySoundFx(audioClipData);

            LoadingScreen loadingScreen = ScreensManager.Instance.GetScreen <LoadingScreen>();

            loadingScreen.Initialize(SceneType.Main);
            loadingScreen.Show();

            IUserProfileModel userProfileModel = ServiceLocator.Instance.Get <IUserProfileModel>();

            if (userProfileModel.TutorialStage == (int)TutorialType.ReturnToCity)
            {
                TutorialPopup tutorialPopup = PopupManager.Instance.GetPopup <TutorialPopup>();
                tutorialPopup.Hide();

                userProfileModel.TutorialStage++;
            }
        }
    public static void PlaySound(this MonoBehaviour sfxSource, AudioClips clip,
                                 SoundType type = SoundType.Default, Vector3?location = null)
    {
        AudioClipData cd = AudioDatabase[clip];

        PlaySound(sfxSource, cd?.Clip, type == SoundType.Default?cd?.SoundType ?? type:type, location);
    }
示例#10
0
 void PlayClip(AudioClipData newClip)
 {
     audioSource.pitch = newClip.pitch;
     audioSource.loop  = newClip.toLoop;
     audioSource.clip  = newClip.audioClip;
     audioSource.Play();
     audioBacklog.Remove(newClip);
 }
示例#11
0
 public void PlayAmbient(AudioClipData clipData)
 {
     _ambientClipData = clipData;
     _ambientSource.clip = clipData.Clip;
     _ambientSource.volume = clipData.Volume;
     _ambientSource.loop = clipData.IsStaticLooped;
     _ambientSource.Play();
 }
示例#12
0
 public void PlayBGM(AudioClipData clipData)
 {
     _bgmClipData = clipData;
     _bgmSource.clip = clipData.Clip;
     _bgmSource.volume = clipData.Volume;
     _bgmSource.loop = clipData.IsStaticLooped;
     _bgmSource.Play();
 }
示例#13
0
    public void PlayBGM(string soundName)
    {
        AudioClipData clipData = BGMData.Find(soundName);

        audioSource.volume = clipData.volume;
        audioSource.clip   = clipData.clip;
        audioSource.Play();
    }
示例#14
0
    public static byte[] GetWav(AudioClipData clipData, out uint length, WavModificationOptions options)
    {
        var data = ConvertAndWrite(clipData.samples, out length, out var samples, options);

        WriteHeader(data, clipData.frequency, clipData.channels, length, samples);

        return(data);
    }
示例#15
0
    public void UpdateTrackUI(AudioClipData Track)
    {
        StopCoroutine(AnimateText());

        PlayTrack(Track);

        SetUI();
    }
示例#16
0
    void PlayTrack(AudioClipData Track)
    {
        isPaused = false;

        ActiveTrack      = Track;
        audioSource.clip = Track.FullTrack;
        audioSource.Play();
    }
    public static AudioClipData Create()
    {
        AudioClipData asset = ScriptableObject.CreateInstance <AudioClipData>();

        AssetDatabase.CreateAsset(asset, "Assets/Scriptable Objects/New Audio Clip Data.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
 public virtual void PlayOneShot(AudioClipData data)
 {
     SetupAudioSource(data);
     if (_audioSource != null) {
         _audioSource.pitch = Random.Range(data.lowPitchRange, data.highPitchRange);
         _audioSource.PlayOneShot(data.audioClip, data.volume);
     }
 }
示例#19
0
    public AudioChannelData(AUDIO_TYPE _eAudioType, AudioSource _tAudioSource)
    {
        m_tAudioClipData = new AudioClipData();

        m_eStatus      = STATUS.IDLE;
        m_tAudioSource = _tAudioSource;
        m_eAudioType   = _eAudioType;
    }
示例#20
0
        protected override void OnClaimButtonClick()
        {
            PopupManager.Instance.HideCurrentPopup();
            AudioClipData audioClipData = ConfigManager.Instance.Get <AudioConfig>().CollectIncomeAudioClipData;

            AudioManager.Instance.PlaySoundFx(audioClipData);

            ServiceLocator.Instance.Get <IncomeService>().GiveIncomeFor(IncomeType.Offline);
        }
 public virtual void PlayOneShot(AudioClipData data)
 {
     SetupAudioSource(data);
     if (_audioSource != null)
     {
         _audioSource.pitch = Random.Range(data.lowPitchRange, data.highPitchRange);
         _audioSource.PlayOneShot(data.audioClip, data.volume);
     }
 }
示例#22
0
 public void Play(AudioClipData _clipData)
 {
     //Debug.Log ("sound play!!!!");
     m_tAudioSource.clip = _clipData.m_AudioClip;
     m_tAudioSource.loop = m_bLoop;
     m_eStatus           = STATUS.PLAYING;
     m_tAudioSource.Play();
     return;
 }
示例#23
0
        public void SetLockedUIActive(bool isActive)
        {
            if (isActive)
            {
                AudioClipData audioClipData = ConfigManager.Instance.Get <AudioConfig>().OpenPopupAudioClipData;
                AudioManager.Instance.PlaySoundFx(audioClipData);
            }

            m_lockedUI.SetActive(isActive);
        }
示例#24
0
        public void Initialize()
        {
            IUserProfileModel userProfileModel = ServiceLocator.Instance.Get <IUserProfileModel>();

            string        cityNumber    = userProfileModel.CurrentCity;
            AudioClipData audioClipData = ConfigManager.Instance.Get <CityConfig>().GetCityData(cityNumber).AudioClipData;

            AudioManager.Instance.PlayBackgroundAudio(audioClipData);

            userProfileModel.CurrentCityProgress.enterTime = DateTime.Now;
        }
示例#25
0
        private void OnClaimX2ButtonClick()
        {
            AdManager.Instance.ShowRewarded("offline_x2", () =>
            {
                PopupManager.Instance.HideCurrentPopup();
                AudioClipData audioClipData = ConfigManager.Instance.Get <AudioConfig>().CollectIncomeAudioClipData;
                AudioManager.Instance.PlaySoundFx(audioClipData);

                ServiceLocator.Instance.Get <IncomeService>().GiveIncomeFor(IncomeType.Offline, 2f);
            }, null);
        }
示例#26
0
    public float PlaySound(AudioClipData data, AudioGroupType group, Action <float> OnFinishTime = null)
    {
        if (data == null || string.IsNullOrEmpty(data.AudioRes))
        {
            return(0);
        }
        var clip = Resources.Load <AudioClip>(data.AudioRes);

        PlaySound(clip, null, AudioListenerNode.position, false, data.Volume, group, OnFinishTime);
        return(clip.length);
    }
示例#27
0
 public void ReplaceNext(AudioClip newClip, bool toLoop = false, float pitch = 1.0f)
 {
     if (hasBacklog && audioBacklog.Count > 0)
     {
         AudioClipData clip = new AudioClipData(newClip, toLoop, pitch);
         audioBacklog[0] = clip;
     }
     else
     {
         PlayOnSchedule(newClip, toLoop, pitch);
     }
 }
    private void LoadBeatmap()
    {
        string path = BeatmapLoader.SelectBeatmapFile();

        if (path != null)
        {
            BeatmapContainer bmc = BeatmapLoader.LoadBeatmapFile(path);
            AudioClipData    cd  = BeatmapLoader.LoadBeatmapAudio(bmc);
            audioPlayer.clip = BeatmapLoader.CreateAudioClipFromData(cd);
            bm = bmc.bm;
        }
    }
示例#29
0
    public static void Save(string filename, AudioClip clip, WavModificationOptions optionsParam = null)
    {
        AudioClipData data = new AudioClipData();

        data.samples = new float[clip.samples * clip.channels];
        clip.GetData(data.samples, 0);

        data.frequency = (uint)clip.frequency;
        data.channels  = (ushort)clip.channels;

        Save(filename, data, optionsParam);
    }
示例#30
0
        public void PlaySoundFx(AudioClipData audioClipData)
        {
            if (m_soundFxAudioSource.isPlaying && !m_audioConfig.IsStopPlayingImmideately)
            {
                return;
            }

            m_soundFxAudioSource.clip   = audioClipData.Clip;
            m_soundFxAudioSource.volume = audioClipData.Volume;

            m_soundFxAudioSource.Play();
        }
示例#31
0
        public static void BuildSpritesData(string folderPath)
        {
            string folderName     = PathHelper.FullAssetPath2Name(folderPath);
            string spriteDataPath = folderPath + "/" + folderName + "AudioClipData.asset";

            string workPath  = EditorUtils.AssetsPath2ABSPath(folderPath);
            var    filePaths = Directory.GetFiles(workPath);

            AudioClipData data = null;

            data = AssetDatabase.LoadAssetAtPath <AudioClipData>(spriteDataPath);

            bool needCreate = false;

            if (data == null)
            {
                data       = ScriptableObject.CreateInstance <AudioClipData>();
                needCreate = true;
            }

            data.ClearAllData();

            for (int i = 0; i < filePaths.Length; ++i)
            {
                string relPath            = EditorUtils.ABSPath2AssetsPath(filePaths[i]);
                UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath(relPath);

                if (objs != null)
                {
                    for (int j = 0; j < objs.Length; ++j)
                    {
                        Log.i(objs[j].GetType().Name);

                        if (objs[j] is AudioClip)
                        {
                            data.AddAudioClip(objs[j] as AudioClip);
                        }
                    }
                }
            }

            data.SortAsFileName();

            if (needCreate && !data.isEmpty)
            {
                AssetDatabase.CreateAsset(data, spriteDataPath);
            }

            EditorUtility.SetDirty(data);
            AssetDatabase.SaveAssets();
            Log.i("Success Process AudioClip Import:" + folderPath);
        }
    public void SetupAudioSource(AudioClipData data)
    {
        if (data == null)
            return;

        isSetup = true;

        if (data.audioClip != null) {
            _audioSource = GetComponent<AudioSource>() != null ? GetComponent<AudioSource>() : gameObject.AddComponent<AudioSource>();
            _audioSource.clip = data.audioClip;
            _audioSource.volume = data.volume;
            _audioSource.spatialBlend = data.spatialBlend;
        }
    }
示例#33
0
 IEnumerator PlayOneShotAfterSecCo(AudioClipData data, float seconds)
 {
     yield return new WaitForSeconds(seconds);
     PlayOneShot(data);
 }
示例#34
0
	/// <summary>
	/// Queries the database for Words and returns the list
	/// </summary>
	/// <returns></returns>
	public List<Word> QueryDatabaseForWords ( string ContainingID )
	{
		//Create query for __to__ table and pull the associated ID's
		DataTable WordIDTable = db.ExecuteQuery( "SELECT * FROM VocabularyItem WHERE ActivityID = '" + ContainingID + "'" );

		//List to hold the Associated ID's
		List<string> WordID = new List<string>();
		foreach ( DataRow row in WordIDTable.Rows )
		{
			//Gather the ID's of each Word from the associated Vocab
			WordID.Add( ( string ) row [ "WordId" ] );
		}

		//List to hold the Words
		List<Word> values = new List<Word>();

		//For each lessonID in the list, pull the associated Lesson and add it to the list
		foreach ( string ID in WordID )
		{
			//Create the query command and generate a reader for the output
			DataTable WordTable = db.ExecuteQuery( "SELECT * FROM Word WHERE ID = '" + ID + "'" );

			//reader.Read() sets the reader to read the next row of fields.
			//The first call sets for the first row
			foreach ( DataRow row in WordTable.Rows )
			{
				//Start by taking the name and blob from the database
				AudioClipData NewClip = new AudioClipData()
				{
					Name = ( string ) row [ "Name" ]
				};
				//Create the nessessary information
				NewClip.Compile( ( byte [] ) row [ "Sound" ] );

				//Create the sound clip from the given data
				AudioClip clip = AudioClip.Create(
					NewClip.Name,
					NewClip.length,
					NewClip.Channels,
					NewClip.Frequency,
					NewClip.Sound3D,
					NewClip.Stream
					);
				clip.SetData( NewClip.AudioSamples, 0 );

				//reader can be referanced by the fields names.
				//by doing so you will have to cast the returned "object"
				values.Add( new Word()
				{
					ID = ( string ) row [ "Id" ],
					name = ( string ) row [ "Name" ],
					description = ( string ) row [ "Description" ],
					sound = clip,
					soundVolume = 1f,
					original = ( byte [] ) row [ "Sound" ]
				} );
			}
		}


		return values;
	}
示例#35
0
 /// <summary>
 /// Set one of the ambient tracks.  valid values for idx are 0 or 1, AudioClipData can be set to null to stop playing a clip
 /// </summary>
 public void SetAmbientTrack(int idx, AudioClipData data, float targetVolume)
 {
     ambientTracks[idx] = data;
     ambientVolume[idx] = targetVolume;
 }