Пример #1
0
        public OpenAudioClipWaveWrapper(IAudioClip clip, T upstream)
        {
            Clip = clip;

            _upstream = upstream;
            _samples  = _upstream.ToSampleProvider();
        }
        public void EnsurePlaying(IAudioClip clip)
        {
            if (currentlyPlaying != null && currentlyPlaying.Id == clip.Id)
            {
                return;
            }

            var player = MyAPIGateway.Session.Player;
            var ent    = player?.Controller?.ControlledEntity?.Entity;

            if (ent != null)
            {
                if (playerEntityId2 != ent.EntityId)
                {
                    if (interruptingSoundEmitter != null)
                    {
                        interruptingSoundEmitter.StopSound(true);
                    }

                    interruptingSoundEmitter = new MyEntity3DSoundEmitter(ent as VRage.Game.Entity.MyEntity);
                    playerEntityId2          = ent.EntityId;
                }

                var soundPair = new MySoundPair(clip.Filename);
                interruptingSoundEmitter.StopSound(true);
                interruptingSoundEmitter.PlaySingleSound(soundPair);
                currentlyPlaying = clip;
            }
        }
Пример #3
0
        private Action PlayAudioClip(IAudioClip clip)
        {
            return(() => {
                audioSystem.PlayAudio(clip);
//                ModLog.Info("PlayAudioClip(" + clip.Filename + ")");
            });
        }
Пример #4
0
 public void PlayAudioRandomChance(double probability, IAudioClip audioClip)
 {
     if (probability > 0.99 || probability <= random.NextDouble())
     {
         PlayAudio(audioClip);
     }
 }
 public void Stop()
 {
     if (interruptingSoundEmitter != null)
     {
         interruptingSoundEmitter.StopSound(true);
     }
     currentlyPlaying = null;
 }
Пример #6
0
 public void QueueAudioMessageOnAllClients(IAudioClip audioClip)
 {
     SendMessageToAllClients(new Message
     {
         MessageType = MessageType.PlaySound,
         AudioClipId = audioClip.Id
     });
 }
Пример #7
0
        public void PlayAudio(IAudioClip clip)
        {
            if (timeUntilNextAudioSeconds > 0)
            {
                waitingClips.Enqueue(clip);
            }
            else
            {
                PlayClip(clip);
            }

            // Play message to other clients if we are the server
            AudioRelay?.QueueAudioMessageOnAllClients(clip);
        }
Пример #8
0
        public async Task <IRoom> LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory factory = game.Factory;

            _bottleEffectClip = await factory.Sound.LoadAudioClipAsync("../../Assets/Sounds/254818__kwahmah-02__rattling-glass-bottles-impact.wav");

            ILoadImageConfig loadConfig = new AGSLoadImageConfig(new AGS.API.Point(0, 0));

            _room             = factory.Room.GetRoom(_roomId, 20f, 310f, 190f, 10f);
            _room.MusicOnLoad = await factory.Sound.LoadAudioClipAsync("../../Assets/Sounds/AMemoryAway.ogg");

            _game.Events.OnSavedGameLoad.Subscribe((sender, e) => onSavedGameLoaded());

            IObject bg = factory.Object.GetObject("Empty Street BG");

            bg.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bg.png");

            _room.Background = bg;

            var           device     = AGSGame.Device;
            AGSMaskLoader maskLoader = new AGSMaskLoader(factory, new ResourceLoader(device.FileSystem, device.Assemblies), device.BitmapLoader);

            _room.Areas.Add(AGSWalkableArea.Create("EmptyStreetWalkable1", await maskLoader.LoadAsync(_baseFolder + "walkable1.png")));
            _room.Areas.Add(AGSWalkableArea.Create("EmptyStreetWalkable2", await maskLoader.LoadAsync(_baseFolder + "walkable2.png")));
            AGSScalingArea.Create(_room.Areas[0], 0.50f, 0.75f);
            AGSScalingArea.Create(_room.Areas[1], 0.75f, 0.90f);

            IObject bottleHotspot = await factory.Object.GetHotspotAsync(_baseFolder + "BottleHotspot.png", "Bottle");

            bottleHotspot.WalkPoint = new AGS.API.PointF(140f, 50f);
            _room.Objects.Add(await factory.Object.GetHotspotAsync(_baseFolder + "CurbHotspot.png", "Curb"));
            _room.Objects.Add(bottleHotspot);
            _room.Objects.Add(await factory.Object.GetHotspotAsync(_baseFolder + "GapHotspot.png", "Gap", new[] { "It's a gap!", "I wonder what's in there!" }));

            _bottle       = factory.Object.GetObject(_bottleId);
            _bottle.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bottle.bmp", loadConfig : loadConfig);

            _bottle.WalkPoint = bottleHotspot.WalkPoint;
            _bottle.X         = 185f;
            _bottle.Y         = 85f;
            _bottle.Hotspot   = "Bottle";
            _room.Objects.Add(_bottle);

            subscribeEvents();

            return(_room);
        }
Пример #9
0
        public async Task <IRoom> LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory factory = game.Factory;

            _bottleEffectClip = await factory.Sound.LoadAudioClipAsync("../../Assets/Sounds/254818__kwahmah-02__rattling-glass-bottles-impact.wav");

            ILoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0));

            _room             = factory.Room.GetRoom(_roomId, 20f, 310f, 190f, 10f);
            _room.MusicOnLoad = await factory.Sound.LoadAudioClipAsync("../../Assets/Sounds/AMemoryAway.ogg");

            _game.Events.OnSavedGameLoad.Subscribe(onSavedGameLoaded);

            IObject bg = factory.Object.GetObject("Empty Street BG");

            bg.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bg.png");

            _room.Background = bg;

            var device = AGSGame.Device;

            _room.Areas.Add(await factory.Room.GetAreaAsync(_baseFolder + "walkable1.png", isWalkable: true));
            _room.Areas.Add(await factory.Room.GetAreaAsync(_baseFolder + "walkable2.png", isWalkable: true));
            factory.Room.CreateScaleArea(_room.Areas[0], 0.50f, 0.75f);
            factory.Room.CreateScaleArea(_room.Areas[1], 0.75f, 0.90f);

            IObject bottleHotspot = await factory.Object.GetHotspotAsync(_baseFolder + "BottleHotspot.png", "Bottle");

            bottleHotspot.GetComponent <IHotspotComponent>().WalkPoint = new PointF(140f, 50f);
            _room.Objects.Add(await factory.Object.GetHotspotAsync(_baseFolder + "CurbHotspot.png", "Curb"));
            _room.Objects.Add(bottleHotspot);
            _room.Objects.Add(await factory.Object.GetHotspotAsync(_baseFolder + "GapHotspot.png", "Gap", new[] { "It's a gap!", "I wonder what's in there!" }));

            _bottle       = factory.Object.GetAdventureObject(_bottleId);
            _bottle.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bottle.bmp", loadConfig : loadConfig);

            _bottle.GetComponent <IHotspotComponent>().WalkPoint = bottleHotspot.GetComponent <IHotspotComponent>().WalkPoint;
            _bottle.X           = 185f;
            _bottle.Y           = 85f;
            _bottle.DisplayName = "Bottle";
            _room.Objects.Add(_bottle);

            subscribeEvents();

            return(_room);
        }
Пример #10
0
        protected override async Task <IRoom> loadAsync()
        {
            clearRoom();

            IGameFactory factory = _game.Factory;

            _room = factory.Room.GetRoom(ROOM_ID);
            _room.RoomLimitsProvider = AGSRoomLimits.FromBackground;

            _music = await factory.Sound.LoadAudioClipAsync(LF.MusicAssetFolder + "Welcome_to_the_Show.ogg");

            _room.Events.OnBeforeFadeIn.Subscribe(onLoad);
            _room.Events.OnAfterFadeIn.Subscribe(onAfterFadeIn);
            _room.Events.OnAfterFadeOut.Subscribe(onLeave);

            _track = await TrackLoader.LoadAsync(_roomAssetFolder + "track01.ini", _roomAssetFolder, _game.Factory.Graphics);

            _race = new Race(_game, _room, _track);

            _room.Background = addObject("RaceRoom.BG", _track.Background);

            // TODO: move to track config
            _startingGrid    = new Vector2[Race.MAX_RACING_CARS];
            _startingGrid[0] = compatVector(1140, 326 + 12);
            _startingGrid[1] = compatVector(1172, 273 + 12);
            _startingGrid[2] = compatVector(1204, 326 + 12);
            _startingGrid[3] = compatVector(1236, 273 + 12);
            _startingGrid[4] = compatVector(1268, 326 + 12);
            _startingGrid[5] = compatVector(1300, 273 + 12);
            Vector2 p1 = compatVector(1104, 399);
            Vector2 p2 = compatVector(1119, 190);

            _lapTestRegion = new Vecregion(p1, p2);

            // Create Ai controllers supported by this track
            if (_track.AiData.AIRegionMask != null && _track.AiData.AIRegionAngles != null)
            {
                _aiRegionBased = new AIRegionBased(_game, _track.AiData.AIRegionMask, _track.AiData.AIRegionAngles);
            }
            if (_track.AiData.AIPathNodes != null)
            {
                _aiPathBased = new AIPathBase(_game, _track.AiData.AIPathNodes);
            }

            _viewMan = new ViewportManager(_game.State);
            return(_room);
        }
Пример #11
0
        public async Task <IRoom> LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory factory = game.Factory;

            _bottleEffectClip = await factory.Sound.LoadAudioClipAsync("Sounds/254818__kwahmah-02__rattling-glass-bottles-impact.wav");

            ILoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0));

            _room             = factory.Room.GetRoom(_roomId, 20f, 310f, 190f, 10f);
            _room.MusicOnLoad = await factory.Sound.LoadAudioClipAsync("Sounds/AMemoryAway.ogg");

            _game.Events.OnSavedGameLoad.Subscribe(onSavedGameLoaded);

            IObject bg = factory.Object.GetObject("Empty Street BG");

            bg.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bg.png");

            _room.Background = bg;

            await factory.Room.GetAreaAsync(_baseFolder + "walkable1.png", _room, isWalkable : true);

            await factory.Room.GetAreaAsync(_baseFolder + "walkable2.png", _room, isWalkable : true);

            factory.Room.CreateScaleArea(_room.Areas[0], 0.50f, 0.75f);
            factory.Room.CreateScaleArea(_room.Areas[1], 0.75f, 0.90f);

            IObject bottleHotspot = await factory.Object.GetHotspotAsync(_baseFolder + "BottleHotspot.png", "Bottle", _room);

            bottleHotspot.GetComponent <IHotspotComponent>().WalkPoint = (140f, 50f);
            await factory.Object.GetHotspotAsync(_baseFolder + "CurbHotspot.png", "Curb", _room, new[] { "I have something long and very important to say about this curb, and about how much this curb means to me!" });

            await factory.Object.GetHotspotAsync(_baseFolder + "GapHotspot.png", "Gap", _room, new[] { "It's a gap!", "I wonder what's in there!" });

            _bottle       = factory.Object.GetAdventureObject(_bottleId, _room);
            _bottle.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bottle.bmp", loadConfig : loadConfig);

            _bottle.GetComponent <IHotspotComponent>().WalkPoint = bottleHotspot.GetComponent <IHotspotComponent>().WalkPoint;
            _bottle.Position    = (185f, 85f);
            _bottle.DisplayName = "Bottle";

            subscribeEvents();

            return(_room);
        }
Пример #12
0
        private void PlayClip(IAudioClip clip)
        {
            var player = MyAPIGateway.Session.Player;
            var ent    = player?.Controller?.ControlledEntity?.Entity;

            if (ent != null)
            {
                if (playerEntityId != ent.EntityId)
                {
                    if (localPlayerSoundEmitter != null)                     // Player has died and lost their old sound emitter
                    {
                        localPlayerSoundEmitter.StopSound(true);
                    }

                    localPlayerSoundEmitter = new MyEntity3DSoundEmitter(ent as VRage.Game.Entity.MyEntity);
                    playerEntityId          = ent.EntityId;
                }
                string audiofile = clip.Filename;
                if (!string.IsNullOrWhiteSpace(audiofile))
                {
                    var soundPair = new MySoundPair(audiofile);
                    localPlayerSoundEmitter.StopSound(true);
                    localPlayerSoundEmitter.PlaySingleSound(soundPair);
                }
            }

            // Added V22
            //MyAPIGateway.Multiplayer.MultiplayerActive
            if (MyAPIGateway.Multiplayer.IsServer)
            {
                //            MyVisualScriptLogicProvider.SendChatMessage(clip.Subtitle, clip.Speaker, 0, clip.Font);
                string[] aLines = clip.Subtitle.Split('\n');
                foreach (var line in aLines)
                {
                    if (!string.IsNullOrEmpty(line))
                    {
                        MyVisualScriptLogicProvider.SendChatMessage(line, clip.Speaker, 0, clip.Font);
                    }
                }
            }
            // chat, notifications, billboards... Bad on DS.
            // The following should NOT be done on  DS because nowhere to show it..
            MyAPIGateway.Utilities.ShowNotification(clip.Speaker + ": " + clip.Subtitle, clip.DisappearTimeMs, clip.Font);
            timeUntilNextAudioSeconds = clip.DisappearTimeMs / 1000 + 2; // Add a little 2 second pause between them
        }
Пример #13
0
		public async Task<IRoom> LoadAsync(IGame game)
		{
			_game = game;
			IGameFactory factory = game.Factory;
			_bottleEffectClip = await factory.Sound.LoadAudioClipAsync("../../Assets/Sounds/254818__kwahmah-02__rattling-glass-bottles-impact.wav");

            ILoadImageConfig loadConfig = new AGSLoadImageConfig(new AGS.API.Point(0, 0));
			_room = factory.Room.GetRoom(_roomId, 20f, 310f, 190f, 10f);
			_room.MusicOnLoad = await factory.Sound.LoadAudioClipAsync("../../Assets/Sounds/AMemoryAway.ogg");

			_game.Events.OnSavedGameLoad.Subscribe((sender, e) => onSavedGameLoaded());

			IObject bg = factory.Object.GetObject("Empty Street BG");
			bg.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bg.png");
			_room.Background = bg;

			AGSMaskLoader maskLoader = new AGSMaskLoader (factory, new ResourceLoader());
            _room.Areas.Add(AGSWalkableArea.Create("EmptyStreetWalkable1", await maskLoader.LoadAsync(_baseFolder + "walkable1.png")));
            _room.Areas.Add(AGSWalkableArea.Create("EmptyStreetWalkable2", await maskLoader.LoadAsync (_baseFolder + "walkable2.png")));
			AGSScalingArea.Create(_room.Areas[0], 0.50f, 0.75f);
			AGSScalingArea.Create(_room.Areas[1], 0.75f, 0.90f);

			IObject bottleHotspot = await factory.Object.GetHotspotAsync(_baseFolder + "BottleHotspot.png", "Bottle");
			bottleHotspot.WalkPoint = new AGS.API.PointF (140f, 50f);
			_room.Objects.Add(await factory.Object.GetHotspotAsync (_baseFolder + "CurbHotspot.png", "Curb"));
			_room.Objects.Add(bottleHotspot);
			_room.Objects.Add(await factory.Object.GetHotspotAsync (_baseFolder + "GapHotspot.png", "Gap", new[]{"It's a gap!", "I wonder what's in there!"}));

			_bottle = factory.Object.GetObject(_bottleId);
			_bottle.Image = await factory.Graphics.LoadImageAsync(_baseFolder + "bottle.bmp", loadConfig: loadConfig);
			_bottle.WalkPoint = bottleHotspot.WalkPoint;
			_bottle.X = 185f;
			_bottle.Y = 85f;
			_bottle.Hotspot = "Bottle";
			_room.Objects.Add(_bottle);

			subscribeEvents();

			return _room;
		}
Пример #14
0
        private void PlayClip(IAudioClip clip)
        {
            var player = MyAPIGateway.Session.Player;
            var ent    = player?.Controller?.ControlledEntity?.Entity;

            if (ent != null)
            {
                if (playerEntityId != ent.EntityId)
                {
                    if (localPlayerSoundEmitter != null)                     // Player has died and lost their old sound emitter
                    {
                        localPlayerSoundEmitter.StopSound(true);
                    }

                    localPlayerSoundEmitter = new MyEntity3DSoundEmitter(ent as VRage.Game.Entity.MyEntity);
                    playerEntityId          = ent.EntityId;
                }
                var soundPair = new MySoundPair(clip.Filename);
                localPlayerSoundEmitter.StopSound(true);
                localPlayerSoundEmitter.PlaySingleSound(soundPair);
            }
            MyAPIGateway.Utilities.ShowNotification(clip.Speaker + ": " + clip.Subtitle, clip.DisappearTimeMs, clip.Font);
            timeUntilNextAudioSeconds = clip.DisappearTimeMs / 1000 + 2;             // Add a little 2 second pause between them
        }
Пример #15
0
        protected override async Task <IRoom> loadAsync()
        {
            IGameFactory factory = _game.Factory;

            _room            = factory.Room.GetRoom(ROOM_ID);
            _room.Background = await addObject("TitleScreen.BG", "gradiented-title.png", 0, -80);

            // TODO: label with the game version number in the corner of the title screen
            var label = factory.UI.GetLabel("VersionLabel", LF.GAME_VERSION, 0, 0, 0, 0, addToUi: false);

            label.TextConfig.Font    = AGSGameSettings.DefaultTextFont;
            label.TextConfig.AutoFit = AutoFit.LabelShouldFitText;
            _room.Objects.Add(label);

            _room.RoomLimitsProvider = AGSRoomLimits.FromBackground;

            _music = await factory.Sound.LoadAudioClipAsync(LF.MusicAssetFolder + "Car-Theft-101.ogg");

            _room.Events.OnBeforeFadeIn.Subscribe(onLoad);
            _room.Events.OnAfterFadeIn.Subscribe(onAfterFadeIn);
            _room.Events.OnAfterFadeOut.Subscribe(onLeave);

            return(_room);
        }
Пример #16
0
 public static UnityEngine.AudioClip ToUnity(this IAudioClip c)
 {
     return((c as UnityAudioClip).AudioClip);
 }
Пример #17
0
 public QueuedClip(IAudioClip clip, TaskCompletionSource <bool> taskCompletion)
 {
     Clip           = clip;
     TaskCompletion = taskCompletion;
 }
Пример #18
0
 public OpenAudioClipSamplesWrapper(IAudioClip clip, T upstream)
 {
     Clip      = clip;
     _upstream = upstream;
 }
Пример #19
0
 protected Action PlayAudioClip(IAudioClip clip)
 {
     return(() => { audioSystem.PlayAudio(clip); });
 }
Пример #20
0
        protected async Task <ITaggedAudioClip> loadClip(string filename, string tag)
        {
            IAudioClip clip = await _game.Factory.Sound.LoadAudioClipAsync(AMG.MusicAssetFolder + filename, filename);

            return(_mlib.AddClip(clip, tag));
        }
Пример #21
0
 public void loopSound(IAudioClip clip)
 {
     source.loop = true;
     source.clip = clip.ToUnity();
     source.Play();
 }
Пример #22
0
 public void playOneShot(IAudioClip clip)
 {
     source.PlayOneShot(clip.ToUnity());
 }
Пример #23
0
 public AGSSpeechLine(IAudioClip audioClip, string text)
 {
     AudioClip = audioClip;
     Text = text;
 }
Пример #24
0
 public AGSSpeechLine(IAudioClip audioClip, string text)
 {
     AudioClip = audioClip;
     audioClip?.Tags.Add(SpeechTag);
     Text = text;
 }
Пример #25
0
 public void loopSound(IAudioClip clip)
 {
     source.loop = true;
     source.clip = clip.ToUnity();
     source.Play();
 }
Пример #26
0
 public void playOneShot(IAudioClip clip)
 {
     source.PlayOneShot(clip.ToUnity());
 }
Пример #27
0
 public AGSSpeechLine(IAudioClip audioClip, string text)
 {
     AudioClip = audioClip;
     Text      = text;
 }