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; } }
private Action PlayAudioClip(IAudioClip clip) { return(() => { audioSystem.PlayAudio(clip); // ModLog.Info("PlayAudioClip(" + clip.Filename + ")"); }); }
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; }
public void QueueAudioMessageOnAllClients(IAudioClip audioClip) { SendMessageToAllClients(new Message { MessageType = MessageType.PlaySound, AudioClipId = audioClip.Id }); }
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); }
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); }
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); }
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); }
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); }
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 }
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; }
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 }
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); }
public static UnityEngine.AudioClip ToUnity(this IAudioClip c) { return((c as UnityAudioClip).AudioClip); }
public QueuedClip(IAudioClip clip, TaskCompletionSource <bool> taskCompletion) { Clip = clip; TaskCompletion = taskCompletion; }
public OpenAudioClipSamplesWrapper(IAudioClip clip, T upstream) { Clip = clip; _upstream = upstream; }
protected Action PlayAudioClip(IAudioClip clip) { return(() => { audioSystem.PlayAudio(clip); }); }
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)); }
public void loopSound(IAudioClip clip) { source.loop = true; source.clip = clip.ToUnity(); source.Play(); }
public void playOneShot(IAudioClip clip) { source.PlayOneShot(clip.ToUnity()); }
public AGSSpeechLine(IAudioClip audioClip, string text) { AudioClip = audioClip; Text = text; }
public AGSSpeechLine(IAudioClip audioClip, string text) { AudioClip = audioClip; audioClip?.Tags.Add(SpeechTag); Text = text; }