void HomeUnderMenu_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.L)) { operated = true; mode--; if (mode < 0) { mode = ModeArray[ModeArray.Length - 1]; } OnModeChanged(mode); sound.Play(PPDSetting.DefaultSounds[3], -1000); drawCount = 0; } else if (args.InputInfo.IsPressed(ButtonType.R)) { operated = true; mode++; if ((int)mode >= ModeArray.Length) { mode = ModeArray[0]; } OnModeChanged(mode); sound.Play(PPDSetting.DefaultSounds[3], -1000); drawCount = 0; } }
void SlideSprite_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.Up)) { if (selectCount > 0) { currentIndex--; if (currentIndex < 0) { currentIndex = textSprite.ChildrenCount - 1; } while (!menuEnabled[currentIndex]) { currentIndex--; if (currentIndex < 0) { currentIndex = textSprite.ChildrenCount - 1; } } sound.Play(PPDSetting.DefaultSounds[0], -1000); } } else if (args.InputInfo.IsPressed(ButtonType.Down)) { if (selectCount > 0) { currentIndex++; if (currentIndex >= textSprite.ChildrenCount) { currentIndex = 0; } while (!menuEnabled[currentIndex]) { currentIndex++; if (currentIndex >= textSprite.ChildrenCount) { currentIndex = 0; } } sound.Play(PPDSetting.DefaultSounds[0], -1000); } } else if (args.InputInfo.IsPressed(ButtonType.Circle)) { if (selectCount > 0) { if (Selected != null) { Selected.Invoke(this, EventArgs.Empty); } } } else if (args.InputInfo.IsPressed(ButtonType.Cross)) { if (FocusManager != null && !FirstSlide) { FocusManager.RemoveFocus(); } } }
/// <summary> /// Test1: Minigun playback simulation from FSM. /// </summary> public void TestMinigunPlayback() { sndStart.Play(); while (sndStart.Playing()) { } sndFire.Play(); while (sndFire.Playing()) { } sndStop.Play(); while (sndStop.Playing()) { } sndStart.Play(); while (sndStart.Playing()) { } sndFire.Play(); while (sndFire.Playing()) { } // No more ammo sndAmmo.Play(); while (sndAmmo.Playing()) { } // Stop minigun sndStop.Play(); while (sndStop.Playing()) { } // Reload ammo sndReload.Play(); while (sndReload.Playing()) { } // More fun .... sndStart.Play(); while (sndStart.Playing()) { } sndFire.Play(); while (sndFire.Playing()) { } sndStop.Play(); while (sndStop.Playing()) { } }
public override void OnLeftMeleeAttack(Scene scene, int damage) { if (!(Weapon is MeleeWeapon meleeWeapon) || meleeWeapon.State != MeleeWeaponState.BlockLeft) { DoHit(scene, damage); return; } defenceSound.Play(0); scene.EventsLogger.SuccessfullyDefence("Игрок"); }
/// <summary> /// Execute this action in the given context. /// </summary> public override void Execute(IActionContext context) { if (sound != null) { sound.Play(); } }
public BasicProjectile(ICanyonShooterGame game, Vector3 startPos, Vector3 direction, string soundName, WeaponHolderType weaponHolderType) : base(game) { if (game != null) { this.game = game; } else { throw new Exception("game can't be null!"); } ConnectedToXpa = true; if (weaponHolderType == WeaponHolderType.Player) { ContactGroup = ContactGroup.PlayerProjectiles; } if (weaponHolderType == WeaponHolderType.Enemy) { ContactGroup = ContactGroup.EnemyProjectiles; } Direction = direction; LocalPosition = startPos; FromPosition = startPos; if (soundName != String.Empty || soundName != "") { sound = game.Sounds.CreateSound(soundName); sound.Play(); } }
/// <summary> /// Load the player contents like model, weapons, ... /// </summary> protected override void LoadContent() { base.LoadContent(); Model.AfterBurnerLength = minBooster; //Initialize WeaponManager if (Weapons == null) { Weapons = new WeaponManager(game, Model, WeaponHolderType.Player); // Equip standard weapons: Weapons.AddWeapon(WeaponType.MINIGUN); Weapons.AddWeapon(WeaponType.MINIGUN2); Weapons.AddWeapon(WeaponType.ULTRA_PHASER); Weapons.AddWeapon(WeaponType.ROCKET_STINGER); Weapons.SetPrimaryWeapon(WeaponType.ULTRA_PHASER); Weapons.SetSecondaryWeapon(WeaponType.ROCKET_STINGER); } else { Weapons.WeaponHolder = Model; } // Helicopter animation hack modelAnimationPart = Model.GetMesh("Rotor"); if (modelAnimationPart != null) { meshSoundEfx = game.Sounds.CreateSound("Heli"); meshSoundEfx.Play(); modelAnimationPart.PlayRotationAnimation(); } // ------------------------------------- }
private void GiveStuff(IPlayer player) { if (player is Player2) { switch (desc.ItemType.ToUpper()) { case "WEAPON": GiveWeapon(player); Intercom.GiveWeapon(); break; case "AMMO": GiveAmmo(player); Intercom.GiveAmmo(); break; case "PLAYER": GivePlayerItem(player); break; default: break; } } game.GameStates.Hud.DisplayScrollingText(desc.ItemType.ToUpper() + System.Environment.NewLine + desc.NameValue, time); ISound powerup = game.Sounds.CreateSound("Ammo"); powerup.Play(); game.World.RemoveObject(this); this.Dispose(); }
public DSPSimplePatcher() { InitializeComponent(); sound = Global.Yse.NewSound(); patcher = Global.Yse.NewPatcher(); patcher.Create(1); mtof = patcher.CreateObject(".mtof"); sine = patcher.CreateObject("~sine"); lfo = patcher.CreateObject("~sine"); volume = patcher.CreateObject("~*"); dac = patcher.CreateObject("~dac"); IHandle multiplier = patcher.CreateObject("~*"); patcher.Connect(mtof, 0, sine, 0); // pass frequency to sine patcher.Connect(sine, 0, multiplier, 0); patcher.Connect(lfo, 0, multiplier, 1); patcher.Connect(multiplier, 0, volume, 0); patcher.Connect(volume, 0, dac, 0); mtof.SetFloatData(0, 60f); lfo.SetFloatData(0, 4f); volume.SetFloatData(1, 0f); sound.Create(patcher); sound.Play(); }
protected override void LoadContent() { base.LoadContent(); if (Weapons == null) { //Initialize WeaponManager Weapons = new WeaponManager(game, Model, WeaponHolderType.Player); // Equip some cool weapons: //TODO: remove this later. Weapons.AddWeapon(WeaponType.ROCKET_STINGER); Weapons.AddWeapon(WeaponType.ULTRA_PHASER); Weapons.AddWeapon(WeaponType.MINIGUN); Weapons.AddWeapon(WeaponType.MINIGUN2); Weapons.AddWeapon(WeaponType.PLASMAGUN); } else { Weapons.WeaponHolder = Model; } // For audio and mesh animation by M.R. modelAnimationPart = Model.GetMesh("Rotor"); if (modelAnimationPart != null) { meshSoundEfx = game.Sounds.CreateSound("Heli"); meshSoundEfx.Play(); modelAnimationPart.PlayRotationAnimation(); } // ------------------------------------- }
public static ISound Play(int id, Vehicle vehicle, bool is3d) { if (vehicle == null || (vehicle.Driver is CpuDriver && ((CpuDriver)vehicle.Driver).InPlayersView) || vehicle.Driver is PlayerDriver) { ISound instance = _playerInstances.Find(a => a.Id == id); if (instance == null) { instance = CreateInstance(id, is3d); } if (instance != null) { if (is3d) { instance.Position = vehicle.Position; } instance.Owner = vehicle; instance.Play(false); //GameConsole.WriteEvent("PlaySound " + id.ToString()); } else { } return(instance); } else { return(null); } }
public DSPSimplePatcher() { InitializeComponent(); sound = Global.Yse.CreateSound(); patcher = Global.Yse.CreatePatcher(); patcher.Create(1); mtof = patcher.AddObject("mtof"); sine = patcher.AddObject("sine"); lfo = patcher.AddObject("sine"); volume = patcher.AddObject("*"); IHandle multiplier = patcher.AddObject("*"); patcher.Connect(mtof, 0, sine, 0); // pass frequency to sine patcher.Connect(sine, 0, multiplier, 0); patcher.Connect(lfo, 0, multiplier, 1); patcher.Connect(multiplier, 0, volume, 0); patcher.Connect(volume, 0, patcher.GetOutputHandle(0), 0); mtof.SetData(0, 60f); lfo.SetData(0, 4f); volume.SetData(1, 0f); sound.Create(patcher); sound.Play(); }
public override void OnWorldUpdate(Scene scene, float elapsedMilliseconds) { base.OnWorldUpdate(scene, elapsedMilliseconds); if (state == LichState.Dead) { return; } if (!IsAlive) { SetState(LichState.Dead); Size = Vector2.Zero; deathSound.Play(0); scene.EventsLogger.MonsterDeath(LichName); return; } if (state == LichState.Shooting && GetCurrentAnimation().IsOver) { var fireBallProbability = CanSeePlayer(scene) ? 0.2 : 1; if (random.NextDouble() < fireBallProbability) { SpawnFireBall(scene); } else { SpawnShockBall(scene); } SetState(LichState.RunningFromPlayer); return; } if (state == LichState.Static) { if (CanSeePlayer(scene)) { scene.EventsLogger.MonsterAttacks(LichName); evilLaugh.Play(0); SetState(LichState.RunningFromPlayer); } } if (state == LichState.RunningFromPlayer) { if (CanShoot(scene)) { SetState(LichState.Shooting); } else { if (!TryRunFromPlayer(scene, elapsedMilliseconds)) { SetState(LichState.Shooting); } } } }
/// <summary> /// Nice sound if the button has been pressed. by M.R. /// </summary> private void PlayButtonSound() { ISound snd = game.Sounds.CreateSound("Button"); snd.Play(); snd.Dispose(); }
public void Trigger(XY _) { if (IsArmed) { _alarmSound.Play(); } }
public void play() { if (sound != null && subtitle != null) { Console.WriteLine(sound.Play()); Console.WriteLine(subtitle.Play()); } }
void OpenBrowserDialog_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.Circle)) { switch (selection) { case 0: sound.Play(PPDSetting.DefaultSounds[1], -1000); OpenBrowser(); break; case 1: sound.Play(PPDSetting.DefaultSounds[2], -1000); break; } FocusManager.RemoveFocus(); } else if (args.InputInfo.IsPressed(ButtonType.Cross)) { sound.Play(PPDSetting.DefaultSounds[2], -1000); FocusManager.RemoveFocus(); } else if (args.InputInfo.IsPressed(ButtonType.Left)) { buttons[selection].Selected = false; selection--; if (selection < 0) { selection = 1; } buttons[selection].Selected = true; sound.Play(PPDSetting.DefaultSounds[0], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Right)) { buttons[selection].Selected = false; selection++; if (selection > 1) { selection = 0; } buttons[selection].Selected = true; sound.Play(PPDSetting.DefaultSounds[0], -1000); } }
public bool ExPlay(int num, int vol, double playRatio) { if (num < count) { sound.Play(num.ToString(), vol); return(true); } return(false); }
private void StartSoundDelayed(ISound sound) { while (sound.Delay > TimeSpan.Zero) { Thread.Sleep(TimeSpan.FromSeconds(1)); sound.Delay -= TimeSpan.FromSeconds(1); } sound.Play(); }
public void Trigger(XY triggerLocation) { if (IsArmed && !_securityAlerted) { _events.Publish(new PositionedAlertSecurityEvent(triggerLocation)); _alarmSound.Play(); _securityAlerted = true; } }
/// <summary> /// Update the audio effects. /// </summary> private void UpdateAudio() { if (modelAnimationPart != null) { if (!meshSoundEfx.Playing()) { meshSoundEfx.Play(); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //Yse.Yse.System().init(); //Global = new YSE.Global(Yse.Yse.System()); Y = new YSE.YseInterface(OnMessage); Y.System.Init(); FileManager = Y.BufferIO as YSE.BufferIO; byte[] fileBuffer = default(byte[]); using (StreamReader sr = new StreamReader(Assets.Open("countdown.ogg"))) { using (var memstream = new MemoryStream()) { sr.BaseStream.CopyTo(memstream); fileBuffer = memstream.ToArray(); } } FileManager.AddBuffer("file1", fileBuffer, fileBuffer.Length); FileManager.Active = true; sound = new YSE.Sound(); sound.Create("file1"); TimerCallback callback = new TimerCallback(Update); timer = new Timer(callback, null, 50, 50); // Get our button from the layout resource, // and attach an event to it Button startbutton = FindViewById <Button>(Resource.Id.startButton); startbutton.Click += delegate { sound.Play(); Y.System.AudioTest = true; startbutton.Text = "" + sound.Length; }; Button pausebutton = FindViewById <Button>(Resource.Id.pauseButton); pausebutton.Click += delegate { sound.Pause(); }; Button stopbutton = FindViewById <Button>(Resource.Id.stopButton); stopbutton.Click += delegate { sound.Stop(); Y.System.AudioTest = false; }; }
void ChangeVolumeSprite_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.Up)) { currentIndex--; if (currentIndex < 0) { currentIndex = 2; } sound.Play(PPDSetting.DefaultSounds[0], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Down)) { currentIndex++; if (currentIndex >= 3) { currentIndex = 0; } sound.Play(PPDSetting.DefaultSounds[0], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Cross)) { if (FocusManager != null) { FocusManager.RemoveFocus(); } } else if (args.InputInfo.IsPressed(ButtonType.Left)) { int scale = args.InputInfo.GetPressingFrame(ButtonType.Left) > 60 ? 10 : 1; ChangeVolume(-10 * scale); AdjustPosition(); sound.Play(PPDSetting.DefaultSounds[0], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Right)) { int scale = args.InputInfo.GetPressingFrame(ButtonType.Right) > 60 ? 10 : 1; ChangeVolume(10 * scale); AdjustPosition(); sound.Play(PPDSetting.DefaultSounds[0], -1000); } }
public override void MakeShoot(Scene scene) { if (State == ShootingWeaponState.Shooting) { return; } State = ShootingWeaponState.Shooting; shootingSound.Play(0); }
/// <summary> /// Turn on the music box and play randomized /// background music. /// </summary> /// <param name="status">The new music box status</param> public void MusicBox(MusicBoxStatus status) { currentStatus = status; int i = 0; switch (currentStatus) { case MusicBoxStatus.Play: // Statemachine PLAY if (currentTrack != null && currentTrack.Playing() == true) { currentTrack.Stop(); } // if no music is playing, create random and play if (currentTrack == null || currentTrack.Playing() == false) { // New index not the same int t; while ((t = rnd.Next(0, mtracks)) == midx) { } midx = t; // Load new track foreach (KeyValuePair <string, SoundType> s in lib) { if (s.Value == SoundType.Music) { if (midx == i) { currentTrack = CreateSound(s.Key); break; } i++; } } } if (!currentTrack.Playing()) { currentTrack.Play(); DisplayArtistName(); } break; case MusicBoxStatus.Stop: // Statemachine STOP currentTrack.Stop(); break; case MusicBoxStatus.Pause: // Statemachine PAUSE currentTrack.Pause(); break; } }
public override void OnWorldUpdate(Scene scene, float elapsedMilliseconds) { base.OnWorldUpdate(scene, elapsedMilliseconds); if ((scene.Player.Position - Position).LengthSquared() < CollectionRadiusSquared) { OnCollect(scene); scene.EventsLogger.AddCollectOfItem(Name); collectionSound.Play(0); scene.RemoveObject(this); } }
private void Victory() { var rndX = new Random(); var rndY = new Random(); this.Level++; this.Player.Direction = Settings.PlayerSettings.Direction; this.Player.Position = Settings.PlayerSettings.Position; this.Player.Board.Exit = new BaseFlag { Position = new Structs.Position { X = rndX.Next(1, this.Player.Board.Width - 1), Y = rndY.Next(1, this.Player.Board.Height - 1) } }; this.Player.Board.Enemies.Clear(); for (var i = 1; i <= this.Level + 2; i++) { var pos = new Structs.Position { X = rndX.Next(1, this.Player.Board.Width - 1) }; while (pos.Equals(this.Player.Board.Exit.Position)) { pos = new Structs.Position { X = rndX.Next(1, this.Player.Board.Width - 1), Y = rndY.Next(1, this.Player.Board.Height - 1) }; } var enemy = new BaseEnemy { Position = pos }; this.Player.Board.Enemies.Add(enemy); } sound.Play(this.Settings.SoundSettings.VictoryFileName); }
void OptionControl_Inputed(IFocusable sender, InputEventArgs args) { if (args.InputInfo.IsPressed(ButtonType.Circle)) { Change(ButtonType.Circle); sound.Play(PPDSetting.DefaultSounds[3], -1000); } else if (args.InputInfo.IsPressed(ButtonType.Cross)) { FocusManager.RemoveFocus(); } else if (args.InputInfo.IsPressed(ButtonType.Triangle)) { FocusManager.RemoveFocus(); } else { if (args.InputInfo.IsPressed(ButtonType.Left)) { Change(ButtonType.Left); sound.Play(PPDSetting.DefaultSounds[3], -1000); } if (args.InputInfo.IsPressed(ButtonType.Right)) { Change(ButtonType.Right); sound.Play(PPDSetting.DefaultSounds[3], -1000); } if (args.InputInfo.IsPressed(ButtonType.Up)) { Change(ButtonType.Up); sound.Play(PPDSetting.DefaultSounds[0], -1000); } if (args.InputInfo.IsPressed(ButtonType.Down)) { Change(ButtonType.Down); sound.Play(PPDSetting.DefaultSounds[0], -1000); } } }
public void Add(ISound sound) { _activeSounds.Add(sound); sound.SoundStateChanged += OnSoundStateChange; if (sound.Delay == TimeSpan.Zero) { sound.Play(); } else { Task.Run(() => StartSoundDelayed(sound)); } }
public override void OnWorldUpdate(Scene scene, float elapsedMilliseconds) { base.OnWorldUpdate(scene, elapsedMilliseconds); if (state == ShockBallState.Blow && CurrentAnimation.IsOver) { scene.RemoveObject(this); return; } if (state == ShockBallState.Blow) { return; } var xRayUnit = MathF.Cos(DirectionAngle); var yRayUnit = MathF.Sin(DirectionAngle); var dx = xRayUnit * MoveSpeed * elapsedMilliseconds; var dy = yRayUnit * MoveSpeed * elapsedMilliseconds; var newPosition = Position + new Vector2(dx, dy); var testX = (int)newPosition.X; var testY = (int)newPosition.Y; var hit = !scene.Map.InBound(testY, testX) || scene.Map.At(testY, testX).Type != MapCellType.Empty; foreach (var obj in scene.Objects.Append(scene.Player)) { if (obj is Bullet || obj is Arrow || obj == master) { continue; } if (!CanDamage(obj)) { continue; } obj.OnShoot(scene, Damage); hit = true; } if (hit) { state = ShockBallState.Blow; blowSound.Play(0); return; } Position = newPosition; }
void UpdateAudio() { UpdateListener(); if (IsJumping) { if (jumpSound == null) { var emitter = new AudioEmitter(); UpdateActorEmitter(emitter); var key = new ActionSoundKey("Jump", null); string soundName; if (Character.ActionSounds.TryGetValue(key, out soundName)) { jumpSound = Scene.CharacterAudioManager.CreateSound(soundName, emitter); jumpSound.Play(); } } else if (jumpSound.IsPlaying) { UpdateActorEmitter(jumpSound.Emitter); } } else { if (jumpSound != null) { if (jumpSound.IsDisposed) { jumpSound = null; } else if (jumpSound.IsPlaying) { UpdateActorEmitter(jumpSound.Emitter); } } } if (footstepSound != null) { if (footstepSound.IsDisposed) { footstepSound = null; //footstepStartPartIndex = 0; } else if (footstepSound.IsPlaying) { UpdateActorEmitter(footstepSound.Emitter); } } // 重力方向に対して衝突があるかどうかを判定します。 Vector3 gravity; Character.RigidBody.GetGravity(out gravity); bool isStanding = Character.CollisionBounds.IsCollidedForDirection(ref gravity); if (isStanding) { Vector3 velocity; Character.RigidBody.GetVeclocity(out velocity); velocity.Y = 0; if (0 < velocity.LengthSquared()) { if (footstepSound == null) { var model = Character.ActorModel as CubeAnimateCharacterActorModel; var currentPartIndex = model.CurrentPartIndex; if (footstepStartPartIndex != currentPartIndex) { var emitter = new AudioEmitter(); UpdateActorEmitter(emitter); var key = new ActionSoundKey("Footstep", null); string soundName; if (Character.ActionSounds.TryGetValue(key, out soundName)) { footstepSound = Scene.CharacterAudioManager.CreateSound(soundName, emitter); footstepSound.Play(); footstepStartPartIndex = currentPartIndex; } } } } } }