Exemplo n.º 1
0
	void BeforePlay()
	{
		float time = GetProceedTime();
		
		if( time > m_Timing)
		{
			switch( m_ActionSound.LoopType)
			{
			case eLoopType.Once:
				m_Sound = AsSoundManager.Instance.PlaySound( m_ActionSound.FileName, m_EntityTrn.position, false);
				break;
			case eLoopType.Once_Cycle:
				if(m_Sound == null)
				{
					m_Sound = AsSoundManager.Instance.PlaySound( m_ActionSound.FileName, m_EntityTrn.position, false);
					if(m_Sound != null)
						GameObject.Destroy( m_Sound.GetComponent<AsSoundObject>());
//					else
//						Debug.LogError("SoundProcessor::BeforePlay: '" + m_ActionSound.FileName + "' is not found");
				}
				else
				{
					m_Sound.Play();
				}
				break;
			case eLoopType.Loop:
				m_Sound = AsSoundManager.Instance.PlaySound( m_ActionSound.FileName, m_EntityTrn.position, true);
				break;
			}
			
			m_State = eSoundState.After_Play;
		}
	}
Exemplo n.º 2
0
        public static void AddTargetForClip(string clipName, AudioSource source) {
            if (!AudioResourceTargetsByName.ContainsKey(clipName)) {
                AudioResourceTargetsByName.Add(clipName, new List<AudioSource> {
                    source
                });
            } else {
                var sources = AudioResourceTargetsByName[clipName];

                // populate the audio clip even if it was loaded previous by another
                AudioClip populatedClip = null;
                // ReSharper disable once ForCanBeConvertedToForeach
                for (var i = 0; i < sources.Count; i++) {
                    var clip = sources[i].clip;

                    if (clip == null) {
                        continue;
                    }

                    populatedClip = clip;
                    break;
                }

                if (populatedClip != null) {
                    source.clip = populatedClip;
                    var aVar = source.GetComponent<SoundGroupVariation>();

                    if (aVar != null) {
                        aVar.internetFileLoadStatus = MasterAudio.InternetFileLoadStatus.Loaded;
                    }
                }

                sources.Add(source);
            }
        }
Exemplo n.º 3
0
  public void init() {
    // Calculate number of samples between each beat.
    OnDisable();
    audioSource = GetComponent<AudioSource>();
    float audioBpm = audioSource.GetComponent<BeatSynchronizer>().bpm;
    //Debug.Log("BPM: " + audioBpm);
    beatPeriod = (60f / (audioBpm * BeatDecimalValues.values[(int)beatValue]));
    samplePeriod = beatPeriod * audioSource.clip.frequency;

    //RhythmManager.rm.setPeriod((60f / (audioBpm * BeatDecimalValues.values[(int)beatValue])));

    if (beatOffset != BeatValue.None) {
      sampleOffset = (60f / (audioBpm * BeatDecimalValues.values[(int)beatOffset])) * audioSource.clip.frequency;
      if (negativeBeatOffset) {
        sampleOffset = samplePeriod - sampleOffset;
      }
    }

    samplePeriod *= beatScalar;
    sampleOffset *= beatScalar;
    nextBeatSample = 0f;
    lastSamplePeriod = samplePeriod;
    OnEnable();
  }
Exemplo n.º 4
0
    void Start()
    {
        Screen.orientation = ScreenOrientation.Portrait;
        scrollingTexture = GameObject.Find ("Plane").GetComponent<ScrollingTexture> ();
        anim = GameObject.Find ("MainMenuCanvas").GetComponentInChildren<Animator> ();
        sushianimators = GameObject.Find ("Sushis").GetComponentsInChildren<Animator> ();

        laughingManager = GameObject.Find("LaughingManager").GetComponent<AudioSource>();
        audioPlayScript = audioManager.GetComponent<AudioPlayScript> ();
        laughingPlayScript = laughingManager.GetComponent <LaughingPlayScript> ();
        Invoke ("PlayHelloSound", 0.5f);
    }
Exemplo n.º 5
0
	public static void DuckSoundGroup(string soundGroupName, AudioSource aSource) {
        var ma = MasterAudio.Instance;

        if (!ma.EnableMusicDucking || !ma.duckingBySoundType.ContainsKey(soundGroupName)) {
            return;
        }

        var matchingDuck = ma.duckingBySoundType[soundGroupName];
		
        // duck music
        var duckLength = aSource.GetComponent<AudioSource>().clip.length;
        var duckPitch = aSource.pitch;

        var pcs = PlaylistController.Instances;
        for (var i = 0; i < pcs.Count; i++)
        {
            pcs[i].DuckMusicForTime(duckLength, duckPitch, matchingDuck.riseVolStart);
        }

        if (pcs.Count == 0) 
        {
            Debug.LogWarning("Playlist Controller is not in the Scene. Cannot duck music.");
        }
	}
Exemplo n.º 6
0
 protected void StopLoop(AudioSource source)
 {
     if (fadeDuration > 0)
     {
         LeanTween.value(source.gameObject,_audioSource.Value.volume,0,fadeDuration
         ).setOnUpdate(
             (float updateVolume)=>{
             source.volume = updateVolume;
         }
         ).setOnComplete(
             ()=>{
             
             source.GetComponent<AudioSource>().Stop();
             if (waitUntilFinished)
             {
                 Continue();
             }
         }
         );
     }
     else
     {
         source.GetComponent<AudioSource>().Stop();
     }
 }
Exemplo n.º 7
0
 public static void FadeOut(this AudioSource a, float duration)
 {
     a.GetComponent <MonoBehaviour>().StartCoroutine(FadeOutCore(a, duration));
 }
Exemplo n.º 8
0
 public static void FadeInCallback(this AudioSource a, float duration, System.Action <AudioSource> callback = null)
 {
     a.GetComponent <MonoBehaviour>().StartCoroutine(FadeInCall(a, duration, callback));
 }
Exemplo n.º 9
0
 public static void FadeIn(this AudioSource audio, float duration)
 {
     audio.GetComponent <MonoBehaviour>().StartCoroutine(FadeInCore(audio, duration));
 }