public static void PlayAudioClip(SoundFX sound) { int key = (int)sound; if( soundDictionary.ContainsKey(key) && soundDictionary[key]) audioSource.PlayOneShot(soundDictionary[key], 0.75f); }
/* * ----------------------- * IsSoundPlaying() * used in the editor * ----------------------- */ static public bool IsSoundPlaying(string soundFxName) { if (theAudioManager == null) { if (!FindAudioManager()) { return(false); } } SoundFX soundFX = FindSoundFX(soundFxName, true); if (soundFX == null) { return(false); } AudioClip clip = soundFX.GetClip(); if (clip != null) { Assembly unityEditorAssembly = typeof(AudioImporter).Assembly; Type audioUtilClass = unityEditorAssembly.GetType("UnityEditor.AudioUtil"); MethodInfo method = audioUtilClass.GetMethod( "IsClipPlaying", BindingFlags.Static | BindingFlags.Public, null, new System.Type[] { typeof(AudioClip) }, null); return(Convert.ToBoolean(method.Invoke(null, new object[] { clip }))); } return(false); }
private void Awake() { if (SoundFX.instance == null) { SoundFX.instance = this; } }
/* * ----------------------- * StopSound() * used in the editor * ----------------------- */ static public void StopSound(string soundFxName) { if (theAudioManager == null) { if (!FindAudioManager()) { return; } } SoundFX soundFX = FindSoundFX(soundFxName, true); if (soundFX == null) { return; } AudioClip clip = soundFX.GetClip(); if (clip != null) { Assembly unityEditorAssembly = typeof(AudioImporter).Assembly; Type audioUtilClass = unityEditorAssembly.GetType("UnityEditor.AudioUtil"); MethodInfo method = audioUtilClass.GetMethod( "StopClip", BindingFlags.Static | BindingFlags.Public, null, new System.Type[] { typeof(AudioClip) }, null); method.Invoke(null, new object[] { clip }); } }
private void GetMovementInput() { //Movement Variables moveInput = Input.GetAxisRaw("Horizontal"); jumpInput = Input.GetButtonDown("Jump"); attackInput = Input.GetButtonDown("Submit"); attackRelease = Input.GetButtonUp("Submit"); //Enables Jumping if (jumpInput && grounded) { Jump(); } // Enables Double jumping if (jumpInput && !grounded && !doubleJumped) { DoubleJump(); } //Enables Attack if (attackInput && grounded) { anim.SetTrigger("Attack"); //TODO: Debug.Log("The length of the animation is: " + anim.GetCurrentAnimatorStateInfo(0).length + " seconds"); SoundFX.PlayOneShot(SFXArray[0]); animAttackClipInfo = anim.GetCurrentAnimatorClipInfo(0); attackClipLength = animAttackClipInfo[0].clip.length; //TODO:Debug.Log("The length of the " + animAttackClipInfo[0].clip.name + " animation is: " + attackClipLength + " seconds"); StartCoroutine(StopMovementWhileAttacking()); } if (attackRelease && grounded) { anim.ResetTrigger("Attack"); } }
private void CreateTaskButton_Click(object sender, RoutedEventArgs e) { SoundFX.PlayFinishCreatingTaskSound(); Haptics.ApplyCreateTaskButtonPressHaptics(); ToDoTask.CreateNote(taskDetailsTextBox.Text); App.NavService.Navigate(typeof(MainPage)); }
private void Start() { mg = GameObject.Find("MultiplayerGameManager").GetComponent <MultiplayerGameManager>(); MultiplayerGameTextBox.transform.Find("OKButton").GetComponent <Button>().onClick.AddListener(LeaveGame); MultiplayerGameTextBox.transform.Find("CancelButton").GetComponent <Button>().onClick.AddListener(CancelLeaveAttempt); SoundManager = GameObject.Find("SoundFX").GetComponent <SoundFX>(); }
private void OnCollisionEnter2D(Collision2D collision) { switch (collision.gameObject.tag) { case "EnemyBandit": if (isDamagable) { SoundFX.PlayOneShot(SFXArray[3]); beingKnockedback = true; PlayerHealth--; if (collision.transform.position.x > transform.position.x) { hitOnRight = true; } else if (collision.transform.position.x < transform.position.x) { hitOnRight = false; } Kickback(); scoreCounter.ScoreCountKeeper--; StartCoroutine(InvincibilityTimer()); } if (PlayerHealth == 0) { SetIsDead(true); } break; //Default Case Handler default: break; } }
void Start() { originPos = Vector3.zero; cam = Camera.main; audioSource = GetComponent <AudioSource>(); sfx = player.gameObject.GetComponent <SoundFX>(); }
// Use this for initialization void Start () { gameController = GameController.current; sfx = SoundFX.current; this.spell = ""; eventController = this.gameObject.GetComponent<EventController> (); spellController = this.gameObject.GetComponent<SpellController> (); }
void Start() { source = Toolbox.GetInstance.GetSound().source; if (source != null) { sfx = source.GetComponent <SoundFX>(); } }
/* * ----------------------- * PlaySound() * ----------------------- */ static public int PlaySound(SoundFX soundFX, EmitterChannel src = EmitterChannel.Any, float delay = 0.0f) { if (!SoundEnabled) { return(-1); } return(PlaySoundAt((staticListenerPosition != null) ? staticListenerPosition.position : Vector3.zero, soundFX, src, delay)); }
private void Awake() { base.Awake(); var soundbank = Instantiate(SoundbankPrefab); _fx = soundbank.GetComponent <SoundFX>(); }
void Start() { audioButton = GetComponent <Button>(); audioButton.onClick.AddListener(OnClick); displayText = GetComponentInChildren <Text>(); am = SoundFX.InstanceAM; }
void Start() { am = SoundFX.InstanceAM; restartBttn = transform.GetChild(2).GetComponent <Button>(); restartBttn.onClick.AddListener(OnRestart); mainMenuBttn = transform.GetChild(3).GetComponent <Button>(); mainMenuBttn.onClick.AddListener(OnMainMenu); }
/* ----------------------- Init() ----------------------- */ void Init() { // look up the actual SoundFX object soundFXCached = AudioManager.FindSoundFX( soundFXName ): if ( soundFXCached == null ) { soundFXCached = AudioManager.FindSoundFX( string.Empty ): } initialized = true: }
private void Start() { positionClose = transform.position; positionOpen = transform.position; positionOpen.y += 6; source = GetComponent <AudioSource>(); sfx = GetComponent <SoundFX>(); }
public void Awake() { if (_instance != null) { Logger.Warning("SoundFX should only be attached once."); return; } _instance = this; }
private async void CompletedStampToggleButton_Checked(object sender, RoutedEventArgs e) { await updateListedTaskFromCompletionResult(); if (PageStuff.navigating == false) { Haptics.ApplyCompletedStampHaptics(); SoundFX.PlayCompletedSound(); } }
public void Remove(SoundFX sound) { // 삭제 if (null == sound) { return; } sound.gameObject.SetActive(false); }
private void Start() { sound = SoundFX.Instance; attackMethods = new List <Func <Vector2, IEnumerator> >() { TryClockwiseSlash, TryCounterClockwiseSlash, TryStab }; ResetRestingPosition(); }
private void Start() { GetComponent <Button>().onClick.AddListener(MainLogicPass); EraseButton.enabled = false; MoveSkillButton.enabled = false; FreezeSkillButton.enabled = false; HintSkillButton.enabled = false; SubmitButton.enabled = false; SoundManager = GameObject.Find("SoundFX").GetComponent <SoundFX>(); }
public void StopSound(string name) { SoundFX soundEffectToPlay = Array.Find(soundEffects, soundEffect => soundEffect.name == name); //Letar igenom arryn "soundEffects" efter en soundEffect där namnvariabeln matchar stringen vi tagit emot. if (soundEffectToPlay == null) { Debug.Log(name + "couldn't be found. You probably spelled it wrong."); return; } soundEffectToPlay.audioSource.Stop(); }
public void playClip(SoundFX clip) { if (clip == SoundFX.winMinigame) { AS.PlayOneShot(winMinigame); } else if (clip == SoundFX.failMinigame) { AS.PlayOneShot(failMinigame); } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
/// <summary> /// Plays the next in line of the soundFX of your choice /// increments the soundFX in the given list for predictable variety /// </summary> /// <param name="soundToPlay"></param> public void PlaySound(SoundFX soundToPlay) { int soundFXIndex = soundFXCount[soundToPlay]; soundFX[soundToPlay].ElementAt <SoundEffect>(soundFXIndex).Play(); soundFXCount[soundToPlay]++; if (soundFXCount[soundToPlay] >= soundFX[soundToPlay].Count) { soundFXCount[soundToPlay] = 0; } }
public ClockStone.AudioObject PlaySFX(SoundFX sfx, bool forceInSilence = false) { if (forceInSilence) { return(this.PlaySFXWithoutSilence(sfx.ToString())); } else { return(this.PlaySFX(sfx.ToString())); } }
public BufferedSoundFX(SoundFX source) { this.source = source; this.canDuplicate = source.canDuplicate; this.canSeek = source.canSeek; this.audioFormat = source.audioFormat; this.length = source.length; this.initialSeekTo = source.currentTime; this.BufferSize = 10 * audioFormat.samplesPerSecond; ThreadPool.QueueUserWorkItem(buffer, this); // schedule a secondary buffer to be filled }
// On frame void Awake() { /// Enemy level eStats = transform.root.GetComponent <EnemyStatsContainer>().eStats; /// NavMesh component navMesh = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); sfx = GetComponent <SoundFX>(); }
private void ChaseTarget() { if (Vector3.Distance(transform.position, player.position) <= eStats.aggroRange) { //Debug.Log("player"); currentTarget = player; losePlayer = eStats.lostRangDuration; if (!isAggro) { isAggro = true; SoundFX sfx = GetComponent <SoundFX>(); sfx.PlaySound(sfx.chosenSource, Toolbox.GetInstance.GetSound().eAggro, true, 0.4f, 0.5f, 0.90f, 1.10f); } } else if (losePlayer < 0) { currentTarget = ReturnClosestTarget(); if (isAggro) { isAggro = false; } } else { losePlayer -= Time.deltaTime * 2f; } if (currentTarget != null) { navMeshAgent.isStopped = false; navMeshAgent.SetDestination(currentTarget.position); } else { navMeshAgent.isStopped = true; } if (navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance) { GetComponent <EnemyMovementState>().EnemyIdle(); } else if (GetComponent <EnemyMovementState>().currentMoveState == EnemyMovementState.MoveState.Crawl) { GetComponent <EnemyMovementState>().EnemyCrawl(); } else { GetComponent <EnemyMovementState>().EnemyWalk(); } }
public override void SetLife(int l) { anim.SetTrigger("Hit"); Debug.Log("man dao"); base.SetLife(l); if (!isDead) { SoundFX.Play(); } gameManager.PlayerLife(life); gameObject.GetComponentInChildren <Weapon>().PreviousWapon(); }
// Use this for initialization void Start () { sfx = SoundFX.current; gameController = GameController.current; currentEvent = 0; currentEventGameObject = GameObject.FindGameObjectWithTag (events[currentEvent]); eventStarted = 0; eventRate = 10f; eventLength = 5f; nextEvent = 5f; }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(this); } DontDestroyOnLoad(instance.gameObject); }
public void Play(SoundFX theSound) { switch (theSound) { case SoundFX.bottle_1: { bottle_1.Play(); break; } case SoundFX.bottle_2: { bottle_2.Play(); //reward.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); break; } case SoundFX.can_1: { can_1.Play(); break; } case SoundFX.can_2: { can_2.Play(); break; } case SoundFX.liquid: { liquid.Play(); break; } case SoundFX.bubble: { bubble.Play(); break; } case SoundFX.button: { button.Play(); break; } default: { break; } } }
//Initialize the background musics and soundfx public void Play(SoundFX theSound) { switch (theSound) { case SoundFX.LineClear: { kaboom.Play((OptionsMenuScreen.soundVolume*.01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("LineClear").Play(); break; } case SoundFX.Reward: { // mSoundBank.GetCue("Tetris").Play(); break; } case SoundFX.LevelClear: { // mSoundBank.GetCue("LevelClear").Play(); break; } case SoundFX.Rotate: { // mSoundBank.GetCue("Rotate").Play(); break; } case SoundFX.Intro: { intro.Play(1.0f, 0.0f, 0.0f, false); // mSoundBank.GetCue("Start").Play(); break; } case SoundFX.Start: { // mSoundBank.GetCue("Start").Play(); break; } case SoundFX.GameOver: { // mSoundBank.GetCue("GameOver").Play(); break; } } }
void Awake() { m_Colors = Colors; m_Game = Game; m_Music = Music; m_Particles = Particles; m_Prefabs = Prefabs; m_Sprites = Sprites; m_Score = Score; m_SoundFX = SoundFX; m_Timer = Timer; if (!MainMenu) m_Camera = Camera; m_Strings = TextStrings; m_Input = InputHandler; if (MainMenu) m_interMain = MainMenu; else if(HUD) m_interGame = HUD; else if (CreateMode) m_interCreate = CreateMode; }
public AudioClip GetSound(SoundFX sound) { AudioClip s = null; switch(sound) { case SoundFX.AttackLoop: s = attackLoop; break; case SoundFX.AttackLoop2: s = attackLoop2; break; case SoundFX.AttackLoop3: s = attackLoop3; break; case SoundFX.AttackStart: float rnd = Random.Range(0f, 1f); if(rnd < 0.33f) s = attackStart; else if(rnd < 0.66f) s = attackStart2; else s = attackStart3; break; case SoundFX.Click: s = click; break; case SoundFX.EnemyDie: s = enemyDie; break; case SoundFX.Freeze: s = freeze; break; case SoundFX.MenuIn: s = menuIn; break; case SoundFX.MenuOut: s = menuOut; break; case SoundFX.MenuScroll: s = menuScroll; break; case SoundFX.OrbPP: s = orbPP; break; case SoundFX.OrbP: s = orbP; break; case SoundFX.OrbM: s = orbM; break; case SoundFX.OrbG: s = orbG; break; case SoundFX.Pause: s = pause; break; case SoundFX.Resume: s = resume; break; case SoundFX.ShopBuy: s = shopBuy; break; case SoundFX.Achievement: s = achievement; break; case SoundFX.DeathRay: s = deathRay; break; case SoundFX.PowerUpCollected: s = powerUpCollect; break; case SoundFX.Score: s = score; break; case SoundFX.PlayerDamage: s = playerDamage; break; case SoundFX.LevelUp: s = levelUp; break; case SoundFX.BossMeteorIdle: s = bossMeteorIdle; break; case SoundFX.BossMeteorDamage: s = bossMeteorDamage; break; case SoundFX.BossMeteorDrop: rnd = Random.Range(0f, 1f); if(rnd < 0.33f) s = meteorDrop1; else if(rnd < 0.66f) s = meteorDrop2; else s = meteorDrop3; break; case SoundFX.BossTwinsIdle: s = bossTwinsIdle; break; case SoundFX.BossTwinsDamage: s = bossTwinsDamage; break; case SoundFX.BossTwinDie: s = bossTwinsDie; break; case SoundFX.BossIllusionIdle: s = bossIllusionIdle; break; case SoundFX.BossIllusionMultiply: s = bossIllusionMultiply; break; case SoundFX.BossIllusionDamage: s = bossIllusionDamage; break; case SoundFX.BossDie: s = bossDie; break; case SoundFX.DamageShield: s = damageShield; break; } return s; }
void Awake() { Instance = this; PackageManager.Instance.onLoaded += Instance_onLoaded; }
void Awake () { current = this; au = gameObject.GetComponent<AudioSource> (); }
//Initialize the background musics and soundfx public void Play(SoundFX theSound) { switch (theSound) { case SoundFX.LineClear: { //kaboom.Play((OptionsMenuScreen.soundVolume*.01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("LineClear").Play(); break; } case SoundFX.Reward: { //reward.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("Tetris").Play(); break; } case SoundFX.LevelClear: { //nextlevel.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("LevelClear").Play(); break; } case SoundFX.Rotate: { //scratch.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("Rotate").Play(); break; } case SoundFX.RotateGrid: { //rotategrid.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("Rotate").Play(); break; } case SoundFX.Intro: { //intro.Play(1.0f, 0.0f, 0.0f, false); // mSoundBank.GetCue("Start").Play(); break; } case SoundFX.Start: { //start.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); //mSoundBank.GetCue("Start").Play(); break; } case SoundFX.GameOver: { //stop.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("GameOver").Play(); break; } case SoundFX.Move: { //move.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("GameOver").Play(); break; } case SoundFX.Selection: { //select.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("GameOver").Play(); break; } case SoundFX.Reload: { reload.Play((OptionsMenuScreen.soundVolume * .04f), 0.0f, 0.0f, false); // mSoundBank.GetCue("GameOver").Play(); break; } case SoundFX.Sniped: { sniped.Play((OptionsMenuScreen.soundVolume * .02f), 0.0f, 0.0f, false); // mSoundBank.GetCue("GameOver").Play(); break; } case SoundFX.Laser: { laser.Play((OptionsMenuScreen.soundVolume * .01f), 0.0f, 0.0f, false); // mSoundBank.GetCue("GameOver").Play(); break; } } }
private IEnumerator PlaySoundFXSimultaneouly(SoundFX[] sounds) { foreach(SoundFX sound in sounds) { AudioClip s = GetSound(sound); audioSourceSoundFX.PlayOneShot(s); //Debug.Log(string.Format("Played sound {0} in {1}", sound, Time.time)); yield return new WaitForEndOfFrame(); } }
public void PlaySoundFX(SoundFX sound) { if(soundFXMute) return; AudioClip s = GetSound(sound); audioSourceSoundFX.PlayOneShot(s); }