Beispiel #1
0
        /// <summary>
        /// Get the required source and pick a random clip to play it on.
        /// </summary>
        void Start()
        {
            AudioSource3D Source = GetComponent <AudioSource3D>();

            Source.clip = Clips[Random.Range(0, Clips.Length)];
            Source.Play();
        }
Beispiel #2
0
    /// <summary>
    /// Hang lejátszása Cavern használatával.
    /// </summary>
    /// <param name="Clip">Hang</param>
    /// <param name="At">Pozíicó</param>
    static void PlayWithCavern(AudioClip Clip, Vector3 At)
    {
        AudioSource3D Source = CreateContainer(Clip, At).AddComponent <AudioSource3D>();

        Source.Clip          = Clip;
        Source.VolumeRolloff = AudioSource3D.Rolloffs.Disabled;
    }
Beispiel #3
0
    /// <summary>
    /// Hang lejátszása egy objektumon, Cavern motorral.
    /// </summary>
    /// <param name="Clip">Hang</param>
    /// <param name="Obj">Objektum</param>
    static void AttachWithCavern(AudioClip Clip, GameObject Obj)
    {
        AudioSource3D Source = Obj.AddComponent <AudioSource3D>();

        Source.Clip          = Clip;
        Source.VolumeRolloff = AudioSource3D.Rolloffs.Disabled;
    }
Beispiel #4
0
 public void Play(AudioSource3D source, AudioClip[] soundpack)
 {
     if (soundpack.Length != 0)
     {
         source.PlayOneShot(soundpack[Random.Range(0, soundpack.Length)]);
     }
 }
Beispiel #5
0
 void OnEnable()
 {
     source = GetComponent <AudioSource3D>();
     filter = new Lowpass(AudioListener3D.Current.SampleRate, 120);
     Update();
     source.AddFilter(filter);
 }
Beispiel #6
0
 void Awake()
 {
     Weapon = WeaponBase.AttachWeapon(WeaponKinds.Unassigned, gameObject);
     WeaponPickup(WeaponKinds.Photon);
     Source = GetComponent <AudioSource3D>();
     Customize.DeserializeTo(transform.GetChild(0).gameObject);
 }
Beispiel #7
0
        /// <summary>
        /// Constructs a new destructor.
        /// </summary>
        /// <param name="attachTo">Object containing a source to destruct</param>
        /// <param name="targetSource">Source to destruct</param>
        /// <param name="destroyAfter">Destroy the parent after playback</param>
        internal static OneShotDestructor Constructor(GameObject attachTo, AudioSource3D targetSource, bool destroyAfter)
        {
            OneShotDestructor destructor = attachTo.AddComponent <OneShotDestructor>();

            destructor.source            = targetSource;
            destructor.destroyGameObject = destroyAfter;
            return(destructor);
        }
Beispiel #8
0
 /// <summary>
 /// Create the required textures.
 /// </summary>
 void Start()
 {
     Source = GetComponent <AudioSource3D>();
     Source.SpatialBlend = 0;
     InnerTexture        = new Texture2D(1, 1);
     InnerTexture.SetPixel(0, 0, new Color(0, 0, 0, .25f));
     InnerTexture.Apply();
     OuterTexture = new Texture2D(1, 1);
     OuterTexture.SetPixel(0, 0, new Color(1, 1, 1, .25f));
     OuterTexture.Apply();
 }
Beispiel #9
0
 void Start()
 {
     Alive = Range / Speed;
     while (Box < Boxes.Count && Boxes[Box].Timestamp < Alive)
     {
         ++Box;
     }
     Source              = gameObject.AddComponent <AudioSource3D>();
     Source.clip         = Song;
     Source.SpatialBlend = 0;
 }
Beispiel #10
0
        /// <summary>
        /// Play a sound at the location of a GameObject.
        /// </summary>
        /// <param name="Obj">Target</param>
        public static void PlaySoundOn(GameObject Obj)
        {
            GameObject NewObj = new GameObject();

            NewObj.transform.position = Obj.transform.position;
            AudioSource3D Source = NewObj.AddComponent <AudioSource3D>();

            Source.clip   = _SelectSound;
            Source.Volume = .1f;
            Source.Play();
            NewObj.AddComponent <TimedDespawner>().Timer = 1;
        }
Beispiel #11
0
 /// <summary>
 /// When the enemy is spawned, set it up.
 /// </summary>
 void Start()
 {
     Damage = MapHandler.Instance.EnemyDamage;
     Health = MapHandler.Instance.EnemyHealth * Health;
     Source = GetComponent <AudioSource3D>();
     if (!Settings.HQAudio)
     {
         Source.Mute = true;
     }
     Creation();               // Enemy specific setup
     Cooldown = ShootingSpeed; // Initial cooldown
 }
Beispiel #12
0
 void LateUpdate()
 {
     if (Source)
     {
         if (!target)
         {
             target = Source.gameObject.AddComponent <AudioSource3D>();
         }
         target.enabled      = Source.enabled;
         target.DopplerLevel = Source.dopplerLevel;
         target.IsPlaying    = Source.isPlaying;
         target.Loop         = Source.loop;
         target.Mute         = Source.mute;
         target.Pitch        = Source.pitch;
         target.SpatialBlend = Source.spatialBlend;
         target.StereoPan    = Source.panStereo;
         if (target.Clip = Source.clip)
         {
             bool decompressed = Source.clip.loadType == AudioClipLoadType.DecompressOnLoad;
             if (!duality)
             {
                 target.Volume = Source.volume;
             }
             else if (decompressed && Source.volume != Mute)
             {
                 target.Volume = Source.volume;
                 Source.volume = Mute;
             }
             AudioSettings.GetDSPBufferSize(out int BufferSize, out int _);
             if (Math.Abs(target.timeSamples - Source.timeSamples) > BufferSize)
             {
                 target.timeSamples = Source.timeSamples;
             }
             if (!decompressed)
             {
                 target.Clip = null;
             }
         }
         target.VolumeRolloff = Source.rolloffMode switch {
             AudioRolloffMode.Linear => Rolloffs.Linear,
             AudioRolloffMode.Logarithmic => Rolloffs.Logarithmic,
             _ => Rolloffs.Disabled,
         };
     }
     else
     {
         if (target)
         {
             Destroy(target);
         }
         Destroy(this);
     }
 }
Beispiel #13
0
    public void OnHit(Target Hit)
    {
        if (Menu.Instance.GameOverUI.activeSelf)
        {
            return;
        }
        AudioSource3D.PlayClipAtPoint(Slash, Hit.transform.position, SlashVolume);
        int   Lane        = Hit.transform.position.x < 0 ? 0 : 1;
        Color TargetColor = Hit.GetComponent <Renderer>().material.color;

        AddToLane(Lane, TargetColor);
        Destroy(Hit.gameObject);
    }
Beispiel #14
0
 void OnEnable()
 {
     source = GetComponent <AudioSource3D>();
     filter = new Filters.Delay(DelayTime, AudioListener3D.Current.SampleRate);
     source.AddFilter(filter);
 }
Beispiel #15
0
 void OnEnable()
 {
     source = GetComponent <AudioSource3D>();
     filter = new Filters.Comb(AudioListener3D.Current.SampleRate, frequency, alpha);
     source.AddFilter(filter);
 }
Beispiel #16
0
 void OnEnable()
 {
     source = GetComponent <AudioSource3D>();
     filter = new Convolver(new float[MaxSamples], 0);
     source.AddFilter(filter);
 }
Beispiel #17
0
 void OnEnable()
 {
     source = GetComponent <AudioSource3D>();
     filter = new Echo(AudioListener3D.Current.SampleRate, Strength, Delay);
     source.AddFilter(filter);
 }