void MusicStarter() { if (SoundIThink == null) { SoundIThink = Audio.PlaySoundAtTransformWithRef("Kahoot!", transform); } }
IEnumerator pressureCount() { timerSound = Audio.PlaySoundAtTransformWithRef("countdown", transform); for (int u = 0; u < timer; u++) { yield return(new WaitForSecondsRealtime(1)); } float p = -2.82f; for (int u = 0; u < 14; u++) { p += 0.1f; piston.transform.localPosition = new Vector3(0, p, 0); yield return(new WaitForSecondsRealtime(0.001f)); } for (int u = 0; u < 14; u++) { p -= 0.1f; piston.transform.localPosition = new Vector3(0, p, 0); yield return(new WaitForSecondsRealtime(0.001f)); } if (!_isSolved && !turn) { Debug.LogFormat("[Manometers #{0}] Time ran out ! Strike and reset !", _moduleId); this.HandleStrike(); } }
private IEnumerator StartingKugel() { scale = 0.05f; basecol = new float[] { 1f, 1f, 1f }; for (int i = -10; scale < 0.1f; i++) { if (i == -9 && kugelID == 1) { sound = Audio.PlaySoundAtTransformWithRef("HighPitch", Module.transform); } sphereMeshRenderer.material.color = new Color(basecol[0], basecol[1], basecol[2]); shinyMeshRenderer.color = new Color(basecol[0], basecol[1], basecol[2], 0.5f); scale += i / 25000f; yield return(new WaitForSeconds(0.02f)); basecol[0] = (1f + basecol[0] * 63f) / 64f; basecol[1] = (1f + basecol[1] * 63f) / 64f; basecol[2] = (1f + basecol[2] * 63f) / 64f; Sphere.transform.localScale = new Vector3(scale, scale, scale); shinyMeshRenderer.range = (i + 140) / 1000f; shinyMeshRenderer.intensity = (i + 240) / 200f; } Sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); //shinyMeshRenderer.range = 0.1f; //shinyMeshRenderer.intensity = 1f; scale = 0.1f; if (kugelID == 1) { sound.StopSound(); sound = null; } StartCoroutine(Run()); }
protected KMAudio.KMAudioRef PlayGameSoundHandlerWithRef(KMSoundOverride.SoundEffect sound, Transform t) { KMAudio.KMAudioRef kmaudioRef = new KMAudio.KMAudioRef(); if (audioSource == null) { return(kmaudioRef); } var clip = SoundEffects.GetAudioClip(sound); if (clip == null) { return(kmaudioRef); } try { audioSource.transform.position = t.position; } catch { } audioSource.loop = false; audioSource.PlayOneShot(clip); KMAudio.KMAudioRef kmaudioRef2 = kmaudioRef; kmaudioRef2.StopSound = (Action)Delegate.Combine(kmaudioRef2.StopSound, new Action(delegate { if (audioSource.isPlaying) { audioSource.Stop(); } })); return(kmaudioRef); }
protected KMAudio.KMAudioRef PlaySoundwithRefHandler(string clipName, Transform t, bool loop) { KMAudio.KMAudioRef kmaudioRef = new KMAudio.KMAudioRef(); if (audioSource == null) { return(kmaudioRef); } if (audioClips.Count <= 0) { return(kmaudioRef); } AudioClip clip = audioClips.Where(a => a.name == clipName).First(); if (clip == null) { return(kmaudioRef); } if (t != null) { audioSource.transform.position = t.position; } audioSource.loop = loop; audioSource.PlayOneShot(clip); KMAudio.KMAudioRef kmaudioRef2 = kmaudioRef; kmaudioRef2.StopSound = (Action)Delegate.Combine(kmaudioRef2.StopSound, new Action(delegate { if (audioSource.isPlaying) { audioSource.Stop(); } })); return(kmaudioRef); }
IEnumerator SubmitAnimation() { StringBuilder stringBuilder = new StringBuilder(Submission.text); float y = 0; float changeCharacter = 0; KMAudio.KMAudioRef audioRef = Audio.PlaySoundAtTransformWithRef("Submit", transform); foreach (float alpha in TimedAnimation(4)) { float curvedAlpha = Mathf.Pow(alpha, 4) / 5; changeCharacter += alpha; while (changeCharacter >= 0.5f) { changeCharacter -= 0.5f; stringBuilder[Random.Range(0, stringBuilder.Length)] = (char)Random.Range(32, 126); CustomDisplayText = stringBuilder.ToString(); } SubmissionMaterial.mainTextureOffset = new Vector2(0, y += curvedAlpha); yield return(null); } audioRef.StopSound(); }
void Awake() { _moduleID = _moduleIdCounter++; while (Outputs.Distinct().Count() < 4) { for (int i = 0; i < 10; i++) { Outputs[i] = Rnd.Range(0, 7); } } Calculate(); Inner.material.color = new Color(1f, 1f, 1f); BlackHole.transform.localScale = new Vector3(0f, 0f, 0f); Block.transform.localPosition += new Vector3(0f, -0.05f, 0f); Block.OnInteract += delegate { if (!GivenAnswer.Contains('[')) { Sound = Audio.PlaySoundAtTransformWithRef("input", BlackHole.transform); } ; GivenAnswer += "["; return(false); }; Block.OnInteractEnded += delegate { GivenAnswer += "]"; }; Module.OnActivate += delegate { StartCoroutine(OnActivate()); }; RotationSpeed = Rnd.Range(0.1f, 0.5f); RotationSpeedMorePoggers = Rnd.Range(0.5f, 1f); ColourblindEnabled = Colourblind.ColorblindModeActive; }
void MusicEnder() { if (SoundIThink != null && !Focused) { SoundIThink.StopSound(); SoundIThink = null; } }
private void StopSound() { if (this.audioRef != null) { this.audioRef.StopSound(); this.audioRef = null; } }
void OnExplode() { if (soundEffect != null) { soundEffect.StopSound(); soundEffect = null; } }
private IEnumerator KugelNextStage() { KMAudio.KMAudioRef pitch = Audio.PlaySoundAtTransformWithRef("HighPitch", Module.transform); yield return(new WaitForSeconds(0.5f)); pitch.StopSound(); pitch = null; }
private void StopSound() { if (this.activationSound != null) { this.activationSound.StopSound(); this.activationSound = null; } }
private void HandleDetonation() { StopAllCoroutines(); if (ambianceRef != null && settings.playAmbiance) { ambianceRef.StopSound(); ambianceRef = null; } }
void OnExplode() { StopCoroutine("pressureCount"); if (timerSound != null) { // Debug.LogFormat ("CUT SOUND"); timerSound.StopSound(); timerSound = null; } }
private bool HandlePlay() { BombModule.HandlePass(); _audioRef = KMAudio.HandlePlayGameSoundAtTransformWithRef(Effects[_index], transform); if (_audioRef != null && _audioRef.StopSound != null) { _audioRefs.Add(_audioRef); } return(false); }
IEnumerator NeedyDistract() { yield return(new WaitForSeconds(Time - 4f)); sound = GetComponent <KMAudio>().PlayGameSoundAtTransformWithRef(KMSoundOverride.SoundEffect.NeedyWarning, transform); yield return(new WaitForSeconds(4f)); sound.StopSound(); sound = null; }
KMSelectable.OnInteractHandler SetupInteraction(Light light) { return(() => { if (light.speed == 0 || Solved || syncPause) { return false; } light.gObject.GetComponent <KMSelectable>().AddInteractionPunch(0.5f); if (SelectAudioRef != null) { SelectAudioRef.StopSound(); SelectAudioRef = null; StopCoroutine(SelectSFXCoroutine); } if (SelectedLight == null) { SelectAudioRef = Audio.PlaySoundAtTransformWithRef("Select", transform); SelectSFXCoroutine = StartCoroutine(StopSelectSFX()); ApplyToSpeed(light, l => { l.selection.SetActive(true); l.StopFlashing(); }); SelectedLight = light; } else { if (SelectedLight.speed == light.speed) { ApplyToSpeed(light, l => { l.selection.SetActive(false); l.StartFlashing(); }); SelectedLight = null; SelectAudioRef = Audio.PlaySoundAtTransformWithRef("Deselect", transform); SelectSFXCoroutine = StartCoroutine(StopSelectSFX()); } else { Audio.PlaySoundAtTransform("Syncing", transform); StartCoroutine(SyncLights(light)); } } return false; }); }
private IEnumerator BeanHeating(int pos) { string chars = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0"; int[] logvalid = { 0, 0 }; for (int i = 0; i < 2; i++) { for (int j = 0; j < 36; j++) { if ((BombInfo.GetSerialNumber()[i] == chars[j])) { logvalid[i] = j % 9; } } } for (int t = 0; t < 40 && heating; t++) { yield return(new WaitForSeconds(0.05f)); } if (heating) { if (logvalid.Contains(pos)) { if (sound != null) { sound.StopSound(); sound = null; } Debug.LogFormat("[Cool Beans #{0}] This bean can't be heated.", _moduleID); Module.HandleStrike(); StartCoroutine(Strike()); heating = false; } else { frozen[pos] = false; Beans[pos].GetComponent <MeshRenderer>().material = meltmat; Beans[pos].GetComponent <MeshRenderer>().material.color = new Color(colours[0][beanArray[pos] % 3] / 255f, colours[1][beanArray[pos] % 3] / 255f, colours[2][beanArray[pos] % 3] / 255f); for (int t = 0; t < 20 && heating; t++) { yield return(new WaitForSeconds(0.05f)); } if (sound != null) { sound.StopSound(); sound = null; } if (heating) { Debug.LogFormat("[Cool Beans #{0}] You let the microwave go off.", _moduleID); Module.HandleStrike(); StartCoroutine(Strike()); Audio.PlaySoundAtTransform("Mbeep", Module.transform); } } } }
void Check(int i) { if (correctStages == 5) { time = 0; stage = 42; Debug.LogFormat("[Jack Attack #{0}] 5 stages solved correctly, module solved.", moduleId); texts[0].text = "You have\ndefeated the"; texts[1].text = ""; texts[2].text = ""; texts[3].text = "JACK"; texts[4].text = "ATTACK"; soundEffect.StopSound(); soundEffect = Audio.PlaySoundAtTransformWithRef("correct", transform); back.GetComponent <MeshRenderer>().material = mats[0]; Button.GetComponent <MeshRenderer>().material = mats[2]; if (cycleInstead == true) { StopCoroutine(cycle); } GetComponent <KMBombModule>().HandlePass(); moduleSolved = true; } else if (missedStages == 3) { Debug.LogFormat("[Jack Attack #{0}] 3 stages missed, module striked.", moduleId); time = 0; stage = 0; missedStages = 0; bigWordOrder.Shuffle(); smallWordOrder.Shuffle(); if (cycleInstead == true) { dontDisp = true; } texts[0].text = PhraseList.phrases[anchor]; texts[1].text = ""; texts[2].text = ""; texts[3].text = "JACK"; texts[4].text = "ATTACK"; strikeGet = true; canClick = false; soundEffect.StopSound(); soundEffect = Audio.PlaySoundAtTransformWithRef("scream", transform); GetComponent <KMBombModule>().HandleStrike(); } else if (i == 1 && correctStages != 5) { GoodAnimation(); if (cycleInstead == true) { dontDisp = true; } } }
private IEnumerator RotateDial(int ix) { cantPress = true; var count = 300 * (ix + 1); var target = 180f + (.1f * count); var elapsed = 0f; var duration = 0f; if (ix == 0 || ix == 1 || ix == 2) { duration = .5f; } else if (ix == 3 || ix == 4 || ix == 5) { duration = .75f; } else if (ix == 6 || ix == 7 || ix == 8) { duration = 1f; } else { duration = 1.25f; } audio.PlaySoundAtTransform("dial", transform); while (elapsed < duration) { dial.localEulerAngles = new Vector3(0f, Mathf.Lerp(180f, target, elapsed / duration), 0f); yield return(null); elapsed += Time.deltaTime; } dial.localEulerAngles = new Vector3(0f, target, 0f); yield return(new WaitForSeconds(.25f)); elapsed = 0f; audioRef = audio.PlaySoundAtTransformWithRef("rewind", transform); while (elapsed < duration) { dial.localEulerAngles = new Vector3(0f, Mathf.Lerp(target, 180f, elapsed / duration), 0f); yield return(null); elapsed += Time.deltaTime; } audioRef.StopSound(); audioRef = null; dial.localEulerAngles = new Vector3(0f, 180f, 0f); cantPress = false; if (input.Length == 3) { CheckAnswer(); } }
private IEnumerator PlayFakeNeedy() { _ref = _audio.PlayGameSoundAtTransformWithRef(KMSoundOverride.SoundEffect.NeedyWarning, transform); yield return(new WaitForSeconds(5.0f)); _ref.StopSound(); _ref = null; gameObject.SetActive(false); }
void HandlePass() { StopCoroutine("pressureCount"); if (timerSound != null) { //Debug.LogFormat ("CUT SOUND"); timerSound.StopSound(); timerSound = null; } Module.HandlePass(); }
private IEnumerator Solve() { Module.HandlePass(); Sound.StopSound(); Sound = null; Solved = true; StatusLight.GetComponent <MeshRenderer>().material = Mats[2]; Audio.PlaySoundAtTransform("solve", BlackHole.transform); StartCoroutine(FlipBlock()); Highlight.transform.localScale = new Vector3(0f, 0f, 0f); for (int i = 0; i < 80; i++) { Block.transform.localScale += new Vector3(-0.001f, -0.001f, -0.001f); yield return(new WaitForSeconds(0.01f)); } BlockGone = true; for (int i = 0; i < 10; i++) { StatusLight.transform.localEulerAngles += new Vector3(-5f, 0f, -5f); yield return(new WaitForSeconds(0.02f)); StatusLight.transform.localEulerAngles = new Vector3(-90f, 0f, 0f); yield return(new WaitForSeconds(0.02f)); } StartCoroutine(StatusLightSpin()); StatusLight.transform.localEulerAngles = new Vector3(-90f, 0f, 0f); for (int i = 0; i < 30; i++) { StatusLight.transform.localPosition += new Vector3(-0.00250556666666666666666666666666f, -8.3666666666666666666666666666667e-4f, -0.00253523333333333333333333333333f); StatusLight.transform.localScale += new Vector3(-0.0005f, -0.0005f, -0.0005f); yield return(new WaitForSeconds(0.01f)); } for (int i = 0; i < 50; i++) { PuzzleBG.transform.localScale += new Vector3(-0.02f, -0.02f, -0.02f); yield return(new WaitForSeconds(0.01f)); } yield return(new WaitForSeconds(0.25f)); for (int i = 0; i < 5; i++) { BlackHole.transform.localScale += new Vector3(-0.0015f, -0.0015f, 0f); yield return(new WaitForSeconds(0.01f)); } Gone = true; for (int i = 0; i < 6; i++) { Text.text += SolvedText[i]; Audio.PlaySoundAtTransform("type", BlackHole.transform); yield return(new WaitForSeconds(0.16666666666666666666666666666667f)); } Audio.PlaySoundAtTransform("ding", BlackHole.transform); }
IEnumerator valveR() { if (timerSound != null) { // Debug.LogFormat ("CUT SOUND"); timerSound.StopSound(); timerSound = null; } Audio.PlaySoundAtTransform("steam", valve.transform); turn = true; float o = 1f; for (int i = 0; i < 200; i++) { valve.gameObject.transform.Rotate(new Vector3(0, 0, o)); yield return(new WaitForSecondsRealtime(0.0001f)); o += 0.05f; } if (_valve) //presT==maxPT&&presBL==maxPBL&&presBR==maxPBR && { if (presT == maxPT && presBL == maxPBL && presBR == maxPBR) { Debug.LogFormat("[Manometers #{0}] Module solved.", _moduleId); _isSolved = true; this.HandlePass(); } else { Debug.LogFormat("[Manometers #{0}] Manometers aren't to their maximum pressure (TOP={1}, BL={2}, BR={3}), that's necessary for the valve to work correctly. 1 Strike and reset !", _moduleId, presT, presBL, presBR); this.HandleStrike(); } } else { Debug.LogFormat("[Manometers #{0}] Valve didn't have to be use. 1 Strike and reset !", _moduleId); this.HandleStrike(); } for (int i = 0; i < 200; i++) { valve.gameObject.transform.Rotate(new Vector3(0, 0, o)); yield return(new WaitForSecondsRealtime(0.0001f)); o -= 0.05f; } turn = false; }
void StartButtonPress() { if (Active) { return; } if (Sound) { SoundIThink = Audio.PlaySoundAtTransformWithRef("ALittleBit", transform); } StartButton.gameObject.SetActive(false); Active = true; WordChoice(); }
//On pressing button a looped sound will play void OnPress(bool correctButton) { Debug.Log("Pressed " + correctButton + " button"); if (correctButton) { audioRef = GetComponent <KMAudio>().PlayGameSoundAtTransformWithRef(KMSoundOverride.SoundEffect.AlarmClockBeep, transform); GetComponent <KMBombModule>().HandlePass(); } else { audioRef = GetComponent <KMAudio>().PlaySoundAtTransformWithRef("doublebeep125", transform); } }
private IEnumerator Strike() { Module.HandleStrike(); GivenAnswer = ""; Sound.StopSound(); Sound = null; StatusLight.GetComponent <MeshRenderer>().material = Mats[1]; for (int i = 0; i < 60; i++) { StatusLight.GetComponent <MeshRenderer>().material.color = new Color(Mathf.Lerp(1f, 0, i / 60f), 0, 0, 0.5f); yield return(new WaitForSeconds(0.01f)); } StatusLight.GetComponent <MeshRenderer>().material = Mats[0]; }
private void StopAmbient() { if (_ambientRef != null) { _ambientRef.StopSound(); _ambientRef = null; } try { GameMusicControl.GameMusicVolume = _defaultGameMusicVolume; } catch (Exception) { } }
private IEnumerator WobbleTime(float duration) { _postProcess = CameraPostProcess.AddPostProcess(Material); _ref = _audio.PlaySoundAtTransformWithRef(WobbleAudio.name, transform); float finalTime = Random.Range(0, 2) == 0 ? Random.Range(0.4f, 0.6f) : Random.Range(1.2f, 1.3f); float sign = Mathf.Sign(finalTime - 1.0f); float startTime = Time.realtimeSinceStartup; while ((Time.realtimeSinceStartup - startTime) < (duration * 0.8f)) { float delta = (Time.realtimeSinceStartup - startTime) / (duration * 0.9f); Time.timeScale = Mathf.SmoothStep(1.0f, finalTime, delta); Material.SetFloat("_Stretch", Mathf.Lerp(1.0f, 1.0f - sign, delta)); Material.SetFloat("_Vignette", Mathf.Lerp(0.0f, sign * -2.0f, delta)); yield return(null); } yield return(new WaitForSeconds(duration * 0.1f)); startTime = Time.realtimeSinceStartup; while ((Time.realtimeSinceStartup - startTime) < (duration * 0.1f)) { float delta = (Time.realtimeSinceStartup - startTime) / (duration * 0.1f); Time.timeScale = Mathf.SmoothStep(finalTime, 1.0f, delta); Material.SetFloat("_Stretch", Mathf.Lerp(1.0f - sign, 1.0f, delta)); Material.SetFloat("_Vignette", Mathf.Lerp(sign * -2.0f, 0.0f, delta)); yield return(null); } Time.timeScale = 1.0f; _ref.StopSound(); _ref = null; DestroyImmediate(_postProcess); _postProcess = null; gameObject.SetActive(false); }
private void PlaySound(int i) { if (_audioRef != null && _sounds[i] == "HiHat") { _audioRef.StopSound(); _audioRef = null; } if (_sounds[i] == "OpenHiHat" && Audio.HandlePlaySoundAtTransformWithRef != null) { _audioRef = Audio.HandlePlaySoundAtTransformWithRef(_sounds[i], transform, false); } else { Audio.PlaySoundAtTransform(_sounds[i], transform); } }