/// <summary> /// /// </summary> /// <param name="other"></param> private void DoPick(Collider other) { DropEffect(other); JCS_SoundPlayer sp = JCS_SoundManager.instance.GetGlobalSoundPlayer(); /* Play Pick Sound */ if (mPlayOneShotWhileNotPlayingForPickSound) { sp.PlayOneShotWhileNotPlaying(mPickSound); } else { sp.PlayOneShot(mPickSound); } // call item effect. mPickCallback.Invoke(other); /* Play Effect Sound */ if (mPlayOneShotWhileNotPlayingForEffectSound) { sp.PlayOneShotWhileNotPlaying(mEffectSound); } else { sp.PlayOneShot(mEffectSound); } mCanPick = false; }
/// <summary> /// Active all the button animation under this panel. /// </summary> private void ActiveAnim() { if (mBtnCounter == mSlideButtons.Length) { return; } if (mBtnCounter != 0) { mSoundPlayer.PlayOneShot(mActiveClip); mSpaceTimer += Time.deltaTime; if (mSpaceTime < mSpaceTimer) { mSpaceTimer = 0; } else { return; } } JCS_SlideEffect se = mSlideButtons[mBtnCounter]; // stop checking if exits se.AutoAddEvent = false; se.Active(); ++mBtnCounter; mSoundPlayer.PlayOneShot(mInsideActiveClip); }
/// <summary> /// Active the effect. (Script) /// </summary> public void Active() { mIsActive = true; mTargetPosition = mTowardPosition; if (mSoundPlayer != null) { mSoundPlayer.PlayOneShot(mActiveClip); } }
/// <summary> /// Do the shake effect with time and margin. /// </summary> /// <param name="time"> time to do the shake. </param> /// <param name="margin"> margin to do the shake. </param> public void DoShake(float time, float margin) { if (!mRepeatOverride) { // if is doing the effect if (mEffect) { // is effecting. return; } } // only record down the first time if (!mEffect) { this.mShakeOrigin = this.transform.position; } this.mShakeTime = time; this.mShakeTimer = 0; this.mShakeMargin = margin; mEffect = true; // Disable the input. if (mStopInputWhileThisEffect) { JCS_GameManager.instance.GAME_PAUSE = true; } // play sound effect! mSoundPlayer.PlayOneShot(mShakeSound); }
/// <summary> /// Hit Sound is the part of sfx sound /// </summary> private void PlayHitSound(AudioClip hitSound) { if (hitSound != null) { // play the hit sound provide by passing in. mSoundPlayer.PlayOneShot(hitSound, JCS_SoundSettings.instance.GetSFXSound_Volume()); } else { if (mHitSound != null) { // play the regular assigned by variable's hit sound. mSoundPlayer.PlayOneShot(mHitSound, JCS_SoundSettings.instance.GetSFXSound_Volume()); } } }
/// <summary> /// Take a snapshot and store image to data path. /// </summary> public string TakeSnapshotWebcam() { // No device detected!! // cannot take snap shot without the device!! if (!mDetectDevice) { JCS_Debug.LogError("No webcam detected in the current devices"); return null; } var gs = JCS_GameSettings.instance; var prefix = gs.WEBCAM_FILENAME; var ext = gs.WEBCAM_EXTENSION; string savePath = SavePath(); JCS_IO.CreateDirectory(savePath); Texture2D snap = new Texture2D(mWebCamTexture.width, mWebCamTexture.height); snap.SetPixels(mWebCamTexture.GetPixels()); snap.Apply(); // get the last saved webcam image's index int last_saved_index = LastImageFileIndex() + 1; string fullPath = ImagePathByIndex(last_saved_index); File.WriteAllBytes(fullPath, snap.EncodeToPNG()); if (mSplash) { JCS_SceneManager sm = JCS_SceneManager.instance; if (sm.GetWhiteScreen() == null) JCS_UtilityFunctions.PopJCSWhiteScreen(); sm.GetWhiteScreen().FadeIn(); // do the snap shot effect mSplashEffectTrigger = true; } // Stop the camera mWebCamTexture.Pause(); // start the timer wait for resume mResumeTrigger = true; // play sound. { var soundm = JCS_SoundManager.instance; JCS_SoundPlayer sp = soundm.GetGlobalSoundPlayer(); sp.PlayOneShot(mTakePhotoSound); } return fullPath; }
/// <summary> /// /// </summary> private void SpawnSwignSound() { if (mAudioClip == null) { return; } mSoundPlayer.PlayOneShot(mAudioClip, mSoundType); }
/// <summary> /// Show the dialogue in the game. /// /// NOTE(jenchieh): this will play the default sound. /// </summary> public void ShowDialogue() { ShowDialogueWithoutSound(); // set focus dialogue if (GetDialogueType() == JCS_DialogueType.PLAYER_DIALOGUE) { JCS_UIManager.instance.SetJCSDialogue(JCS_DialogueType.PLAYER_DIALOGUE, this); } // let UIManager know the window is opened SwapToTheLastOpenWindowList(); if (mOpenWindowClip != null && mJCSSoundPlayer != null) { mJCSSoundPlayer.PlayOneShot(mOpenWindowClip, JCS_SoundType.SOUND_2D); } }
private void Update() { if (mSoundPlayed) { return; } mSoundPlayer.PlayOneShot(mAudioClip, mSoundSettingType); mSoundPlayed = true; }
/// <summary> /// /// </summary> public void TakeSnapshotWebcam() { // No device detected!! // cannot take snap shot without the device!! if (!mDetectDevice) { JCS_Debug.LogError("JCS_Webcam", "No webcam detected in the current devices."); return; } string fullPath = Application.dataPath + mSavePath; // if Directory does not exits, create it prevent error! if (!Directory.Exists(fullPath)) { Directory.CreateDirectory(fullPath); } Texture2D snap = new Texture2D(mWebCamTexture.width, mWebCamTexture.height); snap.SetPixels(mWebCamTexture.GetPixels()); snap.Apply(); System.IO.File.WriteAllBytes(fullPath + mCaptureCounter.ToString() + ".png", snap.EncodeToPNG()); ++mCaptureCounter; if (mSplash) { JCS_SceneManager sm = JCS_SceneManager.instance; if (sm.GetJCSWhiteScreen() == null) { JCS_UtilityFunctions.PopJCSWhiteScreen(); } sm.GetJCSWhiteScreen().FadeIn(); // do the snap shot effect mSplashEffectTrigger = true; } // Stop the camera mWebCamTexture.Stop(); // start the timer wait for resume mResumeTrigger = true; // play sound. mSoundPlayer.PlayOneShot(mTakePhotoSound); }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions /// <summary> /// Randomly play one shot of sound /// from the audio clip pool! /// </summary> public void PlayRandomSound() { if (mAudioClips.Length == 0) { return; } int randIndex = JCS_Random.Range(0, mAudioClips.Length); if (mAudioClips[randIndex] == null) { JCS_Debug.LogError("JCS_SoundPoolAction", "You inlcude a null references in he audio pool..."); return; } float soundVolume = JCS_SoundSettings.instance.GetSoundBaseOnType(mSoundSettingType); mSoundPlayer.PlayOneShot(mAudioClips[randIndex], soundVolume); }
private void Update() { if (!mStartDelay) { return; } mDelayTimer += Time.deltaTime; if (mDelayTime < mDelayTimer) { // switch scene. SwitchScene(); // play sound. mSoundPlayer.PlayOneShot(mSlideScreenSound); // reset timer (ready for next use) mDelayTimer = 0; // disable delay (ready for next use) mStartDelay = false; } }
/// <summary> /// Play switch scene sound. /// </summary> private void PlaySwitchSceneSound() { JCS_SoundPlayer sp = JCS_SoundManager.instance.GetGlobalSoundPlayer(); sp.PlayOneShot(this.mSwitchSceneSound); }