Ejemplo n.º 1
0
 private void OnEnable()
 {
     triggerSignal.onValueChanged += SignalChanged;
     if (triggerSignal.value > treshold || (playOnReverse && triggerSignal.value < 0f - treshold))
     {
         sound.SetPitch(Mathf.Lerp(pitchLow, pitchHigh, Mathf.Abs(triggerSignal.value)));
         sound.Play();
     }
 }
Ejemplo n.º 2
0
    private void SyncAudio()
    {
        if (sound == null)
        {
            return;
        }
        int num = isHot ? Mathf.Clamp(coalList.Count, 0, 5) : 0;

        if (currentAudio == num)
        {
            return;
        }
        currentAudio = num;
        if (num == 0)
        {
            if (sound.isPlaying)
            {
                sound.Stop();
            }
            return;
        }
        sound.SetPitch(0.9f + (float)currentAudio * 0.1f);
        sound.SetVolume(0.5f + fireVolume * 0.1f);
        sound.Switch((char)(65 + num - 1));
        if (!sound.isPlaying)
        {
            sound.Play(forceLoop: true);
        }
    }
Ejemplo n.º 3
0
    public override void Process()
    {
        base.Process();
        bool flag = Mathf.Abs(input.value) >= threshold;

        if (flag == isOn)
        {
            return;
        }
        isOn = flag;
        if (isOn)
        {
            remainingBurstTime = burstDuration;
            if (whistleSound != null)
            {
                whistleSound.PlayOneShot();
            }
        }
        if (hissSound != null)
        {
            if (isOn && !hissSound.isPlaying)
            {
                hissSound.Play(forceLoop: true);
            }
            if (!isOn && hissSound.isPlaying)
            {
                hissSound.Stop();
            }
        }
    }
Ejemplo n.º 4
0
    public float ApplyVolume(int idx, Vector3 pos)
    {
        float num = 0f;

        if (idx + 1 < all.Count)
        {
            num = all[idx + 1].ApplyVolume(idx + 1, pos);
        }
        float num2 = GetOpacity(pos) * baseOpacity;

        if (num2 < grid.volumeTreshold)
        {
            if (sound.isPlaying)
            {
                sound.Stop();
            }
        }
        else if (!sound.isPlaying)
        {
            sound.Play();
        }
        currentVolume = Mathf.MoveTowards(currentVolume, num2 * (1f - num), Time.deltaTime / grid.fadeDuration);
        sound.SetVolume(currentVolume);
        return(num + (1f - num) * num2);
    }
Ejemplo n.º 5
0
    private IEnumerator TheEnd()
    {
        portcullis.isKinematic = false;
        portcullis.WakeUp();
        yield return(new WaitForSeconds(2f));

        Object.Destroy(left.GetComponent <FixedJoint>());
        Object.Destroy(right.GetComponent <FixedJoint>());
        if (doorReleaseSound != null)
        {
            doorReleaseSound.Play();
        }
        else
        {
            doorReleaseSample.Play();
        }
    }
Ejemplo n.º 6
0
    public void ReleaseDoor()
    {
        if (showDebug)
        {
            Debug.Log(base.name + " Release the doors ");
        }
        Vector3 position  = Human.all[0].ragdoll.partWaist.transform.position;
        Vector3 position2 = base.transform.position;

        position.y = position2.y;
        base.transform.position = position;
        left.isKinematic        = false;
        right.isKinematic       = false;
        doorRelease.Play();
        doorRelease.transform.SetParent(null, worldPositionStays: false);
        Object.DontDestroyOnLoad(doorRelease);
        Object.Destroy(doorRelease, 5f);
    }
Ejemplo n.º 7
0
 private void OnCollisionEnter(Collision collision)
 {
     if (!isOnStump && collision.collider == stump)
     {
         isOnStump = true;
         Rigidbody component = GetComponent <Rigidbody>();
         if (component != null)
         {
             component.isKinematic = true;
         }
     }
     if (isCut || !(collision.collider == axe))
     {
         return;
     }
     if (collision.relativeVelocity.magnitude > cutForce)
     {
         cutCount++;
         SendHit(HitType.Cut, collision.GetPoint());
         if (cutCount >= cutsRequired)
         {
             if (cutSound != null)
             {
                 cutSound.Play();
             }
             isCut = true;
             Rigidbody component2 = GetComponent <Rigidbody>();
             if (component2 != null)
             {
                 component2.isKinematic = false;
                 component2.AddForceAtPosition(pushDirection, pushLocation);
             }
         }
     }
     else
     {
         SendHit(HitType.TooWeak, collision.GetPoint());
     }
 }
Ejemplo n.º 8
0
    private void SignalChanged(float val)
    {
        float num = GetValue();

        if (num == to)
        {
            return;
        }
        to    = num;
        from  = value;
        phase = 0f;
        if (sound != null)
        {
            if (restartServoOnSwitch || !sound.isPlaying)
            {
                sound.Play();
            }
        }
        else if (servoSound != null && (restartServoOnSwitch || !servoSound.isPlaying))
        {
            servoSound.Play();
        }
    }
Ejemplo n.º 9
0
    private void FixedUpdate()
    {
        float num = 0f;

        num = ((!(triggerSignal != null)) ? input.value : triggerSignal.value);
        if (motorSound != null)
        {
            if (num != 0f && !motorSound.isPlaying)
            {
                motorSound.Play();
                char choice = (!(floatingmesh.sensor.waterBody == null)) ? 'A' : 'B';
                motorSound.Switch(choice);
            }
            else if (num == 0f && motorSound.isPlaying)
            {
                motorSound.Stop();
            }
        }
        else if (servoSound != null)
        {
            if (num != 0f && !servoSound.isPlaying)
            {
                servoSound.Play();
                bool flag = floatingmesh.sensor.waterBody == null;
                servoSound.secondMedium = (flag && servoSound.loopClips2.Length > 0);
            }
            else if (num == 0f && servoSound.isPlaying)
            {
                servoSound.Stop();
            }
        }
        Rigidbody rigidbody = this.rigidbody;
        float     magnitude = rigidbody.velocity.magnitude;

        if (num != 0f)
        {
            rigidbody.SafeAddForceAtPosition(forcePoint.forward * (force + forceLinear * magnitude + forceSquare * magnitude * magnitude) * num, forcePoint.position);
        }
        if (motorSound != null)
        {
            char choice2 = (!(floatingmesh.sensor.waterBody == null)) ? 'A' : 'B';
            motorSound.Switch(choice2);
            motorSound.SetPitch(Mathf.Lerp(pitchLow, pitchHigh, Mathf.Abs(num)));
        }
        else
        {
            if (!(servoSound != null))
            {
                return;
            }
            bool flag2 = floatingmesh.sensor.waterBody == null && servoSound.loopClips2.Length > 0;
            if (servoSound.secondMedium != flag2)
            {
                servoSound.secondMedium = flag2;
                if (num != 0f)
                {
                    servoSound.CrossfadeLoop();
                }
            }
            servoSound.SetPitch(Mathf.Lerp(pitchLow, pitchHigh, Mathf.Abs(num)));
        }
    }
    private void FixedUpdate()
    {
        float value = triggerSignal.value;

        value = ((value < deadzoneFrom) ? ((value - deadzoneFrom) / (1f + deadzoneFrom)) : ((!(value > deadzoneTo)) ? 0f : ((value - deadzoneTo) / (1f + deadzoneTo))));
        float num = (!(powerSignal != null)) ? 1f : (powerSignal.value / neededVoltage);

        if (Mathf.Abs(num) < 0.5f)
        {
            num   = 0f;
            value = 0f;
        }
        if (oldPower != num)
        {
            PowerChanged(Mathf.Abs(num));
        }
        oldPower = num;
        value   *= num;
        float num2 = maxVelocity * value;

        if (timeToAccelerate == 0f)
        {
            velocity = num2;
        }
        else
        {
            if (velocity > 0f && num2 <= velocity)
            {
                velocity = Mathf.Max(0f, num2);
            }
            if (velocity < 0f && num2 >= velocity)
            {
                velocity = Mathf.Min(0f, num2);
            }
            velocity = Mathf.MoveTowards(velocity, num2, maxVelocity * Time.fixedDeltaTime / timeToAccelerate);
        }
        if (velocity != 0f)
        {
            if (stopSoundOnStop && Mathf.Sign(velocity) == blockedDirection)
            {
                return;
            }
            blockedDirection = 0f;
            if (sound != null)
            {
                if (!sound.isPlaying)
                {
                    sound.Play();
                }
            }
            else if (servoSound != null && !servoSound.isPlaying)
            {
                servoSound.Play();
            }
            float num3 = targetValue;
            targetValue = Mathf.Clamp(targetValue + velocity * Time.fixedDeltaTime, minValue, maxValue);
            if (targetValue == num3)
            {
                timeStopped += Time.fixedDeltaTime;
                if (timeStopped > resetSignalDelay)
                {
                    if (resetSignalOnStop)
                    {
                        triggerSignal.ResetSignal();
                    }
                    if (stopSoundOnStop)
                    {
                        if (sound != null)
                        {
                            sound.Stop();
                        }
                        else
                        {
                            servoSound.Stop();
                        }
                        blockedDirection = Mathf.Sign(velocity);
                    }
                }
            }
            else
            {
                blockedDirection = 0f;
                timeStopped      = 0f;
            }
            if (sound != null)
            {
                sound.SetPitch(((!(velocity > 0f)) ? pitchNegative : pitchPositive) * ((targetValue != num3) ? 1f : pitchLimit));
            }
            else if (servoSound != null)
            {
                servoSound.SetPitch(((!(velocity > 0f)) ? pitchNegative : pitchPositive) * ((targetValue != num3) ? 1f : pitchLimit));
            }
            TargetValueChanged(targetValue);
        }
        else if (sound != null)
        {
            if (sound.isPlaying)
            {
                sound.Stop();
            }
        }
        else if (servoSound != null && servoSound.isPlaying)
        {
            servoSound.Stop();
        }
    }
Ejemplo n.º 11
0
 public void Play()
 {
     sound.Play();
     dronesStartTime = Time.timeSinceLevelLoad;
     StartCoroutine(DestroyWhenDone());
 }