private void Update() { if (this.clips == null || this.intervalPlayRandomClip <= 0f) { this.first = true; } else { float single = Mathf.Max(0.05f, this.intervalPlayRandomClip); if (this.first) { this.lastTime = Time.time - single; } this.first = false; while (Time.time - this.lastTime >= single) { AudioClip audioClip = this.clips[UnityEngine.Random.Range(0, (int)this.clips.Length)]; if (this.on == null || (int)this.on.Length <= 0 || UnityEngine.Random.@value > this.chanceOn) { audioClip.Play(); } else { audioClip.Play(this.on[UnityEngine.Random.Range(0, (int)this.on.Length)]); } SoundPoolTest soundPoolTest = this; soundPoolTest.lastTime = soundPoolTest.lastTime + single; } } }
// Token: 0x06003DF0 RID: 15856 RVA: 0x000DFD18 File Offset: 0x000DDF18 private void Update() { if (this.clips != null && this.intervalPlayRandomClip > 0f) { float num = Mathf.Max(0.05f, this.intervalPlayRandomClip); if (this.first) { this.lastTime = Time.time - num; } this.first = false; while (Time.time - this.lastTime >= num) { AudioClip clip = this.clips[Random.Range(0, this.clips.Length)]; if (this.on != null && this.on.Length > 0 && Random.value <= this.chanceOn) { clip.Play(this.on[Random.Range(0, this.on.Length)]); } else { clip.Play(); } this.lastTime += num; } } else { this.first = true; } }
// Token: 0x06002DBD RID: 11709 RVA: 0x000AC79C File Offset: 0x000AA99C private void Update() { if (this.terraincheck) { int textureIndex = global::TerrainTextureHelper.GetTextureIndex(base.origin); } bool timeLimited; if (!base.stateFlags.grounded || ((timeLimited = this.trait.timeLimited) && this.nextAllowTime > Time.time) || (base.masterControllable && base.masterControllable.idMain != base.idMain)) { return; } bool crouch = base.stateFlags.crouch; Vector3 origin = base.origin; this.movedAmount += Vector3.Distance(this.lastFootstepPos, origin); this.lastFootstepPos = origin; if (this.movedAmount >= this.trait.sqrStrideDist) { this.movedAmount = 0f; AudioClip audioClip = null; if (global::footsteps.quality >= 2 || (global::footsteps.quality == 1 && base.character.localControlled)) { Collider belowObj = this.GetBelowObj(); if (belowObj) { global::SurfaceInfoObject surfaceInfoFor = global::SurfaceInfo.GetSurfaceInfoFor(belowObj, origin); if (surfaceInfoFor) { audioClip = ((!this.trait.animal) ? surfaceInfoFor.GetFootstepBiped(this.lastPlayed) : surfaceInfoFor.GetFootstepAnimal()); this.lastPlayed = audioClip; } } } if (!audioClip) { audioClip = this.trait.defaultFootsteps[Random.Range(0, this.trait.defaultFootsteps.Length)]; if (!audioClip) { return; } } float minAudioDist = this.trait.minAudioDist; float maxAudioDist = this.trait.maxAudioDist; if (crouch) { audioClip.Play(origin, 0.2f, Random.Range(0.95f, 1.05f), minAudioDist * 0.333f, maxAudioDist * 0.333f, 30); } else { audioClip.Play(origin, 0.65f, Random.Range(0.95f, 1.05f), minAudioDist, maxAudioDist, 30); } if (timeLimited) { this.nextAllowTime = Time.time + this.trait.minInterval; } } }
private void Update() { bool flag; if (this.terraincheck) { int textureIndex = TerrainTextureHelper.GetTextureIndex(base.origin); } if ((base.stateFlags.grounded && (!(flag = this.trait.timeLimited) || (this.nextAllowTime <= Time.time))) && ((base.masterControllable == null) || (base.masterControllable.idMain == base.idMain))) { bool crouch = base.stateFlags.crouch; Vector3 origin = base.origin; this.movedAmount += Vector3.Distance(this.lastFootstepPos, origin); this.lastFootstepPos = origin; if (this.movedAmount >= this.trait.sqrStrideDist) { this.movedAmount = 0f; AudioClip clip = null; if ((footsteps.quality >= 2) || ((footsteps.quality == 1) && base.character.localControlled)) { Collider belowObj = this.GetBelowObj(); if (belowObj != null) { SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(belowObj, origin); if (surfaceInfoFor != null) { clip = !this.trait.animal ? surfaceInfoFor.GetFootstepBiped(this.lastPlayed) : surfaceInfoFor.GetFootstepAnimal(); this.lastPlayed = clip; } } } if (clip == null) { clip = this.trait.defaultFootsteps[UnityEngine.Random.Range(0, this.trait.defaultFootsteps.Length)]; if (clip == null) { return; } } float minAudioDist = this.trait.minAudioDist; float maxAudioDist = this.trait.maxAudioDist; if (crouch) { clip.Play(origin, 0.2f, UnityEngine.Random.Range((float)0.95f, (float)1.05f), minAudioDist * 0.333f, maxAudioDist * 0.333f, 30); } else { clip.Play(origin, 0.65f, UnityEngine.Random.Range((float)0.95f, (float)1.05f), minAudioDist, maxAudioDist, 30); } if (flag) { this.nextAllowTime = Time.time + this.trait.minInterval; } } } }
public static void Play(this AudioClip clip, Socket socket, bool parent, float volume, float pitch, AudioRolloffMode rolloffMode, float minDistance, float maxDistance, float doppler, float spread, bool bypassEffects) { if (socket == null) { if (parent) { socket.Snap(); clip.Play(socket.attachParent, socket.position, socket.rotation, volume, pitch, rolloffMode, minDistance, maxDistance, doppler, spread, bypassEffects); } else { clip.Play(socket.position, socket.rotation, volume, pitch, rolloffMode, minDistance, maxDistance, doppler, spread, bypassEffects); } } }
private void OnTriggerEnter2D(Collider2D collision) { // Do nothing if already taken [To manage multi-frames / simultanious collisions] if (IsTaken) { return; } // Do nothing if it's determined that it can't be picked up if (!CanPickup(collision)) { return; } // Flag as taken IsTaken = true; // Play pick up sound PickupSound.Play(); // Do logic for when pick up (add to inventory, heal, etc.) OnPickup(collision); // Dispose of the item (destroy, add to pool, etc.) Dispose(); }
private void PlaySound(AudioClip clip) { if (clip != null) { clip.Play(base.transform.position, (float)1f, (float)5f, (float)20f); } }
public void StartNextVideo() { if (Panels.Count >= 32) { return; } StartContainer.SetActive(false); if (nextVideoPanel == null) { SetupNextVideo(); } var panel = nextVideoPanel; nextVideoPanel = null; panel.transform.parent = PanelContainer.transform; panel.transform.SetAsFirstSibling(); var vid = panel.GetComponent <VideoPanel>(); vid.ShouldPlay = true; Panels.Add(vid); SetupNextVideo(); NewVidSound.Play(pitch: Mathf.Lerp(0.9f, 1.1f, Random.value)); }
public void OnGUI() { if (this.clips != null) { AudioClip[] audioClipArray = this.clips; for (int i = 0; i < (int)audioClipArray.Length; i++) { AudioClip audioClip = audioClipArray[i]; if (GUILayout.Button(audioClip.name, new GUILayoutOption[0])) { audioClip.Play(); } } } GUI.Box(new Rect((float)(Screen.width - 256), 0f, 256f, 24f), string.Concat("Total Sound Nodes ", SoundPool.totalCount)); GUI.Box(new Rect((float)(Screen.width - 256), 30f, 256f, 24f), string.Concat("Playing Sound Nodes ", SoundPool.playingCount)); GUI.Box(new Rect((float)(Screen.width - 256), 60f, 256f, 24f), string.Concat("Reserve Sound Nodes ", SoundPool.reserveCount)); if (GUI.Button(new Rect((float)(Screen.width - 128), 90f, 128f, 24f), "Drain Reserves")) { SoundPool.DrainReserves(); } if (GUI.Button(new Rect((float)(Screen.width - 128), 120f, 128f, 24f), "Drain")) { SoundPool.Drain(); } if (GUI.Button(new Rect((float)(Screen.width - 128), 150f, 128f, 24f), "Stop All")) { SoundPool.Stop(); } }
public void Grow() { if (!enabled) { return; } GrowSound.Play(); for (int i = 0; i < GrowthStages.Length; i++) { GrowthStages[i].gameObject.SetActive(false); } _growthStage++; if (_growthStage >= GrowthStages.Length) { GrowthStages.Last().gameObject.SetActive(true); GrowthStages.Last().SetHumididy(GameManager.MaxHumidity); StartCoroutine(GameManager.Win()); enabled = false; return; } GrowthStages[_growthStage].gameObject.SetActive(true); Wither(); }
private void OnTriggerEnter2D(Collider2D collision) { // Do nothing if already taken [To manage multi-frames / simultanious collisions] if (IsTaken) { return; } // Do nothing if it's determined that it can't be picked up if (!CanPickup(collision)) { return; } // Flag as taken IsTaken = true; // Play pick up sound PickupSound.Play(); // Do logic for when pick up (like add to inventory, heal, etc.) OnPickup(collision); // Remove instance if (this is IPoolable poolable) { poolable.SetAsAvailable(); } else { Destroy(gameObject); } }
private void PlaySound(AudioClip clip) { if (clip) { clip.Play(base.transform.position, 1f, 5f, 20f); } }
public void Initialize(ControlInput input) { _input = input; engineSource = rolling.Play(SoundType.SFX, audioContainer); engineSource.loop = true; othersSource = SoundExtensions.CreateAudioSource("OtherSource", audioContainer, SoundType.SFX); }
private void Client_OnKilledShared(bool killedBy, Character attacker, ref uLink.NetworkMessageInfo info) { Controllable controllable; bool flag; AudioClipArray trait = base.GetTrait <CharacterSoundsTrait>().death; AudioClip item = trait[UnityEngine.Random.Range(0, trait.Length)]; item.Play(base.transform.position, 1f, 1f, 10f); bool flag1 = base.localControlled; if (flag1) { base.rposLimitFlags = RPOSLimitFlags.KeepOff | RPOSLimitFlags.HideInventory | RPOSLimitFlags.HideContext | RPOSLimitFlags.HideSprites; DeathScreen.Show(); } BaseHitBox remote = base.idMain.GetRemote <BaseHitBox>(); if (remote) { remote.collider.enabled = false; } if (!killedBy || !attacker) { controllable = null; flag = false; } else { controllable = attacker.controllable; flag = (!controllable ? false : controllable.localPlayerControlled); } base.AdjustClientSideHealth(0f); if (flag1 || flag) { InterpTimedEvent.Queue(this, "ClientLocalDeath", ref info); if (!flag1) { InterpTimedEvent.Remove(this, true); } else { InterpTimedEvent.Clear(true); } } else { Collider[] componentsInChildren = base.GetComponentsInChildren <Collider>(); for (int i = 0; i < (int)componentsInChildren.Length; i++) { Collider collider = componentsInChildren[i]; if (collider) { collider.enabled = false; } } InterpTimedEvent.Queue(this, "RAG", ref info); NetCull.DontDestroyWithNetwork(this); } }
public void HitCorrect() { var scoreToAdd = Math.Floor(Math.Pow(BaseScore, 1 + VideoManager.Inst.Panels.Count * Exponent)); Score += scoreToAdd; CorrectSound.Play(pitch: Mathf.Lerp(0.9f, 1.1f, Random.value)); Text(scoreToAdd); }
public void Vomit() { if (vomitSound == null) { Bundling.Load <AudioClip>("content/shared/sfx/vomit", out vomitSound); } vomitSound.Play((float)1f); }
public void PlayAndWait(ISoundProperties properties = null) { ISound sound = AudioClip.Play(false, properties); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); Task.Run(async() => await sound.Completed).Wait(); }
public ISound Play(float volume, bool shouldLoop = false) { ISound sound = AudioClip.Play(volume, shouldLoop); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); return(sound); }
public ISound Play(bool shouldLoop = false, ISoundProperties properties = null) { ISound sound = AudioClip.Play(shouldLoop, properties); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); return(sound); }
public void PlayAndWait(float volume) { ISound sound = AudioClip.Play(volume, false); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); Task.Run(async() => await sound.Completed).Wait(); }
/// <summary> /// Plays the audio clip given the URL and a specifier that is /// relative to it. Nothing happens if the audio clip cannot be found. /// </summary> /// <param name="url"> an absolute URL giving the base location of the /// audio clip. </param> /// <param name="name"> the location of the audio clip, relative to the /// <code>url</code> argument. </param> public virtual void Play(URL url, String name) { AudioClip clip = GetAudioClip(url, name); if (clip != null) { clip.Play(); } }
/// <summary> /// Plays the audio clip at the specified absolute URL. Nothing /// happens if the audio clip cannot be found. /// </summary> /// <param name="url"> an absolute URL giving the location of the audio clip. </param> public virtual void Play(URL url) { AudioClip clip = GetAudioClip(url); if (clip != null) { clip.Play(); } }
// Token: 0x060003C1 RID: 961 RVA: 0x00011D7C File Offset: 0x0000FF7C private void Client_OnKilledShared(bool killedBy, global::Character attacker, ref uLink.NetworkMessageInfo info) { global::AudioClipArray death = base.GetTrait <global::CharacterSoundsTrait>().death; AudioClip clip = death[Random.Range(0, death.Length)]; clip.Play(base.transform.position, 1f, 1f, 10f); bool localControlled = base.localControlled; if (localControlled) { base.rposLimitFlags = (global::RPOSLimitFlags.KeepOff | global::RPOSLimitFlags.HideInventory | global::RPOSLimitFlags.HideContext | global::RPOSLimitFlags.HideSprites); global::DeathScreen.Show(); } global::BaseHitBox remote = base.idMain.GetRemote <global::BaseHitBox>(); if (remote) { remote.collider.enabled = false; } bool flag; if (killedBy && attacker) { global::Controllable controllable = attacker.controllable; flag = (controllable && controllable.localPlayerControlled); } else { flag = false; } base.AdjustClientSideHealth(0f); if (!localControlled && !flag) { foreach (Collider collider in base.GetComponentsInChildren <Collider>()) { if (collider) { collider.enabled = false; } } global::InterpTimedEvent.Queue(this, "RAG", ref info); global::NetCull.DontDestroyWithNetwork(this); } else { global::InterpTimedEvent.Queue(this, "ClientLocalDeath", ref info); if (localControlled) { global::InterpTimedEvent.Clear(true); } else { global::InterpTimedEvent.Remove(this, true); } } }
IEnumerator AppearCo() { yield return(new WaitForSeconds(1)); // SPLASH! PREEPS.transform.localScale = Vector3.zero; preepsClip.Play(Vector3.zero, minDistance: 1000); PREEPS.transform.DOScale(Vector3.one * 0.69f, 0.3f); PREEPS.transform.DOPunchRotation(Vector3.forward * 10, 1, 20); yield return(new WaitForSeconds(1)); // PRESENT present.DOScale(Vector3.one * 1.448438f, 0.1f); presentClip.Play(Vector3.zero, minDistance: 1000, volume: 0.5f); yield return(new WaitForSeconds(1)); PREEPS.transform.DOScale(Vector3.zero, 0.3f); // MOLESW! yield return(new WaitForSeconds(startDelay)); GetComponent <AudioSource>().Play(); foreach (SpriteAppear SA in spriteAppears) { yield return(new WaitForSeconds(SA.afterTime)); SA.sprite.enabled = true; SA.sprite.transform.DOPunchScale(Vector3.one * punchSize, 0.2f); SA.sprite.transform.DOPunchRotation(Random.onUnitSphere * punchAngle, 0.2f); pivot.transform.DOPunchRotation(Random.onUnitSphere * punchAngle, 0.1f); } moleswEnded = true; yield return(new WaitForSeconds(0.2f)); playButton.DOScale(1, 0.2f); creditsButton.DOScale(1, 0.2f); yield return(new WaitForSeconds(0.8f)); DontDestroyOnLoad(Instantiate(musicPrefab)); }
public ISound Play(float volume, bool shouldLoop = false) { ISound sound = AudioClip.Play(volume, shouldLoop); OnSoundStarted.Invoke(sound); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); sound.Completed.ContinueWith(_ => OnSoundCompleted?.Invoke(sound)); return(sound); }
public ISound Play(bool shouldLoop = false, ISoundProperties properties = null) { ISound sound = AudioClip.Play(shouldLoop, properties); OnSoundStarted.Invoke(sound); EmittedSound emittedSound = new EmittedSound(sound); _playingSounds.TryAdd(emittedSound.ID, emittedSound); sound.Completed.ContinueWith(_ => OnSoundCompleted?.Invoke(sound)); return(sound); }
static void Update() { if (Input.GetKeyPressed(KeyCode.C)) { fullscreen = !fullscreen; Application.SetFullScreen(fullscreen); } if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } if (Input.GetKeyPressed(KeyCode.E)) { StaticMesh m = new StaticMesh(Settings.ModelsDirPath + "\\Crate1.obj"); int i = Random.Range(0, 4); VisualEntity visual = new VisualEntity(m, mats[i]); visual.Transform.Position = Camera.Main.Position + Camera.Main.Forward * 5f; var bdy = phys.CreateRigidBody(visual.Transform.Position); bdy.AddCollisionShape(new BoxShape(1.1f)); visual.AddComponent(bdy); mWorld.AddEntity(visual); bdy.ApplyForceToCenterOfMass(Camera.Main.Forward * 5000f); shotSound.Play(); } float intensity = GetSliderValueUI_Native(); mWorld.skySettings.exposure = intensity * 32f; if (GetButtonPressedUI_Native() == 1) { for (int i = 0; i < visuals.Length; i++) { float power = 300f; if (GetRadioOptionUI_Native() == 1) { power = 800f; } visuals[i].GetComponent <RigidBody>().ApplyForceToCenterOfMass(Vector3.UnitY * power); } } }
private void Jump() { if (rb.velocity.y != 0) { return; } JumpSound.Play(); if (Animator.isActiveAndEnabled) { Animator.SetBool("IsJumping", true); } rb.AddForce(Vector2.up * Time.deltaTime * JumpForce, ForceMode2D.Impulse); }
public void HitWrong() { WrongMomentum++; wrongDecayTime = 0; var scoreToLose = Score * WrongPerc * (Math.Pow(WrongBase, WrongMomentum) - 1); scoreToLose = Math.Max(2, scoreToLose); Score -= scoreToLose; if (Score < 0) { Stop(); } else { WrongSound.Play(pitch: Mathf.Lerp(0.9f, 1.1f, Random.value)); Text(-scoreToLose); } }
public override void Render() { ang += 1; GL.Clear(ClearFlags); back.DrawFullScreen(0, 0); int mouseY = Settings.Height - Mouse.Y; // invert mouse if (Mouse[MouseButton.Left]) { if (!clicked) { clicked = true; if (Mouse.X >= x && Mouse.X < x + img[tex].Width && mouseY >= y && mouseY < y + img[tex].Height) { visibleTime = 100; score++; snd1.Play(); } else { misses++; snd2.Play(); } } } else { clicked = false; } img[tex].Draw(x + img[tex].Width / 2, y + img[tex].Height / 2, ang, 1, 1, true); crosshair.Draw(Mouse.X, mouseY); font.Write("Hits: " + score + " " + "Misses: " + misses, 0, 0); base.Render(); }