private void OnLocalSoundAdded(object sender, Models.Sound e) { var s = _factory.GetSoundVm(e); Sounds.Add(s); UpdateItemPositions(); }
private async void OnLocalSoundAdded(object sender, Models.Sound e) { var s = _factory.GetSoundVm(e, Sounds.Count); Sounds.Add(s); await _player.AddToPlaylistAsync(e); }
/// <summary> /// Adds an event to the appropriate list for its type; returns the event. /// </summary> public Event Add(Event evnt) { switch (evnt) { case Event.Light e: Lights.Add(e); break; case Event.Sound e: Sounds.Add(e); break; case Event.SFX e: SFX.Add(e); break; case Event.Wind e: Wind.Add(e); break; case Event.Treasure e: Treasures.Add(e); break; case Event.Generator e: Generators.Add(e); break; case Event.Message e: Messages.Add(e); break; case Event.ObjAct e: ObjActs.Add(e); break; case Event.SpawnPoint e: SpawnPoints.Add(e); break; case Event.MapOffset e: MapOffsets.Add(e); break; case Event.Navmesh e: Navmeshes.Add(e); break; case Event.Environment e: Environments.Add(e); break; case Event.PseudoMultiplayer e: PseudoMultiplayers.Add(e); break; default: throw new ArgumentException($"Unrecognized type {evnt.GetType()}.", nameof(evnt)); } return(evnt); }
/// <summary> /// Adds a region to the appropriate list for its type; returns the region. /// </summary> public Region Add(Region region) { switch (region) { case Region.Region0 r: Region0s.Add(r); break; case Region.Light r: Lights.Add(r); break; case Region.StartPoint r: StartPoints.Add(r); break; case Region.Sound r: Sounds.Add(r); break; case Region.SFX r: SFXs.Add(r); break; case Region.Wind r: Winds.Add(r); break; case Region.EnvLight r: EnvLights.Add(r); break; case Region.Fog r: Fogs.Add(r); break; default: throw new ArgumentException($"Unrecognized type {region.GetType()}.", nameof(region)); } return(region); }
private void AddDictionary() { var image = GetImagesName; foreach (var i in image) { var folder = i.Key; var files = i.Value; var folderItem = GetFolderItem(folder); foreach (var file in files) { folderItem.Items.Add(GetFileItem(file, true)); } Images.Add(folderItem); } var sound = GetSoundsName; foreach (var i in sound) { var folder = i.Key; var files = i.Value; var folderItem = GetFolderItem(folder); foreach (var file in files) { folderItem.Items.Add(GetFileItem(file, false)); } Sounds.Add(folderItem); } }
// Called just once at the beginning of the game; used to set up // game objects, variables, etc. and prepare the game world. public override async Task Load() { // initialize our nice-looking retro text fonts Fonts = new Dictionary <string, Font> { ["small"] = await Graphics.NewFont("fonts/font.ttf", 8), ["medium"] = await Graphics.NewFont("fonts/font.ttf", 16), ["large"] = await Graphics.NewFont("fonts/font.ttf", 32) }; Graphics.SetFont(Fonts["small"]); // load up the graphics we'll be using throughout our states Textures = new Dictionary <string, Image> { ["background"] = await Graphics.NewImage("graphics/background.png"), ["main"] = await Graphics.NewImage("graphics/breakout.png"), ["arrows"] = await Graphics.NewImage("graphics/arrows.png"), ["hearts"] = await Graphics.NewImage("graphics/hearts.png"), ["particle"] = await Graphics.NewImage("graphics/particle.png") }; // Quads we will generate for all of our textures; Quads allow us // to show only part of a texture and not the entire thing var util = new Util(); Frames = new Dictionary <string, Quad[]> { ["arrows"] = util.GenerateQuads(Textures["arrows"], 24, 24), ["paddles"] = util.GenerateQuadsPaddles(Textures["main"]), ["balls"] = util.GenerateQuadsBalls(Textures["main"]), ["bricks"] = util.GenerateQuadsBricks(Textures["main"]), ["hearts"] = util.GenerateQuads(Textures["hearts"], 10, 9) }; // set up our sound effects; later, we can just index this table and // call each entry's `play` method Sounds.Add("paddle-hit", await Audio.NewSource("sounds/paddle_hit.wav")); Sounds.Add("score", await Audio.NewSource("sounds/score.wav")); Sounds.Add("wall-hit", await Audio.NewSource("sounds/wall_hit.wav")); Sounds.Add("confirm", await Audio.NewSource("sounds/confirm.wav")); Sounds.Add("select", await Audio.NewSource("sounds/select.wav")); Sounds.Add("no-select", await Audio.NewSource("sounds/no-select.wav")); Sounds.Add("brick-hit-1", await Audio.NewSource("sounds/brick-hit-1.wav")); Sounds.Add("brick-hit-2", await Audio.NewSource("sounds/brick-hit-2.wav")); Sounds.Add("hurt", await Audio.NewSource("sounds/hurt.wav")); Sounds.Add("victory", await Audio.NewSource("sounds/victory.wav")); Sounds.Add("recover", await Audio.NewSource("sounds/recover.wav")); Sounds.Add("high-score", await Audio.NewSource("sounds/high_score.wav")); Sounds.Add("pause", await Audio.NewSource("sounds/pause.wav")); Sounds.Add("music", await Audio.NewSource("sounds/music.wav")); await StateMachine.Change("start", new Dictionary <string, object> { ["highScores"] = await LoadHighScores() }); // play our music outside of all states and set it to looping Sounds["music"].Looping = true; await Sounds["music"].Play(); }
public virtual void ReadChildData(BinaryReader reader) { int x = 0; for (x = 0; (x < _oldMaterialsDONOTUSE.Count); x = (x + 1)) { OldMaterialsDONOTUSE.Add(new OldMaterialEffectMaterialBlockBlock()); OldMaterialsDONOTUSE[x].Read(reader); } for (x = 0; (x < _oldMaterialsDONOTUSE.Count); x = (x + 1)) { OldMaterialsDONOTUSE[x].ReadChildData(reader); } for (x = 0; (x < _sounds.Count); x = (x + 1)) { Sounds.Add(new MaterialEffectMaterialBlockBlock()); Sounds[x].Read(reader); } for (x = 0; (x < _sounds.Count); x = (x + 1)) { Sounds[x].ReadChildData(reader); } for (x = 0; (x < _effects.Count); x = (x + 1)) { Effects.Add(new MaterialEffectMaterialBlockBlock()); Effects[x].Read(reader); } for (x = 0; (x < _effects.Count); x = (x + 1)) { Effects[x].ReadChildData(reader); } }
public void AddSound(Sound sound) { lock (Sounds) { Sounds.Add(sound); } }
internal bool LoadSound(string name, string path) { if (!Sounds.ContainsKey(name)) { Sounds.Add(name, Load <SoundEffect>(path)); return(true); } return(false); }
/// <summary> /// 加载音频数据 /// </summary> /// <returns></returns> private void LoadSoud() { foreach (var key in m_LangInfo) { Sounds.Add(key.Key, key.Value.Voice.ToSoundEffect() ); } }
private void BackButton_OnClick(object sender, RoutedEventArgs e) { Sounds.Clear(); foreach (var item in SoundItemManager.GenerateSounds()) { Sounds.Add(item); } BackButton.Visibility = Visibility.Collapsed; }
public override void LoadContent(ContentManager content) { if (Texture == null) { Texture = content.Load <Texture2D>("Sprites/hvezda"); } SoundEffect snd = content.Load <SoundEffect>("Sounds/zvuk"); Sounds.Add(new Sound(GameScreen, this, snd)); }
public override void LoadContent(ContentManager content) { Texture = content.Load <Texture2D>("Sprites/sablona_persp"); Origin = new Vector2(100, 300); for (int i = 1; i < 5; i++) { SoundEffect snd = content.Load <SoundEffect>("Sounds/grass" + i); Sounds.Add(new Sound(GameScreen, this, snd, "grass" + i)); } }
public override async Task Load() { Sounds.Add("music", await Audio.NewSource("sounds/music3.mp3")); Sounds.Add("select", await Audio.NewSource("sounds/select.wav")); Sounds.Add("error", await Audio.NewSource("sounds/error.wav")); Sounds.Add("match", await Audio.NewSource("sounds/match.wav")); Sounds.Add("clock", await Audio.NewSource("sounds/clock.wav")); Sounds.Add("game-over", await Audio.NewSource("sounds/game-over.wav")); Sounds.Add("next-level", await Audio.NewSource("sounds/next-level.wav")); Textures = new Dictionary <string, Image> { ["main"] = await Graphics.NewImage("graphics/match3.png"), ["background"] = await Graphics.NewImage("graphics/background.png"), }; var util = new Util(); Frames = new Dictionary <string, Quad[][]> { // divided into sets for each tile type in this game, instead of one large // table of Quads ["tiles"] = util.GenerateTileQuads(Textures["main"]) }; // this time, we're keeping our fonts in a global table for readability Fonts = new Dictionary <string, Font> { ["small"] = await Graphics.NewFont("fonts/font.ttf", 8), ["medium"] = await Graphics.NewFont("fonts/font.ttf", 16), ["large"] = await Graphics.NewFont("fonts/font.ttf", 32) }; // set music to loop and start Sounds["music"].Looping = true; await Sounds["music"].Play(); Timer = new GameEngine.Timers.Timer(); // initialize state machine with all state-returning functions StateMachine = new StateMachine(new Dictionary <string, State> { ["start"] = new StartState(), ["begin-game"] = new BeginGameState(), ["play"] = new PlayState(), ["game-over"] = new GameOverState() }); await StateMachine.Change("start"); // keep track of scrolling our background on the X axis backgroundX = 0; }
void CheckTrigger(SoundTrigger trigger) { Logger.WriteLine(3, "Check trigger {0}", trigger); var sound = GameDef.GameSounds.SafeLookup(trigger); if (sound != null && !Sounds.Contains(sound)) { Sounds.Add(sound); VerboseLog("Sound {0} {1}", sound, trigger); } }
internal override Region ReadEntry(BinaryReaderEx br) { RegionType type = br.GetEnum8 <RegionType>(br.Position + 0xA); switch (type) { case RegionType.Region0: var region0 = new Region.Region0(br); Region0s.Add(region0); return(region0); case RegionType.Light: var light = new Region.Light(br); Lights.Add(light); return(light); case RegionType.StartPoint: var startPoint = new Region.StartPoint(br); StartPoints.Add(startPoint); return(startPoint); case RegionType.Sound: var sound = new Region.Sound(br); Sounds.Add(sound); return(sound); case RegionType.SFX: var sfx = new Region.SFX(br); SFXs.Add(sfx); return(sfx); case RegionType.Wind: var wind = new Region.Wind(br); Winds.Add(wind); return(wind); case RegionType.EnvLight: var envLight = new Region.EnvLight(br); EnvLights.Add(envLight); return(envLight); case RegionType.Fog: var fog = new Region.Fog(br); Fogs.Add(fog); return(fog); default: throw new NotImplementedException($"Unimplemented region type: {type}"); } }
private void MenuListView_OnItemClick(object sender, ItemClickEventArgs e) { var itemSelected = e.ClickedItem as MenuItem; if (itemSelected == null) { return; } Sounds.Clear(); foreach (var item in SoundItemManager.GenerateSounds(itemSelected.Category)) { Sounds.Add(item); } BackButton.Visibility = Visibility.Visible; }
public void Parse(XmlDocument contents) { XmlNode rootNode = contents.SelectSingleNode($"/{Constants.RootNodeName}"); Name = Utilities.GetAttributeValue(rootNode, "name"); foreach (XmlNode node in contents.SelectNodes($"/{Constants.RootNodeName}/{Constants.SoundNodeName}")) { try { Sounds.Add(new SoundFile(node)); } catch (Exception) { } } }
private void OnMapComplete(string mapname) { //everything needed was loaded, no need to keep the current cache //FileCache.Report(); FileCache.ClearAll(); //add sounds to playlist (and cache) foreach (var sound in world.sounds) { sounds.Add(sound, null); } Debug.Log(sounds.Count() + " sounds loaded"); if (WeatherEffect.HasMap(mapname)) { //create sky sky = new Sky(); //initialize clouds sky.Initialize(mapname); } else { //no weather effects, set sky color to blueish //Camera.main.backgroundColor = new Color(0.4f, 0.6f, 0.8f, 1.0f); } //add lights GameObject lightsParent = new GameObject("_lights"); lightsParent.transform.parent = mapParent.transform; foreach (var light in world.lights) { var lightObj = new GameObject(light.name); lightObj.transform.SetParent(lightsParent.transform); Light lightComponent = lightObj.AddComponent <Light>(); #if UNITY_EDITOR lightComponent.lightmapBakeType = LightmapBakeType.Baked; #endif lightComponent.color = new Color(light.color[0], light.color[1], light.color[2]); lightComponent.range = light.range; Vector3 position = new Vector3(light.pos[0] + width, -light.pos[1], light.pos[2] + height); lightObj.transform.position = position; } }
private void LoadElementsProjSpecific(XElement element, int parentTriggerIndex) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "leveltrigger": case "trigger": LoadElementsProjSpecific(subElement, LevelTriggerElements.IndexOf(subElement)); break; case "lightsource": LightSourceTriggerIndex.Add(parentTriggerIndex); LightSourceParams.Add(new LightSourceParams(subElement)); break; case "particleemitter": if (ParticleEmitterPrefabs == null) { ParticleEmitterPrefabs = new List <ParticleEmitterPrefab>(); EmitterPositions = new List <Vector2>(); ParticleEmitterTriggerIndex = new List <int>(); } ParticleEmitterPrefabs.Add(new ParticleEmitterPrefab(subElement)); ParticleEmitterTriggerIndex.Add(parentTriggerIndex); EmitterPositions.Add(subElement.GetAttributeVector2("position", Vector2.Zero)); break; case "sound": Sounds.Add(new SoundConfig(subElement, parentTriggerIndex)); break; case "deformablesprite": foreach (XElement deformElement in subElement.Elements()) { var deformation = SpriteDeformation.Load(deformElement, Name); if (deformation != null) { SpriteDeformations.Add(deformation); } } break; } } }
static Sound TryGet(IntPtr soundPtr) { if (soundPtr == IntPtr.Zero) { return(null); } var sound = Sounds.FirstOrDefault(x => x.Handle == soundPtr); if (sound == null) { sound = new Sound(soundPtr); Sounds.Add(sound); } return(sound); }
public void Read(Stream stream) { BinaryReader br = new BinaryReader(stream); long lastOffset; while (stream.Position < stream.Length) { byte type = br.ReadByte(); lastOffset = stream.Position; int chunkLen = br.ReadInt32(); switch (type) { case 5: Doors.Add(PageIO.ReadDoor(br)); break; case 7: Sounds.Add(PageIO.ReadSound(br)); break; case 9: Gamefiles.Add(PageIO.ReadGamefile(br)); break; case 1: case 2: case 6: case 8: case 10: case 0: stream.Seek(chunkLen - 4, SeekOrigin.Current); break; default: throw new InvalidDataException(string.Format("Chunk at offset {0} specified unknown type {1}", lastOffset - 1, type)); } //Diagnostics if (stream.Position - lastOffset != chunkLen) { throw new InvalidDataException(string.Format("Chunk type {3} at offset {0} specified {1} bytes, but read {2}", lastOffset - 1, chunkLen, stream.Position - lastOffset, type)); } } }
/// <summary> /// Adds a region to the appropriate list for its type; returns the region. /// </summary> public Region Add(Region region) { switch (region) { case Region.InvasionPoint r: InvasionPoints.Add(r); break; case Region.EnvironmentMapPoint r: EnvironmentMapPoints.Add(r); break; case Region.Sound r: Sounds.Add(r); break; case Region.SFX r: SFX.Add(r); break; case Region.WindSFX r: WindSFX.Add(r); break; case Region.SpawnPoint r: SpawnPoints.Add(r); break; case Region.Message r: Messages.Add(r); break; case Region.PatrolRoute r: PatrolRoutes.Add(r); break; case Region.MovementPoint r: MovementPoints.Add(r); break; case Region.WarpPoint r: WarpPoints.Add(r); break; case Region.ActivationArea r: ActivationAreas.Add(r); break; case Region.Event r: Events.Add(r); break; case Region.Logic r: Logic.Add(r); break; case Region.EnvironmentMapEffectBox r: EnvironmentMapEffectBoxes.Add(r); break; case Region.WindArea r: WindAreas.Add(r); break; case Region.MufflingBox r: MufflingBoxes.Add(r); break; case Region.MufflingPortal r: MufflingPortals.Add(r); break; case Region.Other r: Others.Add(r); break; default: throw new ArgumentException($"Unrecognized type {region.GetType()}.", nameof(region)); } return(region); }
private void PlaySoundFromBuffer(string soundType, SoundBuffer soundbuffer, Vector2f position) { ClearSounds(); float soundDistance = position.ManhattanDistance(GamestateManager.Instance.Player.Position / 64); float volume = Math.Min(20 * 1 / (soundDistance == 0 ? 1 : soundDistance), 20) * ((soundType == "move") ? 0.25F : 1); if (volume > 0.25) { Sound newSound = new Sound(soundbuffer) { Volume = volume }; newSound.Play(); Sounds.Add(newSound); } }
public override async Task Load() { // set love's default filter to "nearest-neighbor", which essentially // means there will be no filtering of pixels(blurriness), which is // important for a nice crisp, 2D look // love.graphics.setDefaultFilter('nearest', 'nearest') // love.window.setTitle('Pong') // initialize our nice-looking retro text fonts smallFont = await Graphics.NewFont("font.ttf", 8); largeFont = await Graphics.NewFont("font.ttf", 16); scoreFont = await Graphics.NewFont("font.ttf", 32); Graphics.SetFont(smallFont); // Sounds Sounds.Add("paddle_hit", await Audio.NewSource("sounds/paddle_hit.wav")); Sounds.Add("score", await Audio.NewSource("sounds/score.wav")); Sounds.Add("wall_hit", await Audio.NewSource("sounds/wall_hit.wav")); // initialize our player paddles; make them global so that they can be // detected by other functions and modules player1 = new Paddle(10, 30, 5, 20); player2 = new Paddle(VirtualWidth - 10, VirtualHeight - 30, 5, 20); // place a ball in the middle of the screen ball = new Ball(VirtualWidth / 2 - 2, VirtualHeight / 2 - 2, 4, 4); // initialize score variables player1Score = 0; player2Score = 0; // either going to be 1 or 2; whomever is scored on gets to serve the // following turn servingPlayer = 1; // player who won the game; not set to a proper value until we reach // that state in the game winningPlayer = 0; gameState = GameState.Start; }
private void DoOpenPlaylist(object obj) { if (!string.IsNullOrEmpty(SelectedPlaylist.Path)) { var soundList = new List <Sound>(); var allFiles = File.ReadAllLines(SelectedPlaylist.Path); for (int i = 0; i < allFiles.Length - 1; i = i + 2) { soundList.Add(new Sound() { Path = allFiles[i], Name = allFiles[i + 1] }); } Sounds.Clear(); soundList.ForEach(c => Sounds.Add(c)); SetDefaultPlaylist(SelectedPlaylist.Path); } }
public void Add(IMsbRegion item) { switch (item) { case Region.Region0 r: Region0s.Add(r); break; case Region.Light r: Lights.Add(r); break; case Region.StartPoint r: StartPoints.Add(r); break; case Region.Sound r: Sounds.Add(r); break; case Region.SFX r: SFXs.Add(r); break; case Region.Wind r: Winds.Add(r); break; case Region.EnvLight r: EnvLights.Add(r); break; case Region.Fog r: Fogs.Add(r); break; default: throw new ArgumentException( message: "Item is not recognized", paramName: nameof(item)); } }
//Fills ObservableCollection<Sound> Sounds with files found in directory pointed by dirPath. private void FillSoundsDirectory(string dirPath) { if (!string.IsNullOrEmpty(dirPath)) { var allFiles = Directory.GetFiles(dirPath); var soundList = new List <Sound>(); foreach (var file in allFiles) { var pathExtension = Path.GetExtension(file); if (pathExtension?.ToUpper() == ".MP3") { soundList.Add(new Sound() { Name = Path.GetFileNameWithoutExtension(file), Path = file }); } } Sounds.Clear(); soundList.ForEach(c => Sounds.Add(c)); } }
public static async void PlaySound(SoundManagerSounds sound, bool oneatatime = false, bool excludefrommute = false) { if (MuteAllSounds && !excludefrommute) { return; } if (oneatatime) { if (Sounds.Any(a => a.SoundName == sound && a.IsPlaying)) { return; } } var options = new HowlOptions { Sources = new[] { "/Assets/sounds/" + Enum.GetName(typeof(SoundManagerSounds), sound) + ".mp3" }, Formats = new[] { "mp3" } }; var soundid = await Howl.Play(options); if (!Sounds.Any(a => a.SoundName == sound)) { Sounds.Add(new Sound() { SoundId = soundid, SoundName = sound, IsPlaying = true }); } else { Sounds.FirstOrDefault(a => a.SoundName == sound).SoundId = soundid; Sounds.FirstOrDefault(a => a.SoundName == sound).IsPlaying = true; } }
public void Sound_Load(Stream _s) { int num = _s.ReadInteger(); int num2 = _s.ReadInteger(); for (int i = 0; i < num2; i++) { Stream s = _s; if (num == 800) { s = _s.ReadStreamC(); } bool flag = s.ReadBoolean(); KeyValuePair <string, GMSound> item = default(KeyValuePair <string, GMSound>); if (flag) { string key = s.ReadString(); GMSound value = new GMSound(this, s); item = new KeyValuePair <string, GMSound>(key, value); } Sounds.Add(item); } }