예제 #1
0
 public void GrabLever()
 {
     leverGrabbed = true;
     if (sampleType == GearboxSampleType.ReverseIdleFirstSecond && currentGear == 0)
     {
         engine.Switch('B');
         engine.Play();
     }
 }
예제 #2
0
        private void FixedUpdate()
        {
            if (ReplayRecorder.isPlaying || NetGame.isClient)
            {
                return;
            }
            if (remainingIgnitions == 0)
            {
                stopIn -= Time.fixedDeltaTime;
                if (stopIn <= 0f)
                {
                    remainingIgnitions = ignitionsToStart;
                    socket.voltage     = 0f;
                    sound.Stop();
                    Circuit.Refresh(socket);
                    output.SetValue(0f);
                }
                return;
            }
            float magnitude = (starter.localPosition - initialLocalPos).magnitude;

            if (!isStarting && magnitude > startTreshold)
            {
                isStarting = true;
                remainingIgnitions--;
                if (remainingIgnitions == 0)
                {
                    socket.voltage = 2f;
                    if (Circuit.Refresh(socket))
                    {
                        sound.Play();
                        stopIn = runTime;
                        output.SetValue(1f);
                    }
                    else
                    {
                        remainingIgnitions = ignitionsToStart;
                        socket.voltage     = 0f;
                        Circuit.Refresh(socket);
                        sound.Stop();
                        output.SetValue(0f);
                    }
                }
                else
                {
                    FailStart();
                }
            }
            else if (isStarting && magnitude < startTreshold * 0.5f)
            {
                isStarting = false;
            }
        }
예제 #3
0
 public void SetGet(int gear)
 {
     currentGear = gear;
     if (sampleType == GearboxSampleType.ReverseIdleFirstSecond)
     {
         engine.Switch((char)(66 + currentGear));
     }
     else
     {
         engine.Switch((gear != 2) ? 'A' : 'B');
         if (gear != 0)
         {
             engine.Play();
         }
         else
         {
             engine.Stop();
         }
     }
     if (gear < 0)
     {
         if (gearReverse != null)
         {
             gearReverse.PlayOneShot();
         }
     }
     else if (gearShift != null)
     {
         gearShift.PlayOneShot();
     }
     if (!(reverseBeep != null))
     {
         return;
     }
     if (gear == -1)
     {
         if (!reverseBeep.isPlaying)
         {
             reverseBeep.Play(forceLoop: true);
         }
     }
     else if (reverseBeep.isPlaying)
     {
         reverseBeep.Stop();
     }
 }
예제 #4
0
        public override void Process()
        {
            base.Process();
            bool flag = Mathf.Abs(input.value) >= 0.1f;

            if (flag != knownState && sound2 != null)
            {
                knownState = flag;
                if (flag)
                {
                    sound2.Play();
                }
                else
                {
                    sound2.Stop();
                }
            }
        }
예제 #5
0
        private IEnumerator Start()
        {
            Sound2 sound = GetComponent <Sound2>();

            yield return(new WaitForSeconds(Random.Range(0f, maxDelay)));

            while (true)
            {
                if (sound.isPlaying)
                {
                    yield return(null);

                    continue;
                }
                sound.Play();
                yield return(new WaitForSeconds(Random.Range(minDelay, maxDelay)));
            }
        }
예제 #6
0
 private void Start()
 {
     sound2.Play(loop);
 }