示例#1
0
    public void test()
    {
        SoundCategory testCategory = new SoundCategory("Test Category");
        SoundGroup testGroup = new SoundGroup("Test Group");
        SoundSource testSource = new SoundSource("Test Source");

        SoundCategory test2 = new SoundCategory("Test Category 2");
        SoundGroup testgroup2 = new SoundGroup("Test Group 2");
        SoundSource testsource2 = new SoundSource("Test Source 2");

        AudioClip testaudio = (AudioClip)Resources.Load("Jump",typeof(AudioClip));
        AudioClip testaudio2 = (AudioClip)Resources.Load("Jump1",typeof(AudioClip));

        testSource.setGameObject(GameObject.FindGameObjectWithTag("Dragged"));

        testSource.addAudioClip(testaudio);
        testSource.addAudioClip(testaudio2);

        testgroup2.sources.Add(testsource2);
        test2.groups.Add(testgroup2);
        _categories.Add(test2);

        testGroup.sources.Add(testSource);
        testCategory.groups.Add(testGroup);
        _categories.Add(testCategory);
    }
示例#2
0
 public void RemoveSoundSource(SoundSource source)
 {
     foreach(SoundCategory category in _categories)
     {
         if(category.sources.Contains(source))
             category.sources.Remove(source);
     }
 }
    public SoundSourceView(SoundSource s, int a)
        : base(new Vector2(20, 20))
    {
        setParameters(a);
        source = s;

        AddStyle("soundSourceButton");
        AddStyle("soundSourceButtonSelected");
    }
示例#4
0
    //    public static void Play(SoundMainMixer mainMixer, string triggerName){
    //        if (mainMixer != null){
    //            if (mainMixer.categories != null){
    //                foreach(SoundCategory sc in mainMixer.categories){
    //                    foreach (SoundSource ss in sc.sources){
    //                        if (ss.triggerName == triggerName){
    //                            ss.childGo.GetComponent<PlayAudio>().triggerType = ss.musicType;
    //                            ss.childGo.GetComponent<PlayAudio>().transition = ss.transition;
    //                            ss.childGo.GetComponent<PlayAudio>().playAudio();
    //                        }
    //                    }
    //                }
    //            }
    //        }
    //    }
    public static void Play(SoundMainMixer mainMixer, string triggerName)
    {
        SoundSource ss = new SoundSource();
        if ((ss = getFromTrigger(mainMixer, triggerName)) != null){

            ss.childGo.GetComponent<SoundSourcePlayer>().playAudio();
        }
        else { Debug.LogError("Couldn't play " + triggerName); }
    }
示例#5
0
 void parentNewAudioSourceObject(SoundSource ss)
 {
     ss.childGoName = ("sound_" + ss.name);
     ss.childGo = new GameObject(ss.childGoName);
     addScript(ss);
     addAudioSource(ss);
     ss.childGo.transform.parent = this.gameObject.transform;
     ss.childGo.transform.localPosition = Vector3.zero;
     ss.childGo.transform.localRotation = Quaternion.identity;
     ss.childGo.transform.localScale = Vector3.one;
 }
示例#6
0
 public Horn(SoundBuffer startSound, SoundBuffer loopSound, SoundBuffer endSound, bool loop, CarBase car)
 {
     this.Source         = null;
     this.StartSound     = startSound;
     this.LoopSound      = loopSound;
     this.EndSound       = endSound;
     this.Loop           = loop;
     this.StartEndSounds = false;
     this.LoopStarted    = false;
     this.SoundPosition  = new Vector3();
     this.baseCar        = car;
 }
    void Awake()
    {
        footstepSoundLeft   = transform.Find("FootstepSoundLeft").GetComponent <SoundSource>();
        footstepSoundRight  = transform.Find("FootstepSoundRight").GetComponent <SoundSource>();
        animator            = GetComponent <Animator>();
        characterController = GetComponent <CharacterController>();
        characterController.Move(Vector3.zero);
        canvasSphere = GetComponentInChildren <CanvasSphere>();

        controlCameraLeft  = transform.Find("OVR_anchor/OVRCameraRig/TrackingSpace/LeftEyeAnchor").GetComponent <ControlCamera>();
        controlCameraRight = transform.Find("OVR_anchor/OVRCameraRig/TrackingSpace/RightEyeAnchor").GetComponent <ControlCamera>();
    }
示例#8
0
 private void OnCollisionEnter(Collision collision)
 {
     if (m_ShouldImpact && collision.gameObject.CompareTag("Interactable"))
     {
         Rigidbody body = collision.gameObject.GetComponent <Rigidbody>();
         if (body != null)
         {
             body.velocity = transform.forward * AppliedForce + m_Velocity * VelocityFactor;
             SoundSource.PlaySound(ImpactSound);
         }
     }
 }
示例#9
0
 public SoundSystemWalking(GameObject sourceObject)
 {
     SourceObject       = sourceObject;
     ObjectScript       = SourceObject.GetComponent <Character>();
     ObjectSpeed        = ObjectScript.speed;
     SoundSource        = SourceObject.AddComponent <AudioSource>();
     SoundSource.clip   = Resources.Load <AudioClip>("Sounds/Footstep");
     SoundSource.volume = 0.6f;
     SoundSource.loop   = true;
     SoundSource.outputAudioMixerGroup = Resources.Load <AudioMixer>("MasterMixer").FindMatchingGroups("Master")[0];
     SoundSource.Play();
 }
示例#10
0
 internal Horn(SoundBuffer startSound, SoundBuffer loopSound, SoundBuffer endSound, bool loop, Train train)
 {
     this.Source         = null;
     this.StartSound     = startSound;
     this.LoopSound      = loopSound;
     this.EndSound       = endSound;
     this.Loop           = loop;
     this.StartEndSounds = false;
     this.LoopStarted    = false;
     this.SoundPosition  = new Vector3();
     this.baseTrain      = train;
 }
示例#11
0
 /// <summary>Stops the specified sound source.</summary>
 /// <param name="source">The sound source, or a null reference.</param>
 internal static void StopSound(SoundSource source)
 {
     if (source != null)
     {
         if (source.State == SoundSourceState.Playing)
         {
             AL.DeleteSources(1, ref source.OpenAlSourceName);
             source.OpenAlSourceName = 0;
         }
         source.State = SoundSourceState.Stopped;
     }
 }
示例#12
0
    // Play a random firework sound
    public void PlayFireworkSound()
    {
        int random = UnityEngine.Random.Range(0, fireworkSounds.Length - 1);

        SoundSource s = Array.Find(wallSounds, sound => sound.name == fireworkSounds[random].name);

        if (s == null)
        {
            Debug.LogError("[AudioManager] Couldn't find sound: " + fireworkSounds[random].name);
            return;
        }
        s.source.Play();
    }
 public SteamWall(float startPosition)
 {
     Add(new PlayerCollider(OnPlayer));
     Add(new LightOcclude(0.8f));
     Add(_loopSfx = new SoundSource());
     Depth        = -100000;
     Collider     = new Hitbox(16 + startPosition, 0f);
     Add(new Coroutine(SteamPoofSpawnSequence()));
     Add(new Coroutine(ThrowDebrisSequence()));
     Add(new DisplacementRenderHook(RenderDisplacement));
     Add(_transitionListener    = new TransitionListener());
     _transitionListener.OnOut += FadeOutOnTransition;
 }
示例#14
0
        protected int IAnimationMatrix = -1; // index of animation matrix

        /// <summary>
        /// Construct and initialize the class
        /// </summary>
        public TurntableShape(string path, IWorldPosition positionSource, ShapeFlags flags, Turntable turntable, double startingY)
            : base(path, positionSource, flags)
        {
            Turntable                    = turntable;
            Turntable.StartingY          = (float)startingY;
            Turntable.TurntableFrameRate = SharedShape.Animations[0].FrameRate;
            animationKey                 = (Turntable.YAngle / (float)Math.PI * 1800.0f + 3600) % 3600.0f;
            for (var imatrix = 0; imatrix < SharedShape.Matrices.Length; ++imatrix)
            {
                if (SharedShape.MatrixNames[imatrix].ToLower() == turntable.Animations[0].ToLower())
                {
                    IAnimationMatrix = imatrix;
                    break;
                }
            }
            if (viewer.Simulator.TRK.Route.DefaultTurntableSMS != null)
            {
                var soundPath = viewer.Simulator.RoutePath + @"\\sound\\" + viewer.Simulator.TRK.Route.DefaultTurntableSMS;
                try
                {
                    Sound = new SoundSource(viewer, WorldPosition.WorldLocation, SoundEventSource.Turntable, soundPath);
                    viewer.SoundProcess.AddSoundSources(this, new List <SoundSourceBase>()
                    {
                        Sound
                    });
                }
                catch
                {
                    soundPath = viewer.Simulator.BasePath + @"\\sound\\" + viewer.Simulator.TRK.Route.DefaultTurntableSMS;
                    try
                    {
                        Sound = new SoundSource(viewer, WorldPosition.WorldLocation, SoundEventSource.Turntable, soundPath);
                        viewer.SoundProcess.AddSoundSources(this, new List <SoundSourceBase>()
                        {
                            Sound
                        });
                    }
                    catch (Exception error)
                    {
                        Trace.WriteLine(new FileLoadException(soundPath, error));
                    }
                }
            }
            for (var matrix = 0; matrix < SharedShape.Matrices.Length; ++matrix)
            {
                AnimateMatrix(matrix, animationKey);
            }

            MatrixExtension.Multiply(in XNAMatrices[IAnimationMatrix], in WorldPosition.XNAMatrix, out Matrix absAnimationMatrix);
            Turntable.ReInitTrainPositions(absAnimationMatrix);
        }
示例#15
0
        public ConnectedMoveBlock(Vector2 position, int width, int height, MoveBlock.Directions direction, float moveSpeed)
            : base(position, width, height, safe: false)
        {
            Depth          = Depths.Player - 1;
            startPosition  = position;
            Direction      = direction;
            this.moveSpeed = moveSpeed;

            homeAngle   = targetAngle = angle = direction.Angle();
            Add(moveSfx = new SoundSource());
            Add(new Coroutine(Controller()));
            UpdateColors();
            Add(new LightOcclude(0.5f));
        }
示例#16
0
        void CreateSound()
        {
            // Sound source needs a node so that it is considered enabled
            node = new Node();
            SoundSource source = node.CreateComponent <SoundSource>();

            soundStream = new BufferedSoundStream();
            // Set format: 44100 Hz, sixteen bit, mono
            soundStream.SetFormat(44100, true, false);

            // Start playback. We don't have data in the stream yet, but the SoundSource will wait until there is data,
            // as the stream is by default in the "don't stop at end" mode
            source.Play(soundStream);
        }
示例#17
0
 new void Update()
 {
     if (isShooting && currentReloadTime >= ReloadTime)
     {
         SoundSource.Play();
         foreach (var currentBarrel in Barrels)
         {
             var currentProjectile = (Instantiate(Projectile, currentBarrel.transform.position, currentBarrel.transform.rotation) as Transform).gameObject;
             currentProjectile.GetComponent <ProjectileController>().CollidableLayers = CollidableLayers;
         }
         currentReloadTime = 0;
     }
     base.Update();
 }
示例#18
0
        /// <summary>
        /// ゲームを開始する
        /// </summary>
        void StartGame()
        {
            // コントローラーからの入力を受け付ける
            Controller.AcceptInput = true;

            // 音を準備する
            string path = Game.Score.SoundPath;

            BGM = Sound.CreateBGM(path);
            BGM.IsLoopingMode = false;

            // ノーツタイマーを動かす
            Note.Stopwatch.Start();
        }
示例#19
0
    public void Stop(String name)
    {
        SoundSource s = Array.Find(wallSounds, sound => sound.name == name);

        if (s == null)
        {
            Debug.LogWarning("[AudioManager] Couldn't find sound: " + name);
            return;
        }
        if (s.source.isPlaying)
        {
            s.source.Stop();
        }
    }
示例#20
0
 /// <summary>
 /// 播放背景音乐
 /// </summary>
 /// <param name="soundId">Sound identifier.</param>
 /// <param name="loop">If set to <c>true</c> loop.</param>
 /// <param name="delay">Delay.</param>
 public void PlayBGM(string soundId, bool loop = true, float delay = 0)
 {
     lastBGMId = soundId;
     if (!bGMEnable)
     {
         return;
     }
     StopBGM();
     bgm = Statics.GetSoundPrefabClone(soundId).GetComponent <SoundSource>();
     if (bgm != null)
     {
         bgm.Play(loop, delay);
     }
 }
        // This method plays a sound effect
        // Takes a filename and condition whether or not to loop
        private void PlaySound(string name, bool looped)
        {
            Sound sound = new Sound();

            //sound.Looped = looped;
            sound.LoadOggVorbis(ResourceCache.GetFile(name));

            Node        soundNode   = scene.CreateChild("Sound");
            SoundSource soundSource = soundNode.CreateComponent <SoundSource>();

            soundSource.AutoRemoveMode = AutoRemoveMode.Node;
            soundSource.Play(sound);
            //source.AutoRemoveMode = AutoRemoveMode.Component;
        }
示例#22
0
        protected int IAnimationMatrix = -1; // index of animation matrix

        /// <summary>
        /// Construct and initialize the class
        /// </summary>
        public TransfertableShape(string path, IWorldPosition positionSource, ShapeFlags flags, Transfertable transfertable)
            : base(path, positionSource, flags)
        {
            Transfertable = transfertable;
            animationKey  = (Transfertable.XPos - Transfertable.CenterOffset.X) / Transfertable.Width * SharedShape.Animations[0].FrameCount;
            for (var imatrix = 0; imatrix < SharedShape.Matrices.Length; ++imatrix)
            {
                if (SharedShape.MatrixNames[imatrix].ToLower() == transfertable.Animations[0].ToLower())
                {
                    IAnimationMatrix = imatrix;
                    break;
                }
            }
            if (viewer.Simulator.TRK.Route.DefaultTurntableSMS != null)
            {
                var soundPath = viewer.Simulator.RoutePath + @"\\sound\\" + viewer.Simulator.TRK.Route.DefaultTurntableSMS;
                try
                {
                    Sound = new SoundSource(viewer, WorldPosition.WorldLocation, SoundEventSource.Turntable, soundPath);
                    viewer.SoundProcess.AddSoundSources(this, new List <SoundSourceBase>()
                    {
                        Sound
                    });
                }
                catch
                {
                    soundPath = viewer.Simulator.BasePath + @"\\sound\\" + viewer.Simulator.TRK.Route.DefaultTurntableSMS;
                    try
                    {
                        Sound = new SoundSource(viewer, WorldPosition.WorldLocation, SoundEventSource.Turntable, soundPath);
                        viewer.SoundProcess.AddSoundSources(this, new List <SoundSourceBase>()
                        {
                            Sound
                        });
                    }
                    catch (Exception error)
                    {
                        Trace.WriteLine(new FileLoadException(soundPath, error));
                    }
                }
            }
            for (var matrix = 0; matrix < SharedShape.Matrices.Length; ++matrix)
            {
                AnimateMatrix(matrix, animationKey);
            }

            MatrixExtension.Multiply(in XNAMatrices[IAnimationMatrix], in WorldPosition.XNAMatrix, out Matrix absAnimationMatrix);
            Transfertable.ReInitTrainPositions(absAnimationMatrix);
        }
 public override void OnBegin(Level level)
 {
     payphone = Scene.Tracker.GetEntity <Payphone>();
     Add(new Coroutine(Cutscene(level)));
     Add(ringtone = new SoundSource());
     Add(phoneSfx = new SoundSource());
     Add(sprite   = new Sprite(GFX.Game, "cutscenes/payphone/phone"));
     sprite.Add("putdown", "", 0.08f, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
     sprite.Justify = new Vector2(0.5f, 1f);
     sprite.Visible = false;
     if (endLevel)
     {
         level.RegisterAreaComplete();
     }
 }
示例#24
0
    public void OnEndLevel(Level level)
    {
        if (levelBackground != null)
        {
            levelBackground.Stop(1f);
            levelBackground = null;
        }

        User.ClearLevel(Scenes.activeScene);
        User.SaveConfiguration();

        StartCoroutine(Routines.WaitFor(1f, delegate {
            Scenes.LoadSceneAdditiveMerge("FinishScreen");
        }));
    }
示例#25
0
 public void PlaySound(AudioClip clip, AudioSource source)
 {
     if (source == null)
     {
         source.Stop();
         source.clip = clip;
         source.Play();
     }
     else
     {
         SoundSource.Stop();
         SoundSource.clip = clip;
         SoundSource.Play();
     }
 }
示例#26
0
        private void Attack(bool hurt)
        {
            triggered = true;

            if (currentMoveLoopSfx != null)
            {
                currentMoveLoopSfx.Param("end", 1f);
                SoundSource sfx = currentMoveLoopSfx;
                Alarm.Set(this, 0.5f, () => sfx.RemoveSelf());
            }
            Add(currentMoveLoopSfx      = new SoundSource());
            currentMoveLoopSfx.Position = new Vector2(Width, Height) / 2f;

            attackCoroutine.Replace(AttackSequence(hurt));
        }
示例#27
0
        private static void PostProcessSoundSources(Scene scene, List <MapEntityLoader.RawMapEntity> rawEntityData)
        {
            foreach (var soundEntity in FindAllByType("SOND", rawEntityData))
            {
                SoundSource sndSource = new SoundSource();
                sndSource.Name   = soundEntity.Fields.GetProperty <string>("Name");
                sndSource.Fields = soundEntity.Fields;
                sndSource.FourCC = "SOND";

                ProcessTransform(sndSource);
                sndSource.Fields.RemoveProperty("Name");

                scene.Entities.Add(sndSource);
            }
        }
示例#28
0
    public void NextLevel()
    {
        currentIndex++;
        if (currentIndex >= levels.Count)
        {
            currentIndex       = levels.Count - 1;
            mainCamera.enabled = false;
            endScreen.SetActive(true);
            SoundSource.PlayCompleteGame();
        }

        LoadLevel(levels[currentIndex]);

        victoryScreen.SetActive(false);
    }
    /// <summary>
    /// Function to blink a random sphere
    /// </summary>
    private void PlayTutorial()
    {
        //get a random sphere
        isPlayed = true;
        var random = new System.Random();
        int index  = random.Next(soundObjects.Length);

        if (tutorialTrials == 0)
        {
            index = 0;
        }
        //trigger the sphere for it to start blinking
        sphere = (SoundSource)soundObjects[index].GetComponent(typeof(SoundSource));
        sphere.StartFlick(true);
    }
        public SnowballLeft()
        {
            Depth    = -12500;
            Collider = new Hitbox(12f, 9f, -6f, -2f);
            Collider bounceCollider = new Hitbox(16f, 6f, -9f, -8f);

            Add(
                new PlayerCollider(OnPlayer));
            Add(new PlayerCollider(OnPlayerBounce, bounceCollider));
            Add(sine        = new SineWave(0.5f));
            Add(sprite      = GFX.SpriteBank.Create("snowball"));
            sprite.Scale.X *= -1;
            sprite.Play("spin");
            Add(spawnSfx = new SoundSource());
        }
示例#31
0
    public void MakeSound()
    {
        var SoundSpeed = 1 + ObjectScript.speed;

        SoundSource.pitch = Mathf.Clamp(SoundSpeed, 0.9f, 1.5f);
        isPlaying         = Mathf.Abs(ObjectScript.getMoving) > 0 && ObjectScript.getGrounded;
        if (isPlaying)
        {
            SoundSource.UnPause();
        }
        else
        {
            SoundSource.Pause();
        }
    }
示例#32
0
 public void Preload()
 {
     if (Sample == null && Payload != null)
     {
         if (Id >= 1000)
         {
             Sample = new Music(Payload);
         }
         else
         {
             Sample = new Cgen.Audio.Sound(new SoundBuffer(Payload));
         }
         Payload = null;
     }
 }
示例#33
0
 public void Dispose()
 {
     foreach (SoundSource soundSource in _soundIdentifier.Values)
     {
         SoundSource temp = soundSource;
         Al.alDeleteBuffers(1, ref temp._bufferId);
     }
     _soundIdentifier.Clear();
     foreach (int slot in _soundChannels)
     {
         int target = _soundChannels[slot];
         Al.alDeleteSources(1, ref target);
     }
     Alut.alutExit();
 }
        public void GenerateFrequencyDomainImpulseResponse_CheckDistanceAttenuation()
        {
            var sampleRate       = 16000;
            var dftLength        = 1024;
            var delaySampleCount = 30;

            var time     = (double)delaySampleCount / sampleRate;
            var distance = AcousticConstants.SoundSpeed * time;

            var roomSize              = DenseVector.OfArray(new double[] { distance, distance, distance });
            var distanceAttenuation   = new DistanceAttenuation(distance => distance < 0.1 ? 3.1 : 2.3);
            var reflectionAttenuation = new ReflectionAttenuation(frequency => 0.7);
            var room        = new Room(roomSize, distanceAttenuation, reflectionAttenuation, 1);
            var soundSource = new SoundSource(distance / 2, distance / 2, distance / 2);
            var microphone  = new Microphone(distance / 2, distance / 2, distance / 2);

            var response = MirrorMethod.GenerateFrequencyDomainImpulseResponse(room, soundSource, microphone, sampleRate, dftLength);

            var timeDomainSignal = new Complex[dftLength];

            timeDomainSignal[0] = response[0];
            for (var w = 1; w < dftLength / 2; w++)
            {
                timeDomainSignal[w]             = response[w];
                timeDomainSignal[dftLength - w] = response[w].Conjugate();
            }
            timeDomainSignal[dftLength / 2] = response[dftLength / 2];
            Fourier.Inverse(timeDomainSignal, FourierOptions.AsymmetricScaling);

            for (var t = 0; t < dftLength; t++)
            {
                if (t == 0)
                {
                    Assert.AreEqual(3.1, timeDomainSignal[t].Real, 1.0E-6);
                    Assert.AreEqual(0.0, timeDomainSignal[t].Imaginary, 1.0E-6);
                }
                else if (t == delaySampleCount)
                {
                    Assert.AreEqual(6 * 2.3 * 0.7, timeDomainSignal[t].Real, 1.0E-6);
                    Assert.AreEqual(0.0, timeDomainSignal[t].Imaginary, 1.0E-6);
                }
                else
                {
                    Assert.AreEqual(0.0, timeDomainSignal[t].Real, 1.0E-6);
                    Assert.AreEqual(0.0, timeDomainSignal[t].Imaginary, 1.0E-6);
                }
            }
        }
        public DreamSwitchGate(EntityData data, Vector2 offset)
            : base(data, offset)
        {
            permanent = data.Bool("permanent");
            node      = data.Nodes[0] + offset;

            isFlagSwitchGate = data.Bool("isFlagSwitchGate");

            ID   = data.ID;
            Flag = data.Attr("flag");

            inactiveColor = Calc.HexToColor(data.Attr("inactiveColor", "5FCDE4"));
            activeColor   = Calc.HexToColor(data.Attr("activeColor", "FFFFFF"));
            finishColor   = Calc.HexToColor(data.Attr("finishColor", "F141DF"));

            shakeTime = data.Float("shakeTime", 0.5f);
            moveTime  = data.Float("moveTime", 1.8f);
            moveEased = data.Bool("moveEased", true);

            moveSound     = data.Attr("moveSound", SFX.game_gen_touchswitch_gate_open);
            finishedSound = data.Attr("finishedSound", SFX.game_gen_touchswitch_gate_finish);

            allowReturn = data.Bool("allowReturn");

            P_RecoloredFire = new ParticleType(TouchSwitch.P_Fire)
            {
                Color = finishColor
            };
            P_RecoloredFireBack = new ParticleType(TouchSwitch.P_Fire)
            {
                Color = inactiveColor
            };

            string iconAttribute = data.Attr("icon", "vanilla");

            icon = new Sprite(GFX.Game, iconAttribute == "vanilla" ? "objects/switchgate/icon" : $"objects/MaxHelpingHand/flagSwitchGate/{iconAttribute}/icon");
            icon.Add("spin", "", 0.1f, "spin");
            icon.Play("spin");
            icon.Rate  = 0f;
            icon.Color = inactiveColor;
            icon.CenterOrigin();
            iconOffset  = new Vector2(Width, Height) / 2f;
            Add(wiggler = Wiggler.Create(0.5f, 4f, scale => {
                icon.Scale = Vector2.One * (1f + scale);
            }));

            Add(openSfx = new SoundSource());
        }
示例#36
0
    void addAudioSource(SoundSource ss)
    {
        ss.audioSource = ss.childGo.AddComponent<AudioSource>();
        ss.audioSource.mute = ss.mute;
        ss.audioSource.priority = (int)ss.priority;
        if (ss.clips != null){
            ss.audioSource.clip = ss.clips[0];
        }
        ss.audioSource.dopplerLevel = ss.dopplerLevel;
        ss.audioSource.maxDistance = ss.maxDistance;
        ss.audioSource.minDistance = ss.minDistance;
        ss.audioSource.maxDistance = ss.maxDistance;
        ss.audioSource.panLevel = ss.panLevel;
        ss.audioSource.spread = ss.spread;
        //ss.audioSource.rolloffMode = ss.rolloffType;

        //		if(ss.GetType() == typeof(SoundMusicSource)) {
        //			//ss.audioSource = (SoundMusicSource)(ss).bpm;
        //			//ss.audioSource = (SoundMusicSource)(ss).beatify;
        //			//ss.audioSource = (SoundMusicSource)(ss).timeSignature;
        //		}
    }
    public override void Show()
    {
        dimensions = EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
            if(GUILayout.Button("Save",EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                SoundManagerMainWindow.Window.SaveCurrent();
            }

            if(GUILayout.Button("New Sound Source",EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
            {
                SoundSource source = new SoundSource("New Sound Source");
                source.color = Color.white;
                SoundManagerMainWindow.Window.currentSelectedMixer.categories[0].sources.Add(source);
                SoundManagerMainWindow.Window.RebuildGUI();
                SoundInspectorView.Instance.SetContent(source, SoundInspectorView.ContentType.soundSource);
            }

            SoundInspectorView.ContentType inspectorContent = SoundInspectorView.Instance.contentType;

            if(inspectorContent != SoundInspectorView.ContentType.none)
            {
                try
                {
                    if(GUILayout.Button("Delete Selected",EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
                    {
                        SoundInspectorView.Instance.DeleteContent();
                    }
                }
                catch
                {}
            }
            else
                GUILayout.Box("", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));

            _deleteIcon.Show();
            _stateSelect.Show();

        EditorGUILayout.EndHorizontal();
    }
示例#38
0
 void parentNewAudioSourceObject(SoundSource ss)
 {
     ss.childGoName = (ss.go.name+"_audio");
     ss.childGo = new GameObject(ss.childGoName);
     addAudioSource(ss);
     addScript(ss);
     ss.childGo.transform.parent = ss.go.transform;
 }
示例#39
0
 public SoundSource(SoundSource a)
 {
     // copy base class properties.
     foreach (PropertyInfo prop in a.GetType().GetProperties()){
         PropertyInfo prop2 = a.GetType().GetProperty(prop.Name);
         prop2.SetValue(this, prop.GetValue(a, null), null);
     }
 }
示例#40
0
    void setRollofType(SoundSource ss)
    {
        switch (ss.rolloffMode){
            case(AudioRolloffMode.Linear):{
                ss.audioSource.rolloffMode = AudioRolloffMode.Linear;
            break;
            }

            case(AudioRolloffMode.Logarithmic):{
                ss.audioSource.rolloffMode = AudioRolloffMode.Logarithmic;
                break;
            }
        }
    }
示例#41
0
 void addAudioSource(SoundSource ss)
 {
 }
示例#42
0
文件: Sounds.cs 项目: sladen/openbve
 /// <summary>Stops the specified sound source.</summary>
 /// <param name="source">The sound source, or a null reference.</param>
 internal static void StopSound(SoundSource source)
 {
     if (source != null) {
         if (source.State == SoundSourceState.Playing) {
             Al.alDeleteSources(1, ref source.OpenAlSourceName);
             source.OpenAlSourceName = 0;
         }
         source.State = SoundSourceState.Stopped;
     }
 }
示例#43
0
		// --- tests ---
		
		/// <summary>Checks whether the specified sound is playing or supposed to be playing.</summary>
		/// <param name="source">The sound source, or a null reference.</param>
		/// <returns>Whether the sound is playing or supposed to be playing.</returns>
		internal static bool IsPlaying(SoundSource source) {
			if(source == null)
				return false;
			return source.State == SoundSourceState.PlayPending || source.State == SoundSourceState.Playing;
		}
 public void Load(SoundSource source) {
     // URL OR FILE
     //this.sound = SystemSound.FromFile("Sounds/tap.aif");
 }
示例#45
0
文件: Sounds.cs 项目: sladen/openbve
 /// <summary>Checks whether the specified sound is stopped or supposed to be stopped.</summary>
 /// <param name="source">The sound source, or a null reference.</param>
 /// <returns>Whether the sound is stopped or supposed to be stopped.</returns>
 internal static bool IsStopped(SoundSource source)
 {
     if (source != null) {
         if (source.State == SoundSourceState.StopPending | source.State == SoundSourceState.Stopped) {
             return true;
         }
     }
     return false;
 }
 public void Load(SoundSource source) {
     this.player.Reset();
     //this.player.SetDataSource("PATH");
     //this.player.SetAudioStreamType();
     this.player.Prepare();
 }
示例#47
0
 void addScript(SoundSource ss)
 {
     SoundSourcePlayer pa = ss.childGo.AddComponent<SoundSourcePlayer>();
     pa.source = ss;
 }
    void CustomSlider(ref float bottom, ref float top, float min, float max, ref SoundSource.SliderDisplayType singleSlider)
    {
        tempBottom = bottom;
        tempTop = top;

        if(singleSlider == SoundSource.SliderDisplayType.Single){
            tempBottom = EditorGUILayout.Slider(tempBottom, min, max);
            if(tempBottom != bottom){
                bottom = top = tempBottom;
                //GUIUtility.keyboardControl = 0;
            }
        }else{
            EditorGUILayout.MinMaxSlider(ref tempBottom, ref tempTop, min, max);

            if(tempBottom != bottom || tempTop != top){
                bottom = tempBottom;
                top = tempTop;
                GUIUtility.keyboardControl = 0;

                if(bottom >= top){
                    bottom = top;
                    singleSlider = SoundSource.SliderDisplayType.Single;
                }
            }

            EditorGUIUtility.LookLikeControls();
            //display the minimum value for the interval
            EditorGUILayout.BeginHorizontal();
                bottom = EditorGUILayout.FloatField(bottom, EditorStyles.miniTextField, GUILayout.MaxWidth(64));
                GUILayout.FlexibleSpace();
                //display the maximum value for the interval
                top = EditorGUILayout.FloatField(top, EditorStyles.miniTextField, GUILayout.MaxWidth(64));
            EditorGUILayout.EndHorizontal();

        }
    }
 void Awake()
 {
     lightFootstepSound = transform.Find("LightFootstepSound").GetComponent<SoundSource>();
     heavyFootstepSound = transform.Find("HeavyFootstepSound").GetComponent<SoundSource>();
 }
示例#50
0
		protected override void Init()
		{
			soundSource = Node.CreateComponent<SoundSource>();
			soundSource.Gain = 0.1f;
		}
 public void SetContent(SoundSource source)
 {
     _shownSource = source;
 }
示例#52
0
 public virtual void SetSource(SoundSource source)
 {
 }
示例#53
0
		private static void PlaySound(ref int SoundSourceIndex, bool ReturnHandle, int SoundBufferIndex, TrainManager.Train Train, int CarIndex, World.Vector3D Position, Importance Important, bool Looped, double Pitch, double Gain) {
			if (OpenAlContext != IntPtr.Zero) {
				if (Game.MinimalisticSimulation & Important == Importance.DontCare | SoundBufferIndex == -1) {
					return;
				}
				if (SoundSourceIndex >= 0) {
					StopSound(ref SoundSourceIndex);
				}
				int i;
				for (i = 0; i < SoundSources.Length; i++) {
					if (SoundSources[i] == null) break;
				}
				if (i >= SoundSources.Length) {
					Array.Resize<SoundSource>(ref SoundSources, SoundSources.Length << 1);
				}
				SoundSources[i] = new SoundSource();
				SoundSources[i].Position = Position;
				SoundSources[i].OpenAlPosition = new float[] { 0.0f, 0.0f, 0.0f };
				SoundSources[i].OpenAlVelocity = new float[] { 0.0f, 0.0f, 0.0f };
				SoundSources[i].SoundBufferIndex = SoundBufferIndex;
				SoundSources[i].Radius = SoundBuffers[SoundBufferIndex].Radius;
				SoundSources[i].Pitch = (float)Pitch;
				SoundSources[i].Gain = (float)Gain;
				SoundSources[i].Looped = Looped;
				SoundSources[i].Suppressed = true;
				SoundSources[i].FinishedPlaying = false;
				SoundSources[i].Train = Train;
				SoundSources[i].CarIndex = CarIndex;
				SoundSources[i].OpenAlSourceIndex = new OpenAlIndex(0, false);
				SoundSources[i].HasHandle = ReturnHandle;
				SoundSourceIndex = i;
			}
		}
示例#54
0
        /// <summary>
        /// Plays a sound, looking it up by its shorthand name given in Load.
        /// </summary>
        /// <param name="name">
        /// The name of the sound to play.
        /// </param>
        public static SoundSource Play(String name)
        {
            name = name.ToLower();
            if (Sounds.ContainsKey(name))
            {
                SoundEffectInstance sound = Sounds[name].CreateInstance();
                sound.Volume = GameVolume;
                sound.Play();

                SoundSource source = new SoundSource(sound);
                SoundSources.Add(source);

                return source;
            }

            return null;
        }
示例#55
0
文件: Sounds.cs 项目: sladen/openbve
 // --- tests ---
 /// <summary>Checks whether the specified sound is playing or supposed to be playing.</summary>
 /// <param name="source">The sound source, or a null reference.</param>
 /// <returns>Whether the sound is playing or supposed to be playing.</returns>
 internal static bool IsPlaying(SoundSource source)
 {
     if (source != null) {
         if (source.State == SoundSourceState.PlayPending | source.State == SoundSourceState.Playing) {
             return true;
         }
     }
     return false;
 }
 public override void SetSource(SoundSource source)
 {
     base.SetSource (source);
 }
示例#57
0
文件: Sounds.cs 项目: sladen/openbve
 /// <summary>Plays a sound.</summary>
 /// <param name="buffer">The sound buffer.</param>
 /// <param name="pitch">The pitch change factor.</param>
 /// <param name="volume">The volume change factor.</param>
 /// <param name="position">The position. If a train and car are specified, the position is relative to the car, otherwise absolute.</param>
 /// <param name="train">The train the sound is attached to, or a null reference.</param>
 /// <param name="car">The car in the train the sound is attached to.</param>
 /// <param name="looped">Whether to play the sound in a loop.</param>
 /// <returns>The sound source.</returns>
 internal static SoundSource PlaySound(SoundBuffer buffer, double pitch, double volume, OpenBveApi.Math.Vector3 position, TrainManager.Train train, int car, bool looped)
 {
     if (Sources.Length == SourceCount) {
         Array.Resize<SoundSource>(ref Sources, Sources.Length << 1);
     }
     Sources[SourceCount] = new SoundSource(buffer, buffer.Radius, pitch, volume, position, train, car, looped);
     SourceCount++;
     return Sources[SourceCount - 1];
 }
示例#58
0
		// Update is called once per frame
	void Update (){
		Moves = movements;

		if (beginWireCounter != null) {
			float currentWireCount = beginWireCount - movements;
			beginWireCounter.GetComponent<Image> ().fillAmount = Mathf.Lerp (0.0f, 1.0f, currentWireCount/beginWireCount);
			beginWireCounter.GetComponentInChildren<TextMesh> ().text = currentWireCount.ToString ();
		}

		if (!isRunning) {
			return;
		} else {
			playerRay = Camera.main.ScreenPointToRay(Input.mousePosition);
			hits = Physics.RaycastAll(playerRay);
		}

		foreach (RaycastHit hit in hits) {
			if (hit.collider.tag == "GridCell") {
				currentRayCell = hit.transform;
				if (previousRayCell != currentRayCell) {
					rayCellChange = true;
					if (!clickMoving) {
						if (CheckForPair (hit)) {
							if (pairCell != null) {
								Destroy (beginWireCounter.gameObject);
							}
							pairCell = hit.transform.GetComponent<GridCell> ();
							GameObject newWireCounter = (GameObject)Instantiate (wirePairCounter, transform.position, transform.rotation);
							beginWireCounter = newWireCounter.transform;
							beginWireCounter.SetParent (pairCell.transform);
							beginWireCounter.localPosition = Vector3.zero;
							beginWireCounter.rotation = pairCell.transform.rotation;
							beginWireCounter.GetComponent<Image> ().color = pairCell.myPairColor;
							beginWireCounter.GetComponent<RectTransform> ().sizeDelta = pairCell.myPairSize * wireCounterScaleFactor;
							beginWireIngredient = pairCell.gridIngredient;
							beginWireCount = UIManager.GetMenu<Inventory> ().GetIngredientAmount (beginWireIngredient);
							CachedSoundManager.Play (pairHoverEffect);
							UIManager.GetMenu<PuzzleMenu> ().SetWireText (pairCell.gridIngredient, true);
						} else {
							if (pairCell != null) {
								Destroy (beginWireCounter.gameObject);
								pairCell = null;
							}
						}
					}
					if (previousRayCell != null) {
						UIManager.GetMenu<PuzzleMenu> ().SetWireText (previousRayCell.GetComponent<GridCell> ().gridIngredient, false);
					}
				} else {
					rayCellChange = false;
				}
			}
		}

//		if (gridLines == null || gridCells == null) {
//				return;
//		}
		if (Input.GetMouseButtonDown (0)) {
			RayCast (ClickType.Began);
        }
        else if (Input.GetMouseButtonUp (0)) {
			if (currentLine != null) {
				print (currentLine);
				Release (currentLine);
			}
            if (cachedSoundSource != null) CachedSoundManager.Stop(cachedSoundSource);
        }

		if (clickMoving) {
			RayCast (ClickType.Moved);
		}

		if (drawDraggingElement) {
			DrawDraggingElement (Input.mousePosition);
			if (cachedSoundSource == null) cachedSoundSource = CachedSoundManager.Play(lineDrawEffect);
		}
		previousRayCell = currentRayCell;
	}
示例#59
0
		/// <summary>Checks whether the specified sound is stopped or supposed to be stopped.</summary>
		/// <param name="source">The sound source, or a null reference.</param>
		/// <returns>Whether the sound is stopped or supposed to be stopped.</returns>
		internal static bool IsStopped(SoundSource source) {
			if (source == null)
				return false;
			return source.State == SoundSourceState.StopPending || source.State == SoundSourceState.Stopped;
		}
 public override void SetSource(SoundSource s)
 {
     source = s;
 }