Ejemplo n.º 1
0
    public static AudioCue PlaySound(AudioClip clip, Transform followTransform, AudioCue.CueSettings settings)
    {
        AudioCue cue = PlaySound(clip, followTransform.position, settings);

        cue.transform.parent = followTransform;
        return(cue);
    }
Ejemplo n.º 2
0
    public static AudioCue GetActiveCue()
    {
        AudioCue cue = GetInactiveCue();

        cue.SetActive();
        return(cue);
    }
Ejemplo n.º 3
0
    public void Start( )
    {
        _baseColor      = tileImage.color;
        tileImage.color = gameboardColor.value;

        if (constantValue == -1)
        {
            _value          = 0;
            tileImage.color = _baseColor;
            tileText.text   = "";
        }
        else if (constantValue == 0)
        {
            _value = Random.Range(sharedMinTileValue.value, sharedMaxTileValue.value);
        }
        else
        {
            _value = constantValue;
        }

        if (constantValue != -1)
        {
            tileText.SetText(_value.ToString( ));
        }

        _positiveAudioCue = Resources.Load <AudioCue>("Audio/Positive");
    }
Ejemplo n.º 4
0
 public void PlayCue(AudioCue cue)
 {
     if (cue.clips.Length > 0)
     {
         AudioClip clip = cue.clips[random.Next(cue.clips.Length)];
         source.PlayOneShot(clip);
     }
 }
Ejemplo n.º 5
0
 public void SetMusic(AudioCue cue)
 {
     if (currentCue != cue)
     {
         currentCue = cue;
         currentCue.Play(audioSource);
     }
 }
Ejemplo n.º 6
0
    internal static AudioCue CreateAudioCueFactoryAtPath(string path)
    {
        AudioCue asset = ScriptableObject.CreateInstance <AudioCue>();

        asset.name = Path.GetFileName(path);
        AssetDatabase.CreateAsset(asset, path);
        return(asset);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Stops the specified sound
    /// </summary>
    /// <param name="handle">The Handle of the sound to stop.</param>
    public void StopSound(AudioHandle handle)
    {
        AudioCue cue = m_cuePool.GetItem(handle);

        if (null != cue)
        {
            cue.m_cue.Stop(AudioStopOptions.AsAuthored);
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Sets a user-defined variable for the sound
    /// </summary>
    /// <param name="handle">handle to the sound to set</param>
    /// <param name="varName">name of the variable to set</param>
    /// <param name="value">value of the variable to set</param>
    public void SetVariable(AudioHandle handle, string varName, float value)
    {
        AudioCue cue = m_cuePool.GetItem(handle);

        if (null != cue)
        {
            cue.m_cue.SetVariable(varName, value);
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Updates a 3D sound with its latest emitter data
    /// </summary>
    /// <param name="handle">A handle to the sound being played</param>
    /// <param name="emitter">The emitter that contains the position and velocity data</param>
    public void UpdateSound3D(AudioHandle handle, AudioEmitter emitter)
    {
        AudioCue cue = m_cuePool.GetItem(handle);

        if (null != cue)
        {
            cue.m_cue.Apply3D(m_listener, emitter);
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Check whether or not the specified sound is currently playing.
    /// </summary>
    /// <param name="handle">The Handle of the sound to stop.</param>
    /// <returns>true if the sound is currently playing</returns>
    public bool IsPlaying(AudioHandle handle)
    {
        AudioCue cue = m_cuePool.GetItem(handle);

        if (null != cue)
        {
            return(cue.m_cue.IsPlaying);
        }
        return(false);
    }
Ejemplo n.º 11
0
    public void PlayCueAsset(AudioCue cue)
    {
        if (!DisableCues && CueSources.Length > cue.CueSourceIndex && CueSources[cue.CueSourceIndex] != null)
        {
            CueSources[cue.CueSourceIndex].Stop();
            CueSources[cue.CueSourceIndex].PlayOneShot(cue.Clip);

            Get <SubtitleManager>().PlaySubtitles(cue.Subtitles);
        }
    }
Ejemplo n.º 12
0
    private void OnCollisionEnter(Collision collision)
    {
        if (canKnock == false)
        {
            return;
        }

        Rigidbody rb = collision.gameObject.GetComponent <Rigidbody>();

        if (rb != null)
        {
            Debug.Log("Bounce pad is colliding with player");
            Vector3 knockBack = collision.GetContact(0).normal *knockBackForce;
            Debug.DrawLine(transform.position, transform.position + knockBack);

            if (audioPlayer == null)
            {
                audioPlayer = GetComponent <AudioCue>();
            }

            if (audioPlayer != null)
            {
                audioPlayer.PlayAudioCue();
            }



            Transform child = transform.GetChild(0);
            if (child != null)
            {
                child.DOPunchScale(child.localScale * scaleModifier, scaleDuration, 4, 1).SetEase(Ease.OutElastic);
            }

            rippleFX.Play();

            rb.AddForce(knockBack, ForceMode.Impulse);
            canKnock = false;
            StartCoroutine(CoolDown());
        }

        if (collision.gameObject.CompareTag("Player"))
        {
            if (impulse == null)
            {
                impulse = GetComponent <CinemachineImpulseSource>();
            }

            if (impulse != null)
            {
                impulse.GenerateImpulse(knockBackForce / 10);
                Debug.Log("Generating Impulse");
            }
        }
    }
Ejemplo n.º 13
0
    public static AudioCue PlaySound(AudioClip clip, Vector3 location, AudioCue.CueSettings settings)
    {
        AudioCue cue = AudioCue.GetActiveCue();

        cue.transform.position = location;
        cue.Settings           = settings;
        cue.SetClip(clip);
        cue.Play();

        return(cue);
    }
Ejemplo n.º 14
0
        public void AssembleAnimation(UnitStateType state, UnitAsset asset)
        {
            m_asset         = asset;
            m_state         = state;
            m_pool          = m_asset.ObjectPoolAsset();
            m_deathFX       = m_asset.DeathFX();
            m_collisionFX   = m_asset.CollisionFX();
            m_camShakeEvent = m_asset.CamShakeEvent();
            m_motorSFX      = m_asset.MotorSFX();

            m_mesh = m_asset.AddMeshToUnit(transform);
        }
Ejemplo n.º 15
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="audioCue"></param>
    /// <returns></returns>
    public int RegisterAudioCue(AudioCue audioCue)
    {
        for (int i = 0; i < audioCues.Count; i++)
        {
            if (string.Equals(audioCue.name, audioCues[i].name))
            {
                return(i);
            }
        }

        audioCues.Add(audioCue);

        return(audioCues.Count - 1);
    }
Ejemplo n.º 16
0
 private void InitializeAudioCues()
 {
     AudioCue[] audioCues = GetComponents <AudioCue>();
     foreach (AudioCue audioCue in audioCues)
     {
         if (audioCue.Name == "Input Audio")
         {
             InputAudio = audioCue;
         }
         else if (audioCue.Name == "Output Audio")
         {
             OutputAudio = audioCue;
         }
     }
 }
Ejemplo n.º 17
0
    private void Start()
    {
        audioCue     = GetComponent <AudioCue>();
        CollisionMap = new Dictionary <Material, CollisionData>();

        foreach (CollisionData data in ImpactSounds)
        {
            if (data.mat == null)
            {
                continue;
            }

            CollisionMap.Add(data.mat, data);
        }
    }
Ejemplo n.º 18
0
        /// <summary>
        /// Called each frame while this tile is selected (highlighted in UI).
        /// </summary>
        private void WhileHighlit()
        {
            if (previewLength > 0.0f)
            {
                previewSeconds += Time.WallClockFrameSeconds;
                if (previewSeconds > previewLength)
                {
                    OnUnHighlight();
                }
            }
            AudioCue cue = BokuGame.Audio.Play(upid, null, cues);

            if (cue != null)
            {
                cue.OnComplete += OnAudioCueComplete;
            }
        }
Ejemplo n.º 19
0
 private void InitializeAudioCues()
 {
     AudioCue[] audioCues = GetComponents <AudioCue>();
     foreach (AudioCue audioCue in audioCues)
     {
         if (audioCue.Name == "Card Drag Audio")
         {
             CardDragAudio = audioCue;
         }
         else if (audioCue.Name == "Card Drop Valid Audio")
         {
             CardDropValidAudio = audioCue;
         }
         else if (audioCue.Name == "Card Drop Invalid Audio")
         {
             CardDropInvalidAudio = audioCue;
         }
     }
 }
Ejemplo n.º 20
0
    /// <summary>
    /// Allows the game component to update itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    public override void Update(GameTime gameTime)
    {
        // Update the XACT engine.
        m_audioEngine.Update();

        // Go through all the AudioCues looking for any that are finished
#if AUDIO_DEBUG
        int numPlaying = 0;
#endif
        for (UInt16 i = 0; i < MAX_AUDIO_CUE; ++i)
        {
            AudioHandle handle = m_cuePool.GetHandleByIndex(i);
            AudioCue    cue    = m_cuePool.GetItem(handle);
            if (null != cue)
            {         // this cue is alive
                if (AudioCue.State.PLAYING == cue.m_state)
                {     // it thinks it is playing
                    if (false == cue.m_cue.IsPlaying)
                    { // the sound isn't playing anymore - must have stopped
                        cue.Free();
                        cue.m_state = AudioCue.State.AVAILABLE;
                        m_cuePool.Free(handle);
#if AUDIO_DEBUG
                        --m_numPlaying;
                        ++m_numStopped;
                    }
                    else
                    {
                        ++numPlaying;
#endif
                    }
                }
            } //if (null != cue)
        }     //for (UInt16 i = 0; i < MAX_AUDIO_CUE; ++i)

#if AUDIO_DEBUG
        System.Diagnostics.Debug.Assert(numPlaying == m_numPlaying);
        System.Diagnostics.Debug.Assert(numPlaying == m_numPlayed - m_numStopped);
#endif

        base.Update(gameTime);
    }
Ejemplo n.º 21
0
    private static AudioCue CreateNew()
    {
        if (!_audioCuePoolParent)
        {
            _audioCuePoolParent      = new GameObject().transform;
            _audioCuePoolParent.name = "Audio Cue Pool";
            DontDestroyOnLoad(_audioCuePoolParent);
        }

        GameObject newGameObject = new GameObject();

        newGameObject.name = "Audio Cue";
        newGameObject.SetActive(false);
        newGameObject.transform.parent = _audioCuePoolParent;

        AudioCue newCue = newGameObject.AddComponent <AudioCue>();

        newCue.CreateAudioSource();
        _inactiveAudioCues.Add(newCue);
        return(newCue);
    }
Ejemplo n.º 22
0
    /// <summary>
    /// Attempts to play the sound.
    /// Returns a Handle to the AudioCue that gets played.
    /// </summary>
    /// <param name="soundName">The name of the sound to play.</param>
    public AudioHandle PlaySound(String soundName)
    {
        AudioHandle handle = m_cuePool.Allocate();
        AudioCue    cue    = m_cuePool.GetItem(handle);

        if (null != cue)
        {
            System.Diagnostics.Debug.Assert(cue.m_state == AudioCue.State.AVAILABLE);
            System.Diagnostics.Debug.Assert(cue.m_cue == null);
            cue.SetUp(m_soundBank, soundName);
            cue.Play();
#if AUDIO_DEBUG
            ++m_numPlaying;
            ++m_numPlayed;
        }
        else
        {
            ++m_numFailed;
#endif
        }
        return(handle);
    }
Ejemplo n.º 23
0
    private void InitializeAudioCues()
    {
        AudioCue[] audioCues = GetComponents <AudioCue>();
        foreach (AudioCue audioCue in audioCues)
        {
            if (audioCue.Name == "Instruction Drag Audio")
            {
                InstructionDragAudio = audioCue;
            }
            else if (audioCue.Name == "Instruction Drop Valid Audio")
            {
                InstructionDropValidAudio = audioCue;
            }
        }

        Transform content    = this.transform.parent;
        Transform viewport   = content.parent;
        Transform scrollView = viewport.parent;
        Transform window     = scrollView.parent;

        InstructionDropInvalidAudio = window.GetComponent <AudioCue>();
    }
Ejemplo n.º 24
0
    public void Start( )
    {
        playerScore.value = 0;

        _prevScore = 0;
        Vector3 worldToViewPort = Camera.main.WorldToViewportPoint(transform.position);

        worldToViewPort.y -= 0.4625f;

        lineStartRect.anchorMin        = new Vector2(worldToViewPort.x, worldToViewPort.y);
        lineStartRect.anchorMax        = new Vector2(worldToViewPort.x, worldToViewPort.y);
        lineStartRect.anchoredPosition = Vector2.zero;

        lineStartRect.DOAnchorPos(Vector2.zero, 0.25f);

        transform.localScale = new Vector3(0.28f, 0.28f, 1);

        _winAudioCue  = Resources.Load <AudioCue>("Audio/Win");
        _loseAudioCue = Resources.Load <AudioCue>("Audio/Lose");

        GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "game");
    }
Ejemplo n.º 25
0
    public void Start( )
    {
        //textValue.GetComponent<Renderer>( ).sortingLayerName = "AboveDefault";

        //textValue.SetText( "-" + negativeValue );

        _negativeAudioCue = Resources.Load <AudioCue>("Audio/Negative");

        if (!moving)
        {
            return;
        }

        Sequence s = DOTween.Sequence( );

        s.AppendInterval(0.5f);
        s.Append(transform.DOMove(end, moveTime).SetEase(Ease.InOutCubic));
        s.AppendInterval(0.5f);
        //s.Append( transform.DOMove( start, moveTime ).SetEase( Ease.InOutCubic ) );
        //s.AppendInterval( 0.5f );
        s.SetLoops(-1, LoopType.Yoyo);
    }
Ejemplo n.º 26
0
 private void Start()
 {
     world       = GetComponentInParent <MapRotation>();
     audioPlayer = GetComponent <AudioCue>();
 }
Ejemplo n.º 27
0
 private void OnAudioCueComplete(AudioCue cue)
 {
     cues.Remove(cue);
     previewSeconds = 0.0f;
 }
Ejemplo n.º 28
0
 public Song(AudioCue songCue)
 {
     SongCue        = songCue;
     SongEventQueue = new List <SongEvent>();
 }
Ejemplo n.º 29
0
 public NamedAudioCue(string name)
 {
     this.name = name;
     cue       = null;
 }
Ejemplo n.º 30
0
 public NamedAudioCue(string name, AudioCue cue)
 {
     this.name = name;
     this.cue  = cue;
 }