/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _spriteBatch = new SpriteBatch(GraphicsDevice); // Load the object textures into the textures dictionary Textures.Add("Spaceship", this.Content.Load <Texture2D>("Spaceship")); Textures.Add("Bullet", this.Content.Load <Texture2D>("Bullet")); Textures.Add("Rock1", this.Content.Load <Texture2D>("Rock1")); Textures.Add("Rock2", this.Content.Load <Texture2D>("Rock2")); Textures.Add("Rock3", this.Content.Load <Texture2D>("Rock3")); Textures.Add("Star", this.Content.Load <Texture2D>("Star")); Textures.Add("SmokeParticle", this.Content.Load <Texture2D>("SmokeParticle")); // Load fonts Fonts.Add("Miramonte", this.Content.Load <SpriteFont>("Miramonte")); // Load sounds SoundEffects.Add("BulletSound", Content.Load <SoundEffect>("BulletSound")); SoundEffects.Add("HyperspaceOut", Content.Load <SoundEffect>("HyperspaceOut")); SoundEffects.Add("HyperspaceIn", Content.Load <SoundEffect>("HyperspaceIn")); SoundEffects.Add("RockExplosion", Content.Load <SoundEffect>("RockExplosion")); SoundEffects.Add("SpaceshipExplosion", Content.Load <SoundEffect>("SpaceshipExplosion")); SoundEffects.Add("Thruster", Content.Load <SoundEffect>("Thruster")); // Reset the game ResetGame(); }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } audioSources = new AudioSource[soundEffects.Length]; for (int x = 0; x < soundEffects.Length; x++) { AudioSource aSource = gameObject.AddComponent <AudioSource>(); audioSources[x] = aSource; aSource.clip = soundEffects[x]; aSource.volume = sfx.value; } CarryOver.instance.GetComponent <AudioSource>().volume = music.value; sfx.value = PlayerPrefs.GetFloat("sfx"); music.value = PlayerPrefs.GetFloat("music"); }
public void PlaySoundEffect(SoundEffects soundEffect) { AudioClip clip = null; float pitch = 1; switch (soundEffect) { case SoundEffects.ObstacleCollisionSoundEffect: clip = obstacleCollision; break; case SoundEffects.CoinSoundEffect: clip = coinCollection; pitch = 1.5f; break; case SoundEffects.FuelSoundEffect: clip = fuelCollection; break; case SoundEffects.GameOverSoundEffect: clip = gameOver; break; case SoundEffects.GUITapSoundEffect: clip = guiTap; break; } soundEffectsAudio[nextSoundEffectsAudioIndex].pitch = pitch; soundEffectsAudio[nextSoundEffectsAudioIndex].clip = clip; soundEffectsAudio[nextSoundEffectsAudioIndex].Play(); nextSoundEffectsAudioIndex = (nextSoundEffectsAudioIndex + 1) % soundEffectsAudio.Length; }
/// <summary> /// Does some sorting of the Qua /// </summary> public void Sort() { HitObjects = HitObjects.OrderBy(x => x.StartTime).ToList(); TimingPoints = TimingPoints.OrderBy(x => x.StartTime).ToList(); SliderVelocities = SliderVelocities.OrderBy(x => x.StartTime).ToList(); SoundEffects = SoundEffects.OrderBy(x => x.StartTime).ToList(); }
public void playSoundEffect(SoundEffects soundEffect) { AudioClip clip = null; float pitch = 1; switch (soundEffect) { case SoundEffects.ObstacleCollisionSoundEffect: clip = obstacleCollision; break; case SoundEffects.CoinSoundEffect: clip = coinCollection; break; case SoundEffects.PowerUpSoundEffect: clip = powerUpCollection; break; case SoundEffects.GameOverSoundEffect: clip = gameOver; break; case SoundEffects.GUITapSoundEffect: clip = guiTap; break; } soundEffectsAudio.pitch = pitch; soundEffectsAudio.clip = clip; soundEffectsAudio.Play(); }
public void Create() { SE = GameObject.Find("SE").GetComponent <SoundEffects>();//コンポーネント //ここでメッセージウィンドウのインスタンス生成、あと画面アイコン insmeswin = Instantiate(meswinobj, new Vector3(1.25f, -3.75f, -1.0f), Quaternion.identity); insicon = Instantiate(iconobj, new Vector3(-5.41666666667f, -3.75f, -1.0f), Quaternion.identity); insmeswin.transform.localScale = new Vector3(5.0f / 3.0f, 5.0f / 3.0f, 5.0f / 3.0f); insicon.transform.localScale = new Vector3(2.5f, 2.5f, 2.5f); insmeswin.transform.parent = transform; //生成したスプライトを子オブジェクトとして登録 insicon.transform.parent = transform; //生成したスプライトを子オブジェクトとして登録 iconcomp = insicon.GetComponent <MesIcon>(); //コンポーネント //ここからはTEXTとアイコンID。1行ずつ交互に設定してあるのを解凍読み込み var all_scenarioText = Resources.Load <TextAsset>("Scenario/" + stage); scenarios = all_scenarioText.text.Split(new string[] { "@br" }, System.StringSplitOptions.None); scenarios_Length = scenarios.Length / 2; kaoid = new int[scenarios_Length]; for (int i = 0; i < scenarios_Length; i++) { kaoid[i] = int.Parse(scenarios[i * 2]);//各テキストごとの顔id } currentLine = -1; //その他 deathflg = 0; SetNextLine();//ここでcurrentLine 0になる }
//Code for initialization, capture completed, image availability events; also setting the source for the viewfinder. protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { // Initializes SoundEffects class SoundEffects.Initialize(); _appSettings = new AppSettings(); _torchOnImage = new ImageBrush { ImageSource = new BitmapImage(new Uri(_appSettings.ImageOnSetting, UriKind.Relative)) }; _torchOffImage = new ImageBrush { ImageSource = new BitmapImage(new Uri(_appSettings.ImageOffSetting, UriKind.Relative)) }; soundOn = _appSettings.SoundOnSetting; soundOff = _appSettings.SoundOffSetting; TorchButton.Background = _appSettings.TorchInitStateSetting ? _torchOnImage : _torchOffImage; SetBatteryIcon(); InitialiseCaptureDevice(); // The event is fired when the shutter button receives a full press. CameraButtons.ShutterKeyPressed += OnButtonFullPress; // Plays a silent wav to init the audio device if (_appSettings.EnableSoundSetting) { SoundEffects.SfxSilence.Play(); } }
public void MarioLuigiCollisionTest(Mario mario, Luigi luigi, SoundEffects sound) { Rectangle marioRectangle = myMario.GetRectangle(); Rectangle luigiRectangle = luigi.GetRectangle(); Rectangle intersectionRectangle; intersectionRectangle = Rectangle.Intersect(marioRectangle, luigiRectangle); if (!intersectionRectangle.IsEmpty) { if (intersectionRectangle.Width > intersectionRectangle.Height) { if (marioRectangle.Y > luigiRectangle.Y) { luigi.BoostJump(); sound.Bump(); } else if (luigiRectangle.Y > marioRectangle.Y) { mario.BoostJump(); sound.Bump(); } } } }
public void PlaySoundEffect(SoundEffects identifier, float pan = 0, float pitch = 0, Boolean isLooped = false) { if (!muted && LoadSoundEffects && identifier != SoundEffects.None) { int i = (int)identifier; SoundEffectInstance instance = soundEffects[i].CreateInstance(); if (instance != null) { instance.Volume = volume; if (pan > 1) { pan = 1; } else if (pan < -1) { pan = -1; } instance.Pan = pan; instance.Pitch = pitch; instance.IsLooped = isLooped; instance.Play(); soundEffectBuffer.Insert(0, instance); CheckInstanceCount(); } } }
public Screen(Game game, SpriteBatch batch, ChangeScreen changeScreen, BackButtonScreenType backButtonScreenType) { Screen.game = game; Screen.content = game.Content; Screen.batch = batch; changeScreenDelegate = changeScreen; touchIndicator = new TouchIndicatorCollection(); if (music == null) { music = new Music(content); } if (soundEffects == null) { soundEffects = new SoundEffects(content); } if (!isHighScoresLoaded) { highScores.Load(); isHighScoresLoaded = true; } this.backButtonScreenType = backButtonScreenType; }
void Awake() { if (Application.loadedLevelName == "HomeScene") { upgradeMenu = GameObject.Find("Upgrade_Menu"); bikeUpgradeButtons.Add(GameObject.Find("Bike_UG_Button_1").GetComponent <Button>()); bikeUpgradeButtons.Add(GameObject.Find("Bike_UG_Button_2").GetComponent <Button>()); bikeUpgradeButtons.Add(GameObject.Find("Bike_UG_Button_3").GetComponent <Button>()); carUpgradeButtons.Add(GameObject.Find("Car_UG_Button_1").GetComponent <Button>()); carUpgradeButtons.Add(GameObject.Find("Car_UG_Button_2").GetComponent <Button>()); carUpgradeButtons.Add(GameObject.Find("Car_UG_Button_3").GetComponent <Button>()); carObj = GameObject.Find("JEEP_BODY"); if (carObj == null) { Debug.LogError("No car!!!"); } SFX = GameObject.Find("SFXManager").GetComponent <SoundEffects>(); } gameControllerObj = GameObject.Find("GameController"); if (gameControllerObj != null) { gameController = gameControllerObj.GetComponent <GameControllerScript>(); bikeTier = gameController.bikeTier; carTier = gameController.carTier; } else { Debug.LogError("cant find controller"); } upgradeMenu.SetActive(false); }
public void StopSoundFX(SoundEffects effect) { if (this.SoundFXs[effect].State == SoundState.Playing) { this.SoundFXs[effect].Stop(); } }
public void ChangeSoundEffectsVolume() { SoundEffects soundEffects = GameObject.FindGameObjectWithTag("soundEffects").GetComponent <SoundEffects>(); soundEffects.ChangeSoundEffectVolume(soundEffectsSlider.GetComponent <UnityEngine.UI.Slider>().value); soundEffects.PlaySoundEffect(soundEffect); }
/// <summary> /// This method attempts to play the requested sound, but gives up if the /// timeout expires. /// </summary> /// <param name="state">An instance of the SoundEffects enum.</param> private void PlaySoundThread(object state) { bool gotLock = false; try { gotLock = Monitor.TryEnter(PlaybackLock, C_PLAYBACK_TIMEOUT); if (gotLock) { SoundEffects sound = (SoundEffects)state; // Only try to play the sound if it exists. // If we're using a sound pack, missing files will cause the sound to be disabled. if (this.m_SoundEffectPlayers.ContainsKey(sound)) { this.m_SoundEffectPlayers[sound].PlaySync(); } } } finally { if (gotLock) { Monitor.PulseAll(PlaybackLock); Monitor.Exit(PlaybackLock); } } }
/// <summary> /// Adds a GameObject reference to the Objects dictionary /// If a CollidableObject is passed, it is also added to the CollidableObjects List /// </summary> /// <param name="name">GameObject name</param> /// <param name="g">GameObject reference</param> public static void Add(string name, GameObject g) { Objects.Add(name, g); if (g is CollidableObject) { CollidableObject c = (CollidableObject)g; CollidableObjects.Add(c); NonUIObjects.Add(g); } else if (g is Background) { Background b = (Background)g; Backgrounds.Add(b); } else if (g is UIObject) { UIObject ui = (UIObject)g; UIObjects.Add(ui); } else if (g is SFXWrapper) { SFXWrapper wrap = (SFXWrapper)g; SoundEffects.Add(wrap); } else { NonUIObjects.Add(g); } }
public float[] kkp; //流体関連の圧力壁定義点のval void Start() { ucomp = GameObject.Find("ufo").GetComponent <Ufo>(); //ufo コンポーネント frntcomp = GameObject.Find("frontpng").GetComponent <Frontstage>(); //コンポーネント dtprtcomp = GetComponent <DotParticle>(); //コンポーネント stgmngrcomp = GameObject.Find("StageManager").GetComponent <Stagemanager>(); //コンポーネント SE = GameObject.Find("SE").GetComponent <SoundEffects>(); //コンポーネント refer = GameObject.Find("referobj").GetComponent <Referobj>(); //コンポーネント kbp = new uint[Const.CO.WX * Const.CO.WY]; kbpori = new uint[Const.CO.WX * Const.CO.WY]; kbx = new uint[Const.CO.WX * Const.CO.WY]; kby = new uint[Const.CO.WX * Const.CO.WY]; kkx = new float[Const.CO.WX * Const.CO.WY]; kky = new float[Const.CO.WX * Const.CO.WY]; kkp = new float[Const.CO.WX * Const.CO.WY]; res = new int[108]; bulletsMaterial = new Material(bulletsShader); Debug.Log(Mathf.Sqrt(Mathf.Clamp((65536f * 4f) / refer.PARTICLENUM, 0.0f, 1.0f))); bulletsMaterial.SetFloat("_Intensity", Mathf.Sqrt(Mathf.Clamp((65536f * 4f) / refer.PARTICLENUM, 0.0f, 1.0f))); FindKernelInit(); // InitializeComputeBuffer(); //ここで流体関連と粒子等のvram生成 SetKernels(); //カーネル全部作成&引数セット //コマンドバッファ系 commandb = new CommandBuffer(); Camera cam = GameObject.Find("Main Camera").GetComponent <Camera>();//コンポーネント commandb.name = "gpu instanse"; commandb.DrawProcedural(cam.cameraToWorldMatrix, bulletsMaterial, 0, MeshTopology.Points, dtprtcomp.RYS.count, 1); cam.AddCommandBuffer(CameraEvent.AfterForwardOpaque, commandb); GetComponent <LoadWallFromBMP>().stages_speed = 0.0f; GetComponent <LoadWallFromBMP>().LoadWallInfo("0");//ここで壁情報を画像データbmpやpngから読み込み壁情報をvramに転送 cnt = 0; extf = new Vector2(0.0f, 0.0f); }
/// <summary> /// Plays a sound effect /// </summary> /// <param name="soundEffect">The name of the sound effect</param> /// <param name="source">The ID of the game object calling the sound</param> public static void PlaySound(SoundEffects soundEffect, GameObject source) { if (soundEffect != SoundEffects.NONE) { AkSoundEngine.PostEvent(soundEffect.ToString(), source); } }
public static void PlaySound(SoundEffects effect, bool isLooped) { return; if (soundsPlaying.ContainsKey(soundFX[effect.ToString()]) && soundsPlaying[soundFX[effect.ToString()]].State == SoundState.Playing) { return; } // Otherwise, start playing the entry. // Same note as above about reusing instance. SoundEffectInstance instance = soundFX[effect.ToString()].CreateInstance(); instance.IsLooped = isLooped; instance.Play(); // Store the sound in our system. A little complicated to avoid null references. if (soundsPlaying.ContainsKey(soundFX[effect.ToString()])) { soundsPlaying[soundFX[effect.ToString()]] = instance; } else { soundsPlaying.Add(soundFX[effect.ToString()], instance); } }
public static void SFX(SoundEffects sfx) { switch (sfx) { case SoundEffects.Move: PlaySoundFromFile(path + "move.wav"); break; case SoundEffects.Rotate: PlaySoundFromFile(path + "rotate.wav"); break; case SoundEffects.LevelUp: PlaySoundFromFile(path + "levelup.wav"); break; case SoundEffects.ClearLine: PlaySoundFromFile(path + "clearline.wav"); break; case SoundEffects.Drop: PlaySoundFromFile(path + "drop.wav"); break; case SoundEffects.GameOver: PlaySoundFromFile(path + "gameover.wav"); break; } }
/// <summary> /// Damages a section of ship. /// </summary> /// <param name="section">section</param> /// <param name="amount">amount</param> public void Damage(Point gridLocation, int amount) { var damageScale = 1f; var upgrades = _topology.Upgrades .Select(x => x.GetType()) .ToArray(); if (upgrades.Contains(typeof(HullReinforcement))) { damageScale -= 0.1f; } this.Update(() => { var section = _topology.SectionAt(gridLocation); if (section == null) { return; } section.Damage((int)(amount * damageScale)); if (section.Health == 0) { _topology.SectionAt(gridLocation)?.Module?.OnDestruction(this, GetNodeForSection(gridLocation)); _topology.Remove(gridLocation); SoundEffects.Get("ChunkyExplosion")?.Play(); //PerformPartsAnalysis(); } }); }
private void addFrogToFrogHome(FrogHome frogHome) { SoundEffects.PlayHomeLandingSound(); frogHome.AddFrog(); this.gameCanvas.Children.Add(frogHome.Sprite); this.playerScores(); }
private void gameOver() { this.timer.Stop(); this.onGameOverReached(EventArgs.Empty); SoundEffects.PlayGameOverSound(); this.handleRetrievePlayerName(); }
public void playSoundEffect(SoundEffects soundEffect) { AudioClip clip = null; float pitch = 1; switch (soundEffect) { case SoundEffects.ObstacleCollisionSoundEffect: clip = obstacleCollision; break; case SoundEffects.CoinSoundEffect: clip = coinCollection; pitch = 1.5f; break; case SoundEffects.PowerUpSoundEffect: clip = powerUpCollection; break; case SoundEffects.GameOverSoundEffect: clip = gameOver; break; case SoundEffects.GUITapSoundEffect: clip = guiTap; break; } soundEffectsAudio[nextSoundEffectsAudioIndex].pitch = pitch; soundEffectsAudio[nextSoundEffectsAudioIndex].clip = clip; soundEffectsAudio[nextSoundEffectsAudioIndex].Play(); nextSoundEffectsAudioIndex = (nextSoundEffectsAudioIndex + 1) % soundEffectsAudio.Length; }
int counter;//裏コマンド // Use this for initialization void Start() { SE = GameObject.Find("SE").GetComponent <SoundEffects>();//コンポーネント tex = new Texture2D(64, 64, TextureFormat.RGBA32, false); //Texture2DからSpriteを作成 sprite = Sprite.Create( texture: tex, rect: new Rect(0, 0, 64, 64), pivot: new Vector2(0.5f, 0.5f) ); for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { tex.SetPixel(i, j, new Color(1.0f, 1.0f, 1.0f, 1.0f)); } } tex.Apply(); GetComponent <SpriteRenderer>().sprite = sprite; gameobj_easy = GameObject.Find("font02_96px_11"); gameobj_easy.SetActive(false); gameobj_norm = GameObject.Find("font02_96px_12"); gameobj_norm.SetActive(false); gameobj_hard = GameObject.Find("font02_96px_13"); gameobj_hard.SetActive(false); cnt = 0; counter = 0; flg = 0; select_x_id = 0; buttondown_now = 0; buttondown_log = 0; }
public void PlayAudioClip(SoundEffects sound) { switch (sound) { case SoundEffects.MoneyKaching: _sfxSource.PlayOneShot(_moneyKaching); break; case SoundEffects.BoxThud: _sfxSource.PlayOneShot(_boxThud); break; case SoundEffects.ButtonBonk: _sfxSource.PlayOneShot(_buttonBonk); break; case SoundEffects.TrashCrumple: _sfxSource.PlayOneShot(_trashCrumple); break; case SoundEffects.MouseClick: _sfxSource.PlayOneShot(_mouseClick); break; case SoundEffects.ErrorBeep: _sfxSource.PlayOneShot(_errorBeep); break; default: Debug.LogError("No sound named " + sound); break; } }
public void playSound(SoundEffects sound) { switch (sound) { case SoundEffects.Gameover: audio.PlayOneShot(Gameover); break; case SoundEffects.Weather: audio.PlayOneShot(Weather); break; case SoundEffects.Reservoir: audio.PlayOneShot(Reservoir); break; case SoundEffects.Hp50: audio.PlayOneShot(Hp50); break; case SoundEffects.Hp25: audio.PlayOneShot(Hp25); break; case SoundEffects.Hp10: audio.PlayOneShot(Hp10); break; case SoundEffects.Honking: audio.PlayOneShot(Honking); break; case SoundEffects.BuildChargingStation: audio.PlayOneShot(BuildChargingStation); break; default: Debug.LogWarning("Unknown sound " + sound.ToString()); break; } }
public static void PlaySound(SoundEffects effect) { var index = 0; switch (effect) { case SoundEffects.HAMMER: index = Random.Range(0, current.hammerSounds.Length - 1); AudioSource.PlayClipAtPoint(current.hammerSounds[index], Camera.main.transform.position); break; case SoundEffects.HURT: index = Random.Range(0, current.hurtSounds.Length - 1); AudioSource.PlayClipAtPoint(current.hurtSounds[index], Camera.main.transform.position); break; case SoundEffects.ANIMALDIE: index = Random.Range(0, current.animalDieSounds.Length - 1); AudioSource.PlayClipAtPoint(current.animalDieSounds[index], Camera.main.transform.position); break; case SoundEffects.NAILBROKE: index = Random.Range(0, current.nailBrokeSounds.Length - 1); AudioSource.PlayClipAtPoint(current.nailBrokeSounds[index], Camera.main.transform.position); break; case SoundEffects.SUCCESS: index = Random.Range(0, current.successSounds.Length - 1); AudioSource.PlayClipAtPoint(current.successSounds[index], Camera.main.transform.position); break; } }
public void Play(SoundEffects effect) { switch (effect) { case SoundEffects.Jump: int i = rnd.Next(0, 3); switch (i) { case 0: jump1.Play(); break; case 1: jump2.Play(); break; case 2: jump3.Play(); break; default: break; } break; case SoundEffects.Dash: dash.Play(volume, zero, zero); break; } }
void Awake() { clicked = false; quickPrompt = GameObject.Find("Quick_Prompt"); if (quickPrompt != null) { promptTitle = quickPrompt.transform.FindChild("Prompt_Title_Text").GetComponent <Text>(); promptDesc = quickPrompt.transform.FindChild("Prompt_Desc_Text").GetComponent <Text>(); yesButton = quickPrompt.transform.FindChild("Yes_Button").GetComponent <Button>(); noButton = quickPrompt.transform.FindChild("No_Button").GetComponent <Button>(); } else { Debug.LogError("QP not found !!"); } SFXManager = GameObject.Find("SFXManager"); if (SFXManager != null) { soundEffects = SFXManager.GetComponent <SoundEffects>(); } else { Debug.Log("sfx manager not found"); } }
/// <summary> /// Modifies the volume of a playing sound /// </summary> /// <param name="soundEffect">Name of the effect</param> /// <param name="volume">Volume of the sound effect. Use a scale of zero to one</param> public static void SetSoundVolume(SoundEffects soundEffect, float volume) { if (soundEffect != SoundEffects.NONE) { AkSoundEngine.SetRTPCValue(soundEffect.ToString(), volume); } }
private void Button_Click(object sender, RoutedEventArgs e) { var sticker = GetContent(_message); if (sticker == null) { return; } if (_message.Content is MessageText) { var started = Player.Play(); if (started) { var sound = _message.ProtoService.GetEmojiSound(sticker.Emoji); if (sound != null && sound.Local.IsDownloadingCompleted) { SoundEffects.Play(sound); } } } else { _message.Delegate.OpenSticker(sticker); } }
public PlayerBrain(InputBindings bindings, int torchEntityID, SoundEffects soundEffects) { _bindings = bindings; _torchEntityID = torchEntityID; _soundEffects = soundEffects; }
public virtual void Damage(Hurtbox hurt, Hitbox hit) { if (hit.gameObject.tag != gameObject.tag && !_isInvincible) { health -= hit.damage; if (hit.direction == Vector3.zero) { Force(hurt.transform.position - hit.transform.position, hit.force); } else { Force(hit.direction, hit.force); } _sprite.FlashAdd(Color.white); _sprite.Shake(10, 0.125f); Particle.SpawnCross(transform.position + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0), Color.red); Particle.SpawnCross(transform.position + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0), Color.blue); Particle.SpawnCross(transform.position + new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(-0.25f, 0.25f), 0), Color.green); SoundEffects.PlayHit(); DamagePlus(); hit.OnHit(); } }
public static void PlayEffect(SoundEffects effectType) { string sfxPath = string.Empty; switch (effectType) { case SoundEffects.Build: sfxPath = "Resources/Audio/Effects/buildingHammer.wav"; break; case SoundEffects.ChopWood: sfxPath = "Resources/Audio/Effects/woodChop.wav"; break; case SoundEffects.FireCrack: sfxPath = "Resources/Audio/Effects/fireCrackle.wav"; break; case SoundEffects.StoneCollect: sfxPath = "Resources/Audio/Effects/stoneCollect.wav"; break; default: break; } if (string.IsNullOrEmpty(sfxPath)) { return; } var soundPlayer = new SoundPlayer(sfxPath); soundPlayer.Play(); }
public void ItemCollisionTest(SoundEffects sound, HUD hud, IList<IItem> items) { Rectangle luigiRectangle = myLuigi.GetRectangle(); Rectangle itemRectangle; Rectangle intersectionRectangle; Queue<IItem> doomedItems = new Queue<IItem>(); foreach (IItem item in items) { itemRectangle = item.GetRectangle(); intersectionRectangle = Rectangle.Intersect(luigiRectangle, itemRectangle); if (!intersectionRectangle.IsEmpty) { // todo switch (item.GetItemName()) { case "Coin": //myLuigi.Coin(); hud.addCoinLuigi(); hud.increaseScoreLuigi(Constants.coinValue); hud.achievements.CoinGet(); break; case "Mushroom": sound.Powerup(); myLuigi.Mushroom(); hud.increaseScoreLuigi(Constants.mushroomValue); hud.achievements.MushroomGet(); break; case "Fireflower": sound.Powerup(); myLuigi.Fireflower(); hud.increaseScoreLuigi(Constants.fireflowerValue); hud.achievements.FlowerGet(); break; case "Oneup": sound.OneUp(); hud.extraLifeLuigi(); hud.increaseScoreLuigi(Constants.oneUpValue); break; case "Star": sound.Powerup(); myLuigi.Star(); hud.increaseScoreLuigi(Constants.starValue); hud.achievements.StarGet(); break; default: // nothing break; } doomedItems.Enqueue(item); } } while (doomedItems.Count() > 0) { IItem item = doomedItems.Dequeue(); items.Remove(item); } }
public Tuple<int, bool> EnemyCollisionTest(Luigi luigi, HUD hud, IList<IEnemy> enemies, int x, SoundEffects sound) { Rectangle luigiRectangle = myLuigi.GetRectangle(); Rectangle enemyRectangle; bool enemyKilled = false; bool invincible = myLuigi.Invincible(); int xpos = x; Rectangle intersectionRectangle; Queue<IEnemy> doomedEnemies = new Queue<IEnemy>(); foreach (IEnemy enemy in enemies) { enemyRectangle = enemy.GetRectangle(); intersectionRectangle = Rectangle.Intersect(luigiRectangle, enemyRectangle); if (!intersectionRectangle.IsEmpty) { if (intersectionRectangle.Width >= intersectionRectangle.Height) { sound.Bump(); doomedEnemies.Enqueue(enemy); hud.luigiEnemyKill(luigi); enemyKilled = true; } else if (invincible) { doomedEnemies.Enqueue(enemy); } else { myLuigi.Hit(); if (luigiRectangle.X < enemyRectangle.X) { xpos = xpos - intersectionRectangle.Width; } else { xpos = xpos + intersectionRectangle.Width; } if (myLuigi.IsDead()) { hud.lifeLostLuigi(); } } } } while (doomedEnemies.Count() > 0) { IEnemy enemie = doomedEnemies.Dequeue(); enemies.Remove(enemie); } return new Tuple<int,bool>(xpos, enemyKilled); }
void Awake() { playerAttackAnim = GetComponent<Animator>(); _sfx = GetComponent<SoundEffects>(); attackTriggerR.enabled = false; attackTriggerL.enabled = false; }
// Use this for initialization void Start() { GameObject go = GameObject.FindGameObjectWithTag ("SoundEffect"); se = go.GetComponent<SoundEffects>(); if(audio != null) { this.audio.volume = GlobalFlags.getMusicVolume(); } }
public void Hit(IList<IItem> items, bool isMario, bool isBig, HUD hud, SoundEffects sound) { if (isBig) { sound.BreakBlock(); hud.increaseScoreMario(Constants.brokenBrickValue); GreenBrickSprite = null; } }
/// <summary> /// Initializes a new instance of the <see cref="AudioController"/> class. /// </summary> /// <param name="background">Background.</param> /// <param name="sound">Sound.</param> /// <param name="soundEffectsMuted">If set to <c>true</c> sound effects muted.</param> /// <param name="backgroundSoundMuted">If set to <c>true</c> background sounds muted.</param> /// <param name="configSettings">Config settings.</param> public AudioController(BackgroundSound background, SoundEffects sound, bool soundEffectsMuted, bool backgroundSoundMuted, ConfigurableSettings configSettings) { configurableSettings = configSettings; backgroundSound = background; soundEffects = sound; SoundEffectsMuted = soundEffectsMuted; BackgroundSoundMuted = backgroundSoundMuted; if(!BackgroundSoundMuted) backgroundSound.PlayOnStart = true; }
public void PlaySound(SoundEffects sound, float delay, float volumeMultiplier) { AudioClip clip = null; int randomClipIndex = 0; switch (sound) { case SoundEffects.Sacrifice: randomClipIndex = Random.Range(1, 3); clip = Resources.Load("sacrifice_" + randomClipIndex.ToString()) as AudioClip; break; case SoundEffects.Splatter: if (splatterPlaying || !gameStarted) { return; } randomClipIndex = Random.Range(1, 5); clip = Resources.Load("splatter_" + randomClipIndex.ToString()) as AudioClip; splatterPlaying = true; splatterTimer = splatterMinInterval; break; case SoundEffects.Cut: randomClipIndex = Random.Range(1, 1); clip = Resources.Load("cut_" + randomClipIndex.ToString()) as AudioClip; break; } if (clip == null) { return; } var source = effectSources[0]; for (int i = 0; i < effectSources.Length && source.isPlaying; i++) { source = effectSources[i]; } if (source.isPlaying && source.time < 0.15f) { return; } source.Stop(); source.pitch = Random.Range(0.95f, 1.05f); source.clip = clip; source.volume = volumeMultiplier * sfxVolume; source.PlayDelayed(delay); }
public Shoot(ObjectType p_bullet, int p_damage, float p_xSpeed, float p_ySpeed, float p_gravityAccel, int delay, bool playShootAnimation) { this.sound = SoundEffects.Nothing; this.damage = p_damage; this.playAnim = playShootAnimation; this.bullet = p_bullet; this.preDelay = 1; this.postDelay = delay; this.xSpeed = p_xSpeed; this.ySpeed = p_ySpeed; this.applyGravity = true; this.gravityAcccel = p_gravityAccel; this.time = this.preDelay; }
// Use this for initialization void Start () { if (myManager == null) { DontDestroyOnLoad (gameObject); myManager = this; } else if (myManager != this) { Destroy (gameObject); } sfx = GetComponentInChildren<SoundEffects> (); levelMusic = GetComponent<AudioSource> (); levelMusic.loop = true; levelMusic.volume = volume; startMusic (Application.loadedLevelName); }
public Shoot(ObjectType p_bullet, int p_damage, float p_xSpeed, float p_ySpeed, int p_preDelay, int p_postDelay, bool p_applyGravity, bool playShootAnimation, SoundEffects p_sound) { this.sound = p_sound; this.playAnim = playShootAnimation; this.damage = p_damage; this.bullet = p_bullet; this.preDelay = p_preDelay; this.postDelay = p_postDelay; this.xSpeed = p_xSpeed; this.ySpeed = p_ySpeed; this.applyGravity = p_applyGravity; this.gravityAcccel = 2f; this.time = this.preDelay; }
public static void PlaySoundEffect(SoundEffects effect) { switch (effect) { case SoundEffects.Cursor: Instance.soundEffectAudioSource.PlayOneShot(Instance.SoundEffectCursor); break; case SoundEffects.CursorCancel: Instance.soundEffectAudioSource.PlayOneShot(Instance.SoundEffectCursorCancel); break; case SoundEffects.CursorError: Instance.soundEffectAudioSource.PlayOneShot(Instance.SoundEffectCursorError); break; } }
/// <summary> /// loads the music this particular level will use /// </summary> /// <param name="c"></param> /// <param name="songpaths"></param> //play whatever SoundEffect is specified public static void PlaySoundEffect(SoundEffects name) { //if(soundEnabled) sounds[(int)name].Play(); }
public void PlaySound(SoundEffects sound) { int index = (int) sound; if (index >= 0) { this.sounds[index].Play(); } }
//this is coupled with a few things it doesn't need to be. public void Hit(IList<IItem> items, bool isMario, bool isBig, HUD hud, SoundEffects sound) { switch (state) { case BrickState.bstar: sound.Popup(); IItem star = new Items.Star(xPosition, yPosition - 16, camera); items.Add(star); state = BrickState.qempty; BrickSprite = new Sprites.HitQBlockSprite(); break; case BrickState.bcoin: sound.Coin(); IItem c; //make the coin noise c = new Items.Coin(xPosition, yPosition - Constants.tileLength, camera); items.Add(c); if (isMario) { hud.increaseScoreMario(Constants.brokenBrickValue); hud.addCoinMario(); } else { hud.increaseScoreLuigi(Constants.brokenBrickValue); hud.addCoinLuigi(); } state = BrickState.qempty; BrickSprite = new Sprites.HitQBlockSprite(); break; case BrickState.bempty: if (isBig) { sound.BreakBlock(); if (isMario) { hud.increaseScoreMario(Constants.brokenBrickValue); } else { hud.increaseScoreLuigi(Constants.brokenBrickValue); } state = BrickState.destroyed; BrickSprite = null; } break; case BrickState.qitem: IItem i; sound.Popup(); if (!isBig) { i = new Items.Mushroom(xPosition, yPosition - Constants.tileLength, camera); } else { i = new Items.Fireflower(xPosition, yPosition - Constants.tileLength, camera); } items.Add(i); state = BrickState.qempty; BrickSprite = new Sprites.HitQBlockSprite(); break; case BrickState.qlife: items.Add(new Items.Oneup(xPosition, yPosition - Constants.tileLength, camera)); state = BrickState.qempty; BrickSprite = new Sprites.HitQBlockSprite(); break; case BrickState.qcoin: sound.Coin(); //make the coin noise c = new Items.Coin(xPosition, yPosition - Constants.tileLength, camera); items.Add(c); if (isMario) { hud.increaseScoreMario(Constants.brokenBrickValue); hud.addCoinMario(); } else { hud.increaseScoreLuigi(Constants.brokenBrickValue); hud.addCoinLuigi(); } state = BrickState.qempty; BrickSprite = new Sprites.HitQBlockSprite(); break; default: break; } }
// Use this for initialization void Start() { enemyAnim = GetComponent<Animator>(); _sfx = GetComponent<SoundEffects>(); _rBody = this.GetComponent<Rigidbody2D>(); }
private void internalPlayClip( SoundEffects soundEffect ) { if( audioObject == null ) return; AudioSource audioSource = audioObject.AddComponent<AudioSource>(); audioSource.loop = false; audioSource.volume = (float)globalVolume; switch( soundEffect ) { case SoundEffects.BallBounce: audioSource.clip = BallBounceClip; break; case SoundEffects.ToBall: audioSource.clip = ToBallClip; break; case SoundEffects.GotHit: audioSource.clip = GotHitClip; break; case SoundEffects.Hit: audioSource.clip = HitClip; break; case SoundEffects.Jump: audioSource.clip = JumpClip; break; case SoundEffects.CarryBall: audioSource.clip = CarryBallClip; break; case SoundEffects.Score: audioSource.clip = ScoreClip; break; case SoundEffects.ToggleUp: audioSource.clip = ToggleUpClip; break; case SoundEffects.ToggleDown: audioSource.clip = ToggleDownClip; break; case SoundEffects.AdvanceScreen: audioSource.clip = AdvanceScreenClip; break; case SoundEffects.Countdown1: audioSource.clip = Countdown1Clip; break; case SoundEffects.Countdown2: audioSource.clip = Countdown2Clip; break; case SoundEffects.Countdown3: audioSource.clip = Countdown3Clip; break; case SoundEffects.CountdownGo: audioSource.clip = CountdownGoClip; break; case SoundEffects.Logo: audioSource.clip = LogoClip; break; case SoundEffects.Fanfare: audioSource.clip = FanfareClip; break; case SoundEffects.Invulernability: audioSource.clip = InvulernabilityClip; break; case SoundEffects.Impact: audioSource.clip = ImpactClip; break; } if( audioSource.clip == null ) { Destroy( audioSource ); return; } audioSource.Play(); StartCoroutine( DestroyOnFinish( audioSource, audioSource.clip.length ) ); }
public static void PlayClip( SoundEffects soundEffect ) { if( instance ) instance.internalPlayClip( soundEffect ); }
public void Hit(IList<IItem> items, bool isMario, bool isBig, HUD hud, SoundEffects sound) { }
public void PlaySoundAndLock(SoundEffects sound) { this.StopSound(sound); this.PlaySound(sound); this.lockTimer = 60; }
public static void Sfx(SoundEffects sfx) { if (sfxOn) { switch (sfx) { case SoundEffects.Move: PlaySoundFromFile(Path + "move.wav"); break; case SoundEffects.Rotate: PlaySoundFromFile(Path + "rotate.wav"); break; case SoundEffects.LevelUp: PlaySoundFromFile(Path + "levelup.wav"); break; case SoundEffects.ClearLine: PlaySoundFromFile(Path + "clearline.wav"); break; case SoundEffects.Drop: PlaySoundFromFile(Path + "drop.wav"); break; case SoundEffects.GameOver: PlaySoundFromFile(Path + "gameover.wav"); break; } } }
void Awake() { soundEffects = GetComponent<SoundEffects>(); }
public static Cue GetEffect(SoundEffects soundEffect) { return soundBank.GetCue(effectsLib[soundEffect]); }
public static SoundEffectInstance PlayEffect(SoundEffects soundEffect, bool loop, float volume) { SoundEffect effect = content.Load<SoundEffect>("Assets\\Sound\\" + effectsLib[soundEffect]); SoundEffectInstance instance = effect.CreateInstance(); instance.IsLooped = loop; instance.Play(); instance.Volume = 0.5f; soundEffects.Add(instance); return instance; }
public static void PlayEffect(SoundEffects soundEffect) { currentEffect = soundBank.GetCue(effectsLib[soundEffect]); currentEffect.Play(); }
private void SetSound(SoundEffects sound) { string str = "Sounds." + sound.ToString() + ".wav"; this.sounds[(int) sound] = new Sound(str, this.soundDevice); }
public void StopSound(SoundEffects sound) { int index = (int) sound; if (index >= 0) { this.sounds[index].Stop(); } }