void Awake() { mPressSound = AudioManager.Instance.GetSoundsEvent("ButtonClick/QuestionMark", true); }
void Awake() { // creat collision efets mWorldGen = transform.Find("WorldGen").GetComponent<WorldGen>(); mBgGen = transform.Find("BgGen").GetComponent<WorldGen>(); GameObject playerObj = GameObject.Find("Player"); if (playerObj == null) { playerObj = GameObject.Instantiate(mPlayerPrefab); playerObj.name = mPlayerPrefab.name; } mPlayer = playerObj.GetComponent<Player>(); GameObject dirLightObj = GameObject.Find("InGame DirectionalLight"); if (dirLightObj == null) { dirLightObj = GameObject.Instantiate(mDirectionalLightPrefab); dirLightObj.name = mDirectionalLightPrefab.name; } mDirectionalLight = dirLightObj; GameObject deathMenuObj = GameObject.Find("pop_up_menu_results"); if (deathMenuObj == null) { deathMenuObj = GameObject.Instantiate(mDeathMenuPrefab); deathMenuObj.name = mDeathMenuPrefab.name; } mDeathMenu = deathMenuObj; mDeathMenu.SetActive(false); fmodMusic = AudioManager.Instance.GetMusicEvent("AsteroidLevelMusic/AsteroidMusicPrototype", false); fmodPerfect = AudioManager.Instance.GetSoundsEvent("PerfectDistance/PerfectDistance", true, 3); mPerfectDistanceMid = GameObject.Instantiate(mPerfectDistanceMidPrefab); // creat collision efets mAstCollParticle1Manager = GetComponents<ParticleManager>()[0]; mAstCollParticle2Manager = GetComponents<ParticleManager>()[1]; mBulletCollParticleManager = GetComponents<ParticleManager>()[2]; mMissileCollParticleManager = GetComponents<ParticleManager>()[3]; mLightningCollParticleManager = GetComponents<ParticleManager>()[4]; }
public AudioInstanceData GetEvent(string path, bool latencyFix, int variants) { if (latencyFix) { // check cached first if (mLoadedAudioFixFiles.ContainsKey(path)) { return new AudioInstanceData(mLoadedAudioFixFiles[path]); } #if UNITY_EDITOR int acsCount = Resources.LoadAll<AudioClip>(path.Substring(0, path.LastIndexOf('/') + 1)).Length; if ((acsCount != variants) && ((acsCount != 1) || (variants != 0))) { Debug.LogError("Error: illegal variants count: " + path + " varanbtr: " + variants + " vs " + acsCount); return null; } #endif AudioInstanceData aid = null; if (variants == 0) { int ID = mSoundPool.load(path); if (ID == -1) { return null; } aid = new AudioInstanceData(ID); } else { int[] IDs = new int[variants]; for (int i = 0; i < variants; i++) { IDs[i] = mSoundPool.load(path + (i + 1)); if (IDs[i] == -1) { return null; } } aid = new AudioInstanceData(IDs); } mLoadedAudioFixFiles[path] = aid.mIDs; return aid; } else { AudioSource audioSource = gameObject.AddComponent<AudioSource>(); // check cached first if (mLoadedAudioFiles.ContainsKey(path)) { return new AudioInstanceData(mLoadedAudioFiles[path], audioSource); } #if UNITY_EDITOR int acsCount = Resources.LoadAll<AudioClip>(path).Length; if ((acsCount != variants) && ((acsCount != 1) || (variants != 0))) { Debug.LogError("Error: illegal variants count:" + path + " varanbtr:" + variants + "vs " + acsCount); return null; } #endif AudioInstanceData aid = null; if (variants == 0) { AudioClip ac = loadAudioClip(path); if (ac == null) { return null; } aid = new AudioInstanceData(ac, audioSource); } else { AudioClip[] acs = new AudioClip[variants]; for (int i = 0; i < variants; i++) { acs[i] = loadAudioClip(path + (i + 1)); if (acs[i] == null) { return null; } } aid = new AudioInstanceData(acs, audioSource); } mLoadedAudioFiles[path] = aid.mAudioClips; return aid; } }
void Awake() { mRb = GetComponent<Rigidbody> (); mClash = AudioManager.Instance.GetSoundsEvent("AsteroidCollision/AsteroidCollision", true, 3); }
void StartAudio(AudioInstanceData fmodEvent, bool oneShot, float volume) { if (fmodEvent.mAudioSource != null) { AudioClip ac = fmodEvent.mAudioClips[Random.Range(0, fmodEvent.mAudioClips.Length)]; if (oneShot) { fmodEvent.mAudioSource.PlayOneShot(ac, volume); } else { fmodEvent.mAudioSource.clip = ac; fmodEvent.mAudioSource.volume = volume; fmodEvent.mAudioSource.Play(); } } else { float volume2 = fmodEvent.mVolume * volume * 100; int playID = fmodEvent.mIDs[Random.Range(0, fmodEvent.mIDs.Length)]; int streamID = mSoundPool.play(playID, volume2, volume2, 0, fmodEvent.mLoop, 1.0f); if (!oneShot) { fmodEvent.mStreamID = streamID; } } }
void StopAudio(AudioInstanceData fmodEvent) { if (fmodEvent.mAudioSource != null) { fmodEvent.mAudioSource.Stop(); } else { mSoundPool.stop(fmodEvent.mStreamID); fmodEvent.mStreamID = 0; } }
public void StopSound(AudioInstanceData fmodEvent) { if (fmodEvent == null) { Debug.LogError("ERROR! Audio missing."); return; } if (mPlayingSoundEvents.Remove (fmodEvent) && mDebug) { printSound(); } StopAudio(fmodEvent); }
public void PlayMusic(AudioInstanceData fmodEvent) { PlayMusic(fmodEvent, false); }
public void PlaySound(AudioInstanceData fmodEvent, bool playOnce) { if (fmodEvent == null) { Debug.LogError("ERROR! Audio missing."); return; } if (!playOnce) { if (!mPlayingSoundEvents.Contains(fmodEvent)) { mPlayingSoundEvents.Add(fmodEvent); } if (mDebug) { printSound(); } } if (mMuteMaster || mMuteSounds) { return; } StartAudio(fmodEvent, playOnce, mSoundsLevel * mMasterLevel); }
public void PlaySoundOnce(AudioInstanceData fmodEvent) { PlaySound(fmodEvent, true); }
// sound public void PlaySound(AudioInstanceData fmodEvent) { PlaySound(fmodEvent, false); }
// music public void PlayMusicOnce(AudioInstanceData fmodEvent) { PlayMusic(fmodEvent, true); }
public void PlayMusic(AudioInstanceData fmodEvent, bool playOnce) { if (fmodEvent == null) { Debug.LogError("ERROR! Audio missing."); return; } if (!playOnce) { if (!mPlayingMusicEvents.Contains(fmodEvent)) { mPlayingMusicEvents.Add(fmodEvent); } if (mDebug) { printMusic(); } } if (mMuteMaster || mMuteMusic) { return; } StartAudio(fmodEvent, false, mMusicLevel * mMasterLevel); }
void Awake() { if (instance == null) { instance = this; } mSettingAudioManagerBackup = GetComponent<AudioManager> (); if (mBackgroundPrefab != null) { mBackground = GameObject.Instantiate (mBackgroundPrefab); } else { mBackground = new GameObject("Menu Background"); } fmodMusic = AudioManager.Instance.GetMusicEvent("MenuMusic/DroneMeny", false); fmodSwipe = AudioManager.Instance.GetSoundsEvent("MenuSectionSwipe/MenuSwipeShort", true); mGameMenus = GetComponentsInChildren<GameMenu> (); mCurrentGameMenu = mGameMenus [0]; }
private void SetAudioVolume(AudioInstanceData audioInstanceData, float p) { if (audioInstanceData.mAudioSource != null) { audioInstanceData.mAudioSource.volume = p; } else { if (audioInstanceData.mStreamID == 0) { return; } mSoundPool.setVolume(audioInstanceData.mStreamID, p * 100, p * 100); } }
// Use this for initialization void Awake() { // keep player along levels mBoltParticleManager = GetComponents<ParticleManager>()[1]; mPickupTextManager = GetComponents<ParticleManager>()[0]; // init compoments mRb = GetComponent<Rigidbody>(); mAntenLensFlare = GetComponentInChildren<LensFlare>(); mAni = transform.Find ("Chubby_Hover").GetComponent<Animator> (); mMovementControls = new MovementControls(this); mDash = transform.Find("Burst_Trail").gameObject; skinnedMeshRenderer = GetComponentsInChildren<SkinnedMeshRenderer>().Where(x => x.name != "Backpack").ToArray(); mDownSwipeSound = AudioManager.Instance.GetSoundsEvent("DownSwipe/DownSwipe", true, 4); mHurtHitSound = AudioManager.Instance.GetSoundsEvent("TakeDamage/TakeDamage", true, 3); mCoinPickUpSound = AudioManager.Instance.GetSoundsEvent("ScewsPling/ScrewsPling", true, 4); mInflateSound = AudioManager.Instance.GetSoundsEvent("Inflate/Inflate", true, 4); mDeflateSound = AudioManager.Instance.GetSoundsEvent("Deflate/Deflate", true, 4); mInflateSound.mVolume = 100; mDeflateSound.mVolume = 100; transform.position = Vector3.zero; }
void Awake() { mRestatButton[0] = ButtonManager.CreateButton(gameObject, "button_1_base"); mMenuButton[0] = ButtonManager.CreateButton(gameObject, "button_2_base"); mRestatButton[1] = ButtonManager.CreateButton(gameObject, "button_1_core"); mMenuButton[1] = ButtonManager.CreateButton(gameObject, "button_2_core"); mRestatButton[2] = ButtonManager.CreateButton(gameObject, "Text/restart"); mMenuButton[2] = ButtonManager.CreateButton(gameObject, "Text/main menu"); mTexts = gameObject.GetComponentsInChildren<TextMesh> (); for (int i = 0; i < mTexts.Length; i++) { if (mTexts[i].gameObject.name == "bolts gathered") mBoltsText = mTexts[i]; if (mTexts[i].gameObject.name == "distance total") mDisText = mTexts[i]; else if (mTexts[i].gameObject.name == "multiplier number") mMultiText = mTexts[i]; else if (mTexts[i].gameObject.name == "bolts total") mTotalBoltsText = mTexts[i]; } fmodDeathMusic = AudioManager.Instance.GetMusicEvent("ScrapScoreMusic/ScrapScoreMusic", false); mDisDown = AudioManager.Instance.GetSoundsEvent("ScrapScoreTicker/RewardTickerBoTH", false); //mCoinUp = AudioManager.Instance.GetSoundsEvent("RewardTickerDistance/TickerDistance"); }